net.sourceforge.nite.meta.impl
Class NiteResourceData

java.lang.Object
  extended by net.sourceforge.nite.meta.impl.NiteResourceData
All Implemented Interfaces:
NResourceData, org.xml.sax.ext.LexicalHandler

public class NiteResourceData
extends java.lang.Object
implements NResourceData, org.xml.sax.ext.LexicalHandler

Instantiates NResourceData which handles any resource file associated with a corpus: if present this must define all the information about where on disk codings live, and what competing versions of annotations exist.

Author:
jonathan

Constructor Summary
NiteResourceData(NMetaData meta, java.lang.String filename)
          the NiteResourceData constructor takes its parent metadata and its filename.
 
Method Summary
 void addResource(java.lang.String coding, NResource resource)
          add a new resource
 void addResourceGroup(NResourceGroup nrg)
          add a NResourceGroup element for resources that instantiate the named coding.
 void comment(char[] ch, int start, int length)
          Store comments (part of the LexicalHandler interface)
 void deleteResource(java.lang.String resourceid)
          delete resource given its ID
 void endCDATA()
          part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use
 void endDTD()
          part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use
 void endEntity(java.lang.String name)
          part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use
 java.util.List getCoherentResourceGroups(java.lang.String coding)
          Return the full list of real resources for a coding, except that if there are virtual resources, add them to the list and remove any resources they draw from.
 java.util.List getCoherentResourceGroups(java.lang.String coding, java.lang.String observation)
          Return the full list of real resources, except that if there are virtual resources, add them to the list and remove any resources they draw from.
 java.util.List getDefaultedResourcesForCoding(java.lang.String coding)
          find a list of NResource elements that instantiate the named coding and have their default attribute set to true.
 java.util.List getIncompatibleResources(NResource res)
          get a List of NResource elements that are incompatible with this one
 NResource getResourceByID(java.lang.String rid)
          find a resource from its ID
 java.lang.String getResourceFilePath()
          Return the path to the resource file (absolute)
 NResourceGroup getResourceGroupForCoding(java.lang.String coding)
          find a NResourceGroup elements that instantiate the named coding.
 java.lang.String getResourcePath(NResource resource)
          find the path to the resource: each resource has one location on disk which can be affected by: the location of the resource file (if paths are relative); the 'path' attribute of the resource-type element in the resource file; the 'path' attribute of the 'resource' element
 java.lang.String getResourcePath(java.lang.String resourceid)
          find the path to the resource: each resource has one location on disk which can be affected by: the location of the resource file (if paths are relative); the 'path' attribute of the resource-type element in the resource file; the 'path' attribute of the 'resource' element
 java.util.List getResourcesForCoding(java.lang.String coding)
          find a list of NRealResource elements that instantiate the named coding.
 java.util.List getVirtualResourcesForCoding(java.lang.String coding)
          find a list of NVirtualResource elements that instantiate the named coding
 void setFilename(java.lang.String filename)
          set the resource filename for any future save: relative paths are assumed to be relative to the metadata directory.
 void startCDATA()
          part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use
 void startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId)
          part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use
 void startEntity(java.lang.String name)
          part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use
 void writeResourceFile()
          save the resource file to the current filename (by default the file it was created from, or set using setFilename).
 void writeResourceFile(java.lang.String filename)
          save the metadata to a file with the given filename.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NiteResourceData

public NiteResourceData(NMetaData meta,
                        java.lang.String filename)
                 throws NiteMetaException
the NiteResourceData constructor takes its parent metadata and its filename. If the filename is relative, it's relative to the metadata, not the working directory.

Throws:
NiteMetaException
Method Detail

writeResourceFile

public void writeResourceFile()
save the resource file to the current filename (by default the file it was created from, or set using setFilename).

Specified by:
writeResourceFile in interface NResourceData

writeResourceFile

public void writeResourceFile(java.lang.String filename)
save the metadata to a file with the given filename.

Specified by:
writeResourceFile in interface NResourceData

setFilename

public void setFilename(java.lang.String filename)
set the resource filename for any future save: relative paths are assumed to be relative to the metadata directory. NOTE: This does NOT update the resource file name saved in the metadata file: you shoud really use NMetaData.setResourceFilename.

Specified by:
setFilename in interface NResourceData

getResourceFilePath

public java.lang.String getResourceFilePath()
Return the path to the resource file (absolute)

Specified by:
getResourceFilePath in interface NResourceData

getResourceByID

public NResource getResourceByID(java.lang.String rid)
find a resource from its ID

Specified by:
getResourceByID in interface NResourceData

getResourcesForCoding

public java.util.List getResourcesForCoding(java.lang.String coding)
find a list of NRealResource elements that instantiate the named coding. If there are zero, return null.

Specified by:
getResourcesForCoding in interface NResourceData

getResourceGroupForCoding

public NResourceGroup getResourceGroupForCoding(java.lang.String coding)
find a NResourceGroup elements that instantiate the named coding. If there are zero, return null.

Specified by:
getResourceGroupForCoding in interface NResourceData

addResourceGroup

public void addResourceGroup(NResourceGroup nrg)
add a NResourceGroup element for resources that instantiate the named coding.

Specified by:
addResourceGroup in interface NResourceData

getDefaultedResourcesForCoding

public java.util.List getDefaultedResourcesForCoding(java.lang.String coding)
find a list of NResource elements that instantiate the named coding and have their default attribute set to true. If there are zero, return null.

Specified by:
getDefaultedResourcesForCoding in interface NResourceData

getVirtualResourcesForCoding

public java.util.List getVirtualResourcesForCoding(java.lang.String coding)
find a list of NVirtualResource elements that instantiate the named coding

Specified by:
getVirtualResourcesForCoding in interface NResourceData

getCoherentResourceGroups

public java.util.List getCoherentResourceGroups(java.lang.String coding)
Return the full list of real resources for a coding, except that if there are virtual resources, add them to the list and remove any resources they draw from. Return null if none can be found.

Specified by:
getCoherentResourceGroups in interface NResourceData

getCoherentResourceGroups

public java.util.List getCoherentResourceGroups(java.lang.String coding,
                                                java.lang.String observation)
Return the full list of real resources, except that if there are virtual resources, add them to the list and remove any resources they draw from. Return null if none can be found.

Specified by:
getCoherentResourceGroups in interface NResourceData

deleteResource

public void deleteResource(java.lang.String resourceid)
delete resource given its ID

Specified by:
deleteResource in interface NResourceData

addResource

public void addResource(java.lang.String coding,
                        NResource resource)
add a new resource

Specified by:
addResource in interface NResourceData

getResourcePath

public java.lang.String getResourcePath(java.lang.String resourceid)
find the path to the resource: each resource has one location on disk which can be affected by: the location of the resource file (if paths are relative); the 'path' attribute of the resource-type element in the resource file; the 'path' attribute of the 'resource' element

Specified by:
getResourcePath in interface NResourceData

getResourcePath

public java.lang.String getResourcePath(NResource resource)
find the path to the resource: each resource has one location on disk which can be affected by: the location of the resource file (if paths are relative); the 'path' attribute of the resource-type element in the resource file; the 'path' attribute of the 'resource' element

Specified by:
getResourcePath in interface NResourceData

getIncompatibleResources

public java.util.List getIncompatibleResources(NResource res)
get a List of NResource elements that are incompatible with this one

Specified by:
getIncompatibleResources in interface NResourceData

comment

public void comment(char[] ch,
                    int start,
                    int length)
Store comments (part of the LexicalHandler interface)

Specified by:
comment in interface org.xml.sax.ext.LexicalHandler

endCDATA

public void endCDATA()
part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use

Specified by:
endCDATA in interface org.xml.sax.ext.LexicalHandler

endDTD

public void endDTD()
part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use

Specified by:
endDTD in interface org.xml.sax.ext.LexicalHandler

endEntity

public void endEntity(java.lang.String name)
part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use

Specified by:
endEntity in interface org.xml.sax.ext.LexicalHandler

startCDATA

public void startCDATA()
part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use

Specified by:
startCDATA in interface org.xml.sax.ext.LexicalHandler

startDTD

public void startDTD(java.lang.String name,
                     java.lang.String publicId,
                     java.lang.String systemId)
part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use

Specified by:
startDTD in interface org.xml.sax.ext.LexicalHandler

startEntity

public void startEntity(java.lang.String name)
part of the org.xml.sax.ext.LexicalHandler implementation - not for programming use

Specified by:
startEntity in interface org.xml.sax.ext.LexicalHandler