|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.generic.persistence.XMLReader
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).
| 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 |
protected static final ConstraintParser constraintParser
| Constructor Detail |
public XMLReader(java.io.InputStream inStream)
InputStream to use.
inStream - the InputStream to use.| Method Detail |
public void setInput(java.io.InputStream inStream)
inStream - the InputStream that method
read() will use.
public AttributeList read()
throws ReadException,
XMLParseException
ReaderAttributeList.
read in interface ReaderAttributeList with the read information.
XMLParseException - thrown if the an error occurs during the
processing of XML data.
ReadException - is thrown whenever an error occurs
while reading the informationReader.read()
protected boolean parseToCollection(org.w3c.dom.Element elem,
AttributeCollection collection)
throws IllegalNameException,
IllegalValueException,
IllegalAttributeException,
ConstraintViolationException,
ConstraintParserException,
java.text.ParseException
elem - the element to start parsing with.collection - the AttributeCollection to build from the
element.
true, if the parsing succeeded
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
protected Constraint getConstraint(org.w3c.dom.Element elem)
throws java.text.ParseException,
ConstraintParserException
elem - the current xml element of the document.
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
ConstraintParserExceptionprotected boolean isAttribute(org.w3c.dom.Element element)
Element is an
Attribute.
element - the Element to be checked.
true, if the given element is an
Attribute.protected boolean isSet(org.w3c.dom.Element element)
Element contains a
Set.
element - the Element to be checked.
true, if the given element is a Set.protected boolean isConstraint(org.w3c.dom.Element element)
Element is a
Constraint.
element - the Element to be checked
true, if the given element is an
Constraintprotected boolean isList(org.w3c.dom.Element element)
Element contains a
List.
element - the Element to be checked.
true, if the given element contains a
List.
protected java.lang.Object parseToObject(org.w3c.dom.Element elem)
throws java.text.ParseException
elem - the xml element node containing (at least) the following
attributes:Object.
java.text.ParseException - If the element is not parseable
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||