[Castore-commits] ParagraphElement.java NONE 1.1

Céline BENOIT cbenoit at adullact1.hosting.cri74.org
Mer 22 Mar 14:57:38 CET 2006


Update of /cvsroot/castore/castore-core/src/java/fr/emn/castor/documents/metier/textes/retro/flatxmlrawdata
In directory adullact1:/tmp/cvs-serv29393/src/java/fr/emn/castor/documents/metier/textes/retro/flatxmlrawdata

Added Files:
	ParagraphElement.java 
Log Message:
déplacement du fichier 

--- NEW FILE: ParagraphElement.java ---
/*
 * $Id: ParagraphElement.java,v 1.1 2006/03/22 13:57:36 cbenoit Exp $
 *
 * Plateforme CASTORE
 * CeCILL Copyright (C) 2005-2006 by EMN
 * Made by Stéphane Bouchet, Xerox
 * Web site = http://www.emn.fr/castore
 * Contact = Cédric Dumas, e-mail = Cedric.Dumas at emn.fr
 *
 * Version 1.0 (1er mars 2005)
 *
 * Ce logiciel est un programme informatique servant à créer une plateforme
 * open-source de bibliothèque numérique XML pour Conserver, Valoriser et
 * Diffuser le patrimoine documentaire de votre institut.
 *
 * Ce logiciel est régi par la licence CeCILL soumise au droit français et
 * respectant les principes de diffusion des logiciels libres. Vous pouvez
 * utiliser, modifier et/ou redistribuer ce programme sous les conditions de la
 * licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA sur le site
 * "http://www.cecill.info". En contrepartie de l'accessibilité au code source
 * et des droits de copie, de modification et de redistribution accordés par
 * cette licence, il n'est offert aux utilisateurs qu'une garantie limitée. Pour
 * les mêmes raisons, seule une responsabilité restreinte pèse sur l'auteur du
 * programme, le titulaire des droits patrimoniaux et les concédants successifs.
 * A cet égard l'attention de l'utilisateur est attirée sur les risques associés
 * au chargement, à l'utilisation, à la modification et/ou au développement et à
 * la reproduction du logiciel par l'utilisateur étant donné sa spécificité de
 * logiciel libre, qui peut le rendre complexe à manipuler et qui le réserve
 * donc à des développeurs et des professionnels avertis possédant des
 * connaissances informatiques approfondies. Les utilisateurs sont donc invités
 * à charger et tester l'adéquation du logiciel à leurs besoins dans des
 * conditions permettant d'assurer la sécurité de leurs systèmes et ou de leurs
 * données et, plus généralement, à l'utiliser et l'exploiter dans les mêmes
 * conditions de sécurité. Le fait que vous puissiez accéder à cet en-tête
 * signifie que vous avez pris connaissance de la licence CeCILL, et que vous en
 * avez accepté les termes.
 *
 */
package fr.emn.castor.documents.metier.textes.retro.flatxmlrawdata;

import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdom.Element;

/**
 * @author  rdelambe  TODO To change the template for this generated type comment go to Window -  Preferences - Java - Code Style - Code Templates
 */
public class ParagraphElement extends FxrdElement {

    /** le logger.*/
    private static Log logger = LogFactory.getLog(ParagraphElement.class);

    /**
     * Default constructor
     */
    public ParagraphElement() {
        super();
        paragraphComponents = new Vector<ParagraphComponent>();
        outputParagraphElements = new Vector<OutputParagraphElement>();
        ParagraphElementsFromSchema = null;
        Reset();
    }

    /**
     * Class members
     */
    public Vector<ParagraphComponent> paragraphComponents;

    public Vector<OutputParagraphElement> outputParagraphElements;

    /**
     */
    public Collection ParagraphElementsFromSchema;

    /**
     */
    protected int lastProcessedOutputParagraphElement = -1;

    /**
     */
    protected Iterator iteratorParagraphElementsFromSchema = null;

    public void Reset() {
        super.Reset();
        lastProcessedOutputParagraphElement = -1;
        iteratorParagraphElementsFromSchema = null;
        ParagraphElementsFromSchema = null;
    }

    public int getLpope() {
        return lastProcessedOutputParagraphElement;
    }

    public void setLpope(int lpope) {
        lastProcessedOutputParagraphElement = lpope;
    }

    public Iterator getIpefs() {
        return iteratorParagraphElementsFromSchema;
    }

    public void setIpefs(Iterator ippefs) {
        iteratorParagraphElementsFromSchema = ippefs;
    }

    /**
     * load paraElem into a java instance
     * 
     * @param element
     */
    public void load(Element element) {

        Element paragraphContent = element.getChild(
            PARAGRAPH_CONTENT, FlatXmlRawData.NAMESPACE);
        if (paragraphContent != null) {

            List paragraphComponentNodeList = paragraphContent.getChildren();
            ParagraphComponent paragraphComponent;

            for (int i = 0; i < paragraphComponentNodeList.size(); i++) {
                Element paragraphComponentNode = (Element) paragraphComponentNodeList
                    .get(i);

                if (paragraphComponentNode.getName().equals(TEXT_ELEMENT)) {
                    paragraphComponent = new TextElement();
                } else {
                    if (paragraphComponentNode.getName().equals(
                        INLINE_LAYOUT_ELEMENT)) {
                        paragraphComponent = new InlineLayoutElement();
                    } else {
                        // InlineTextualElement
                        paragraphComponent = new InlineTextualElement();
                    }
                }
                // load it with XML info
                paragraphComponent.load(paragraphComponentNode);
                // add it to the Vector 
                paragraphComponents.add(paragraphComponent);
            }
        }

        // load OutPutParagraphElements
        List outputParaElemList = element.getChildren(
            OUTPUT_PARA_ELEM, FlatXmlRawData.NAMESPACE);
        if (outputParaElemList == null)
            return;

        for (int i = 0; i < outputParaElemList.size(); i++) {
            OutputParagraphElement ithOutputParaElem = new OutputParagraphElement();
            // load the ith output paragraph element into a java instance
            ithOutputParaElem.load((Element) outputParaElemList.get(i));
            outputParagraphElements.add(ithOutputParaElem);
        }
    }

    /**
     * display the paragraph element
     *  
     */
    public void display() {
        logger.debug("ParagraphElement");
        logger.debug("  ParagraphContent = ");
        for (int i = 0; i < paragraphComponents.size(); i++) {
            ((ParagraphComponent) paragraphComponents.get(i)).display();
        }

        if (outputParagraphElements != null) {
            for (int i = 0; i < outputParagraphElements.size(); i++) {
                ((OutputParagraphElement) outputParagraphElements.get(i))
                    .display();
            }
        }
        logger.debug("end of ParagraphElement");
    }

    /**
     * getter method for paragraphComponents attribute
     * @return
     */
    public Vector getParagraphComponents() {
        return paragraphComponents;
    }

    /**
     * getter method for outputParagraphElements attribute
     * @return
     */
    public Vector getOutputParagraphElements() {
        return outputParagraphElements;
    }

    /**
     * Class constants
     *  
     */
    private static final String PARAGRAPH_CONTENT = "ParagraphContent";

    private static final String TEXT_ELEMENT = "Text";

    private static final String INLINE_LAYOUT_ELEMENT = "InlineLayoutElement";

    private static final String OUTPUT_PARA_ELEM = "OutputParagraphElement";
}




Plus d'informations sur la liste de diffusion Castore-commits