public abstract class FlistToXML extends java.lang.Object implements XMLConstants
To use, get an instance of converter and specify the flist to convert
to xml via convert. The XML document can be retrieved as
a org.w3c.dom.Document object using getXMLDoc,
as a string using getXMLDocAsString or written to a file
using serializeToFile.
Note: This converter currently supports two formats: PIN_XML_BY_SHORT_NAME and PIN_XML_TYPE.
It is also possible to invoke this converter from the command line. See
main method for usage.
| Modifier and Type | Field and Description |
|---|---|
static int |
INPUT_FLIST
Used in the convert() method - indicates that the given FList is
the input FList for the given opcode.
|
protected org.w3c.dom.Document |
mDoc |
protected static java.lang.String |
NEWLINE |
static int |
OUTPUT_FLIST
Used in the convert() method - indicates that the given FList is
the output FList for the given opcode.
|
PIN_XML_BY_NAME, PIN_XML_BY_SHORT_NAME, PIN_XML_NOTIFICATION, PIN_XML_TYPE| Modifier | Constructor and Description |
|---|---|
protected |
FlistToXML() |
protected |
FlistToXML(java.util.Map<java.lang.String,java.lang.String> fieldMap)
Instantiate Flist to XML converter.
|
| Modifier and Type | Method and Description |
|---|---|
void |
convert(FList f)
Convert the specified flist to XML.
|
void |
convert(FList f,
java.lang.String opcode,
int type)
Convert the specified flist to XML.
|
void |
convertNew(FList f)
Convert the specified flist to XML, with New schema
|
void |
convertNew(FList f,
java.lang.String opcode,
int type)
Convert the specified flist to XML with New Schema.
|
protected abstract org.w3c.dom.Element |
createElement(Field field,
int is_new)
This method should create an element for a flist field.
|
static FlistToXML |
getInstance()
Factory method to get an instance of the converter to default,
PIN_XML_BY_SHORT_NAME, XML format.
|
static FlistToXML |
getInstance(int xmlType)
Factory method to get an instance of the converter for specified,
XML format.
|
static FlistToXML |
getInstance(int xmlType,
java.util.Map<java.lang.String,java.lang.String> fieldMap)
Factory method to get an instance of the converter for specified,
XML format.
|
static FlistToXML |
getInstance(java.util.Map<java.lang.String,java.lang.String> fieldMap)
Factory method to get an instance of the converter for specified,
XML format.
|
protected java.lang.String |
getMappedFieldName(java.lang.String pinFldName)
This method checks to see if the given field is specified in a map
|
protected java.lang.String |
getNameXMLForm(java.lang.String source)
This method converts the input name to Hungarian notation and
also removes the prefix 'PIN_', like
PCM_ABC_XYZ to AbcXyz
|
org.w3c.dom.Document |
getXMLDoc()
Returns the created XML document as org.w3c.dom.Document object.
|
java.lang.String |
getXMLDocAsString()
Returns the created XML document as a string.
|
static void |
main(java.lang.String[] args)
Invokes the flist to XML converter from the command line.
|
void |
serializeToFile(java.io.File file)
Serialize XML document to a file.
|
protected void |
setArrayAttributes(org.w3c.dom.Element arrayElem,
int arrayIndex)
Method to set attributes for Array element.
|
protected void |
setByteBufferAttributes(org.w3c.dom.Element elem,
ByteBuffer bb)
Method to set attributes for ByteBuffer Buffer field type.
|
protected void |
setFileBufferAttributes(org.w3c.dom.Element elem,
FileBuffer fb)
Method to set attributes for FileBuffer Buffer type.
|
protected org.w3c.dom.Document mDoc
public static final int INPUT_FLIST
public static final int OUTPUT_FLIST
protected static final java.lang.String NEWLINE
protected FlistToXML()
protected FlistToXML(java.util.Map<java.lang.String,java.lang.String> fieldMap)
getInstance factory method to get an appropriate
instance.
Flists can be converted to two XML formats:
XMLConstants.PIN_XML_BY_SHORT_NAME and
XMLConstants.PIN_XML_TYPE.
XML types are defined in XMLConstants. *
XMLConstantspublic static FlistToXML getInstance()
public static FlistToXML getInstance(int xmlType)
xmlType - Known XML types are defined in XMLConstants. Two
XML formats are currently supports:
XMLConstants.PIN_XML_BY_SHORT_NAME and
XMLConstants.PIN_XML_TYPEpublic static FlistToXML getInstance(java.util.Map<java.lang.String,java.lang.String> fieldMap)
fieldMap - A mapping between PIN_FLD names and custom names. To be used
during XML transformation.public static FlistToXML getInstance(int xmlType, java.util.Map<java.lang.String,java.lang.String> fieldMap)
xmlType - Known XML types are defined in XMLConstants. Two
XML formats are currently supports:
XMLConstants.PIN_XML_BY_SHORT_NAME and
XMLConstants.PIN_XML_TYPEfieldMap - A mapping between PIN_FLD names and custom names. To be used
during XML transformation.public void convert(FList f) throws javax.xml.parsers.ParserConfigurationException, EBufException
f - The FList to convert to XMLjavax.xml.parsers.ParserConfigurationExceptionEBufExceptionpublic void convertNew(FList f) throws javax.xml.parsers.ParserConfigurationException, EBufException
f - The FList to convert to XMLjavax.xml.parsers.ParserConfigurationExceptionEBufExceptionpublic void convert(FList f, java.lang.String opcode, int type) throws javax.xml.parsers.ParserConfigurationException, EBufException
f - The FList to convert to XMLopcode - The opcode this FList is for - may be null. If null then
a schema reference is not generatedtype - Either FlistToXML.INPUT_FLIST or FlistToXML.OUTPUT_FLIST to
indicate if the FList is the input or output FList for the opcode.javax.xml.parsers.ParserConfigurationExceptionEBufExceptionpublic void convertNew(FList f, java.lang.String opcode, int type) throws javax.xml.parsers.ParserConfigurationException, EBufException
f - The FList to convert to XMLopcode - The opcode this FList is for - may be null. If null then
a schema reference is not generatedtype - Either FlistToXML.INPUT_FLIST or FlistToXML.OUTPUT_FLIST to
indicate if the FList is the input or output FList for the opcode.javax.xml.parsers.ParserConfigurationExceptionEBufExceptionpublic org.w3c.dom.Document getXMLDoc()
public java.lang.String getXMLDocAsString()
public void serializeToFile(java.io.File file)
throws javax.xml.transform.TransformerException
file - Where to serializejavax.xml.transform.TransformerExceptionprotected abstract org.w3c.dom.Element createElement(Field field, int is_new)
field - Flist field for which an element node is being createdis_new - int to specify which schema to use, (=1 for new schema).FlistToXMLByType,
FlistToXMLShortName,
FlistToXMLNotificationpublic static void main(java.lang.String[] args)
Usage: java com.portal.pcm.FlistToXML [-n]ew [-type|-shortname] flistfilename
protected java.lang.String getNameXMLForm(java.lang.String source)
source - Input date in srcFormatprotected void setArrayAttributes(org.w3c.dom.Element arrayElem,
int arrayIndex)
arrayElem - Array element being processed.arrayIndex - Index of the array element.protected void setByteBufferAttributes(org.w3c.dom.Element elem,
ByteBuffer bb)
elem - ByteBuffer Element.bb - ByteBuffer value.protected void setFileBufferAttributes(org.w3c.dom.Element elem,
FileBuffer fb)
elem - FileBuffer element.fb - FileBuffer value.protected java.lang.String getMappedFieldName(java.lang.String pinFldName)
pinFldName - Field name of the form PIN_FLD_NAME.