Package com.portal.pcm
Class FlistToXML
java.lang.Object
com.portal.pcm.FlistToXML
- All Implemented Interfaces:
XMLConstants
FlistToXML converts an flist to XML document.
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.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Used in the convert() method - indicates that the given FList is the input FList for the given opcode.protected Document
protected static final String
static final int
Used in the convert() method - indicates that the given FList is the output FList for the given opcode.Fields inherited from interface com.portal.pcm.XMLConstants
PIN_XML_BY_NAME, PIN_XML_BY_SHORT_NAME, PIN_XML_NOTIFICATION, PIN_XML_TYPE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
FlistToXML
(Map<String, String> fieldMap) Instantiate Flist to XML converter. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Convert the specified flist to XML.void
Convert the specified flist to XML.void
convertNew
(FList f) Convert the specified flist to XML, with New schemavoid
convertNew
(FList f, String opcode, int type) Convert the specified flist to XML with New Schema.protected abstract Element
createElement
(Field field, int is_new) This method should create an element for a flist field.static FlistToXML
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, Map<String, String> fieldMap) Factory method to get an instance of the converter for specified, XML format.static FlistToXML
getInstance
(Map<String, String> fieldMap) Factory method to get an instance of the converter for specified, XML format.protected String
getMappedFieldName
(String pinFldName) This method checks to see if the given field is specified in a mapprotected String
getNameXMLForm
(String source) This method converts the input name to Hungarian notation and also removes the prefix 'PIN_', like PCM_ABC_XYZ to AbcXyzReturns the created XML document as org.w3c.dom.Document object.Returns the created XML document as a string.static void
Invokes the flist to XML converter from the command line.void
serializeToFile
(File file) Serialize XML document to a file.protected void
setArrayAttributes
(Element arrayElem, int arrayIndex) Method to set attributes for Array element.protected void
setByteBufferAttributes
(Element elem, ByteBuffer bb) Method to set attributes for ByteBuffer Buffer field type.protected void
setFileBufferAttributes
(Element elem, FileBuffer fb) Method to set attributes for FileBuffer Buffer type.
-
Field Details
-
mDoc
-
INPUT_FLIST
public static final int INPUT_FLISTUsed in the convert() method - indicates that the given FList is the input FList for the given opcode.- See Also:
-
OUTPUT_FLIST
public static final int OUTPUT_FLISTUsed in the convert() method - indicates that the given FList is the output FList for the given opcode.- See Also:
-
NEWLINE
- See Also:
-
-
Constructor Details
-
FlistToXML
protected FlistToXML() -
FlistToXML
Instantiate Flist to XML converter. The constructor is protected, usegetInstance
factory method to get an appropriate instance.Flists can be converted to two XML formats:
XMLConstants.PIN_XML_BY_SHORT_NAME
andXMLConstants.PIN_XML_TYPE
. XML types are defined in XMLConstants. *- See Also:
-
-
Method Details
-
getInstance
Factory method to get an instance of the converter to default, PIN_XML_BY_SHORT_NAME, XML format. -
getInstance
Factory method to get an instance of the converter for specified, XML format.- Parameters:
xmlType
- Known XML types are defined in XMLConstants. Two XML formats are currently supports:XMLConstants.PIN_XML_BY_SHORT_NAME
andXMLConstants.PIN_XML_TYPE
-
getInstance
Factory method to get an instance of the converter for specified, XML format.- Parameters:
fieldMap
- A mapping between PIN_FLD names and custom names. To be used during XML transformation.
-
getInstance
Factory method to get an instance of the converter for specified, XML format.- Parameters:
xmlType
- Known XML types are defined in XMLConstants. Two XML formats are currently supports:XMLConstants.PIN_XML_BY_SHORT_NAME
andXMLConstants.PIN_XML_TYPE
fieldMap
- A mapping between PIN_FLD names and custom names. To be used during XML transformation.
-
convert
Convert the specified flist to XML.- Parameters:
f
- The FList to convert to XML- Throws:
ParserConfigurationException
EBufException
-
convertNew
Convert the specified flist to XML, with New schema- Parameters:
f
- The FList to convert to XML- Throws:
ParserConfigurationException
EBufException
-
convert
public void convert(FList f, String opcode, int type) throws ParserConfigurationException, EBufException Convert the specified flist to XML. If the opcode name is specified, the output XML will contain a reference to the schema for that opcode which will enable the XML to be validated.- Parameters:
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.- Throws:
ParserConfigurationException
EBufException
-
convertNew
public void convertNew(FList f, String opcode, int type) throws ParserConfigurationException, EBufException Convert the specified flist to XML with New Schema.- Parameters:
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.- Throws:
ParserConfigurationException
EBufException
-
getXMLDoc
Returns the created XML document as org.w3c.dom.Document object.- Returns:
- XML document created from the flist.
-
getXMLDocAsString
Returns the created XML document as a string.- Returns:
- String of the XML document created from the flist or null if problems are encountered.
-
serializeToFile
Serialize XML document to a file.- Parameters:
file
- Where to serialize- Throws:
TransformerException
-
createElement
This method should create an element for a flist field. Since the content of elements vary based on the type of XML format constructed, subclasses override this method and output correct contents.- Parameters:
field
- Flist field for which an element node is being createdis_new
- int to specify which schema to use, (=1 for new schema).- Returns:
- DOM Element object for the field. The contents are then added to the element.
- See Also:
-
main
Invokes the flist to XML converter from the command line. Outputs the XML to the console and writes it to file. The output filename is the input filename with ".bytype.txt" or ".byshortname.txt" appended to it.Usage:
java com.portal.pcm.FlistToXML [-n]ew [-type|-shortname] flistfilename
-
getNameXMLForm
This method converts the input name to Hungarian notation and also removes the prefix 'PIN_', like PCM_ABC_XYZ to AbcXyz- Parameters:
source
- Input date in srcFormat- Returns:
- converted String in XML notation
-
setArrayAttributes
Method to set attributes for Array element.- Parameters:
arrayElem
- Array element being processed.arrayIndex
- Index of the array element.
-
setByteBufferAttributes
Method to set attributes for ByteBuffer Buffer field type.- Parameters:
elem
- ByteBuffer Element.bb
- ByteBuffer value.
-
setFileBufferAttributes
Method to set attributes for FileBuffer Buffer type.- Parameters:
elem
- FileBuffer element.fb
- FileBuffer value.
-
getMappedFieldName
This method checks to see if the given field is specified in a map- Parameters:
pinFldName
- Field name of the form PIN_FLD_NAME.- Returns:
- Returns the mapped tag for the input PIN_FLD field name.
-