Package helma.objectmodel.dom

# Class XmlWriter

java.lang.Object
java.io.Writer
java.io.OutputStreamWriter
helma.objectmodel.dom.XmlWriter

All Implemented Interfaces:
  `XmlConstants`, `Closeable`, `Flushable`, `Appendable`, `AutoCloseable`

public class XmlWriter extends OutputStreamWriter implements XmlConstants

## Field Summary

Fields
Modifier and Type
Field
Description
`int`
`rootState`

### Fields inherited from class java.io.Writer

`lock`

### Fields inherited from interface helma.objectmodel.dom.XmlConstants

`DATEFORMAT, NAMESPACE`

## Constructor Summary

Constructors
Constructor
Description
`XmlWriter()`
empty constructor, will use System.out as outputstream.
`XmlWriter(File file)`
Creates a new XmlWriter object.
`XmlWriter(File file, String enc)`
Creates a new XmlWriter object.
`XmlWriter(OutputStream out)`
Creates a new XmlWriter object.
`XmlWriter(OutputStream out, String enc)`
Creates a new XmlWriter object.
`XmlWriter(String desc)`
Creates a new XmlWriter object.
`XmlWriter(String desc, String enc)`
Creates a new XmlWriter object.

## Method Summary

Modifier and Type
Method
Description
`static int`
`generateID()`
create ids that can be used for temporary files.
`void`
`setDatabaseMode(boolean dbmode)`
`void`
`setIndent(int ct)`
set the number of space chars
`void`
`setMaxLevels(int levels)`
by default writing only descends 50 levels into the node tree to prevent infite loops.
`boolean`
`write(INode node)`
starting point for printing a node tree.
`void`
`write(INode node, String elementName, String propName, int level)`
write a hopobject and print all its properties and children.
`void`
`writeln(String str)`
`void`
`writeProperty(IProperty property, String elementName, String propName)`
write a single property, set attribute type according to type, apply xml-encoding.
`void`
`writeReferenceTag(INode node, String name, String propName)`
write a tag holding a reference to an element that has been written out before.
`void`
`writeTagClose(String name)`
write a closing tag for a node e.g.
`void`
`writeTagOpen(INode node, String name, String propName)`
write an opening tag for a node.

### Methods inherited from class java.io.OutputStreamWriter

`append, append, close, flush, getEncoding, write, write, write`

### Methods inherited from class java.io.Writer

`append, nullWriter, write, write`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### rootState

public int rootState

## Constructor Details

### XmlWriter

public XmlWriter()
empty constructor, will use System.out as outputstream.

### XmlWriter

public XmlWriter(OutputStream out)
Creates a new XmlWriter object.

Parameters:
  `out` - ...

### XmlWriter

public XmlWriter(OutputStream out, String enc) throws UnsupportedEncodingException
Creates a new XmlWriter object.

Parameters:
  `out` - ...
  `enc` - ...
Throws:
  `UnsupportedEncodingException` - ...

### XmlWriter

public XmlWriter(String desc) throws FileNotFoundException
Creates a new XmlWriter object.

Parameters:
  `desc` - ...
Throws:
  `FileNotFoundException` - ...

### XmlWriter

public XmlWriter(String desc, String enc) throws FileNotFoundException, UnsupportedEncodingException
Creates a new XmlWriter object.

Parameters:
  `desc` - ...
  `enc` - ...
Throws:
  `FileNotFoundException` - ...
  `UnsupportedEncodingException` - ...

### XmlWriter

public XmlWriter(File file) throws FileNotFoundException
Creates a new XmlWriter object.

Parameters:
  `file` - ...
Throws:
  `FileNotFoundException` - ...

### XmlWriter

public XmlWriter(File file, String enc) throws FileNotFoundException, UnsupportedEncodingException
Creates a new XmlWriter object.

Parameters:
  `file` - ...
  `enc` - ...
Throws:
  `FileNotFoundException` - ...
  `UnsupportedEncodingException` - ...

## Method Details

### generateID

public static int generateID()
create ids that can be used for temporary files.

### setMaxLevels

public void setMaxLevels(int levels)
by default writing only descends 50 levels into the node tree to prevent infite loops. number can be changed here.

### setDatabaseMode

public void setDatabaseMode(boolean dbmode)

Parameters:
  `dbmode` - ...

### setIndent

public void setIndent(int ct)
set the number of space chars

### write

public boolean write(INode node) throws IOException
starting point for printing a node tree. creates document header too and initializes the cache of already converted nodes.

Throws:
  `IOException`

### write

public void write(INode node, String elementName, String propName, int level) throws IOException
write a hopobject and print all its properties and children. references are made here if a node already has been fully printed or if this is the last level that's going to be dumped

Throws:
  `IOException`

### writeProperty

public void writeProperty(IProperty property, String elementName, String propName) throws IOException
write a single property, set attribute type according to type, apply xml-encoding.

Throws:
  `IOException`

### writeTagOpen

public void writeTagOpen(INode node, String name, String propName) throws IOException
write an opening tag for a node. Include id and prototype, use a name if parameter is non-empty.

Throws:
  `IOException`

### writeTagClose

public void writeTagClose(String name) throws IOException
write a closing tag for a node e.g. </root>

Throws:
  `IOException`

### writeReferenceTag

public void writeReferenceTag(INode node, String name, String propName) throws IOException
write a tag holding a reference to an element that has been written out before. e.g.

Throws:
  `IOException`

### writeln

public void writeln(String str) throws IOException

Parameters:
  `str` - ...
Throws:
  `IOException` - ...