|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
XML Serializer for marshalling and unmarshalling a Java object to and from XML.
For example and assuming that mev
is a managed entity value:
Serializer serializer = mev.makeSerializer( XmlSerializer.getClass().getName()); XmlSerializer mevXmlSerializer = (XmlSerializer) serializer; //If you want to use another encoding style than the default mevXmlSerializer.setEncodingStyle( <API>XmlSerializerEncodingStyles.SomeEncodingStyle); String xmlDoc = mevXmlSerializer.toXml( mev , "Value" ); mev = (ManagedEntityValue) xmlSerializer.fromXml( xmlDoc );
Serializer
,
SerializerFactory
Method Summary | |
java.lang.Object |
fromXml(org.w3c.dom.Element element)
Deserialize the XML DOM element subtree into the Java object. |
java.lang.String |
toXml(java.lang.Object object,
java.lang.String elementName)
Serialize this Java object as an XML element. |
Methods inherited from interface com.sun.management.oss.Serializer |
getDefaultEncodingStyle, getEncodingStyle, getSupportedEncodingStyles, getType, setEncodingStyle |
Method Detail |
public java.lang.String toXml(java.lang.Object object, java.lang.String elementName) throws java.lang.IllegalArgumentException
For example assuming that this is a Serializer for a <ManagedEntity>Key
then calling toXML( "myElementName")
would result in the following:
< myElementName > < co:applicationContext > < co:factoryClass >String</co:factoryClass > < co:url >http://www.xmlspy.com< /co:url > < co:systemProperties > < co:property > < co:name >String< /co:name > < co:value >String< /co:value > < /co:property > < /co:systemProperties > < /co:applicationContext > < co:applicationDN >String< /co:applicationDN > < co:type >String< /co:type > < primaryKey >String< /primaryKey > < /myElementName >
object
- the value to be marshalled into XML.elementName
- the name of the XML element.
java.lang.IllegalArgumentException
- if the object is not of the proper type.public java.lang.Object fromXml(org.w3c.dom.Element element) throws java.lang.IllegalArgumentException
< ManagedEntity >Key
and that we have a DOM element representing the following:
< key > < co:applicationContext > < co:factoryClass >String< /co:factoryClass > < co:url >String< /co:url > < co:systemProperties > < co:property > < co:name >String< /co:name > < co:value >String< /co:value > < /co:property > < /co:systemProperties > < /co:applicationContext > < co:applicationDN >String< /co:applicationDN > < co:type >String< /co:type > < primaryKey >String< /primaryKey > < /key >Then the returned object would be a < ManagedEntity >Key key populated with the proper
ApplicationContext
, applicationDN
, primaryKey
and type
info.
element
- the org.w3c.dom.Element
subtree representing the serialized object.
java.lang.IllegalArgumentException
- if an invalid dom element is passed.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |