Class XmlResourceCollection

java.lang.Object
ucar.unidata.util.ResourceCollection
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
  • Constructor Details

    • 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, XmlResourceCollection that)
      copy ctor
      Parameters:
      id - new id
      that - resourcecollection to copy from
    • 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)
      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. deprecated not good anymore
  • Method Details

    • 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.