Cisco Systems, Inc.

com.pcube.apps.engage.common
Class XMLFormatter

java.lang.Object
  extended by com.pcube.apps.engage.common.XMLFormatter
All Implemented Interfaces:
Formatter

public class XMLFormatter
extends java.lang.Object
implements Formatter

A class which formats the Policy's data into XML format.

Author:

Field Summary
static java.lang.String PQB_FORMAT_KEY
          Comment for PQB_FORMAT_KEY
 
Constructor Summary
XMLFormatter()
           
 
Method Summary
 void clearProperties()
           
 void consumeString(java.io.BufferedReader in, java.lang.String toConsume)
          consumes the specified string from the specified reader
 java.io.InputStream createXMLSubSectionInputStream(java.io.BufferedReader reader)
           
static java.lang.String escape(java.lang.String s)
           
 void format(java.io.PrintStream out, Formattable t, java.lang.String name)
          Method format
 void formatValue(java.io.PrintStream out, java.lang.Object value)
          Method formatValue
static float getCurrentXMLFormatId()
           
 float getPqbFormat()
           
 java.lang.String getProperty(java.lang.String key)
           
 java.util.List getTagNameStack()
           
 void init()
          init must be called at the begining of any file parsing or root object formating.
 void parse(java.io.BufferedReader in, Formattable t, java.lang.String name)
          Method parse
 java.lang.String parseValue(java.io.BufferedReader in)
          Method parseValue
 void readChildSeparator(java.io.BufferedReader in)
          Method readChildSeparator
 void readElement(java.io.BufferedReader in, java.lang.String tagName)
          read the input stream till the end of the specified element name
 java.lang.String readUntil(java.io.BufferedReader in, int charUntil)
           
 java.lang.Object setProperty(java.lang.String key, java.lang.String value)
           
static java.lang.String unescape(java.lang.String s)
           
 void writeChildSeparator(java.io.PrintStream out)
          Method writeChildSeparator
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PQB_FORMAT_KEY

public static final java.lang.String PQB_FORMAT_KEY
Comment for PQB_FORMAT_KEY

See Also:
Constant Field Values
Constructor Detail

XMLFormatter

public XMLFormatter()
Method Detail

clearProperties

public void clearProperties()
Specified by:
clearProperties in interface Formatter

consumeString

public void consumeString(java.io.BufferedReader in,
                          java.lang.String toConsume)
                   throws ImportExportException
consumes the specified string from the specified reader

Parameters:
in -
toConsume -
Throws:
ImportExportException - if the specified string wasn't found
java.io.IOException

format

public void format(java.io.PrintStream out,
                   Formattable t,
                   java.lang.String name)
Method format

Specified by:
format in interface Formatter
Parameters:
out -
t -
name -

formatValue

public void formatValue(java.io.PrintStream out,
                        java.lang.Object value)
Method formatValue

Specified by:
formatValue in interface Formatter
Parameters:
out -
value -

getPqbFormat

public float getPqbFormat()
Specified by:
getPqbFormat in interface Formatter
Returns:

getProperty

public java.lang.String getProperty(java.lang.String key)
Specified by:
getProperty in interface Formatter
Parameters:
key -
Returns:

init

public void init()
init must be called at the begining of any file parsing or root object formating. The application uses formatter as a singleton so its state must be initialized at the begining of a new format or parse.

Specified by:
init in interface Formatter

parse

public void parse(java.io.BufferedReader in,
                  Formattable t,
                  java.lang.String name)
           throws ImportExportException
Description copied from interface: Formatter
Method parse

Specified by:
parse in interface Formatter
Throws:
ImportExportException
See Also:
com.pcube.apps.engage.common.Formatter#parse(java.io.BufferedReader, com.pcube.apps.engage.common.Formattable, java.lang.String[])

parseValue

public java.lang.String parseValue(java.io.BufferedReader in)
                            throws ImportExportException
Method parseValue

Specified by:
parseValue in interface Formatter
Parameters:
in -
Returns:
Throws:
ImportExportException

readChildSeparator

public void readChildSeparator(java.io.BufferedReader in)
Method readChildSeparator

Specified by:
readChildSeparator in interface Formatter
Parameters:
in -

readElement

public void readElement(java.io.BufferedReader in,
                        java.lang.String tagName)
                 throws ImportExportException
read the input stream till the end of the specified element name

Specified by:
readElement in interface Formatter
Parameters:
tagName - -
Throws:
ImportExportException

setProperty

public java.lang.Object setProperty(java.lang.String key,
                                    java.lang.String value)
Specified by:
setProperty in interface Formatter
Parameters:
key -
value -
Returns:

writeChildSeparator

public void writeChildSeparator(java.io.PrintStream out)
Method writeChildSeparator

Specified by:
writeChildSeparator in interface Formatter
Parameters:
out -

getCurrentXMLFormatId

public static float getCurrentXMLFormatId()

readUntil

public java.lang.String readUntil(java.io.BufferedReader in,
                                  int charUntil)
                           throws ImportExportException
Parameters:
string -
Returns:
Throws:
ImportExportException

getTagNameStack

public java.util.List getTagNameStack()
Returns:
Returns the tagNameStack.

createXMLSubSectionInputStream

public java.io.InputStream createXMLSubSectionInputStream(java.io.BufferedReader reader)
Specified by:
createXMLSubSectionInputStream in interface Formatter

escape

public static java.lang.String escape(java.lang.String s)

unescape

public static java.lang.String unescape(java.lang.String s)

Cisco Systems, Inc.

Copyright © 2013 Cisco Systems, Inc. Confidential.