com.ptc.windchill.structconf.xconf
Class XconfParser

java.lang.Object
  extended bycom.ptc.windchill.structconf.xconf.XconfParser

public class XconfParser
extends Object

A parser to parse xconf files.


Nested Class Summary
(package private) static class XconfParser.CarrierException
           
private  class XconfParser.Handler
           
 
Field Summary
private  URL currentFileBeingParsed_
           
static int DECLARATION
          Use in constructor to instruct parser to parse declarative xconf files.
private static String DEFAULT_SERVICE_PROVIDER_VALUE
           
private  URLSet fileBookKeeperSet_
           
private  boolean followReferences_
           
private  XconfHandler handler_
           
private  ParseLocator lastLocator_
           
private  XconfParser outerThis_
           
private  int parserMode_
           
private  int platformMode_
           
private  Locator saxLocator_
           
private static SAXParserFactory saxParserFactory__
           
private  LinkedList serviceProviderStack_
           
static int SITE
          Use in constructor to instruct parser to parse site specific xconf files.
private  File targetBase_
           
private  LinkedList targetFileStack_
           
static int UNIX
          Use in constructor to instruct parser to use UNIX default values when a platform specific property default value is encountered.
static int WINDOWS
          Use in constructor to instruct parser to use Windows default values when a platform specific property default value is encountered.
 
Constructor Summary
XconfParser(File target_base, int parser_mode, int platform_mode)
          Equivalent of this(target, parser_mode, platform_mode, true).
XconfParser(File target_base, int parser_mode, int platform_mode, boolean follow_references)
           
 
Method Summary
 boolean currentElementDeclaresTargetFile()
          Returns true of the current element declares its own target file instead of inheriting from it's containing elements.
 URL getCurrentFileBeingParsed()
           
 String getCurrentServiceProvider()
           
 File getCurrentTargetFileCanonicalized()
          The appropriate target file based on the current position of the parser in the xconf file hierarchy.
 ParseLocator getCurrentTargetFileParseLocation()
          The ParseLocator at which the current target file was declared.
 String getCurrentTargetFileRelativePath()
          The relative path to the which the current target file based on the target root directory.
 File getCurrentTargetFileUncanonicalized()
          The appropriate target file based on the current position of the parser in the xconf file hierarchy.
 ParseLocator getLocator()
           
 int getMode()
           
private  Locator getSAXLocator()
           
 boolean isDeclarationMode()
           
private  void parse_(URL url)
           
 void parse(File source_xconf_file)
           
 void parse(File source_xconf_file, XconfHandler handler)
           
 void parse(String source_xconf_url_or_file)
           
 void parse(String source_xconf_url_or_file, XconfHandler handler)
           
 void parse(URL source_xconf_url)
           
 void parse(URL source_xconf_url, XconfHandler handler)
           
private  void popServiceProvider()
           
private  void popTargetFile()
           
private  void pushServiceProvider()
           
private  void pushServiceProvider(String service_provider)
           
private  void pushTargetFile()
           
private  void pushTargetFile(String target_file_string)
           
private  void recurseIntoHrefFor(String qualified_name, Attributes attributes)
           
 void setHandler(XconfHandler handler)
           
(package private) static int validate(int parser_mode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SERVICE_PROVIDER_VALUE

private static final String DEFAULT_SERVICE_PROVIDER_VALUE
See Also:
Constant Field Values

DECLARATION

public static final int DECLARATION
Use in constructor to instruct parser to parse declarative xconf files.

See Also:
XconfParser(java.io.File, int, int), Constant Field Values

SITE

public static final int SITE
Use in constructor to instruct parser to parse site specific xconf files.

See Also:
XconfParser(java.io.File, int, int), Constant Field Values

UNIX

public static final int UNIX
Use in constructor to instruct parser to use UNIX default values when a platform specific property default value is encountered.

See Also:
Constant Field Values

WINDOWS

public static final int WINDOWS
Use in constructor to instruct parser to use Windows default values when a platform specific property default value is encountered.

See Also:
Constant Field Values

outerThis_

private XconfParser outerThis_

targetBase_

private File targetBase_

saxParserFactory__

private static SAXParserFactory saxParserFactory__

currentFileBeingParsed_

private URL currentFileBeingParsed_

handler_

private XconfHandler handler_

targetFileStack_

private LinkedList targetFileStack_

serviceProviderStack_

private LinkedList serviceProviderStack_

parserMode_

private final int parserMode_

platformMode_

private final int platformMode_

followReferences_

private final boolean followReferences_

saxLocator_

private Locator saxLocator_

lastLocator_

private ParseLocator lastLocator_

fileBookKeeperSet_

private URLSet fileBookKeeperSet_
Constructor Detail

XconfParser

public XconfParser(File target_base,
                   int parser_mode,
                   int platform_mode)
Equivalent of this(target, parser_mode, platform_mode, true).

See Also:
XconfParser(java.io.File,int,int,boolean)

XconfParser

public XconfParser(File target_base,
                   int parser_mode,
                   int platform_mode,
                   boolean follow_references)
Parameters:
target_base - the root directory which is used in coputing target property files when relative paths are specified in xconf files
parser_mode - either XconfParser.DECLARATION or XconfParser.SITE
follow_references - whether the parser should recurse into included xconf files.
Throws:
IllegalArgumentException - if an invalid parser_mode is supplied(note this is an unchecked exception)
See Also:
DECLARATION, SITE
Method Detail

validate

static int validate(int parser_mode)

getMode

public int getMode()
Returns:
XconfParser.DECLARATION or XconfParser.SITE
See Also:
DECLARATION, SITE

isDeclarationMode

public boolean isDeclarationMode()

setHandler

public void setHandler(XconfHandler handler)

parse

public final void parse(String source_xconf_url_or_file)
                 throws XconfException
Throws:
XconfException

parse

public final void parse(String source_xconf_url_or_file,
                        XconfHandler handler)
                 throws XconfException
Throws:
XconfException

parse

public final void parse(File source_xconf_file)
                 throws XconfException
Throws:
XconfException

parse

public final void parse(File source_xconf_file,
                        XconfHandler handler)
                 throws XconfException
Throws:
XconfException

parse

public final void parse(URL source_xconf_url)
                 throws XconfException
Throws:
XconfException

parse

public final void parse(URL source_xconf_url,
                        XconfHandler handler)
                 throws XconfException
Throws:
XconfException

getCurrentFileBeingParsed

public final URL getCurrentFileBeingParsed()

getCurrentTargetFileRelativePath

public final String getCurrentTargetFileRelativePath()
The relative path to the which the current target file based on the target root directory.

Returns:
a String; null if there is no contextual target file
See Also:
#getCurrentTargetFile()

getCurrentTargetFileUncanonicalized

public final File getCurrentTargetFileUncanonicalized()
The appropriate target file based on the current position of the parser in the xconf file hierarchy. The file will be based relative to Paths#getTargetRootDirectory() and will be canonicalized.

Returns:
a file that has not been canonicalized; null if there is no contextual target file

getCurrentTargetFileCanonicalized

public final File getCurrentTargetFileCanonicalized()
The appropriate target file based on the current position of the parser in the xconf file hierarchy. The file will be based relative to Paths#getTargetRootDirectory() and will be canonicalized.

Returns:
a canonicalized file; null if there is no contextual target file

getCurrentTargetFileParseLocation

public final ParseLocator getCurrentTargetFileParseLocation()
The ParseLocator at which the current target file was declared.

Returns:
a canonicalized file; null if there is no contextual target file
See Also:
#getCurrentTargetFile()

currentElementDeclaresTargetFile

public boolean currentElementDeclaresTargetFile()
Returns true of the current element declares its own target file instead of inheriting from it's containing elements.


getSAXLocator

private Locator getSAXLocator()

getLocator

public final ParseLocator getLocator()
Returns:
possibly null values

pushTargetFile

private void pushTargetFile(String target_file_string)

pushTargetFile

private void pushTargetFile()

popTargetFile

private void popTargetFile()

getCurrentServiceProvider

public final String getCurrentServiceProvider()

pushServiceProvider

private void pushServiceProvider(String service_provider)

pushServiceProvider

private void pushServiceProvider()

popServiceProvider

private void popServiceProvider()

recurseIntoHrefFor

private void recurseIntoHrefFor(String qualified_name,
                                Attributes attributes)
                         throws SAXException
Throws:
SAXException

parse_

private void parse_(URL url)
             throws SAXException
Throws:
SAXException