com.tensegrity.generic.persistence
Class XMLReader

java.lang.Object
  extended bycom.tensegrity.generic.persistence.XMLReader
All Implemented Interfaces:
Reader

Deprecated. use XMLStreamReader instead.

public class XMLReader
extends java.lang.Object
implements Reader

Reads a xml file and parses its contents into an AttributeList, which can contain AttributeSets and Attributes. Additionally constraints may be assigned to all these types through the document.

Structure of XML-file:

 
- LIST:

  <list name=NAME>
      (LIST | SET | ATTRIBUTE)*
      (constraint)+
  </list>
 
      NAME: Name of list (in a set this has to be unique)

  
- SET:

  <set name=NAME>
      (SET | ATTRIBUTE)*
  </set>
 
       NAME: String name of this set (in a set this has to be unique)

  
- ATTRIBUTE:

  <attribute name=NAME type=TYPE value=VALUE>
      (CONSTRAINT)+
  </attribute>
 
       NAME: String name of this attribute (in a set this has to be unique)
       TYPE: Full classname of the value of this attribute
      VALUE: Initial value of the instance of this valueobject 
 
 
- CONSTRAINT:

  <constraint>
      <![cdata[(EXPR)]]>
  </constraint>
 
  (Instead of the cdata-Part a text node is allowed, too:
   <constraint>value==0</constraint>
   But concerning the special characters (">", ...) it should not be used.)


- EXPR:

  String expression that must be parseable by the 
  ConstraintParser.
 
 

Structure of AttributeList:

 
- LIST:

  AttributeList, containing attributes of following types:
      (LIST-ATTRIBUTE | SET-ATTRIBUTE | ATTRIBUTE)*
      May contain a valid constraint of any type.

  
- LIST-ATTRIBUTE:

  Attribute with name and value. In a set the name has to be unique.
  The name will be stored as name of the list. 
  The value is of type AttributeList.
  Must not contain a constraint, as this is ignored during writing to xml.
  Instead the constraint should be assigned to the AttributeList directly.
  The list itself may contain the following attributes:
  (LIST-ATTRIBUTE | SET-ATTRIBUTE | ATTRIBUTE)*

  
- SET-ATTRIBUTE:

  Attribute with name and value. In a set the name has to be unique.
  The name will be stored as name of the set. 
  The value is of type AttributeSet.
  Must not contain a constraint, as this is ignored during writing to xml.
  Instead the constraint should be assigned to the AttributeSet directly.
  The set itself may contain the following attributes:
  (SET-ATTRIBUTE | ATTRIBUTE)*

  
- ATTRIBUTE:

  Any attribute with a name and value. In a set the name has to be unique.
  The value may be of any type that can be recreated/stored by 
  parseToObject() (or storeToString() of XMLWriter).
 
 

Version:
$Id: XMLReader.java,v 1.36 2004/10/11 10:31:11 MichaelKegel Exp $
Author:
MichaelKegel, BurkhardWick

Field Summary
protected static ConstraintParser constraintParser
          Deprecated. to create give constraints for the attributes
 
Constructor Summary
XMLReader(java.io.InputStream inStream)
          Deprecated. use XMLStreamReader instead.
 
Method Summary
protected  Constraint getConstraint(org.w3c.dom.Element elem)
          Deprecated. Reads the constraints under the current xml element.
protected  boolean isAttribute(org.w3c.dom.Element element)
          Deprecated. Checks whether the given Element is an Attribute.
protected  boolean isConstraint(org.w3c.dom.Element element)
          Deprecated. Checks whether the given Element is a Constraint.
protected  boolean isList(org.w3c.dom.Element element)
          Deprecated. Checks whether the given Element contains a List.
protected  boolean isSet(org.w3c.dom.Element element)
          Deprecated. Checks whether the given Element contains a Set.
protected  boolean parseToCollection(org.w3c.dom.Element elem, AttributeCollection collection)
          Deprecated. Parses a xml element (and its subnodes) to fill the given collection
