Main Page | Packages | Class Hierarchy | Class List | Directories | Class Members | Related Pages

org.colimas.services.xml.XMLObject Class Reference

List of all members.

Public Member Functions

 XMLObject (Document dom)
 XMLObject (InputStream inputStream, int type, String countryCode)
 XMLObject (String value, int type)
void appendChild (Node eParent, Node eNewChild)
Element createAndInsertElement (Element eParent, String childName, String childValue) throws SAXException, IOException, XMLException
Element createElement (String elementName) throws IOException, SAXException, XMLException
void deleteFromElement (Element element)
Vector getAllSibling (Element fromElement, String elementName)
Document getDOM ()
DTD getDTD () throws XMLException
Element getRoot ()
String getTagValue (Element element)
String getTagValue (Element fromElement, String tagName)
String getTagValue (Element fromElement, String tagName, String attributeName, String attributeValue)
Node importNode (Node node)
void insertElement (Element newElement, Element parent) throws IOException, SAXException, XMLException
void replaceElement (Node oldElement, Node newElement)
Element searchElement (Element fromNode, String name)
Element searchElement (Element fromElement, String name, String value)
Element searchElement (Element fromNode, String name, String attrName, String attrValue)
Element searchElement (Element fromElement, String name, String attrName, String attrValue, String value)
void setTagValue (Element element, String value)
void setTagValue (Element fromElement, String tagName, String value)
void setTagValue (Element fromElement, String tagName, String value, boolean createIfNotExists) throws SAXException, IOException, XMLException
void setTagValue (Element fromElement, String tagName, String attributeName, String attributeValue, String value)
void startParser () throws XMLException
String writeToString () throws IOException

Static Public Attributes

static final String TRACE_PROPERTY = "xmlobject.trace"
static final int DTDFILE = 2
static final int XMLFILE = 0
static final int XMLSTRING = 1

Protected Member Functions

XMLFactory createXMLFactory () throws IOException, SAXException, XMLException
void initFromDTD (String publicId) throws IOException, SAXException, XMLException, XMLException
void initFromFile (File xmlFile) throws SAXException, IOException, XMLException, XMLException
void initFromString (String xmlString) throws SAXException, IOException, XMLException
void initFromXML (InputStream in) throws SAXException, IOException, javax.xml.parsers.ParserConfigurationException, XMLException
void initFromXML (Reader reader) throws SAXException, IOException, javax.xml.parsers.ParserConfigurationException, XMLException

Static Package Attributes

static final long serialVersionUID = -7828347354799405399L

Detailed Description

XMLObject.java

Function:
This class is a centric class into the application. It handles, in a transparent way, all operations done onto XML and DTD streams.

Author:
zhao lei
Version:
1.0
Modification History:
 SEQ DATE       ORDER DEVELOPER      DESCRIPTION
 --- ---------- ----- -------------- -----------------------------
 001 2005/12/23          zhao lei       INIT
 002 2005/12/24          zhao lei       delete warning
 003 2005/12/25          zhao lei       delete I_Service interface
 


Constructor & Destructor Documentation

org.colimas.services.xml.XMLObject.XMLObject Document  dom  ) 
 

Builds an XMLObject from an existing Document

org.colimas.services.xml.XMLObject.XMLObject InputStream  inputStream,
int  type,
String  countryCode
 

Builds an XMLObject from an XML stream.
Only pure XML streams can be parsed by this method (i.e. the parameter must be set to XMLFILE).

Parameters:
inputStream The stream to be read.
type Must be XMLFILE
countryCode Code of the country for encoding (can be null)

org.colimas.services.xml.XMLObject.XMLObject String  value,
int  type
 

Builds an XMLOBject according to the given type.

  • XMLFILE : value contains a file path
  • XMLSTRING : value contains an XML string
  • DTDFILE : value contains a public ID of DTD
See also:
XMLDTDServer


Member Function Documentation

void org.colimas.services.xml.XMLObject.appendChild Node  eParent,
Node  eNewChild
 

This method append the eNewChild node under the eParent node. It is used n the cases where the Node.appendChild() cannot be used because eNewChild does not belong to the same DOM than the eParent. An "adoption" must be then performed in order to append the child to its new parent.
Note : the eParent node must belong to a org.apache.xerces.dom.DocumentImpl which is the DOM implementation supported by the XMLObject. In all others case, an IllegalArgumentException will be raised.

Parameters:
eParent The parent node
eNewChild The child node (from another DOM or not)

Element org.colimas.services.xml.XMLObject.createAndInsertElement Element  eParent,
String  childName,
String  childValue
throws SAXException, IOException, XMLException
 

Creates a new element and inserts it under its parent.

Returns:
The created element
Parameters:
eParent The parent of the element
childName The child name
childValue The child text (can be null if theere is no value)

Element org.colimas.services.xml.XMLObject.createElement String  elementName  )  throws IOException, SAXException, XMLException
 

