org.daml.validator
Class Preferences

java.lang.Object
  |
  +--org.xml.sax.helpers.DefaultHandler
        |
        +--org.daml.validator.Preferences
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class Preferences
extends org.xml.sax.helpers.DefaultHandler

Parse the preference file


Field Summary
 java.util.HashMap cache
          Maps URIs to local cache filenames.
 java.util.HashSet cacheList
          Keep a list of original cache items
 URISubstitution outdatedURIs
          URISubstitution structure that store the mapping from old to new URIs.
 java.util.Hashtable propertyList
          Properties
 java.util.HashSet subList
          Keep a list of original substitution items
 
Constructor Summary
Preferences()
          Parse the given prefernces file and return the results in a new Preference object.
 
Method Summary
 void addSubstitution(java.lang.String original, java.lang.String replacement, boolean warn, boolean load)
          Add substitution information for a URI.
 void addToCache(java.lang.String original, java.lang.String file)
          Add a URI and filename to the cache records.
 java.lang.String cacheURI(java.lang.String uri)
          Looks in the cache for a URI and returns a cache file or the original URI.
 boolean getBooleanProperty(java.lang.String name, boolean defaultVal)
           
 int getIntProperty(java.lang.String name, int defaultVal)
           
 java.lang.String getProperty(java.lang.String name)
           
 java.lang.String getProperty(java.lang.String name, java.lang.String defaultVal)
          Get a property's value.
 boolean hasCache(java.lang.String uri)
          Is the uri in the cache.
 java.lang.String normalizeURI(java.lang.String uri)
          Given a URI, convert it to a namespace string (ie, strip file extension and add ending #).
static Preferences parse(java.lang.String file)
           
 void removeFromCache(java.lang.String original)
          Delete a URI from the cache records.
 void save(java.lang.String filename)
          Save the preferences file to the specified filename.
 void setProperty(java.lang.String name, java.lang.String value)
          Set a property value
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attributes)
           
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outdatedURIs

public URISubstitution outdatedURIs
URISubstitution structure that store the mapping from old to new URIs. Used for the disk cache and for mappings & warnings about outdated URIs.


subList

public java.util.HashSet subList
Keep a list of original substitution items


cache

public java.util.HashMap cache
Maps URIs to local cache filenames.


cacheList

public java.util.HashSet cacheList
Keep a list of original cache items


propertyList

public java.util.Hashtable propertyList
Properties

Constructor Detail

Preferences

public Preferences()
Parse the given prefernces file and return the results in a new Preference object.

Method Detail

parse

public static Preferences parse(java.lang.String file)
                         throws java.lang.Exception
java.lang.Exception

addToCache

public void addToCache(java.lang.String original,
                       java.lang.String file)
Add a URI and filename to the cache records. This does not create the cache item.


addSubstitution

public void addSubstitution(java.lang.String original,
                            java.lang.String replacement,
                            boolean warn,
                            boolean load)
Add substitution information for a URI.


setProperty

public void setProperty(java.lang.String name,
                        java.lang.String value)
Set a property value


getProperty

public java.lang.String getProperty(java.lang.String name,
                                    java.lang.String defaultVal)
Get a property's value. Returns default if the property was not set.


getProperty

public java.lang.String getProperty(java.lang.String name)

getBooleanProperty

public boolean getBooleanProperty(java.lang.String name,
                                  boolean defaultVal)

getIntProperty

public int getIntProperty(java.lang.String name,
                          int defaultVal)

removeFromCache

public void removeFromCache(java.lang.String original)
Delete a URI from the cache records. This does not delete the cache file.


startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attributes)
                  throws org.xml.sax.SAXException
Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException

normalizeURI

public java.lang.String normalizeURI(java.lang.String uri)
Given a URI, convert it to a namespace string (ie, strip file extension and add ending #).


save

public void save(java.lang.String filename)
          throws java.io.IOException
Save the preferences file to the specified filename.

java.io.IOException

cacheURI

public java.lang.String cacheURI(java.lang.String uri)
Looks in the cache for a URI and returns a cache file or the original URI.


hasCache

public boolean hasCache(java.lang.String uri)
Is the uri in the cache.