|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.essbase.eas.framework.defs.transfer.XMLTransferObject
public class XMLTransferObject
provides a generic mechanism for transporting Java objects via XML. It is intended to transport objects that primarily consist of properties implemented via get/set method pairs.
There are several guidelines to this transport method:
public Color getBackground()
and public void setBackground(Color value)
. The get method must have 0 (zero) parameters, the set method must have 1 (one) argument, the return type of the get method must match the type of the single parameter in the set method. Note: it is permissable for the get method to be defined as an "is" method; normally this would be used only for boolean
methods but the XMLTransferObject class doesn't enforce that semantic.String
, Integer
, Long
, Short
, Byte
, Double
, Float
, BigDecimal
, BigInteger
, Boolean
and their underlying native types (i.e., long
, short
, etc.public List getACollection()
and public void setACollection(List value)
are not supported.public AliasTable[] getAliasTables()
and public void SetAliasTables(AliasTable[] values)
.This class makes heavy use of Java introspection to generate and parse the XML.
When using this object to export XML, call the add(Object obj)
method to add objects to the set of objects to be transported. Call get()
to retrieve the set of objects that have been transported.
Field Summary | |
---|---|
protected java.util.ArrayList |
data contains the objects to be transported or that have been parsed after transport |
protected java.util.List |
dtds contains a list of dtd objects for this transfer object. |
protected java.util.List |
messages contains the set of messages that were parsed after transport |
protected com.essbase.eas.framework.defs.command.CommandStatus |
status contains the command status object |
protected java.util.Hashtable |
substitutions contains a hashtable of possible substitution classes for importing. |
Constructor Summary | |
---|---|
XMLTransferObject() default constructor |
|
XMLTransferObject(java.util.Hashtable substitutions) Creates a XMLTransferObject and initializes the table of substitutions classes to use for certain classes. |
Method Summary | |
---|---|
void |
add(java.util.Collection coll) adds a collection of objects to the set of objects this instance will export |
void |
add(java.lang.Object obj) adds an object to the set of objects this instance will export. |
void |
addAll(java.lang.Object[] objects) adds an array of objects to the set of objects this instance will export. |
void |
addDTD(java.io.InputStream istream) adds a dtd to the set of dts for this transfer object |
void |
addDTD(java.lang.String name) Adds a dtd to the set of dtds for this transfer object |
void |
addMessage(java.lang.Object value) adds a message to the set of messages for this instance. |
void |
addMessages(java.util.Collection values) adds a collection of messages to the set of messages for this instance. |
static java.lang.Class |
classForName(java.lang.String className) |
void |
clearData() clears the internal data. |
static XMLTransferObject |
createInstance(java.lang.Class c, java.lang.String xmlDoc) creates an instance of an XMLTransferObject , using a specific class and imports an XML string into the internal data structures. |
static XMLTransferObject |
createInstance(java.lang.String xmlDoc) creates an instance of an XMLTransferObject and imports an XML string into the internal data structures. |
void |
dispose() This is called when you nolonger need this class |
void |
exportData(org.w3c.dom.Element root) |
protected void |
exportNonStandardData(org.w3c.dom.Element root) |
static java.lang.String |
exportObjectToXML(java.lang.Class c, java.lang.Object id) Exports the object to XML string |
static java.lang.String |
exportObjectToXML(java.lang.Object id) exports an object to XML so that it can be used as a parameter to an http request. |
java.io.ByteArrayOutputStream |
exportXml() builds and exports the Xml stream for the set of objects that need to be transported. |
java.lang.String |
exportXmlAsString() build and export the Xml stream for the set of objects that need to be transported. |
void |
exportXmlToFile(java.lang.String fname) exports the XML stream to a file. |
void |
extractData(java.lang.String xmlDoc) This methods extracts data from the XML Document. |
java.io.ByteArrayOutputStream |
generateXmlDocument(java.util.List dtdList) |
com.essbase.eas.framework.defs.command.CommandStatus |
getCommandStatus() returns the object considered to be the "command status". |
java.lang.Object[] |
getData() retrieves the set of data that this object represents. |
java.lang.Object[] |
getDataForClass(java.lang.Class c) retrieves the set of data by class type. |
java.util.List |
getDTDList() Retrieves the set of dtd documents that are to be embedded in the XML stream generated by this object. |
XMLTransferMessage |
getMessage() This method will always return the first XMLTransferMessage |
java.util.Collection |
getMessages() |
java.lang.Object[] |
getMessages(java.lang.Class c) |
static java.util.Collection |
getMessages(java.util.List messages) |
static java.lang.Object |
getObjectFromXML(java.lang.String xmlString, java.lang.Class c) Returns the first data object of the type Class c from the XML document |
boolean |
getValidating() |
void |
importData(org.w3c.dom.Document doc) |
protected void |
importNonStandardData(org.w3c.dom.Document doc) imports any non-standard data from the XML stream. |
void |
importXml(java.lang.String xmlDoc) parses an incoming XML string into a set of objects and a set of messages. |
void |
importXmlFromFile(java.lang.String fname) |
void |
importXmlFromURL(java.net.URL url) Parses an XML document from a URL source |
static void |
setClassFinder(ClassFinder classfinder) |
void |
setCommandStatus(com.essbase.eas.framework.defs.command.CommandStatus value) sets the command status for this transfer object. |
void |
setSchemaSources(java.io.InputStream[] inpStreams) |
void |
setValidating(boolean valid) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.ArrayList data
protected java.util.List messages
protected com.essbase.eas.framework.defs.command.CommandStatus status
protected java.util.Hashtable substitutions
protected java.util.List dtds
Constructor Detail |
---|
public XMLTransferObject()
public XMLTransferObject(java.util.Hashtable substitutions)
substitutions
- the table of classes used for initializationMethod Detail |
---|
public static XMLTransferObject createInstance(java.lang.String xmlDoc)
XMLTransferObject
and imports an XML string into the internal data structures.xmlDoc
- the text to be importedpublic static XMLTransferObject createInstance(java.lang.Class c, java.lang.String xmlDoc)
XMLTransferObject
, using a specific class and imports an XML string into the internal data structures.c
- a Class object the must be inherited from the XMLTransferObject
class.xmlDoc
- the text to be importedpublic final java.util.List getDTDList()
public final void addDTD(java.lang.String name)
name
- the dtd name to add to the set of dtdspublic final void addDTD(java.io.InputStream istream)
istream
- the dtd to addpublic final java.io.ByteArrayOutputStream exportXml() throws java.lang.Exception
any
- exception that occursjava.lang.Exception
public final java.lang.String exportXmlAsString() throws java.lang.Exception
any
- exception that occursjava.lang.Exception
public final void exportXmlToFile(java.lang.String fname)
fname
- the file name to export to.public final void extractData(java.lang.String xmlDoc) throws java.lang.Exception
data
xmlDoc
- the string containing the XML data.java.lang.Exception
- that occurspublic final void importXml(java.lang.String xmlDoc) throws java.lang.Exception
xmlDoc
- the string containing the XML data.java.lang.Exception
- that occurspublic final void importXmlFromURL(java.net.URL url)
url
- xml URLpublic final void importXmlFromFile(java.lang.String fname)
public final void exportData(org.w3c.dom.Element root) throws java.lang.Exception
java.lang.Exception
protected void exportNonStandardData(org.w3c.dom.Element root) throws java.lang.Exception
java.lang.Exception
public final void importData(org.w3c.dom.Document doc) throws java.lang.Exception
java.lang.Exception
protected void importNonStandardData(org.w3c.dom.Document doc)
doc
- the XML document for importing datapublic static java.lang.Class classForName(java.lang.String className) throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
public final void add(java.lang.Object obj)
obj
- the object to eventually export for transport.public final void addAll(java.lang.Object[] objects)
objects
- the array of objects to add.public final void add(java.util.Collection coll)
coll
- the collection of objects to add.public final void addMessage(java.lang.Object value)
value
- a message objectpublic final void addMessages(java.util.Collection values)
values
- a collection of message objects.public final void setCommandStatus(com.essbase.eas.framework.defs.command.CommandStatus value)
value
- the CommandStatus
to be set for this objectpublic void clearData()
public final com.essbase.eas.framework.defs.command.CommandStatus getCommandStatus()
XMLTransferObject
class; however, since on of the primary uses is to move data between the client and mid-tier via command requests, this is a helper routine. Semantically, we would like to force a convention that every command contain exactly one instance of a command status object when it returns from the mid-tier. In versions of EAS numbered 6.5.3 and before we cannot do that; however, beginning with version 7.0 we will enforce this rule.public final XMLTransferMessage getMessage()
XMLTransferMessage
XMLTransferMessage
object.public final java.util.Collection getMessages()
public static final java.util.Collection getMessages(java.util.List messages)
public final java.lang.Object[] getMessages(java.lang.Class c)
c
- the Class
name for tpublic final java.lang.Object[] getData()
public final java.lang.Object[] getDataForClass(java.lang.Class c)
MyData[] results = (MyData[]) gxo.getDataForClass(MyData.class)
for (int i = 0; i < results.length; ++i)
doSomething ...
c
- a class that represents the data we want.public final java.io.ByteArrayOutputStream generateXmlDocument(java.util.List dtdList) throws java.lang.Exception
java.lang.Exception
public void setValidating(boolean valid)
public boolean getValidating()
public void setSchemaSources(java.io.InputStream[] inpStreams)
public void dispose()
public static java.lang.String exportObjectToXML(java.lang.Object id) throws java.lang.Exception
java.lang.Exception
public static java.lang.String exportObjectToXML(java.lang.Class c, java.lang.Object id) throws java.lang.Exception
c
- the class which is typically subclassed from the XMLTransferObject
classid
- us the object to be transferredid
exported as an XML documentjava.lang.Exception
- that occurspublic static java.lang.Object getObjectFromXML(java.lang.String xmlString, java.lang.Class c)
xmlString
- the xml documentc
- the Class of which the data object is to be extractedpublic static void setClassFinder(ClassFinder classfinder)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |