|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.ucsb.nceas.morpho.datapackage.PackageUtil
This class contains static utility methods that are used throughtout the other *.morpho.datapackage.* classes.
Constructor Summary | |
PackageUtil()
|
Method Summary | |
static java.lang.String |
addTriplesToTriplesFile(TripleCollection triples,
DataPackage dataPackage,
Morpho morpho)
method to add a collection of triples to a triples file. |
static java.lang.String |
addTriplesToTriplesString(TripleCollection triples,
java.lang.String dataPackageString,
Morpho morpho)
method to add a collection of triples to a triples string. |
static java.lang.String |
deleteTriplesInTriplesFile(java.lang.String searchstring,
DataPackage dataPackage,
Morpho morpho)
method to delete triples with a specified string from the triples file |
static java.util.Hashtable |
getConfigFileTypeAttributes(Morpho morpho,
java.lang.String hashby)
gets the file types from the config file and hashes them by a specified attribute |
static org.w3c.dom.Document |
getDoc(java.io.File file,
Morpho morpho)
parses file with the dom parser and returns a dom Document |
static org.w3c.dom.Document |
getDoc(java.io.File file,
java.lang.String catalogPath)
parses file with the dom parser and returns a dom Document |
static EditorInterface |
getEditor(Morpho morpho)
gets the editor context and returns it |
static org.w3c.dom.NodeList |
getPathContent(java.io.File f,
java.lang.String path,
Morpho morpho)
gets the content of a tag in a given xml file with the given path |
static org.w3c.dom.NodeList |
getPathContent(java.io.File f,
java.util.Vector paths,
Morpho morpho)
Takes in a vector of paths and searches for each of the paths until a node is found that matches the paths. |
static java.lang.String |
getStringFromFile(java.io.File xmlFile)
returns the string representation of a file |
static java.io.File |
openFile(java.lang.String name,
Morpho morpho)
opens a file on metacat or local. |
static java.io.File |
openFile(java.lang.String name,
java.lang.String location,
Morpho morpho)
figures out a files location if it is not known and opens it. |
static java.lang.String |
print(org.w3c.dom.Node node)
This method can 'print' any DOM subtree. |
static java.lang.String |
printDoctype(org.w3c.dom.Document doc)
prints out the doctype part of and xml document. |
static void |
save(java.lang.String filename,
org.w3c.dom.Document doc,
java.lang.String doctype,
Morpho morpho)
Save the DOM doc as a file |
static void |
saveDOM(java.lang.String fileName,
org.w3c.dom.Document doc,
java.lang.String doctype,
Morpho morpho)
This method wraps the 'print' method to send DOM back to the XML document (file) that was used to create the DOM. |
protected static org.w3c.dom.Attr[] |
sortAttributes(org.w3c.dom.NamedNodeMap attrs)
Returns a sorted list of attributes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PackageUtil()
Method Detail |
public static org.w3c.dom.NodeList getPathContent(java.io.File f, java.util.Vector paths, Morpho morpho)
public static org.w3c.dom.NodeList getPathContent(java.io.File f, java.lang.String path, Morpho morpho)
f
- the file to parsepath
- the path to get the content frommorpho
- a morpho object that has a valid config filepublic static org.w3c.dom.Document getDoc(java.io.File file, java.lang.String catalogPath) throws org.xml.sax.SAXException, java.lang.Exception
file
- the file to create the document fromcatalogPath
- the path to the catalog where the files doctype info
can be found.
org.xml.sax.SAXException
java.lang.Exception
public static org.w3c.dom.Document getDoc(java.io.File file, Morpho morpho) throws org.xml.sax.SAXException, java.lang.Exception
file
- the file to create the document frommorpho
- the top level Morpho class
org.xml.sax.SAXException
java.lang.Exception
public static java.lang.String print(org.w3c.dom.Node node)
node
- node usually set to the 'doc' node for complete XML file
re-writeprotected static org.w3c.dom.Attr[] sortAttributes(org.w3c.dom.NamedNodeMap attrs)
public static java.lang.String printDoctype(org.w3c.dom.Document doc)
doc
- the dom of the document to print the doctype forpublic static java.io.File openFile(java.lang.String name, Morpho morpho) throws java.io.FileNotFoundException, CacheAccessException
name
- the name of the filemorpho
- the morpho object that is currently running.
java.io.FileNotFoundException
CacheAccessException
public static java.io.File openFile(java.lang.String name, java.lang.String location, Morpho morpho) throws java.io.FileNotFoundException, CacheAccessException
name
- the file to openlocation
- the location of the file. set to null if the location is
unknownmorpho
- the morpho object that is currently running.
java.io.FileNotFoundException
CacheAccessException
public static EditorInterface getEditor(Morpho morpho)
public static java.lang.String getStringFromFile(java.io.File xmlFile)
public static java.lang.String addTriplesToTriplesFile(TripleCollection triples, DataPackage dataPackage, Morpho morpho)
triples
- the collection of triples to adddataPackage
- the package that you want to add the triples tomorpho
- the morpho object that is currently running.public static java.lang.String addTriplesToTriplesString(TripleCollection triples, java.lang.String dataPackageString, Morpho morpho)
triples
- the collection of triples to adddataPackageString
- the package that you want to add the triples tomorpho
- the morpho object that is currently running.public static java.lang.String deleteTriplesInTriplesFile(java.lang.String searchstring, DataPackage dataPackage, Morpho morpho)
searchstring
- the string to search for in the triples. when this
string is found the entire triple to which it belongs is deleted.dataPackage
- the package that you want to delete the triples frommorpho
- the morpho object that is currently running.public static java.util.Hashtable getConfigFileTypeAttributes(Morpho morpho, java.lang.String hashby)
morpho
- the client morpho that is currently activehashby
- a key from the attributes to hash the table by. note
that this must be one of the required fields or else the hashtable
will try to hash values to nullpublic static void save(java.lang.String filename, org.w3c.dom.Document doc, java.lang.String doctype, Morpho morpho)
public static void saveDOM(java.lang.String fileName, org.w3c.dom.Document doc, java.lang.String doctype, Morpho morpho)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |