|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.opencyc.xml.XMLWriter
Implements an XMLWriter with facilities for surrounding data elements with tags appropriately named and indented.
Copyright 2001 Cycorp, Inc., license is open source GNU LGPL.
THIS SOFTWARE AND KNOWLEDGE BASE CONTENT ARE PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENCYC ORGANIZATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE AND KNOWLEDGE BASE CONTENT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Constructor Summary | |
XMLWriter()
|
Method Summary | |
abstract void |
close()
Closes the XMLWriter . |
abstract void |
flush()
Flushes the XMLWriter . |
int |
getIndentLength()
Returns the length of the current value of @see #indentString. |
abstract void |
indentPrint(java.lang.String string,
int indent,
boolean relative)
Prints a string to this XMLWriter indenting it
by the number of spaces indicated by @see #indent either relative to the
current indentation level (if @see #relative is true ) or with
respect to the beginning of the line (if @see #relative is false ). |
void |
indentPrintln(java.lang.String string,
int indent,
boolean relative)
Prints a string and terminates the line. |
void |
indentPrintSafe(java.lang.String string,
int indent,
boolean relative)
Prints a string to this XMLWriter after replacing all the reserved XML characters
with the appropriate XML entity references indenting it
by the number of spaces indicated by @see #indent either relative to the
current indentation level (if @see #relative is true ) or with
respect to the beginning of the line (if @see #relative is false ). |
void |
indentPrintSafeln(java.lang.String string,
int indent,
boolean relative)
Prints a string after replacing all the reserved XML characters with the appropriate XML entity references and terminates the line. |
static java.lang.String |
introduceXMLEntities(java.lang.String inputString)
Replaces all occurences of reserved characters <, &, >, ", ' with the predefined XML entities <, &, >, ", ' |
abstract void |
print(java.lang.String string)
Prints @see #string to this XMLWriter . |
void |
printSafe(java.lang.String string)
Prints @see #string to this XMLWriter after performing all the appropriate
substitutions of XML reserved characters. |
void |
printXMLAtomicTag(java.lang.String tag,
int indent,
boolean relative)
Prints to this XMLWriter an atomic XML tag with no attributes. |
void |
printXMLAtomicTag(java.lang.String tag,
java.util.ListIterator attributesIterator,
int indent,
boolean relative)
Prints to this XMLWriter an atomic XML tag with attributes. |
void |
printXMLAtomicTag(java.lang.String tag,
java.lang.String attributeName,
java.lang.String attributeValue,
int indent,
boolean relative,
boolean newline)
Prints to this XMLWriter an atomic XML tag with a single attribute. |
void |
printXMLEndTag(java.lang.String tag)
Prints to this XMLWriter an XML end tag. |
void |
printXMLEndTag(java.lang.String tag,
int indent,
boolean relative)
Prints to this XMLWriter an XML end tag. |
void |
printXMLStartTag(java.lang.String tag,
int indent,
boolean relative)
|
void |
printXMLStartTag(java.lang.String tag,
int indent,
boolean relative,
boolean newline)
Prints to this XMLWriter an XML start tag with no attributes. |
void |
printXMLStartTag(java.lang.String tag,
java.util.ListIterator attributesIterator,
int indent,
boolean relative,
boolean newline)
Prints to this XMLWriter an XML start tag with attributes. |
void |
printXMLStartTag(java.lang.String tag,
java.lang.String attributeName,
java.lang.String attributeValue,
int indent,
boolean relative,
boolean newline)
Prints to this XMLWriter an XML start tag with a single attribute. |
void |
resetIndent()
Resets the indentationof the XMLWriter to its default value. |
void |
setIndent(int indent,
boolean relative)
Sets the length of the indentation of the XMLFileWriter object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public XMLWriter()
Method Detail |
public static java.lang.String introduceXMLEntities(java.lang.String inputString)
inputString
- a string to be checked for the occurrence of
reserved characters.public void setIndent(int indent, boolean relative) throws java.lang.RuntimeException
indent
- the number of spaces that constitute the indentation.relative
- determines whether indentation should be relative to the
current level of indentation -- relative = true
-- or else
absolute -- relative = false
.public void resetIndent()
XMLWriter
to its default value.public int getIndentLength()
public abstract void flush() throws java.io.IOException
XMLWriter
.public abstract void close() throws java.io.IOException
XMLWriter
.public abstract void print(java.lang.String string) throws java.io.IOException
XMLWriter
.string
- the string to be printed.java.io.IOException
- if the XMLWriter
cannot
print to the file specified.public void printSafe(java.lang.String string) throws java.io.IOException
XMLWriter
after performing all the appropriate
substitutions of XML reserved characters.string
- the string to be printed.java.io.IOException
- if the XMLWriter
cannot
print to the file specified.public abstract void indentPrint(java.lang.String string, int indent, boolean relative) throws java.io.IOException
XMLWriter
indenting it
by the number of spaces indicated by @see #indent either relative to the
current indentation level (if @see #relative is true
) or with
respect to the beginning of the line (if @see #relative is false
).string
- the string to be printed.indent
- the number of spaces by which the string needs to be indented.relative
- id true
the string is further indented with respect
to the current indentation level, if false
is indented with respect to
the beginning of the line.public void indentPrintSafe(java.lang.String string, int indent, boolean relative) throws java.io.IOException
XMLWriter
after replacing all the reserved XML characters
with the appropriate XML entity references indenting it
by the number of spaces indicated by @see #indent either relative to the
current indentation level (if @see #relative is true
) or with
respect to the beginning of the line (if @see #relative is false
).string
- the string to be printed.indent
- the number of spaces by which the string needs to be indented.relative
- id true
the string is further indented with respect
to the current indentation level, if false
is indented with respect to
the beginning of the line.public void indentPrintln(java.lang.String string, int indent, boolean relative) throws java.io.IOException
XMLWriter
and indented by the number of spaces indicated by @see #indent either relative to the
current indentation level (if @see #relative is true
) or with
respect to the beginning of the line (if @see #relative is false
).string
- the string to be printed.indent
- the number of spaces by which the string needs to be indented.relative
- id true
the string is further indented with respect
to the current indentation level, if false
is indented with respect to
the beginning of the line.public void indentPrintSafeln(java.lang.String string, int indent, boolean relative) throws java.io.IOException
XMLWriter
and indented by the number
of spaces indicated by @see #indent either relative to the current indentation
level (if @see #relative is true
) or with respect to the beginning
of the line (if @see #relative is false
).string
- the string to be printed.indent
- the number of spaces by which the string needs to be indented.relative
- id true
the string is further indented with respect
to the current indentation level, if false
is indented with respect to
the beginning of the line.public void printXMLAtomicTag(java.lang.String tag, int indent, boolean relative) throws java.io.IOException
XMLWriter
an atomic XML tag with no attributes.
The tag is indented by @see #indent spaces either from the beginning of the
line (if @see #relative is false
) or relative to the current
indentation level(if @see #relative is true
).tag
- the name of the XML tag.indent
- the number of spaces by which the tag needs to be indented.relative
- specifies whether the indentation is from the beginning
of the line (if @see #relative is false
) or from the current
level of indentation (if @see #relative is true
).public void printXMLAtomicTag(java.lang.String tag, java.util.ListIterator attributesIterator, int indent, boolean relative) throws java.io.IOException
XMLWriter
an atomic XML tag with attributes.
The tag is indented by @see #indent spaces either from the beginning of the
line (if @see #relative is false
) or relative to the current
indentation level(if @see #relative is true
).tag
- the name of the XML tag.attributesIterator
- an iterator over a list of attribute/value
Pair
s.indent
- the number of spaces by which the tag needs to be indented.relative
- specifies whether the indentation is from the beginning
of the line (if @see #relative is false
) or from the current
level of indentation (if @see #relative is true
).public void printXMLStartTag(java.lang.String tag, int indent, boolean relative) throws java.io.IOException
public void printXMLAtomicTag(java.lang.String tag, java.lang.String attributeName, java.lang.String attributeValue, int indent, boolean relative, boolean newline) throws java.io.IOException
XMLWriter
an atomic XML tag with a single attribute.
The tag is indented by @see #indent spaces either from the beginning of the
line (if @see #relative is false
) or relative to the current
indentation level(if @see #relative is true
).tag
- the name of the XML tag.attributeName
- the name of the attribute.attributeValue
- the value of the attribute.indent
- the number of spaces by which the tag needs to be indented.relative
- specifies whether the indentation is from the beginning
of the line (if @see #relative is false
) or from the current
level of indentation (if @see #relative is true
).newline
- specifies whether the line should be terminated after the tag
has been printedpublic void printXMLStartTag(java.lang.String tag, int indent, boolean relative, boolean newline) throws java.io.IOException
XMLWriter
an XML start tag with no attributes.
The tag is indented by @see #indent spaces either from the beginning of the
line (if @see #relative is false
) or relative to the current
indentation level(if @see #relative is true
).tag
- the name of the XML tag.indent
- the number of spaces by which the tag needs to be indented.relative
- specifies whether the indentation is from the beginning
of the line (if @see #relative is false
) or from the current
level of indentation (if @see #relative is true
).newline
- specifies whether the line should be terminated after the tag
has been printedpublic void printXMLStartTag(java.lang.String tag, java.util.ListIterator attributesIterator, int indent, boolean relative, boolean newline) throws java.io.IOException
XMLWriter
an XML start tag with attributes.
The tag is indented by @see #indent spaces either from the beginning of the
line (if @see #relative is false
) or relative to the current
indentation level(if @see #relative is true
).tag
- the name of the XML tag.attributesIterator
- an iterator over a list of attribute/valueindent
- the number of spaces by which the tag needs to be indented.relative
- specifies whether the indentation is from the beginning
of the line (if @see #relative is false
) or from the current
level of indentation (if @see #relative is true
).newline
- specifies whether the line should be terminated after the tag
has been printedpublic void printXMLStartTag(java.lang.String tag, java.lang.String attributeName, java.lang.String attributeValue, int indent, boolean relative, boolean newline) throws java.io.IOException
XMLWriter
an XML start tag with a single attribute.
The tag is indented by @see #indent spaces either from the beginning of the
line (if @see #relative is false
) or relative to the current
indentation level(if @see #relative is true
).tag
- the name of the XML tag.attributesName
- the name of the attribute.attributesValue
- the value of the attribute.indent
- the number of spaces by which the tag needs to be indented.relative
- specifies whether the indentation is from the beginning
of the line (if @see #relative is false
) or from the current
level of indentation (if @see #relative is true
).newline
- specifies whether the line should be terminated after the tag
has been printedpublic void printXMLEndTag(java.lang.String tag, int indent, boolean relative) throws java.io.IOException
XMLWriter
an XML end tag.
The tag is indented by @see #indent spaces either from the beginning of the
line (if @see #relative is false
) or relative to the current
indentation level(if @see #relative is true
).tag
- the name of the XML tag.indent
- the number of spaces by which the tag needs to be indented.relative
- specifies whether the indentation is from the beginning
of the line (if @see #relative is false
) or from the current
level of indentation (if @see #relative is true
).public void printXMLEndTag(java.lang.String tag) throws java.io.IOException
XMLWriter
an XML end tag.tag
- the name of the XML tag.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |