Package de.unirostock.sems.cbarchive
Class Utils
- java.lang.Object
-
- de.unirostock.sems.cbarchive.Utils
-
public class Utils extends Object
Some tools.- Author:
- martin scharm
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUtils.SimpleOutputStreamThe Class SimpleOutputStream.
-
Field Summary
Fields Modifier and Type Field Description static intBUFFER_SIZEThe default buffer size.static CopyOption[]COPY_OPTIONThe COPY_OPTION used to copy/move files.static SimpleDateFormatdateFormaterThe date formater.static org.jdom2.NamespacedcNSThe DC namespace.static StringNEWLINEThe newline character.static org.jdom2.NamespaceomexNsThe OMEX namespace.static org.jdom2.NamespaceomexSpecNsThe OMEX spec namespace.static org.jdom2.NamespacerdfNSThe RDF namespace.static org.jdom2.NamespacevcNSThe vcard namespace.
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddelete(File f)Recursively delete file or directory.static List<org.jdom2.Element>getElementsByTagName(org.jdom2.Element parent, String name, org.jdom2.Namespace ns)Gets elements of an XML subtree by tag name.static StringgetExtension(String fileName)Extracts the extension of a filename.static URIgetOmexManifestUri()Gets the OMEX manifest URI.static URIgetOmexMetaDataUri()Get the URI representing OMEX meta datastatic URIgetOmexSpecUri()Gets the URI representing the OMEX specification.static StringpathFixer(String path)Utility to fix paths on different operating systems.static StringprettyPrintDocument(org.jdom2.Document doc)Pretty print an XML document.static org.jdom2.DocumentreadXmlDocument(Path fileToRead)Reads an XML file and creates a Document.
-
-
-
Field Detail
-
rdfNS
public static final org.jdom2.Namespace rdfNS
The RDF namespace.
-
dcNS
public static final org.jdom2.Namespace dcNS
The DC namespace.
-
vcNS
public static final org.jdom2.Namespace vcNS
The vcard namespace.
-
omexSpecNs
public static final org.jdom2.Namespace omexSpecNs
The OMEX spec namespace.
-
omexNs
public static final org.jdom2.Namespace omexNs
The OMEX namespace.
-
dateFormater
public static final SimpleDateFormat dateFormater
The date formater.
-
BUFFER_SIZE
public static final int BUFFER_SIZE
The default buffer size.- See Also:
- Constant Field Values
-
NEWLINE
public static final String NEWLINE
The newline character.
-
COPY_OPTION
public static final CopyOption[] COPY_OPTION
The COPY_OPTION used to copy/move files.
-
-
Method Detail
-
readXmlDocument
public static final org.jdom2.Document readXmlDocument(Path fileToRead) throws org.jdom2.JDOMException, IOException
Reads an XML file and creates a Document.- Parameters:
fileToRead- the file to read- Returns:
- the XML document
- Throws:
org.jdom2.JDOMException- the JDOM exceptionIOException- Signals that an I/O exception has occurred.
-
getElementsByTagName
public static List<org.jdom2.Element> getElementsByTagName(org.jdom2.Element parent, String name, org.jdom2.Namespace ns)
Gets elements of an XML subtree by tag name.- Parameters:
parent- the root of the subtreename- the tag namens- the namespace- Returns:
- the elements by sharing this tag name
-
prettyPrintDocument
public static String prettyPrintDocument(org.jdom2.Document doc) throws IOException, TransformerException
Pretty print an XML document.- Parameters:
doc- the XML document- Returns:
- the beautified string
- Throws:
IOException- Signals that an I/O exception has occurred.TransformerException- the transformer exception
-
getExtension
public static String getExtension(String fileName)
Extracts the extension of a filename.- Parameters:
fileName- the file name- Returns:
- the extension, or null if we're not able to find an extension
-
delete
public static void delete(File f) throws IOException
Recursively delete file or directory.- Parameters:
f- the file/dir to delete- Throws:
IOException- Signals that an I/O exception has occurred.
-
getOmexMetaDataUri
public static URI getOmexMetaDataUri()
Get the URI representing OMEX meta data- Returns:
- OMEX meta data URI
-
getOmexSpecUri
public static URI getOmexSpecUri()
Gets the URI representing the OMEX specification.- Returns:
- the OMEX specification URI
-
getOmexManifestUri
public static URI getOmexManifestUri()
Gets the OMEX manifest URI.- Returns:
- the OMEX manifest URI
-
pathFixer
public static String pathFixer(String path)
Utility to fix paths on different operating systems. Will make sure that all paths use '/'. If the operation systems uses something else, such as '\' or ':', we're going to replace that with an '/'.- Parameters:
path- the path as retrieved by your operating system- Returns:
- the fixed path
-
-