viper.descriptors
Class DescHolder

java.lang.Object
  extended byviper.descriptors.DescHolder
All Implemented Interfaces:
DescriptorData

public class DescHolder
extends java.lang.Object
implements DescriptorData

Implements the DescriptorData interface for the old data file format, as well as the XML format. It supports XML input and output, as well as the old format. This makes it somewhat fragile... there are certain things that can only be done in the XML format that must be avoided for now. Fixme - only supports either one sourcefile w/ no filename or all sourcefiles with a filename


Field Summary
 
Fields inherited from interface viper.descriptors.DescriptorData
NAMESPACE_URI
 
Constructor Summary
DescHolder()
          Constructs a new, empty descriptor holder.
 
Method Summary
 boolean addFileName(java.lang.String S)
          Adds a new URL/filename to the set that this object describes (Optional).
 DescriptorConfigs getDescriptorConfigs()
          Gets the DescriptorConfigs associated with this data.
 java.util.Iterator getFileNames()
          Returns the URL/filenames of all the media this DescriptorData describes.
 DescriptorList getFlattenedData()
          Returns the list as one long DescriptorList.
 DescriptorList getForFile(java.lang.String filename)
          Return the DescriptorList who describe the media with the specified filename or URL String.
 java.lang.String getInformation()
          Returns a string for .raw output summarizing what media files this descriptor uses and so forth.
 Equivalencies getMap()
          Gets the Equivalency map for this list.
 org.w3c.dom.Element getXMLFormat(org.w3c.dom.Document root)
          Gets the data in ViPER XML format.
 boolean isMultifile()
          Determines if this describes more than one media file.
 void merge(DescriptorData other)
          Adds the data from the other DescriptorData to this one.
 void parseData(DescVector data)
          Parses a DescVector in flat format into a multifile format.
 void parseData(org.w3c.dom.Document document, Equivalencies map, RuleHolder limits, DescriptorConfigs cfgs, java.io.PrintWriter logfile, java.lang.String filename)
          Parses data from an XML DOM document root.
 void parseData(org.xml.sax.InputSource input, Equivalencies map, RuleHolder limits, DescriptorConfigs cfgs, java.io.PrintWriter logfile)
          Parses data from an XML file.
 void parseData(java.util.List allFiles, DescriptorConfigs cfgs, RuleHolder limits, Equivalencies map)
          Parse the data.
 void parseData(java.util.List allFiles, DescriptorConfigs cfgs, RuleHolder limits, Equivalencies map, boolean all, boolean err, boolean warn, boolean bad, boolean totals)
          Parse the data.
 DescriptorList removeFile(java.lang.String filename)
          Removes the given file name and its corresponding metadata.
 void resetIds()
          Resets all object ids.
 DescriptorList setDataForFile(java.lang.String S, DescriptorList l)
          Replaces the DesciptorList associated to a given filename with the DescriptorList that is passed in.
 void setDescriptorConfigs(DescriptorConfigs cfgs)
          Sets the descriptor schema associated with this holder.
 void setMap(Equivalencies map)
          Sets the equivalency map of the list.
 java.lang.String toString()
          Gets the data in gtf format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DescHolder

public DescHolder()
Constructs a new, empty descriptor holder.

Method Detail

getDescriptorConfigs

public DescriptorConfigs getDescriptorConfigs()
Description copied from interface: DescriptorData
Gets the DescriptorConfigs associated with this data.

Specified by:
getDescriptorConfigs in interface DescriptorData
Returns:
the DescriptorConfigs associated with this data

setDescriptorConfigs

public void setDescriptorConfigs(DescriptorConfigs cfgs)
Sets the descriptor schema associated with this holder.

Parameters:
cfgs - the new schema

isMultifile

public boolean isMultifile()
Description copied from interface: DescriptorData
Determines if this describes more than one media file.

Specified by:
isMultifile in interface DescriptorData
Returns:
true if this describes more than one media file

parseData

public void parseData(java.util.List allFiles,
                      DescriptorConfigs cfgs,
                      RuleHolder limits,
                      Equivalencies map)
Parse the data.

Specified by:
parseData in interface DescriptorData
Parameters:
allFiles - list of file names/paths (String objects)
cfgs - the configuration
limits - the rules to use while parsing
map - the equivalency list

parseData

public void parseData(java.util.List allFiles,
                      DescriptorConfigs cfgs,
                      RuleHolder limits,
                      Equivalencies map,
                      boolean all,
                      boolean err,
                      boolean warn,
                      boolean bad,
                      boolean totals)
Parse the data.

Parameters:
allFiles - list of file names/paths (String objects)
cfgs - the configuration
limits - the rules to use while parsing
map - the equivalency list
all - display all lines
err - display errors
warn - display warnings
bad - display general errors
totals - print error/warning totals at end

parseData

public void parseData(DescVector data)
Parses a DescVector in flat format into a multifile format. This is not an issue with the xml data structure, but the gtf structure treats multiple media files (for example, a list of jpegs) as a single file, mapped to a single 'framespace' using the FILE descriptor. A File descriptor containing the SOURCEFILES, SOURCEDIR, SOURCETYPE and NUMFRAMES attribute qualifies as in the canonical form.

Parameters:
data - A DescVector to convert to this DescHolder

toString

public java.lang.String toString()
Gets the data in gtf format

Returns:
the data in gtf format. Includes (lots of) new lines.

getFlattenedData

public DescriptorList getFlattenedData()
Description copied from interface: DescriptorData
Returns the list as one long DescriptorList.

Specified by:
getFlattenedData in interface DescriptorData
Returns:
the list as one long DescriptorList, with the frame spans shifted so the media files are serialized

getForFile

public DescriptorList getForFile(java.lang.String filename)
Description copied from interface: DescriptorData
Return the DescriptorList who describe the media with the specified filename or URL String.

Specified by:
getForFile in interface DescriptorData
Parameters:
filename - the file to get the metadata of
Returns:
the descriptors for the given file

getFileNames

public java.util.Iterator getFileNames()
Description copied from interface: DescriptorData
Returns the URL/filenames of all the media this DescriptorData describes.

Specified by:
getFileNames in interface DescriptorData
Returns:
the names of all the described files

addFileName

public boolean addFileName(java.lang.String S)
Description copied from interface: DescriptorData
Adds a new URL/filename to the set that this object describes (Optional).

Specified by:
addFileName in interface DescriptorData
Parameters:
S - the name of the file to add
Returns:
true, if it was added

setDataForFile

public DescriptorList setDataForFile(java.lang.String S,
                                     DescriptorList l)
Description copied from interface: DescriptorData
Replaces the DesciptorList associated to a given filename with the DescriptorList that is passed in. Should be implemented if addFileName() is implemented.

Specified by:
setDataForFile in interface DescriptorData
Parameters:
S - the name of the file to change
l - the new value
Returns:
the previous value

removeFile

public DescriptorList removeFile(java.lang.String filename)
Description copied from interface: DescriptorData
Removes the given file name and its corresponding metadata.

Specified by:
removeFile in interface DescriptorData
Parameters:
filename - the file to remove
Returns:
the metadata for the file

getInformation

public java.lang.String getInformation()
Description copied from interface: DescriptorData
Returns a string for .raw output summarizing what media files this descriptor uses and so forth. The data is formatted as
 
 Directory Sequence mapping (list of frame / filename pairs) SEQUENCE |
 FRAMES Number of Frames
 
 

Specified by:
getInformation in interface DescriptorData
Returns:
the file information in raw format

parseData

public void parseData(org.xml.sax.InputSource input,
                      Equivalencies map,
                      RuleHolder limits,
                      DescriptorConfigs cfgs,
                      java.io.PrintWriter logfile)
               throws java.io.IOException,
                      BadDataException
Parses data from an XML file.

Specified by:
parseData in interface DescriptorData
Parameters:
input - the xml input source
cfgs - if this is null, the parser is looks for the <config> element and generates its own config information. If you want to do things like limitation parsing and evaluations, you will have to parse the config info first.
limits - the rules to use while parsing
map - the equivalency list
logfile - log for the errors/warnings
Throws:
java.io.IOException
BadDataException

parseData

public void parseData(org.w3c.dom.Document document,
                      Equivalencies map,
                      RuleHolder limits,
                      DescriptorConfigs cfgs,
                      java.io.PrintWriter logfile,
                      java.lang.String filename)
               throws java.io.IOException,
                      BadDataException
Parses data from an XML DOM document root.

Parameters:
document - the xml document
cfgs - if this is , the parser is looks for the <config> element and generates its own config information. If you want to do things like limitation parsing and evaluations, you will have to parse the config info first.
limits - the rules to use while parsing
map - the equivalency list
logfile - the error writer
filename - the name of the file; useful for error writing
Throws:
java.io.IOException
BadDataException

getXMLFormat

public org.w3c.dom.Element getXMLFormat(org.w3c.dom.Document root)
Description copied from interface: DescriptorData
Gets the data in ViPER XML format. Probably should be moved into own class...

Specified by:
getXMLFormat in interface DescriptorData
Parameters:
root - the document to use while creating the element
Returns:
the viper root element

merge

public void merge(DescriptorData other)
           throws java.lang.IllegalArgumentException
Description copied from interface: DescriptorData
Adds the data from the other DescriptorData to this one.

Specified by:
merge in interface DescriptorData
Parameters:
other - the data to merge from
Throws:
java.lang.IllegalArgumentException

resetIds

public void resetIds()
Description copied from interface: DescriptorData
Resets all object ids. Useful for mixing and matching descriptors from different sources.

Specified by:
resetIds in interface DescriptorData

getMap

public Equivalencies getMap()
Gets the Equivalency map for this list.

Specified by:
getMap in interface DescriptorData
Returns:
the name equivalency list

setMap

public void setMap(Equivalencies map)
Sets the equivalency map of the list.

Specified by:
setMap in interface DescriptorData
Parameters:
map - the name equivalencies