protected  java.lang.Object parseToObject(org.w3c.dom.Element elem)
          Deprecated. Used string representations of the type (full classname) and the value to create an instance of an object.
 AttributeList read()
          Deprecated. This method reads the information available in the data source and returns them in form of an AttributeList.
 void setInput(java.io.InputStream inStream)
          Deprecated. Sets the input stream for a second use for this class instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constraintParser

protected static final ConstraintParser constraintParser
Deprecated. 
to create give constraints for the attributes

Constructor Detail

XMLReader

public XMLReader(java.io.InputStream inStream)
Deprecated. use XMLStreamReader instead.

Constructor specifying the InputStream to use.

Parameters:
inStream - the InputStream to use.
Method Detail

setInput

public void setInput(java.io.InputStream inStream)
Deprecated. 
Sets the input stream for a second use for this class instance.

Parameters:
inStream - the InputStream that method read() will use.

read

public AttributeList read()
                   throws ReadException,
                          XMLParseException
Deprecated. 
Description copied from interface: Reader
This method reads the information available in the data source and returns them in form of an AttributeList.

Specified by:
read in interface Reader
Returns:
AttributeList with the read information.
Throws:
XMLParseException - thrown if the an error occurs during the processing of XML data.
ReadException - is thrown whenever an error occurs while reading the information
See Also:
Reader.read()

parseToCollection

protected boolean parseToCollection(org.w3c.dom.Element elem,
                                    AttributeCollection collection)
                             throws IllegalNameException,
                                    IllegalValueException,
                                    IllegalAttributeException,
                                    ConstraintViolationException,
                                    ConstraintParserException,
                                    java.text.ParseException
Deprecated. 
Parses a xml element (and its subnodes) to fill the given collection

Parameters:
elem - the element to start parsing with.
collection - the AttributeCollection to build from the element.
Returns:
true, if the parsing succeeded
Throws:
IllegalNameException - If an error occurs
IllegalValueException - If an error occurs
IllegalAttributeException - If an error occurs
ConstraintViolationException - If an error occurs
ConstraintParserException - If an error occurs
java.text.ParseException - If an error occurs

getConstraint

protected Constraint getConstraint(org.w3c.dom.Element elem)
                            throws java.text.ParseException,
                                   ConstraintParserException
Deprecated. 
Reads the constraints under the current xml element.

Parameters:
elem - the current xml element of the document.
Returns:
the constraint that was read, if any
Throws:
ParseException, - if there is a constraint without expression or more than one constraint.
ConstraintParserException, - if the expression is not parseable to a Constraint by the ConstraintParser
java.text.ParseException
ConstraintParserException

isAttribute

protected boolean isAttribute(org.w3c.dom.Element element)
Deprecated. 
Checks whether the given Element is an Attribute.

Parameters:
element - the Element to be checked.
Returns:
true, if the given element is an Attribute.

isSet

protected boolean isSet(org.w3c.dom.Element element)
Deprecated. 
Checks whether the given Element contains a Set.

Parameters:
element - the Element to be checked.
Returns:
true, if the given element is a Set.

isConstraint

protected boolean isConstraint(org.w3c.dom.Element element)
Deprecated. 
Checks whether the given Element is a Constraint.

Parameters:
element - the Element to be checked
Returns:
true, if the given element is an Constraint

isList

protected boolean isList(org.w3c.dom.Element element)
Deprecated. 
Checks whether the given Element contains a List.

Parameters:
element - the Element to be checked.
Returns:
true, if the given element contains a List.

parseToObject

protected java.lang.Object parseToObject(org.w3c.dom.Element elem)
                                  throws java.text.ParseException
Deprecated. 
Used string representations of the type (full classname) and the value to create an instance of an object.

Parameters:
elem - the xml element node containing (at least) the following attributes:
  • type: The full classname of the object to create.
  • value: A string representatin of the value to initialize the object with.
  • Returns:
    the created Object.
    Throws:
    java.text.ParseException - If the element is not parseable


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.