XML message wrapper is used as a shortcut to create a XMLDoc containing a named XML node. More...
Public Member Functions | |
void | readFile (final String path) throws Exception |
void | read (InputSource source) throws Exception |
void | write (Writer out) throws Exception |
write XML stream preserving previous white space and comments | |
void | write (Writer out, int mode) throws Exception |
write XML stream | |
void | write (Writer out, int mode, int indent) throws IOException |
write node with children tree | |
void | writeFormating (Writer out) throws Exception |
write XML stream with formating | |
void | writeFormating (final String path) throws Exception |
void | writeFile (final String path) throws Exception |
void | writeFile (final String path, int mode) throws Exception |
String | getName () |
String | toString () |
void | clear () |
void | assign (final XMLNode other) |
void | addChild (XMLNode child) |
add a new child node | |
String | get (final String attrName) |
read only access to an attribute | |
String | get (final String attrName, final String def) |
read only access to an attribute with default value | |
void | put (final String attrName, final String value) |
write access to an attribute | |
String | getSubattrib (final String nodeName, final String attrName) |
convenient value access in children node | |
String | getSubattrib (final String nodeName, final String attrName, int n) |
void | putSubattrib (final String nodeName, final String attrName, final String value) |
convenient storage of distinct values in children node | |
void | putSubattrib (final String nodeName, final String attrName, final String value, int n) |
Children | getChildren () |
String | getContent () |
void | setContent (final String s) |
void | setContent (final String s, boolean cdata) |
XMLNode | find (final String nodeName) |
Find a children node by name. | |
XMLNode | find (final String nodeName, int n) |
Find the n'th children node with tag nodeName. | |
XMLNode | find (final String nodeName, final String attrName, final String attrValue) |
Search matching child node identified by key name and an attribute value. | |
XMLNode | find (final String nodeName, final String attrName, final String attrValue, int n) |
Search matching child node identified by key name and an attribute value. | |
XMLInt | getInt (final String attrName) |
XMLInt | getInt (final String attrName, int def) |
XMLNumber | getNumber (final String attrName) |
XMLNumber | getNumber (final String attrName, BigDecimal def) |
XMLBool | getBool (final String attrName) |
XMLBool | getBool (final String attrName, boolean def) |
XMLString | getString (final String attrName) |
XMLString | getString (final String attrName, final String def) |
Public Attributes | |
XMLHeader | _header = new XMLHeader() |
Static Public Attributes | |
static final int | FORMAT_SMART = 0 |
static final int | FORMAT_ORIGINAL = 1 |
preserve original white space and comments if present; pretty print otherwise | |
static final int | FORMAT_PRETTY = 2 |
write XML stream preserving original white space and comments | |
static final String | XML_INDENT_SPACE = " " |
Protected Member Functions | |
XMLNode | getFirstChild () |
void | writeWorker (Writer out, int indent) throws IOException |
Write node with children tree using original white space. | |
void | prettyWriteWorker (Writer out, int indent) throws IOException |
void | smartWriteWorker (Writer out, int indent) throws IOException |
Protected Attributes | |
String | _name |
Children | _children = new Children() |
AttributeMap | _attributes = new AttributeMap() |
String | _leading = "" |
String | _content = "" |
String | _endLeading = "" |
String | _trailing = "" |
Package Functions | |
XMLMessage (final String name) | |
Constructs a XMLMessage object. | |
XMLNode | findRelative (XPath xpath) |
XPath find function. | |
AbstractXMLNode | createRelative (XPath xpath) |
relative XPath create function | |
Private Attributes | |
XMLPos | _pos |
XML message wrapper is used as a shortcut to create a XMLDoc containing a named XML node.
Definition at line 45 of file XMLMessage.java.
de.mfuchs.xmlstorage.XMLMessage.XMLMessage | ( | final String | name ) | [package] |
Constructs a XMLMessage object.
name | tag name |
Definition at line 51 of file XMLMessage.java.
References de.mfuchs.xmlstorage.XMLMessage._pos, and de.mfuchs.xmlstorage.XMLPos.create().
void de.mfuchs.xmlstorage.XMLNode.addChild | ( | XMLNode | child ) | [inherited] |
add a new child node
Definition at line 152 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._children.
Referenced by de.mfuchs.xmlstorage.XMLPos.addDown(), de.mfuchs.xmlstorage.XMLNode.createRelative(), and de.mfuchs.xmlstorage.XMLNode.putSubattrib().
{ _children.addLast(child); }
void de.mfuchs.xmlstorage.XMLNode.assign | ( | final XMLNode | other ) | [inherited] |
Definition at line 139 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._attributes, de.mfuchs.xmlstorage.XMLNode._children, de.mfuchs.xmlstorage.XMLNode._content, de.mfuchs.xmlstorage.XMLNode._endLeading, de.mfuchs.xmlstorage.XMLNode._leading, de.mfuchs.xmlstorage.XMLNode._trailing, and de.mfuchs.xmlstorage.XMLNode.Children.assign().
Referenced by de.mfuchs.xmlstorage.XMLNode.XMLNode().
{ _children.assign(other._children); _attributes = (AttributeMap) other._attributes.clone(); _leading = other._leading; _content = other._content; _endLeading = other._endLeading; _trailing = other._trailing; }
void de.mfuchs.xmlstorage.XMLNode.clear | ( | ) | [inherited] |
Definition at line 126 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._attributes, de.mfuchs.xmlstorage.XMLNode._children, de.mfuchs.xmlstorage.XMLNode._content, de.mfuchs.xmlstorage.XMLNode._endLeading, de.mfuchs.xmlstorage.XMLNode._leading, de.mfuchs.xmlstorage.XMLNode._name, de.mfuchs.xmlstorage.XMLNode._trailing, and de.mfuchs.xmlstorage.XMLNode.Children.clear().
Referenced by de.mfuchs.xmlstorage.XMLNode.Children.clear().
{ _leading = ""; _content = ""; _endLeading = ""; _trailing = ""; _attributes.clear(); _children.clear(); _name = ""; }
AbstractXMLNode de.mfuchs.xmlstorage.XMLNode.createRelative | ( | XPath | xpath ) | [package, inherited] |
relative XPath create function
Definition at line 372 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode.addChild(), de.mfuchs.xmlstorage.XMLNode.find(), de.mfuchs.xmlstorage.XMLNode.put(), and de.mfuchs.xmlstorage.XMLNode.XMLNode().
{ XMLNode node = this; for(XPathElement elem : xpath) { XMLNode child = elem.find(node); if (child == null) { child = new XMLNode(elem._childName); node.addChild(child); for(Map.Entry<String, String> it : elem._mAttrAndAttr.entrySet()) put(it.getKey(), it.getValue()); } node = child; } return node; }
XMLNode de.mfuchs.xmlstorage.XMLNode.find | ( | final String | nodeName ) | [inherited] |
Find a children node by name.
nodeName |
Definition at line 297 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._children.
Referenced by de.mfuchs.xmlstorage.XMLNode.createRelative(), de.mfuchs.xmlstorage.XMLNode.findRelative(), de.mfuchs.xmlstorage.XMLNode.getSubattrib(), de.mfuchs.xmlstorage.XMLPos.goDown(), de.mfuchs.xmlstorage.XMLNode.putSubattrib(), and de.mfuchs.xmlstorage.XMLPos.smartCreate().
XMLNode de.mfuchs.xmlstorage.XMLNode.find | ( | final String | nodeName, |
int | n | ||
) | [inherited] |
Find the n'th children node with tag nodeName.
nodeName | |
n |
Definition at line 312 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._children.
XMLNode de.mfuchs.xmlstorage.XMLNode.find | ( | final String | nodeName, |
final String | attrName, | ||
final String | attrValue | ||
) | [inherited] |
Search matching child node identified by key name and an attribute value.
nodeName | |
attrName | |
attrValue |
Definition at line 329 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._children.
XMLNode de.mfuchs.xmlstorage.XMLNode.find | ( | final String | nodeName, |
final String | attrName, | ||
final String | attrValue, | ||
int | n | ||
) | [inherited] |
Search matching child node identified by key name and an attribute value.
nodeName | |
attrName | |
attrValue | |
n |
Definition at line 346 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._children.
XPath find function.
Definition at line 357 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode.find().
Referenced by de.mfuchs.xmlstorage.XMLPos.go().
{ XMLNode node = this; for(XPathElement xelem : xpath) { node = xelem.find(node); if (node == null) break; } return node; }
String de.mfuchs.xmlstorage.XMLNode.get | ( | final String | attrName, |
final String | def | ||
) | [virtual, inherited] |
read only access to an attribute with default value
Implements de.mfuchs.xmlstorage.AbstractXMLNode.
Definition at line 169 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._attributes.
{ String found = _attributes.get(attrName); if (found != null) return found; else return def; }
String de.mfuchs.xmlstorage.XMLNode.get | ( | final String | attrName ) | [virtual, inherited] |
read only access to an attribute
Implements de.mfuchs.xmlstorage.AbstractXMLNode.
Definition at line 158 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._attributes.
Referenced by de.mfuchs.xmlstorage.XMLNumberRef.bigDecimalValue(), de.mfuchs.xmlstorage.XMLBoolRef.boolValue(), de.mfuchs.xmlstorage.XMLPos.get(), de.mfuchs.xmlstorage.XMLIntRef.intValue(), de.mfuchs.xmlstorage.XMLStringRef.toString(), de.mfuchs.xmlstorage.XMLBoolRef.XMLBoolRef(), de.mfuchs.xmlstorage.XMLIntRef.XMLIntRef(), de.mfuchs.xmlstorage.XMLNumberRef.XMLNumberRef(), and de.mfuchs.xmlstorage.XMLStringRef.XMLStringRef().
{ String found = _attributes.get(attrName); if (found != null) return found; else return ""; }
XMLBool de.mfuchs.xmlstorage.AbstractXMLNode.getBool | ( | final String | attrName ) | [inherited] |
Definition at line 42 of file AbstractXMLNode.java.
{ return new XMLBool(this, attrName); }
XMLBool de.mfuchs.xmlstorage.AbstractXMLNode.getBool | ( | final String | attrName, |
boolean | def | ||
) | [inherited] |
Definition at line 46 of file AbstractXMLNode.java.
{ return new XMLBool(this, attrName, def); }
Children de.mfuchs.xmlstorage.XMLNode.getChildren | ( | ) | [inherited] |
Definition at line 231 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._children.
Referenced by de.mfuchs.xmlstorage.XMLChildrenFilter.XMLChildrenFilter().
{ return _children; }
String de.mfuchs.xmlstorage.XMLNode.getContent | ( | ) | [virtual, inherited] |
Implements de.mfuchs.xmlstorage.AbstractXMLNode.
Definition at line 236 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._content, and de.mfuchs.xmlstorage.XMLHelper.decodeXMLString().
Referenced by de.mfuchs.xmlstorage.XMLPos.getContent().
{ return XMLHelper.decodeXMLString(_content); }
XMLNode de.mfuchs.xmlstorage.XMLNode.getFirstChild | ( | ) | [protected, inherited] |
Definition at line 284 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._children.
Referenced by de.mfuchs.xmlstorage.XMLPos.goDown().
XMLInt de.mfuchs.xmlstorage.AbstractXMLNode.getInt | ( | final String | attrName ) | [inherited] |
Definition at line 24 of file AbstractXMLNode.java.
{ return new XMLInt(this, attrName); }
XMLInt de.mfuchs.xmlstorage.AbstractXMLNode.getInt | ( | final String | attrName, |
int | def | ||
) | [inherited] |
Definition at line 28 of file AbstractXMLNode.java.
{ return new XMLInt(this, attrName, def); }
String de.mfuchs.xmlstorage.XMLNode.getName | ( | ) | [virtual, inherited] |
Implements de.mfuchs.xmlstorage.AbstractXMLNode.
Definition at line 73 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._name.
{ return _name; }
XMLNumber de.mfuchs.xmlstorage.AbstractXMLNode.getNumber | ( | final String | attrName ) | [inherited] |
Definition at line 33 of file AbstractXMLNode.java.
{ return new XMLNumber(this, attrName); }
XMLNumber de.mfuchs.xmlstorage.AbstractXMLNode.getNumber | ( | final String | attrName, |
BigDecimal | def | ||
) | [inherited] |
Definition at line 37 of file AbstractXMLNode.java.
{ return new XMLNumber(this, attrName, def); }
XMLString de.mfuchs.xmlstorage.AbstractXMLNode.getString | ( | final String | attrName ) | [inherited] |
Definition at line 51 of file AbstractXMLNode.java.
{ return new XMLString(this, attrName); }
XMLString de.mfuchs.xmlstorage.AbstractXMLNode.getString | ( | final String | attrName, |
final String | def | ||
) | [inherited] |
Definition at line 55 of file AbstractXMLNode.java.
{ return new XMLString(this, attrName, def); }
String de.mfuchs.xmlstorage.XMLNode.getSubattrib | ( | final String | nodeName, |
final String | attrName | ||
) | [inherited] |
convenient value access in children node
Definition at line 186 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode.find(), and de.mfuchs.xmlstorage.AbstractXMLNode.get().
{ final AbstractXMLNode node = find(nodeName); if (node != null) return node.get(attrName); else return ""; }
String de.mfuchs.xmlstorage.XMLNode.getSubattrib | ( | final String | nodeName, |
final String | attrName, | ||
int | n | ||
) | [inherited] |
Definition at line 196 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode.find(), and de.mfuchs.xmlstorage.AbstractXMLNode.get().
{ final AbstractXMLNode node = find(nodeName, n); if (node != null) return node.get(attrName); else return ""; }
void de.mfuchs.xmlstorage.XMLNode.prettyWriteWorker | ( | Writer | out, |
int | indent | ||
) | throws IOException [protected, inherited] |
Definition at line 438 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._attributes, de.mfuchs.xmlstorage.XMLNode._children, de.mfuchs.xmlstorage.XMLNode._content, de.mfuchs.xmlstorage.XMLNode._name, de.mfuchs.xmlstorage.XMLHelper.encodeXMLString(), and de.mfuchs.xmlstorage.XMLNode.XML_INDENT_SPACE.
Referenced by de.mfuchs.xmlstorage.XMLNode.write().
{ for(int i=indent; i-->0; ) out.write(XML_INDENT_SPACE); out.write('<'); out.write(XMLHelper.encodeXMLString(_name)); for(Map.Entry<String,String> it : _attributes.entrySet()) { String attrValue = it.getValue(); if (attrValue != null) { out.write(' '); out.write(XMLHelper.encodeXMLString(it.getKey())); out.write("=\""); out.write(XMLHelper.encodeXMLString(attrValue)); out.write("\""); } } if (!_children.isEmpty() || _content.length()>0) { out.write(">\n"); for(XMLNode child : _children) child.prettyWriteWorker(out, indent+1); for(int i=indent; i-->0; ) out.write(XML_INDENT_SPACE); out.write("</"); out.write(XMLHelper.encodeXMLString(_name)); out.write(">\n"); } else out.write("/>\n"); }
void de.mfuchs.xmlstorage.XMLNode.put | ( | final String | attrName, |
final String | value | ||
) | [inherited] |
write access to an attribute
Definition at line 180 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._attributes.
Referenced by de.mfuchs.xmlstorage.XMLStringRef.assign(), de.mfuchs.xmlstorage.XMLNumberRef.assign(), de.mfuchs.xmlstorage.XMLIntRef.assign(), de.mfuchs.xmlstorage.XMLBoolRef.assign(), de.mfuchs.xmlstorage.XMLNode.createRelative(), de.mfuchs.xmlstorage.stream.XMLStreamWriter.put(), de.mfuchs.xmlstorage.XMLPos.put(), de.mfuchs.xmlstorage.XMLNode.putSubattrib(), and de.mfuchs.xmlstorage.XMLPos.smartCreate().
{ _attributes.put(attrName, value); }
void de.mfuchs.xmlstorage.XMLNode.putSubattrib | ( | final String | nodeName, |
final String | attrName, | ||
final String | value, | ||
int | n | ||
) | [inherited] |
Definition at line 219 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode.addChild(), de.mfuchs.xmlstorage.XMLNode.find(), de.mfuchs.xmlstorage.XMLNode.put(), and de.mfuchs.xmlstorage.XMLNode.XMLNode().
{ XMLNode node = find(nodeName, n); if (node == null) { node = new XMLNode(nodeName); addChild(node); } node.put(attrName, value); }
void de.mfuchs.xmlstorage.XMLNode.putSubattrib | ( | final String | nodeName, |
final String | attrName, | ||
final String | value | ||
) | [inherited] |
convenient storage of distinct values in children node
Definition at line 207 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode.addChild(), de.mfuchs.xmlstorage.XMLNode.find(), de.mfuchs.xmlstorage.XMLNode.put(), and de.mfuchs.xmlstorage.XMLNode.XMLNode().
Referenced by de.mfuchs.xmlstorage.XMLPos.putSubattrib().
{ XMLNode node = find(nodeName); if (node == null) { node = new XMLNode(nodeName); addChild(node); } node.put(attrName, value); }
void de.mfuchs.xmlstorage.XMLDoc.read | ( | InputSource | source ) | throws Exception [inherited] |
Definition at line 79 of file XMLDoc.java.
References de.mfuchs.xmlstorage.XMLHeader._additional, de.mfuchs.xmlstorage.XMLDoc._header, de.mfuchs.xmlstorage.XMLDocReader.getInstructions(), and de.mfuchs.xmlstorage.XMLDocReader.read().
Referenced by de.mfuchs.xmlstorage.XMLDoc.readFile().
{ XMLDocReader reader = new XMLDocReader(this); reader.read(source); _header._additional = reader.getInstructions(); }
void de.mfuchs.xmlstorage.XMLDoc.readFile | ( | final String | path ) | throws Exception [inherited] |
Definition at line 69 of file XMLDoc.java.
References de.mfuchs.xmlstorage.XMLDoc.read().
Referenced by de.mfuchs.XMLTest.test1(), de.mfuchs.XMLTest.test2Read(), de.mfuchs.Example3.testRead(), de.mfuchs.Example1.testRead(), and de.mfuchs.xmlstorage.XMLDoc.XMLDoc().
{ InputStream in = new FileInputStream(path); InputSource source = new InputSource(in); source.setSystemId(path); read(source); }
void de.mfuchs.xmlstorage.XMLNode.setContent | ( | final String | s, |
boolean | cdata | ||
) | [inherited] |
Definition at line 246 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._content, and de.mfuchs.xmlstorage.XMLHelper.encodeXMLString().
{ _content = XMLHelper.encodeXMLString(s, cdata); }
void de.mfuchs.xmlstorage.XMLNode.setContent | ( | final String | s ) | [inherited] |
Definition at line 241 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLPos.setContent().
{ setContent(s, false); }
void de.mfuchs.xmlstorage.XMLNode.smartWriteWorker | ( | Writer | out, |
int | indent | ||
) | throws IOException [protected, inherited] |
Definition at line 474 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._attributes, de.mfuchs.xmlstorage.XMLNode._children, de.mfuchs.xmlstorage.XMLNode._content, de.mfuchs.xmlstorage.XMLNode._endLeading, de.mfuchs.xmlstorage.XMLNode._leading, de.mfuchs.xmlstorage.XMLNode._name, de.mfuchs.xmlstorage.XMLNode._trailing, de.mfuchs.xmlstorage.XMLHelper.encodeXMLString(), and de.mfuchs.xmlstorage.XMLNode.XML_INDENT_SPACE.
Referenced by de.mfuchs.xmlstorage.XMLNode.write().
{ if (_leading.length() == 0) for(int i=indent; i-->0; ) out.write(XML_INDENT_SPACE); else out.write(_leading); out.write('<'); out.write(XMLHelper.encodeXMLString(_name)); for(Map.Entry<String,String> it : _attributes.entrySet()) { String attrValue = it.getValue(); if (attrValue != null) { out.write(' '); out.write(XMLHelper.encodeXMLString(it.getKey())); out.write("=\""); out.write(XMLHelper.encodeXMLString(attrValue)); out.write("\""); } } if (_children.isEmpty() && _content.length()==0) out.write("/>"); else { out.write('>'); if (_content.length() == 0) out.write('\n'); else out.write(_content); Iterator<XMLNode> it = _children.iterator(); if (it.hasNext()) { while(it.hasNext()) it.next().smartWriteWorker(out, indent+1); if (_endLeading.length() == 0) for(int i=indent; i-->0; ) out.write(XML_INDENT_SPACE); else out.write(_endLeading); } else out.write(_endLeading); out.write("</"); out.write(XMLHelper.encodeXMLString(_name)); out.write('>'); } if (_trailing.length() == 0) out.write('\n'); else out.write(_trailing); }
String de.mfuchs.xmlstorage.XMLNode.toString | ( | ) | [virtual, inherited] |
Implements de.mfuchs.xmlstorage.AbstractXMLNode.
Definition at line 78 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._name.
Referenced by de.mfuchs.xmlstorage.XMLPos.toString().
{ return _name; }
void de.mfuchs.xmlstorage.XMLNode.write | ( | Writer | out, |
int | mode, | ||
int | indent | ||
) | throws IOException [inherited] |
write node with children tree
Definition at line 268 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode.FORMAT_ORIGINAL, de.mfuchs.xmlstorage.XMLNode.FORMAT_PRETTY, de.mfuchs.xmlstorage.XMLNode.prettyWriteWorker(), de.mfuchs.xmlstorage.XMLNode.smartWriteWorker(), and de.mfuchs.xmlstorage.XMLNode.writeWorker().
{ switch(mode) { case FORMAT_PRETTY: prettyWriteWorker(out, indent); break; case FORMAT_ORIGINAL: writeWorker(out, indent); break; default: // FORMAT_SMART smartWriteWorker(out, indent); } }
void de.mfuchs.xmlstorage.XMLDoc.write | ( | Writer | out, |
int | mode | ||
) | throws Exception [inherited] |
write XML stream
Reimplemented from de.mfuchs.xmlstorage.XMLNode.
Definition at line 96 of file XMLDoc.java.
References de.mfuchs.xmlstorage.XMLNode._children, de.mfuchs.xmlstorage.XMLDoc._header, and de.mfuchs.xmlstorage.XMLHeader.print().
{ _header.print(out);//TODO, mode!=FORMAT_PLAIN if (_children.size() == 1) _children.getFirst().write(out, mode); else if (!_children.isEmpty()) throw new Exception("more than one XML root entry"); }
void de.mfuchs.xmlstorage.XMLDoc.write | ( | Writer | out ) | throws Exception [inherited] |
write XML stream preserving previous white space and comments
Reimplemented from de.mfuchs.xmlstorage.XMLNode.
Definition at line 89 of file XMLDoc.java.
References de.mfuchs.xmlstorage.XMLNode.FORMAT_SMART.
Referenced by de.mfuchs.xmlstorage.XMLDoc.writeFile(), and de.mfuchs.xmlstorage.XMLDoc.writeFormating().
{ write(out, FORMAT_SMART); }
void de.mfuchs.xmlstorage.XMLDoc.writeFile | ( | final String | path, |
int | mode | ||
) | throws Exception [inherited] |
Definition at line 117 of file XMLDoc.java.
References de.mfuchs.xmlstorage.XMLHeader._encoding, de.mfuchs.xmlstorage.XMLDoc._header, and de.mfuchs.xmlstorage.XMLDoc.write().
{ String encoding = _header._encoding.length()>0? _header._encoding: "UTF-8"; Writer out = new OutputStreamWriter(new FileOutputStream(path), encoding); try { write(out, mode); } finally { out.close(); } }
void de.mfuchs.xmlstorage.XMLDoc.writeFile | ( | final String | path ) | throws Exception [inherited] |
Definition at line 112 of file XMLDoc.java.
References de.mfuchs.xmlstorage.XMLNode.FORMAT_SMART.
Referenced by de.mfuchs.XMLTest.test1(), de.mfuchs.XMLTest.test2Write(), de.mfuchs.XMLTest.test3Write(), de.mfuchs.Example3.testWrite(), de.mfuchs.Example2.testWrite(), and de.mfuchs.Example1.testWrite().
{ writeFile(path, FORMAT_SMART); }
void de.mfuchs.xmlstorage.XMLDoc.writeFormating | ( | Writer | out ) | throws Exception [inherited] |
write XML stream with formating
Definition at line 107 of file XMLDoc.java.
References de.mfuchs.xmlstorage.XMLNode.FORMAT_PRETTY, and de.mfuchs.xmlstorage.XMLDoc.write().
Referenced by de.mfuchs.xmlstorage.XMLDoc.writeFormating().
{ write(out, FORMAT_PRETTY); }
void de.mfuchs.xmlstorage.XMLDoc.writeFormating | ( | final String | path ) | throws Exception [inherited] |
Definition at line 130 of file XMLDoc.java.
References de.mfuchs.xmlstorage.XMLDoc.writeFormating().
{ Writer out = new OutputStreamWriter(new FileOutputStream(path), "UTF-8"); try { writeFormating(out); } finally { out.close(); } }
void de.mfuchs.xmlstorage.XMLNode.writeWorker | ( | Writer | out, |
int | indent | ||
) | throws IOException [protected, inherited] |
Write node with children tree using original white space.
out | |
indent |
IOException |
Definition at line 400 of file XMLNode.java.
References de.mfuchs.xmlstorage.XMLNode._attributes, de.mfuchs.xmlstorage.XMLNode._children, de.mfuchs.xmlstorage.XMLNode._content, de.mfuchs.xmlstorage.XMLNode._endLeading, de.mfuchs.xmlstorage.XMLNode._leading, de.mfuchs.xmlstorage.XMLNode._name, de.mfuchs.xmlstorage.XMLNode._trailing, and de.mfuchs.xmlstorage.XMLHelper.encodeXMLString().
Referenced by de.mfuchs.xmlstorage.XMLNode.write().
{ out.write(_leading); out.write('<'); out.write(XMLHelper.encodeXMLString(_name)); for(Map.Entry<String,String> it : _attributes.entrySet()) { String attrValue = it.getValue(); if (attrValue != null) { out.write(' '); out.write(XMLHelper.encodeXMLString(it.getKey())); out.write("=\""); out.write(XMLHelper.encodeXMLString(attrValue)); out.write("\""); } } if (!_children.isEmpty() || _content.length()>0) { out.write('>'); out.write(_content); for(XMLNode child: _children) child.writeWorker(out, indent+1); out.write(_endLeading); out.write("</"); out.write(XMLHelper.encodeXMLString(_name)); out.write('>'); } else out.write("/>"); out.write(_trailing); }
AttributeMap de.mfuchs.xmlstorage.XMLNode._attributes = new AttributeMap() [protected, inherited] |
Definition at line 119 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.assign(), de.mfuchs.xmlstorage.XMLNode.clear(), de.mfuchs.xmlstorage.XMLNode.get(), de.mfuchs.xmlstorage.XMLNode.prettyWriteWorker(), de.mfuchs.xmlstorage.XMLNode.put(), de.mfuchs.xmlstorage.XMLNode.smartWriteWorker(), de.mfuchs.xmlstorage.XMLDocReader.startElement(), and de.mfuchs.xmlstorage.XMLNode.writeWorker().
Children de.mfuchs.xmlstorage.XMLNode._children = new Children() [protected, inherited] |
Definition at line 118 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.addChild(), de.mfuchs.xmlstorage.XMLNode.assign(), de.mfuchs.xmlstorage.XMLNode.clear(), de.mfuchs.xmlstorage.XMLDocReader.endElement(), de.mfuchs.xmlstorage.XPathElement.find(), de.mfuchs.xmlstorage.XMLNode.find(), de.mfuchs.xmlstorage.XMLNode.getChildren(), de.mfuchs.xmlstorage.XMLNode.getFirstChild(), de.mfuchs.xmlstorage.XMLNode.prettyWriteWorker(), de.mfuchs.xmlstorage.XMLDocReader.read(), de.mfuchs.xmlstorage.XMLNode.smartWriteWorker(), de.mfuchs.xmlstorage.XMLDocReader.startElement(), de.mfuchs.xmlstorage.XMLDoc.write(), and de.mfuchs.xmlstorage.XMLNode.writeWorker().
String de.mfuchs.xmlstorage.XMLNode._content = "" [protected, inherited] |
Definition at line 122 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.assign(), de.mfuchs.xmlstorage.XMLNode.clear(), de.mfuchs.xmlstorage.XMLDocReader.endElement(), de.mfuchs.xmlstorage.XMLNode.getContent(), de.mfuchs.xmlstorage.XMLNode.prettyWriteWorker(), de.mfuchs.xmlstorage.XMLNode.setContent(), de.mfuchs.xmlstorage.XMLNode.smartWriteWorker(), de.mfuchs.xmlstorage.XMLDocReader.startElement(), and de.mfuchs.xmlstorage.XMLNode.writeWorker().
String de.mfuchs.xmlstorage.XMLNode._endLeading = "" [protected, inherited] |
Definition at line 123 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.assign(), de.mfuchs.xmlstorage.XMLNode.clear(), de.mfuchs.xmlstorage.XMLDocReader.endElement(), de.mfuchs.xmlstorage.XMLNode.smartWriteWorker(), and de.mfuchs.xmlstorage.XMLNode.writeWorker().
XMLHeader de.mfuchs.xmlstorage.XMLDoc._header = new XMLHeader() [inherited] |
Definition at line 55 of file XMLDoc.java.
Referenced by de.mfuchs.xmlstorage.XMLDoc.read(), de.mfuchs.xmlstorage.XMLDoc.write(), and de.mfuchs.xmlstorage.XMLDoc.writeFile().
String de.mfuchs.xmlstorage.XMLNode._leading = "" [protected, inherited] |
Definition at line 121 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.assign(), de.mfuchs.xmlstorage.XMLNode.clear(), de.mfuchs.xmlstorage.XMLNode.smartWriteWorker(), de.mfuchs.xmlstorage.XMLNode.writeWorker(), and de.mfuchs.xmlstorage.XMLNode.XMLNode().
String de.mfuchs.xmlstorage.XMLNode._name [protected, inherited] |
Definition at line 71 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.clear(), de.mfuchs.xmlstorage.XMLNode.getName(), de.mfuchs.xmlstorage.XMLNode.prettyWriteWorker(), de.mfuchs.xmlstorage.XMLNode.smartWriteWorker(), de.mfuchs.xmlstorage.XMLNode.toString(), de.mfuchs.xmlstorage.XMLNode.writeWorker(), and de.mfuchs.xmlstorage.XMLNode.XMLNode().
XMLPos de.mfuchs.xmlstorage.XMLMessage._pos [private] |
Definition at line 58 of file XMLMessage.java.
Referenced by de.mfuchs.xmlstorage.XMLMessage.XMLMessage().
String de.mfuchs.xmlstorage.XMLNode._trailing = "" [protected, inherited] |
Definition at line 124 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.assign(), de.mfuchs.xmlstorage.XMLNode.clear(), de.mfuchs.xmlstorage.XMLDocReader.read(), de.mfuchs.xmlstorage.XMLNode.smartWriteWorker(), de.mfuchs.xmlstorage.XMLDocReader.startElement(), and de.mfuchs.xmlstorage.XMLNode.writeWorker().
final int de.mfuchs.xmlstorage.XMLNode.FORMAT_ORIGINAL = 1 [static, inherited] |
preserve original white space and comments if present; pretty print otherwise
Definition at line 254 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.write().
final int de.mfuchs.xmlstorage.XMLNode.FORMAT_PRETTY = 2 [static, inherited] |
write XML stream preserving original white space and comments
Definition at line 255 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.write(), and de.mfuchs.xmlstorage.XMLDoc.writeFormating().
final int de.mfuchs.xmlstorage.XMLNode.FORMAT_SMART = 0 [static, inherited] |
Definition at line 253 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.write(), de.mfuchs.xmlstorage.XMLDoc.write(), and de.mfuchs.xmlstorage.XMLDoc.writeFile().
final String de.mfuchs.xmlstorage.XMLNode.XML_INDENT_SPACE = " " [static, inherited] |
Definition at line 436 of file XMLNode.java.
Referenced by de.mfuchs.xmlstorage.XMLNode.prettyWriteWorker(), de.mfuchs.xmlstorage.XMLNode.smartWriteWorker(), de.mfuchs.xmlstorage.stream.XMLStreamWriter.writePost(), and de.mfuchs.xmlstorage.stream.XMLStreamWriter.writePre().