Create a new element tree from its name. The corresponding structure is found into the main DTD owned by the XMLObject. The multiplicity that are used are those of the XMLObject.

Returns:
An element with its valid childrens and attributes.
Parameters:
elementName The element to create

XMLFactory org.colimas.services.xml.XMLObject.createXMLFactory  )  throws IOException, SAXException, XMLException [protected]
 

Creates an XMLFactory according to the parameters that are into the XMLObject

See also:
XMLFactory

void org.colimas.services.xml.XMLObject.deleteFromElement Element  element  ) 
 

Delete the Element identified by his name including all his child nodes.

Parameters:
element Element to delete

Vector org.colimas.services.xml.XMLObject.getAllSibling Element  fromElement,
String  elementName
 

Get all sibling Elements which share the same name.
The searching process starts from the specified Element.

Returns:
a Vector class which contains the Elements
Parameters:
fromElement the Element from which the search begins.
elementName Name of the Element to find

Document org.colimas.services.xml.XMLObject.getDOM  ) 
 

Getter on the current DOM

Returns:
The DOM handled by the XMLObject

DTD org.colimas.services.xml.XMLObject.getDTD  )  throws XMLException
 

Returns the DTD associated with the document.

Returns:
The DTD (it is never null, if the document has not DTD, this method throws an exception).

Element org.colimas.services.xml.XMLObject.getRoot  ) 
 

Get the root element of the XML

String org.colimas.services.xml.XMLObject.getTagValue Element  fromElement,
String  tagName,
String  attributeName,
String  attributeValue
 

Retrieve the Value contained in the specified tag using the specified attribute name and the attribute value.
The search process for this tag starts from the specified Element
Beware: This only works for leaf tag. (ie: <myTag> ma value </myTag>)

Returns:
the Value of the tag or null if the tag is not a leaf tag or if it couldn't be find.
Parameters:
fromElement The Element from which the search process begins
tagName Tag Name from which the value has to be retrieved
AttrName Name of the attribute contained in the Element to find
AttrValue Value of the attribute AttrName

String org.colimas.services.xml.XMLObject.getTagValue Element  fromElement,
String  tagName
 

Retrieve the Value contained in the specified tag.
The search process for this tag starts from the specified Element
Beware: This only works for leaf tag. (ie: <myTag> ma value </myTag>)

Returns:
the Value of the tag or null if the tag is not a leaf tag or if it couldn't be find.
Parameters:
fromElement The Element from which the search process begins
tagName Tag Name from which the value has to be retrieved

String org.colimas.services.xml.XMLObject.getTagValue Element  element  ) 
 

Retrieve the Value contained in the specified tag.

Returns:
the Value of the tag or null if the tag is not a leaf tag or if it couldn't be find.
Parameters:
element Tag Element from which the value has to be retrieved

Node org.colimas.services.xml.XMLObject.importNode Node  node  ) 
 

This method import the node node into the current DOM. It is used in the cases where the Node.cloneNode() cannot be used because node does not belong to the same DOM than the one where we want to move it. An "adoption" must be then performed in order to append the child to its new parent.

Parameters:
node The node to import

void org.colimas.services.xml.XMLObject.initFromDTD String  publicId  )  throws IOException, SAXException, XMLException, XMLException [protected]
 

Creates the XML object from a DTD

Parameters:
publicId java.lang.String

void org.colimas.services.xml.XMLObject.initFromFile File  xmlFile  )  throws SAXException, IOException, XMLException, XMLException [protected]
 

Init the XMLObject from an XML file

Parameters:
xmlFile The XML file

void org.colimas.services.xml.XMLObject.initFromString String  xmlString  )  throws SAXException, IOException, XMLException [protected]
 

Init the XMLObject from an XML string

Parameters:
xmlString The XML string

void org.colimas.services.xml.XMLObject.initFromXML Reader  reader  )  throws SAXException, IOException, javax.xml.parsers.ParserConfigurationException, XMLException [protected]
 

Init the XMLObject from an IO reader

Parameters:
reader The reader
See also:
XMLReader

void org.colimas.services.xml.XMLObject.initFromXML InputStream  in  )  throws SAXException, IOException, javax.xml.parsers.ParserConfigurationException, XMLException [protected]
 

Init the XMLObject from an IO stream

Parameters:
in The input stream
See also:
XMLReader

void org.colimas.services.xml.XMLObject.insertElement Element  newElement,
Element  parent
throws IOException, SAXException, XMLException
 

Insert an Element in the correct location described in the current DTD.
No check is performed if validation is not set.

Parameters:
newElement The new Element to insert to (which become a child of parent)
parent The parent element where to insert the newElement
See also:
isValidation

void org.colimas.services.xml.XMLObject.replaceElement Node  oldElement,
Node  newElement
 

Replace oldElement by newElement

