|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ujac.util.xml.BaseObjectSerializer
public abstract class BaseObjectSerializer
Name: BaseObjectSerializer
Description: A base class for classes which read/write objects from/to XML documents.
Nested Class Summary | |
---|---|
class |
BaseObjectSerializer.ObjectHandler
Name: ObjectHandler Description: Description of the class. |
class |
BaseObjectSerializer.StackElement
Name: StackElement Description: A class holding stack elements. |
Field Summary | |
---|---|
protected BaseObjectSerializer |
parentSerializer
The parent serializer. |
Constructor Summary | |
---|---|
BaseObjectSerializer()
Constructs a BaseObjectSerializer instance with no specific attributes. |
|
BaseObjectSerializer(String encoding)
Constructs a BaseObjectSerializer instance with specific attributes. |
Method Summary | |
---|---|
void |
closeOpenTag(PrintWriter writer,
boolean bodyLess,
boolean newLine)
Closes an open tag to the given writer. |
void |
delegateHandler(BaseObjectSerializer delegate)
Delegates the XML parsing to the given serializer. |
abstract void |
endElement(BaseObjectSerializer.StackElement localElement,
String content,
BaseObjectSerializer.StackElement parentElement,
Object root)
Ends the given local element. |
String |
getEncoding()
Getter method for the the property encoding. |
int |
getRootLevel()
Getter method for the the property rootLevel. |
Object |
getRootObject()
Gets the parsed root object. |
void |
indent(PrintWriter writer,
int level)
Writes the defined indention to the given print writer. |
protected boolean |
parseBooleanValue(String string,
boolean defaultValue)
Parses the given boolean value. |
protected int |
parseIntValue(String string,
int defaultValue)
Parses an integer value from the given String. |
Object |
read(InputSource src)
Parses an instance from the given input source. |
Object |
read(InputStream is)
Parses an object from the given input stream. |
Object |
read(Reader reader)
Parses an object from the given reader. |
void |
setEncoding(String encoding)
Setter method for the the property encoding. |
void |
setRootLevel(int rootLevel)
Setter method for the the property rootLevel. |
abstract void |
startElement(BaseObjectSerializer.StackElement localElement,
BaseObjectSerializer.StackElement parentElement,
Object root)
Starts the given local element. |
void |
startNewLine(PrintWriter writer)
Starts a new line. |
void |
write(OutputStream os,
Object obj)
Writes an object to the given output stream. |
void |
write(PrintWriter writer,
Object obj)
Writes an object to the given print writer. |
void |
write(Writer writer,
Object obj)
Writes an object to the given writer. |
void |
writeAttribute(PrintWriter writer,
String name,
boolean value)
Writes a XML attribute to the given writer. |
void |
writeAttribute(PrintWriter writer,
String name,
int value)
Writes a XML attribute to the given writer. |
void |
writeAttribute(PrintWriter writer,
String name,
String value)
Writes a XML attribute to the given writer. |
void |
writeCloseTag(PrintWriter writer,
String name,
boolean newLine)
Writes a close tag to the given writer. |
void |
writeOpenTag(PrintWriter writer,
String name,
boolean leaveOpen,
boolean newLine)
Writes an open tag to the given writer. |
void |
writeTag(PrintWriter writer,
String name,
Object value,
boolean isCData)
Writes a XML tag to the given writer. |
void |
writeTagBody(PrintWriter writer,
Object value,
boolean cData)
Writes a tag body. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected BaseObjectSerializer parentSerializer
Constructor Detail |
---|
public BaseObjectSerializer()
public BaseObjectSerializer(String encoding)
encoding
- The encoding to use.Method Detail |
---|
public Object getRootObject()
public int getRootLevel()
public void setRootLevel(int rootLevel)
rootLevel
- The value to set for the property rootLevel.public Object read(InputStream is) throws SAXException, IOException
is
- The stream to read the object from.
SAXException
- In case the parsing failed.
IOException
- In case an I/O failure occurred or the parsing failed.public Object read(Reader reader) throws SAXException, IOException
reader
- The reader to read the object from.
SAXException
- In case the parsing failed.
IOException
- In case an I/O failure occurred or the parsing failed.public Object read(InputSource src) throws SAXException, IOException
src
- The input source to read the WebForm from.
SAXException
- In case the parsing failed.
IOException
- In case an I/O failure occurred.public void write(OutputStream os, Object obj) throws IOException
os
- The stream to write the object to.obj
- The instance to write.
IOException
- In case an I/O failure occurred.public void write(Writer writer, Object obj) throws IOException
writer
- The writer to write the WebForm to.obj
- The instance to write.
IOException
- In case an I/O failure occurred.public void write(PrintWriter writer, Object obj) throws IOException
writer
- The writer to write the WebForm to.obj
- The instance to write.
IOException
- In case an I/O failure occurred.public void writeTagBody(PrintWriter writer, Object value, boolean cData)
writer
- The writer to write to.value
- The value to write.cData
- Tells whether or not wrap value into CDATA.public void writeAttribute(PrintWriter writer, String name, String value)
writer
- The writer to write to.name
- The name of the attribute to write.value
- The attribute's value.public void writeAttribute(PrintWriter writer, String name, boolean value)
writer
- The writer to write to.name
- The name of the attribute to write.value
- The attribute's value.public void writeAttribute(PrintWriter writer, String name, int value)
writer
- The writer to write to.name
- The name of the attribute to write.value
- The attribute's value.public void indent(PrintWriter writer, int level)
writer
- The writer to write the WebForm to.level
- The indention level.public void startNewLine(PrintWriter writer)
writer
- The writer to write the WebForm to.public void writeOpenTag(PrintWriter writer, String name, boolean leaveOpen, boolean newLine)
writer
- The writer to write to.name
- The name of the tag to open.leaveOpen
- Tells to leave the tag open.newLine
- Tells to start a new line after the tag.public void closeOpenTag(PrintWriter writer, boolean bodyLess, boolean newLine)
writer
- The writer to write to.bodyLess
- Tells whether or not to close a bodyless tag.newLine
- Tells to start a new line after the tag.public void writeCloseTag(PrintWriter writer, String name, boolean newLine)
writer
- The writer to write to.name
- The name of the tag to open.newLine
- Tells to start a new line after the tag.public void writeTag(PrintWriter writer, String name, Object value, boolean isCData)
writer
- The writer to write to.name
- The name of the tag to write.value
- The attribute's value.isCData
- Tells whether or not the body should be written as CDATA.public String getEncoding()
public void setEncoding(String encoding)
encoding
- The value to set for the property encoding.public void delegateHandler(BaseObjectSerializer delegate) throws SAXException
delegate
- The serializer to delegat the job to.
SAXException
- In case the parsing failed.public abstract void startElement(BaseObjectSerializer.StackElement localElement, BaseObjectSerializer.StackElement parentElement, Object root) throws SAXException
localElement
- The element to process.parentElement
- The parent element if present, else null.root
- The root object of the data structure.
SAXException
- In case the parsing failed.public abstract void endElement(BaseObjectSerializer.StackElement localElement, String content, BaseObjectSerializer.StackElement parentElement, Object root) throws SAXException
localElement
- The element to process.content
- The content of the local element.parentElement
- The parent element if present, else null.root
- The root object of the data structure.
SAXException
- In case the parsing failed.protected int parseIntValue(String string, int defaultValue)
string
- The String to parse.defaultValue
- The default value.
protected boolean parseBooleanValue(String string, boolean defaultValue)
string
- The String to parse.defaultValue
- The default value.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |