de.bsd.x2svg.parsers
Class PropertiesParser

java.lang.Object
  extended by de.bsd.x2svg.parsers.PropertiesParser
All Implemented Interfaces:
InputParser

public class PropertiesParser
extends java.lang.Object
implements InputParser

Simple example of a InputParser for Property files. This is mostly here to show what is needed to accomplish a simple parsing task.

Author:
hwr@pilhuhn.de

Field Summary
private static java.lang.String FILE_SUFFIX_STRING
           
private static java.lang.String MODE_STRING
           
private  java.io.File pFile
          Properties file to use
private  java.util.Properties properties
           
 
Constructor Summary
PropertiesParser()
           
 
Method Summary
 java.lang.String getFileSuffix()
          We react on .properties
 java.lang.String getMode()
          Our mode is 'props'
 java.lang.String getSpecificHelp()
          We have no options so far ...
private  void loadPropertiesFile()
          Load the properties that we want to display from the file set via setInputFile(File) and store it in the variable properties
 Container parseInput()
          Parse the input an construct a Tree of Containers.
 void setDebug()
          Tells the parer to set the debug mode.
 void setInputFile(java.io.File inputFile)
          Sets the input file to work on
 void setParserOptions(java.lang.String[] options)
          Pass in options to this parser.
 void setWithAttributes(boolean value)
          Tells the parser that parsing attributes of elements is wanted.
 void setWithElementComments(boolean value)
          Tells the parser that parsing comments for elements (and possibly attributes) is desired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_SUFFIX_STRING

private static final java.lang.String FILE_SUFFIX_STRING
See Also:
Constant Field Values

MODE_STRING

private static final java.lang.String MODE_STRING
See Also:
Constant Field Values

pFile

private java.io.File pFile
Properties file to use


properties

private java.util.Properties properties
Constructor Detail

PropertiesParser

public PropertiesParser()
Method Detail

parseInput

public Container parseInput()
                     throws java.lang.Exception
Parse the input an construct a Tree of Containers. The properties file needs be passed in via other means.

Specified by:
parseInput in interface InputParser
Returns:
A valid container
Throws:
java.lang.Exception - if anything goes wrong.
See Also:
Container

loadPropertiesFile

private void loadPropertiesFile()
                         throws ParserProblemException
Load the properties that we want to display from the file set via setInputFile(File) and store it in the variable properties

Throws:
ParserProblemException - if the input file is not acessible

setInputFile

public void setInputFile(java.io.File inputFile)
Sets the input file to work on

Specified by:
setInputFile in interface InputParser
Parameters:
inputFile - a vaild file object to work on

setParserOptions

public void setParserOptions(java.lang.String[] options)
Pass in options to this parser. So far there is nothing to do.

Specified by:
setParserOptions in interface InputParser
Parameters:
options - array of individual option parts as passed on the command line.

getSpecificHelp

public java.lang.String getSpecificHelp()
We have no options so far ...

Specified by:
getSpecificHelp in interface InputParser
Returns:
a help string or null if no help is available.
See Also:
InputParser.getSpecificHelp()

getFileSuffix

public java.lang.String getFileSuffix()
We react on .properties

Specified by:
getFileSuffix in interface InputParser
Returns:
the file suffix

getMode

public java.lang.String getMode()
Our mode is 'props'

Specified by:
getMode in interface InputParser
Returns:
the mode string

setDebug

public void setDebug()
Description copied from interface: InputParser
Tells the parer to set the debug mode. It depends on the individual parser if it actually has a debug mode.

Specified by:
setDebug in interface InputParser

setWithAttributes

public void setWithAttributes(boolean value)
Description copied from interface: InputParser
Tells the parser that parsing attributes of elements is wanted. It depends on the individual parser if it acutally can parse them. For example the DtdParser is able to do this, while the PropertiesParser is not.

Specified by:
setWithAttributes in interface InputParser
Parameters:
value - The value to set this to.

setWithElementComments

public void setWithElementComments(boolean value)
Description copied from interface: InputParser
Tells the parser that parsing comments for elements (and possibly attributes) is desired.
It depends on the individual parser if it actually can parse them

Specified by:
setWithElementComments in interface InputParser
Parameters:
value - The value to set this to.


x2svg version 1.2.1