Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Package Functions | Private Attributes

de.mfuchs.xmlstorage.XMLMessage Class Reference

XML message wrapper is used as a shortcut to create a XMLDoc containing a named XML node. More...

Inheritance diagram for de.mfuchs.xmlstorage.XMLMessage:
Inheritance graph
[legend]
Collaboration diagram for de.mfuchs.xmlstorage.XMLMessage:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

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.


Constructor & Destructor Documentation

de.mfuchs.xmlstorage.XMLMessage.XMLMessage ( final String  name ) [package]

Constructs a XMLMessage object.

Parameters:
nametag name

Definition at line 51 of file XMLMessage.java.

References de.mfuchs.xmlstorage.XMLMessage._pos, and de.mfuchs.xmlstorage.XMLPos.create().

    {
        _pos = new XMLPos(this);

        _pos.create(name);
    }

Here is the call graph for this function:


Member Function Documentation

void de.mfuchs.xmlstorage.XMLNode.addChild ( XMLNode  child ) [inherited]
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;
    }

Here is the call graph for this function:

void de.mfuchs.xmlstorage.XMLNode.clear (  ) [inherited]
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;
    }

Here is the call graph for this function:

XMLNode de.mfuchs.xmlstorage.XMLNode.find ( final String  nodeName ) [inherited]

Find a children node by name.

Parameters:
nodeName
Returns:

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().

    {
        for(XMLNode child : _children)
            if (child._name.equals(nodeName))
                return child;

        return null;
    }
XMLNode de.mfuchs.xmlstorage.XMLNode.find ( final String  nodeName,
int  n 
) [inherited]

Find the n'th children node with tag nodeName.

Parameters:
nodeName
n
Returns:

Definition at line 312 of file XMLNode.java.

References de.mfuchs.xmlstorage.XMLNode._children.

    {
        for(XMLNode child : _children)
            if (child._name.equals(nodeName))
                if (n-- == 0)
                    return child;

        return null;
    }
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.

Parameters:
nodeName
attrName
attrValue
Returns:
XMLNode

Definition at line 329 of file XMLNode.java.

References de.mfuchs.xmlstorage.XMLNode._children.

    {
        for(XMLNode child : _children)
            if (child._name.equals(nodeName) && child.get(attrName).equals(attrValue))
                return child;

        return null;
    }
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.

Parameters:
nodeName
attrName
attrValue
n
Returns:
XMLNode

Definition at line 346 of file XMLNode.java.

References de.mfuchs.xmlstorage.XMLNode._children.

    {
        for(XMLNode node : _children)
            if (node._name.equals(nodeName) && node.get(attrName).equals(attrValue))
                if (n-- == 0)
                    return node;

        return null;
    }
XMLNode de.mfuchs.xmlstorage.XMLNode.findRelative ( XPath  xpath ) [package, inherited]

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;
    }

Here is the call graph for this function:

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]
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]
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);
    }

Here is the call graph for this function:

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().

    {
        if (!_children.isEmpty())
            return _children.getFirst();
        else
            return null;
    }
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 "";
    }

Here is the call graph for this function:

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 "";
    }

Here is the call graph for this function:

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");
    }

Here is the call graph for this function:

void de.mfuchs.xmlstorage.XMLNode.put ( final String  attrName,
final String  value 
) [inherited]
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);
    }

Here is the call graph for this function:

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);
    }

Here is the call graph for this function:

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();
    }

Here is the call graph for this function:

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);
    }

Here is the call graph for this function:

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);
    }

Here is the call graph for this function:

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);
    }

Here is the call graph for this function:

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);
        }
    }

Here is the call graph for this function:

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");
    }

Here is the call graph for this function:

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();
        }
    }

Here is the call graph for this function:

void de.mfuchs.xmlstorage.XMLDoc.writeFile ( final String  path ) throws Exception [inherited]
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);
    }

Here is the call graph for this function:

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();
        }
    }

Here is the call graph for this function:

void de.mfuchs.xmlstorage.XMLNode.writeWorker ( Writer  out,
int  indent 
) throws IOException [protected, inherited]

Write node with children tree using original white space.

Parameters:
out
indent
Exceptions:
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);
    }

Here is the call graph for this function:


Member Data Documentation

String de.mfuchs.xmlstorage.XMLNode._content = "" [protected, inherited]
String de.mfuchs.xmlstorage.XMLNode._endLeading = "" [protected, inherited]
String de.mfuchs.xmlstorage.XMLNode._leading = "" [protected, inherited]
String de.mfuchs.xmlstorage.XMLNode._name [protected, inherited]

Definition at line 58 of file XMLMessage.java.

Referenced by de.mfuchs.xmlstorage.XMLMessage.XMLMessage().

String de.mfuchs.xmlstorage.XMLNode._trailing = "" [protected, inherited]
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]
final String de.mfuchs.xmlstorage.XMLNode.XML_INDENT_SPACE = " " [static, inherited]

The documentation for this class was generated from the following file: