|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.generic.persistence.XMLWriter
Writes an AttributeList to a XML-file, which can
contain AttributeLists, AttributeSets and
Attributes.
Additionally Constraints may be assigned to all these types,
which will be stored in the document, too.
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).
| Constructor Summary | |
XMLWriter(java.io.OutputStream outStream)
Deprecated. use XMLStreamWriter instead. |
|
XMLWriter(java.io.OutputStream outStream,
boolean omitXMLHeader)
Deprecated. use XMLStreamWriter instead. |
|
| Method Summary | |
protected boolean |
isAttribute(Attribute attribute)
Deprecated. Checks whether the given Attribute is not of type
AttributeSet and not of type
AttributeList. |
protected boolean |
isAttributeList(Attribute attribute)
Deprecated. Checks whether the given Attribute is an instance of class
AttributeList. |
protected boolean |
isAttributeSet(Attribute attribute)
Deprecated. Checks whether the given Attribute is of type
AttributeSet. |
protected boolean |
isComment(Attribute attribute)
Deprecated. Checks if the given Attribute contains a comment. |
void |
setOutput(java.io.OutputStream outStream)
Deprecated. Sets the OutputStream to be used for this instance. |
protected void |
storeConstraint(Constraint constraint,
org.w3c.dom.Element element,
org.w3c.dom.Document doc)
Deprecated. Stores the given constraint as a child of element
element in the document. |
protected void |
storeToAttributes(org.w3c.dom.Element element,
java.lang.Object object)
Deprecated. Stores the attributes (classname, ...) of the object as attributes of the given Element. |
protected boolean |
storeToDocument(AttributeCollection collection,
org.w3c.dom.Element element,
org.w3c.dom.Document document)
Deprecated. Stores the give collection under the node given by element.
|
protected java.lang.String |
stripPackageName(java.lang.String className)
Deprecated. Returns the given String without the possibly extant package-extension. |
void |
write(AttributeList attributeList)
Deprecated. This method writes the information given by an AttributeList
to a data storage. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public XMLWriter(java.io.OutputStream outStream)
XMLWriter based on the given
OutputStream.
outStream - the OutputStream that should be used to
write out the document.
public XMLWriter(java.io.OutputStream outStream,
boolean omitXMLHeader)
OutputStream. The
omitXMLHeader flag indicates whether to leave out the xml
declaration header.
outStream - the OutputStream that should be used to
write out the document.omitXMLHeader - a switch to omit the xml header of the document.| Method Detail |
public void setOutput(java.io.OutputStream outStream)
OutputStream to be used for this instance.
outStream - the OutputStream that method
write() will use.
public void write(AttributeList attributeList)
throws WriteException
WriterAttributeList
to a data storage.
write in interface WriterattributeList - list holding the information to write.
WriteException - is thrown whenever an error occurs while writing
out the information stored in the AttributeList.AttributeList
protected boolean storeToDocument(AttributeCollection collection,
org.w3c.dom.Element element,
org.w3c.dom.Document document)
element.
It differentiates between AttributeSets,
AttributeLists, single Attributes and comments.
collection - the collection to store.element - the node under which the collection is to be stored.document - the document to which the element belongs.
true, if storing was successful
protected void storeConstraint(Constraint constraint,
org.w3c.dom.Element element,
org.w3c.dom.Document doc)
constraint as a child of element
element in the document.
constraint - the attribute-constraint to be stored.element - the "father"-element to which the
constraint will belong.doc - document holding the given
element.protected boolean isAttributeSet(Attribute attribute)
Attribute is of type
AttributeSet.
attribute - the Attribute to check.
true, if the given Attribute is of type
AttributeSetprotected boolean isAttributeList(Attribute attribute)
Attribute is an instance of class
AttributeList.
attribute - the Attribute to check.
true, if the given Attribute is of type
AttributeList.protected boolean isAttribute(Attribute attribute)
Attribute is not of type
AttributeSet and not of type
AttributeList.
attribute - the Attribute to check.
true, if the given Attribute is
not of type AttributeSet and not of
type AttributeList.protected boolean isComment(Attribute attribute)
attribute - the Attribute to check.
true, if the Attribute
contains a comment.protected java.lang.String stripPackageName(java.lang.String className)
Example:
stripPackageName("com.tensegrity.generic.persistence.XMLWriter")
returns "XMLWriter"
className - the classname to be shortened.
protected void storeToAttributes(org.w3c.dom.Element element,
java.lang.Object object)
Element.
element - the element that will store the
object-attributes.object - the object to store the attributes for.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||