Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.management.oss
Interface XmlSerializer

All Superinterfaces:
  java.io.Serializable, Serializer

All Known Implementing Classes:
  PmXmlSerializerImpl, PmXmlSerializerImpl

public interface XmlSerializer
extends Serializer

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 );

See Also:
  `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

### toXml

    public java.lang.String toXml(java.lang.Object object,
                                  java.lang.String elementName)
                           throws java.lang.IllegalArgumentException

  Serialize this Java object as an XML element. No doctype declaration is generated, in order to allow this String to be embedded as an element of a larger XML document instance.

  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 >

  Parameters:
    `object` - the value to be marshalled into XML.
    `elementName` - the name of the XML element.
  Returns:
    the XML representation of the object.
  Throws:
    `java.lang.IllegalArgumentException` - if the object is not of the proper type.

### fromXml

    public java.lang.Object fromXml(org.w3c.dom.Element element)
                             throws java.lang.IllegalArgumentException

  Deserialize the XML DOM element subtree into the Java object. For example assume that this a Serializer for a `< 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.

  Parameters:
    `element` - the `org.w3c.dom.Element` subtree representing the serialized object.
  Returns:
    a java object corresponding to the XML document.
  Throws:
    `java.lang.IllegalArgumentException` - if an invalid dom element is passed.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD