ucar.unidata.xml
Class XmlResourceCollection

java.lang.Object
  extended by ucar.unidata.util.ResourceCollection
      extended by ucar.unidata.xml.XmlResourceCollection

public class XmlResourceCollection
extends ResourceCollection

An extension of ResourceCollection that handles xml documents.

Version:
$Revision: 1.27 $ $Date: 2006/10/30 18:10:01 $
Author:
Metapps development team

Nested Class Summary
 
Nested classes/interfaces inherited from class ucar.unidata.util.ResourceCollection
ResourceCollection.Resource
 
Field Summary
 
Fields inherited from class ucar.unidata.util.ResourceCollection
description, id, idToPath, pathToId, writableIndex, writableResource
 
Constructor Summary
XmlResourceCollection(String id)
          Construct a new object with the given id (The id is simply a name, not one of the resources).
XmlResourceCollection(String id, List resources)
          Construct a new object with the given id and list of resource paths.
XmlResourceCollection(String id, String description)
          Construct a new object with the given id (The id is simply a name, not one of the resources) and description.
XmlResourceCollection(String id, String writableResource, List resources)
          Deprecated. not good anymore
 
Method Summary
 void clearCache()
          clear the cache
 Element getRoot(int resourceIndex)
          Create (if not already) and return the xml Element root of the xml resource at the given index.
 Element getRoot(int resourceIndex, boolean lookAtCache)
          Create (if not already) and return the xml Element root of the xml resource at the given index.
 Document getWritableDocument(String dfltXml)
          Return the Document which is the user's writable xml document.
 Element getWritableRoot(String dfltXml)
          Create (if not created) and return the root of the user's writable xml.
 void removeWritable()
          Remove the writable resource from the list
 void setWritableDocument(Document d, Element root)
          Set the document and root element which represent the user's writable xml document.
 void writeWritable()
          Write out the user's writable xml into the writable resource path.
 void writeWritableResource(String contents)
          Write the given contents into the writable resource file.
 
Methods inherited from class ucar.unidata.util.ResourceCollection
addLabels, addResource, addResource, addResourceAtStart, addResourceAtStart, addResources, contains, deleteAllFiles, get, getCanLoadMore, getDescription, getId, getLabel, getPathFromId, getProperty, getResourceId, getResources, getShortName, getWritable, hasWritableResource, isHttp, isHttp, isValid, isWritable, isWritableResource, read, read, read, readWritableResource, removeAll, setCanLoadMore, setDescription, setId, setIdForPath, size, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlResourceCollection

public XmlResourceCollection(String id)
Construct a new object with the given id (The id is simply a name, not one of the resources).

Parameters:
id - The id or name of this collection.

XmlResourceCollection

public XmlResourceCollection(String id,
                             String description)
Construct a new object with the given id (The id is simply a name, not one of the resources) and description.

Parameters:
id - The id or name of this collection.
description - A human readable description of this collection

XmlResourceCollection

public XmlResourceCollection(String id,
                             List resources)
Construct a new object with the given id and list of resource paths.

Parameters:
id - The id or name of this collection.
resources - The list of resource paths.

XmlResourceCollection

public XmlResourceCollection(String id,
                             String writableResource,
                             List resources)
Deprecated. not good anymore

Construct a new object with the given id, user writable resource and list of other resource paths.

Parameters:
id - The id or name of this collection.
writableResource - The resource path that the user can write to.
resources - The list of resource paths.
Method Detail

clearCache

public void clearCache()
clear the cache

Overrides:
clearCache in class ResourceCollection

writeWritableResource

public void writeWritableResource(String contents)
                           throws FileNotFoundException,
                                  IOException
Write the given contents into the writable resource file. This overwrites the base class method to reset the writable xml document and root.

Overrides:
writeWritableResource in class ResourceCollection
Parameters:
contents -
Throws:
FileNotFoundException
IOException

writeWritable

public void writeWritable()
                   throws FileNotFoundException,
                          IOException
Write out the user's writable xml into the writable resource path.

Throws:
FileNotFoundException - When the write fails.
IOException - When the write fails.

getWritableRoot

public Element getWritableRoot(String dfltXml)
Create (if not created) and return the root of the user's writable xml.

Parameters:
dfltXml - If the user's document does not exist then use this xml to create the document.
Returns:
The root of the user's writable xml document.

getWritableDocument

public Document getWritableDocument(String dfltXml)
Return the Document which is the user's writable xml document.

Parameters:
dfltXml - If the user's document does not exist then use this xml to create the document.
Returns:
The writable xml document.

setWritableDocument

public void setWritableDocument(Document d,
                                Element root)
Set the document and root element which represent the user's writable xml document.

Parameters:
d - The new document.
root - The root of the writable xml.

removeWritable

public void removeWritable()
Remove the writable resource from the list

Overrides:
removeWritable in class ResourceCollection

getRoot

public Element getRoot(int resourceIndex)
Create (if not already) and return the xml Element root of the xml resource at the given index.

Parameters:
resourceIndex - Which resource.
Returns:
The root Element.

getRoot

public Element getRoot(int resourceIndex,
                       boolean lookAtCache)
Create (if not already) and return the xml Element root of the xml resource at the given index.

Parameters:
resourceIndex - Which resource.
lookAtCache - SHould we check the cache first
Returns:
The root Element.