nanoxml
Class XMLElement

java.lang.Object
  extended by nanoxml.XMLElement
Direct Known Subclasses:
StockImageData

public class XMLElement
extends java.lang.Object

This class is modified from nanoxml.XMLElement.
The reason to modify the original class is small memory of embeded devices.


Version:
$Revision: 1.1 $ $Date: 2007/05/09 15:54:52 $
Author:
peaklau
email:peaklau@hotmail.com
HomePage

Nested Class Summary
static class XMLElement.FakeProperties
           
 
Field Summary
static int NANOXML_MAJOR_VERSION
           
static int NANOXML_MINOR_VERSION
           
 
Constructor Summary
XMLElement()
           
 
Method Summary
 void attribute(java.lang.String key, java.lang.String value)
           
 void content(java.lang.String value)
           
 XMLElement createInstance()
           
protected  java.lang.String decodeString(java.lang.String s, int lineNr)
          Converts &...; sequences to "normal" chars.
 void endElement(java.lang.String name)
           
 java.lang.String getContents()
          Returns the #PCDATA content of the object.
 int getLineNr()
          Returns the line nr on which the element is found.
 java.lang.String getTagName()
          Returns the class (i.e. the name indicated in the tag) of the object.
 int parseArray(byte[] input, int offset, int end)
          Parses an XML definition starting at offset.
 int parseArray(byte[] input, int offset, int end, int startingLineNr)
          Parses an XML definition starting at offset.
protected  int scanChildren(byte[] input, int contentOffset, int contentSize, int contentLineNr)
          !!!
 void setContent(java.lang.String content)
          Changes the content string.
 void setTagName(java.lang.String tagName)
          Changes the tag name.
protected  int skipBogusTag(byte[] input, int offset, int end, int[] lineNr)
          Skips a tag that don't contain any useful data: <?...?
 void startElement(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NANOXML_MAJOR_VERSION

public static final int NANOXML_MAJOR_VERSION
See Also:
Constant Field Values

NANOXML_MINOR_VERSION

public static final int NANOXML_MINOR_VERSION
See Also:
Constant Field Values
Constructor Detail

XMLElement

public XMLElement()
Method Detail

startElement

public void startElement(java.lang.String name)
                  throws XMLParseException
Throws:
XMLParseException

content

public void content(java.lang.String value)
             throws XMLParseException
Throws:
XMLParseException

attribute

public void attribute(java.lang.String key,
                      java.lang.String value)
               throws XMLParseException
Throws:
XMLParseException

endElement

public void endElement(java.lang.String name)
                throws XMLParseException
Throws:
XMLParseException

createInstance

public XMLElement createInstance()

getContents

public java.lang.String getContents()
Returns the #PCDATA content of the object. If there is no such content, null is returned.


getLineNr

public int getLineNr()
Returns the line nr on which the element is found.


getTagName

public java.lang.String getTagName()
Returns the class (i.e. the name indicated in the tag) of the object.


parseArray

public int parseArray(byte[] input,
                      int offset,
                      int end)
               throws XMLParseException
Parses an XML definition starting at offset.

Returns:
the offset of the array following the XML data (<= end)
Throws:
XMLParseException - if an error occured while parsing the array

parseArray

public int parseArray(byte[] input,
                      int offset,
                      int end,
                      int startingLineNr)
               throws XMLParseException
Parses an XML definition starting at offset.

Returns:
the offset of the array following the XML data (<= end)
Throws:
XMLParseException - if an error occured while parsing the array

scanChildren

protected int scanChildren(byte[] input,
                           int contentOffset,
                           int contentSize,
                           int contentLineNr)
                    throws XMLParseException
!!! Searches the content for child objects. If such objects exist, the content is reduced to null.

Throws:
XMLParseException - if an error occured while parsing the array
See Also:
XMLElement#parseCharArray

setContent

public void setContent(java.lang.String content)
Changes the content string.

Parameters:
content - The new content string.

setTagName

public void setTagName(java.lang.String tagName)
Changes the tag name.

Parameters:
tagName - The new tag name.

skipBogusTag

protected int skipBogusTag(byte[] input,
                           int offset,
                           int end,
                           int[] lineNr)
Skips a tag that don't contain any useful data: <?...?>, <!...> and comments.

Returns:
the position after the tag
Throws:
XMLParseException - if an error occured while parsing the array

decodeString

protected java.lang.String decodeString(java.lang.String s,
                                        int lineNr)
Converts &...; sequences to "normal" chars.



Copyright © 2007-2009 peaklau. All Rights Reserved.