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 Object
implements Formatter

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

Author:

Field Summary
static String PQB_FORMAT_KEY
          Comment for PQB_FORMAT_KEY
 
Constructor Summary
XMLFormatter()
           
 
Method Summary
 void clearProperties()
           
 void consumeString(BufferedReader in, String toConsume)
          consumes the specified string from the specified reader
 InputStream createXMLSubSectionInputStream(BufferedReader reader)
           
static String escape(String s)
           
 void format(PrintStream out, Formattable t, String name)
          Method format
 void formatValue(PrintStream out, Object value)
          Method formatValue
static float getCurrentXMLFormatId()
           
 float getPqbFormat()
           
 String getProperty(String key)
           
 List getTagNameStack()
           
 void init()
          init must be called at the begining of any file parsing or root object formating.
 void parse(BufferedReader in, Formattable t, String name)
          Method parse
 String parseValue(BufferedReader in)
          Method parseValue
 void readChildSeparator(BufferedReader in)
          Method readChildSeparator
 void readElement(BufferedReader in, String tagName)
          read the input stream till the end of the specified element name
 String readUntil(BufferedReader in, int charUntil)
           
 Object setProperty(String key, String value)
           
static String unescape(String s)
           
 void writeChildSeparator(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 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(BufferedReader in,
                          String toConsume)
                   throws ImportExportException
consumes the specified string from the specified reader

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

format

public void format(PrintStream out,
                   Formattable t,
                   String name)
Method format

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

formatValue

public void formatValue(PrintStream out,
                        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 String getProperty(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(BufferedReader in,
                  Formattable t,
                  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 String parseValue(BufferedReader in)
                  throws ImportExportException
Method parseValue

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

readChildSeparator

public void readChildSeparator(BufferedReader in)
Method readChildSeparator

Specified by:
readChildSeparator in interface Formatter
Parameters:
in -

readElement

public void readElement(BufferedReader in,
                        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 Object setProperty(String key,
                          String value)
Specified by:
setProperty in interface Formatter
Parameters:
key -
value -
Returns:

writeChildSeparator

public void writeChildSeparator(PrintStream out)
Method writeChildSeparator

Specified by:
writeChildSeparator in interface Formatter
Parameters:
out -

getCurrentXMLFormatId

public static float getCurrentXMLFormatId()

readUntil

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

getTagNameStack

public List getTagNameStack()
Returns:
Returns the tagNameStack.

createXMLSubSectionInputStream

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

escape

public static String escape(String s)

unescape

public static String unescape(String s)

Cisco Systems, Inc.

Copyright © 2011 Cisco Systems, Inc. Confidential.