[Castore-commits] FlatXmlRawData.java NONE 1.1
Céline BENOIT
cbenoit at adullact1.hosting.cri74.org
Mer 22 Mar 14:55:31 CET 2006
Update of /cvsroot/castore/castore-core/src/java/fr/emn/castor/documents/metier/textes/retro/flatxmlrawdata
In directory adullact1:/tmp/cvs-serv28961/src/java/fr/emn/castor/documents/metier/textes/retro/flatxmlrawdata
Added Files:
FlatXmlRawData.java
Log Message:
déplacement du fichier
--- NEW FILE: FlatXmlRawData.java ---
/*
* $Id: FlatXmlRawData.java,v 1.1 2006/03/22 13:55:29 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.List;
import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdom.Attribute;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.Namespace;
import fr.emn.castor.documents.metier.textes.retro.tools.XMLUtils;
/**
* Java class corresponding to the FlatXMLRawData xml file
*
* @author $Author: cbenoit $
* @version $Revision: 1.1 $
*
*/
public class FlatXmlRawData {
/** le logger.*/
private static Log logger = LogFactory.getLog(FlatXmlRawData.class);
/**
* Class members
*/
// the XML file path
protected String fxrdFilePath;
/** the root element */
protected String rootElement;
/** the namespace */
protected String targetNamespace;
// the contained elements
protected Vector<FxrdElement> fxrdElements;
/**
* Default constructor
*
*/
public FlatXmlRawData() {
fxrdFilePath = "";
rootElement = "";
targetNamespace = "";
fxrdElements = new Vector<FxrdElement>();
}
/**
* Constructor
*
*/
public FlatXmlRawData(String theFilePath) {
fxrdFilePath = theFilePath;
rootElement = "";
targetNamespace = "";
fxrdElements = new Vector<FxrdElement>();
}
/**
* getter method for fxrdFilePath attribute
* @return the file path attribute
*/
public String getFxrdFilePath() {
return fxrdFilePath;
}
/**
* getter method for rootElement attribute
* @return the root element name
*/
public String getRootElement() {
return rootElement;
}
/**
* getter method for targetNamespace attribute
* @return the targetNamespace
*/
public String getTargetNamespace() {
return targetNamespace;
}
/**
* getter method for fxrdElements attribute
* @return the vector of the fxrdElements contained in the document
*/
public Vector<FxrdElement> getFxrdElements() {
return fxrdElements;
}
/**
* load XML File into the java class
*
*/
public void load() /* throws DOMException */
{
Document fxrdDoc = XMLUtils.getDocumentFromXMLFile(fxrdFilePath);
Element docElem = fxrdDoc.getRootElement();
loadRootElement(docElem);
loadTargetNamespace(docElem);
/*
* NodeList paragraphElementList = docElem
* .getElementsByTagName(PARAGRAPH_ELEMENT); NodeList layoutElementList =
* docElem .getElementsByTagName(LAYOUT_ELEMENT);
*/
// Get the node list of this document
List docElementList = docElem.getChildren();
int elementsCount = docElementList.size() + 1;
// create all FxrdElements
// Load information from input FlatXmlRawData file
for (int i = 0; i < elementsCount - 1; i++) {
Element ithElement = (Element) docElementList.get(i);
FxrdElement ithFxrdElement;
if (ithElement.getName().equals(PARAGRAPH_ELEMENT)) {
ithFxrdElement = new ParagraphElement();
} else {
ithFxrdElement = new LayoutElement();
}
// load it with XML info
ithFxrdElement.load(ithElement);
// add it to the Vector
fxrdElements.add(ithFxrdElement);
}
}
/**
* load the rootElement attribute
*
* @param elem
*/
public void loadRootElement(Element docElem) {
Attribute rootAttribute = docElem.getAttribute(ROOT_ELEMENT);
if (rootAttribute != null)
rootElement = rootAttribute.getValue();
}
/**
* load the namespace attribute
*
* @param elem
*/
public void loadTargetNamespace(Element docElem) {
Attribute targetNamespaceAttribute = docElem
.getAttribute(TARGET_NAMESPACE);
if (targetNamespaceAttribute != null)
targetNamespace = targetNamespaceAttribute.getValue();
}
/**
* display the document
*
*/
public void display() {
logger.debug("FlatWmlRawData");
// display rootElement
logger.debug("rootElement = " + getRootElement());
for (int i = 0; i < fxrdElements.size(); i++) {
// display each FxrdElement in the document
((FxrdElement) fxrdElements.get(i)).display();
}
logger.debug("end of FlatWmlRawData");
}
/**
* Class constants
*
*/
// used in OutputDocumentGenerator
public static final String ROOT_ELEMENT = "rootElement";
public static final String TARGET_NAMESPACE = "namespace";
public static final String PARAGRAPH_ELEMENT = "ParagraphElement";
public static final String LAYOUT_ELEMENT = "LayoutElement";
public static Namespace NAMESPACE = Namespace
.getNamespace("urn:xgs:names:reverse:xmlns:fxrd:1.0");
}
Plus d'informations sur la liste de diffusion Castore-commits