org.activemath.omdocjdom.map
Class JDM

java.lang.Object
  extended by org.jdom.Content
      extended by org.jdom.Element
          extended by org.activemath.omdocjdom.OJElement
              extended by org.activemath.omdocjdom.map.JDM
All Implemented Interfaces:
Serializable, Cloneable, Infoable, OJMap, OJNode, org.jdom.Parent

public class JDM
extends OJElement
implements OJMap

RAM-based implementation of OJMap which bases on JDOM objects.

See Also:
Serialized Form

Field Summary
static DateFormat dateFormat
           
static NumberFormat fixedFormat
           
static org.jdom.Namespace JDMNamespace
           
static NumberFormat longFormat
           
 
Fields inherited from class org.activemath.omdocjdom.OJElement
DEBUG, id, info, log
 
Fields inherited from class org.jdom.Element
additionalNamespaces, name, namespace
 
Fields inherited from class org.jdom.Content
parent
 
Constructor Summary
JDM(File baseDir, String collectionId)
          Constructs the map anew.
 
Method Summary
 int computeHash()
          Computes the sum of the hashes.
 OJElement constructSpecialEltSubclass(String name, org.jdom.Namespace namespace)
           
 boolean doesIdExist(ID id)
           
 File getBaseDir()
           
 String getCollectionId()
           
 Date getLastModified(ID id)
           
 Date getLastUpdate()
           
 String getType(ID id)
           
 Iterator listCollectionContent(String collection, String type)
           
 Iterator listTheories(String collection)
           
 Iterator listTheoryContent(ID theoryId)
           
static JDM loadFromFile(File baseDir, String collectionId, URL sourceLocation)
          Constructs the map from existing data, one would still run refresh and clean after this. .
static void main(String[] args)
          Invoke with mapFile and a few path-to-directories...
 void refresh()
          Lists the contained files, parses the ones needed, refills its state.
 void setBaseDir(File baseDir)
           
 void setCollectionId(String collectionId)
           
 void setDirectories(List directories)
          Writes down the directories to be followed (relative to the base-directory) Marks the ones to forget and the ones to relist.
 void writeFile(File file)
           
 
Methods inherited from class org.activemath.omdocjdom.OJElement
addContentMaybeCloning, addContentMaybeCloning, addContentMaybeCloning, addContentMaybeCloning, addContentMaybeCloning, addDCmetadata, addProperlyIndented, addProperlyIndented, clearExtraNamespaces, findChildWithID, getAnyTitle, getAnyTitle, getChildrenRefs, getCompleteDCMetadata, getContainingItem, getContainingTheory, getContainingTheoryIDstring, getCreator, getEnclosingID, getFirstDCMetadata, getID, getIndentOfElementWithNL, getInfo, getLanguage, getNL, getOrMakeMetadata, getorMakeMetadataExtradata, getParentOJElement, getRealContent, getTitle, getTitleMap, getTitleMapAsJdomElts, getTitleMapAsJdomNodeList, getTitleMapAsXmlString, getUnionOfDCMetadataEntries, listItems, setID, setID, setInfo, setNamespace, toString
 
Methods inherited from class org.jdom.Element
addContent, addContent, addContent, addContent, addContent, addNamespaceDeclaration, clone, cloneContent, getAdditionalNamespaces, getAttribute, getAttribute, getAttributes, getAttributeValue, getAttributeValue, getAttributeValue, getAttributeValue, getChild, getChild, getChildren, getChildren, getChildren, getChildText, getChildText, getChildTextNormalize, getChildTextNormalize, getChildTextTrim, getChildTextTrim, getContent, getContent, getContent, getContentSize, getDescendants, getDescendants, getName, getNamespace, getNamespace, getNamespacePrefix, getNamespaceURI, getQualifiedName, getText, getTextNormalize, getTextTrim, getValue, indexOf, isAncestor, isRootElement, removeAttribute, removeAttribute, removeAttribute, removeChild, removeChild, removeChildren, removeChildren, removeContent, removeContent, removeContent, removeContent, removeNamespaceDeclaration, setAttribute, setAttribute, setAttribute, setAttributes, setAttributes, setContent, setContent, setContent, setContent, setName, setText
 
Methods inherited from class org.jdom.Content
detach, equals, getDocument, getParent, getParentElement, hashCode, setParent
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.activemath.omdocjdom.OJNode
getDocument, getParent
 
Methods inherited from interface org.jdom.Parent
getDocument, getParent
 

Field Detail

JDMNamespace

public static final org.jdom.Namespace JDMNamespace

dateFormat

public static DateFormat dateFormat

longFormat

public static NumberFormat longFormat

fixedFormat

public static NumberFormat fixedFormat
Constructor Detail

JDM

public JDM(File baseDir,
           String collectionId)
Constructs the map anew. Follow with setDirectories(java.util.List) and refresh().

Method Detail

doesIdExist

public boolean doesIdExist(ID id)
Specified by:
doesIdExist in interface OJMap

getType

public String getType(ID id)
Specified by:
getType in interface OJMap

getLastModified

public Date getLastModified(ID id)
Specified by:
getLastModified in interface OJMap

getLastUpdate

public Date getLastUpdate()
Specified by:
getLastUpdate in interface OJMap

listCollectionContent

public Iterator listCollectionContent(String collection,
                                      String type)
Specified by:
listCollectionContent in interface OJMap

listTheoryContent

public Iterator listTheoryContent(ID theoryId)
Specified by:
listTheoryContent in interface OJMap

listTheories

public Iterator listTheories(String collection)
Specified by:
listTheories in interface OJMap

getBaseDir

public File getBaseDir()

setBaseDir

public void setBaseDir(File baseDir)

getCollectionId

public String getCollectionId()

setCollectionId

public void setCollectionId(String collectionId)

writeFile

public void writeFile(File file)
               throws IOException
Throws:
IOException

loadFromFile

public static JDM loadFromFile(File baseDir,
                               String collectionId,
                               URL sourceLocation)
                        throws IOException,
                               org.jdom.JDOMException
Constructs the map from existing data, one would still run refresh and clean after this. .

Throws:
IOException
org.jdom.JDOMException

constructSpecialEltSubclass

public OJElement constructSpecialEltSubclass(String name,
                                             org.jdom.Namespace namespace)

setDirectories

public void setDirectories(List directories)
Writes down the directories to be followed (relative to the base-directory) Marks the ones to forget and the ones to relist.


refresh

public void refresh()
             throws IOException,
                    SAXException,
                    org.jdom.JDOMException
Lists the contained files, parses the ones needed, refills its state.

Throws:
IOException
SAXException
org.jdom.JDOMException

main

public static void main(String[] args)
                 throws Exception
Invoke with mapFile and a few path-to-directories... Will load mapFile, if it exists, and update it with the content of the omdoc files in the directory.

Throws:
Exception

computeHash

public int computeHash()
Computes the sum of the hashes. The map is expected to be loaded.