Parameters:
oldElement Element to replace
newElement Element to insert at the place of oldElement

Element org.colimas.services.xml.XMLObject.searchElement Element  fromElement,
String  name,
String  attrName,
String  attrValue,
String  value
 

Search for an Element using the specified name, the attribute name, the attribute value and the value contained in the tag.
The search process starts from the specified Element

Returns:
the Element if found or null if not found.
Parameters:
fromElement Element from which the search begins
name Name of the Element to find
AttrName Name of the attribute contained in the Element to find
AttrValue Value of the attribute AttrName
value Value contained int the tag to find

Element org.colimas.services.xml.XMLObject.searchElement Element  fromNode,
String  name,
String  attrName,
String  attrValue
 

Search for an Element using the specified name, attibute name and attibute value.
The search process start from the Element FromNode

Returns:
the Element if found or null if not found
Parameters:
FromNode Element from which the searche process begins
name Name of the Element to find
AttrName Name of the attribute contained in the Element to find
AttrValue Value of the attribute AttrName

Element org.colimas.services.xml.XMLObject.searchElement Element  fromElement,
String  name,
String  value
 

Search for an Element using the specified name and the value contained in the tag.
The search process starts from the specified fromElement

Returns:
the Element if found or null if not found
Parameters:
fromElement Element from which the search begins
name Name of the Element to find
value Value contained int the tag to find

Element org.colimas.services.xml.XMLObject.searchElement Element  fromNode,
String  name
 

Search for an Element using the specified name and start the search process from a specified Element.
If many Elements with the same name exist in the current DOM, return the nearest to the root Element.

Returns:
The Element if found or null if not found
Parameters:
fromNode Element from which the search begins
name Name of the Element to find

void org.colimas.services.xml.XMLObject.setTagValue Element  fromElement,
String  tagName,
String  attributeName,
String  attributeValue,
String  value
 

Modify the value contained in the specified tag.
The search process of this tag starts from the specified Element
Beware: This only works for leaf tag. (ie: <myTag> ma value </myTag>)

Parameters:
fromElement The Element from which the search process begins
tagName Tag Name which value has to be modified
AttrName Name of the attribute contained in the Element to find
AttrValue Value of the attribute AttrName
value The new value to set for this tag

void org.colimas.services.xml.XMLObject.setTagValue Element  fromElement,
String  tagName,
String  value,
boolean  createIfNotExists
throws SAXException, IOException, XMLException
 

Modify the value contained in the specified tag.
The search process of this tag starts from the specified Element
. If the node does not exist and if createIfNotExists is true, the node is created. If the node does not exists, the method does nothing. Beware: This only works for leaf tag. (ie: <myTag> my value </myTag>)

Parameters:
fromElement The Element from which the search process begins
tagName Tag Name which value has to be modified
value The new value to set for this tag

void org.colimas.services.xml.XMLObject.setTagValue Element  fromElement,
String  tagName,
String  value
 

Modify the value contained in the specified tag.
The search process of this tag starts from the specified Element
Beware: This only works for leaf tag. (ie: <myTag> ma value </myTag>)

Parameters:
fromElement The Element from which the search process begins
tagName Tag Name which value has to be modified
value The new value to set for this tag

void org.colimas.services.xml.XMLObject.setTagValue Element  element,
String  value
 

Modify the value contained in the specified tag.
Beware: This only works for leaf tag. (ie: <myTag> ma value </myTag>)

Parameters:
element The Element which Value has to be modified
value The new value to set for this tag

void org.colimas.services.xml.XMLObject.startParser  )  throws XMLException
 

Ask the parser to begins his job.
Can only be use one time.

Exceptions:
XMLException Exception occurs when the parser encounter a problem

String org.colimas.services.xml.XMLObject.writeToString  )  throws IOException
 

Print the current DOM to a string in the XML format using the curring encoding.

Returns:
The string which contains the DOM


Member Data Documentation

final int org.colimas.services.xml.XMLObject.DTDFILE = 2 [static]
 

Used to indicate to the constructor that the type of the first arameter is a DTD file.

final long org.colimas.services.xml.XMLObject.serialVersionUID = -7828347354799405399L [static, package]
 

Serial number of the XMLObject. It used for serialization.

final String org.colimas.services.xml.XMLObject.TRACE_PROPERTY = "xmlobject.trace" [static]
 

Trace property name, to enable trace set syetem property of this name to "true"

final int org.colimas.services.xml.XMLObject.XMLFILE = 0 [static]
 

Used to indicate to the constructor that the type of the first parameter is a XML file.

final int org.colimas.services.xml.XMLObject.XMLSTRING = 1 [static]
 

Used to indicate to the constructor that the type of the first parameter is a String wich contains a XML.


The documentation for this class was generated from the following file:
Generated on Sat Jan 14 02:04:38 2006 for Colimas by  doxygen 1.4.4