public class IDataXMLCoder extends IDataCoder
Important: If you use IDataXMLCoder to encode IData objects, then you MUST use IDataXMLCoder. to decode it. Although webMethods may change the XML format produced by this class in the future, it will always remain backwardly compatible. If you modify the XML outside of IDataXMLCoder methods, you might not be able to decode that XML in a future release.
XMLCoder can encode IData objects that contain any of the following Object < types.
Valid Primary Object Types
IData | IDataCodable | Codable |
Vector | Number | String |
Mboolean | boolean | true or false |
Valid Object Array Types
String[] | IData[] | IDataCodable[] |
Vector[] | Object[] | Object[][] |
Objects other than those listed above are not supported, and IDataXMLCoder will not encode or decode them. If an unsupported object is contained in an IData object that you are encoding, IDataXMLCoder will post a warning message to the debug log.
IDataCodable
,
IDataXMLCoder
,
IData
Constructor and Description |
---|
IDataXMLCoder()
Constructs a new IDataXMLCoder object.
|
Modifier and Type | Method and Description |
---|---|
IData |
decode(java.io.InputStream is)
Decodes the XML in the specified InputStream to an IData object.
|
void |
encode(java.io.OutputStream os,
IData data)
Encodes the specified IData object as an XML document and writes that document to an OutputStream.
|
java.lang.String |
getContentType()
Returns a String object indicating the current content type.
|
void |
setContentType(java.lang.String ctype)
Sets the content type.
|
void |
setIgnoreInvalid(boolean ignore)
Sets a boolean flag that specifies whether this IDataXMLCoder ignores unsupported object types in the data that it encodes or decodes.
|
void |
setUseOIDs(boolean use)
Specifies whether Object Identifiers (OIDs) are assigned to object values.
|
void |
setUseXMLHeader(boolean use)
Sets a boolean flag that specifies whether or not an XML header (for example, <?xml version="1.0" encoding "UTF-8" >) is included in the XML document.
|
decodeFromBytes, encodeToBytes, readFromFile, writeToFile
public IData decode(java.io.InputStream is) throws java.io.IOException, InvalidDatatypeException
decode
in class IDataCoder
is
- An InputStream that contains the XML document that you want to decode.java.io.IOException
- If an error occurs while reading InputStream.InvalidDatatypeException
- If the XML in InputStream cannot be decoded or it contains an unsupported object type and setIgnoreInvalid is false.setIgnoreInvalid(boolean)
,
encode(java.io.OutputStream, com.wm.data.IData)
public void encode(java.io.OutputStream os, IData data) throws java.io.IOException, InvalidDatatypeException
encode
in class IDataCoder
os
- The OutputStream into which you want the XML-encoded IData object written.data
- The IData object that you want to encode.java.io.IOException
- If error occurs while writing to the OutputStream.InvalidDataTypeException
- If the IData object contains an unsupported object type and setIgnoreInvalid is false.InvalidDatatypeException
- If the data in the IData object cannot be encoded (i.e.,
the IData object contains an object type that is not supported by the specific
implementation of encode that you are using).setIgnoreInvalid(boolean)
,
decode(java.io.InputStream)
public java.lang.String getContentType()
getContentType
in class IDataCoder
setContentType(java.lang.String)
public void setContentType(java.lang.String ctype)
Note: If you want to use the standard webMethods ContentHandler, then do not use this method to override the default content type with a custom one.
ctype
- A String specifying the content type for this XMLCoder.getContentType()
public void setIgnoreInvalid(boolean ignore)
ignore
- A boolean specifying whether unsupported objects are ignored.
Set ignore to… |
To… |
true | Ignore unsupported objects types when encountered (default). |
false | Throw an InvalidDataTypeException when an unsupported object type is encountered. |
public void setUseOIDs(boolean use)
use
- A boolean specifying whether to assign Object Identifiers (OID) to each object value.
Set use to… |
To… |
true | Assign OIDs to object values. |
false | Omit OIDs from object values. |
public void setUseXMLHeader(boolean use)
use
- A boolean specifying whether this IDataXMLCoder will include an XML header when it encodes an IData object as XML.
Set use to… |
To… |
true | Include the XML header. (default) |
false | Omit the XML header. |