|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectODFMetaFileAnalyzer
Analyze an OpenDocument meta file and create an
OpenDocumentMetadata
object.
This code depends upon there being no duplicate
element names between the Dublin Core and OpenDocument
meta namespaces. If there are, this code will break.
This code also depends upon there being no nested elements
in the <office:meta>
element.
Field Summary | |
protected String |
dcNamespace
|
protected String |
metaNamespace
|
protected String |
officeNamespace
|
Constructor Summary | |
ODFMetaFileAnalyzer()
|
Method Summary | |
static OpenDocumentMetadata |
analyzeFile(File inputFile)
Analyzes an Open Document meta file, presumed to be in .zip format. |
OpenDocumentMetadata |
analyzeMetadata(InputStream metaStream)
Analyze the metadata in an InputStream . |
OpenDocumentMetadata |
analyzeMetaData(InputStream metaStream)
Analyze the metadata in an InputStream . |
OpenDocumentMetadata |
analyzeZip(File inputFile)
Analyze the metadata in a File which is a .zip file. |
OpenDocumentMetadata |
analyzeZip(InputStream inputStream)
Analyze the metadata in a InputStream which
is a .zip file. |
protected String |
extractNamespace(String namespaceAttrName)
Extract a namespace from a namespace attribute. |
protected void |
findNamespaces(Element rootElement)
Finds the namespace prefixes associated with OpenDocument, Dublin Core, and OpenDocument meta elements. |
protected String |
getBaseName(Node node)
Get the "local" name in a non-namespace-aware parser. |
protected String |
makeSetMethodName(String elementName)
Create a set method name corresponding to a meta-element. |
protected void |
processElement(Element element,
OpenDocumentMetadata metadataResult)
Put the content of this element into the metadata object. |
protected void |
processStatistic(Element element,
OpenDocumentMetadata metadataResult)
Put the content of the statistic element's attributes into the metadata object. |
protected void |
processUserDefined(Element element,
OpenDocumentMetadata metadataResult)
Put the content of this element into the user-defined section of the metadata object. |
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected String officeNamespace
protected String dcNamespace
protected String metaNamespace
Constructor Detail |
public ODFMetaFileAnalyzer()
Method Detail |
public OpenDocumentMetadata analyzeMetadata(InputStream metaStream)
InputStream
.
Algorithm:
Document
office:
, meta:
, and
dc:
.<office:meta>
element, process it with the
processElement()
method, except for
<meta:document-statistic>
, which is handled with
the processStatistic()
, and
<meta:user-defined>
, which is handled with the
processUserDefined()
method.
metaStream
- an InputStream
that contains OpenDocument
meta-information.
OpenDocumentMetadata
structure that
represents the file's meta information.public OpenDocumentMetadata analyzeMetaData(InputStream metaStream)
InputStream
.
This is a wrapper for the correctly-capitalized
analyzeMetadata()
method.
public OpenDocumentMetadata analyzeZip(InputStream inputStream)
InputStream
which
is a .zip file.
Written by Antti Jokipii to allow streaming of the
.zip file
inputStream
- a InputStream
that contains
.zip with OpenDocument meta-information.
OpenDocumentMetadata
structure that
represents the file's meta information.public OpenDocumentMetadata analyzeZip(File inputFile)
File
which is a .zip file.
inputFile
- a File
that contains OpenDocument
meta-information.
OpenDocumentMetadata
structure that
represents the file's meta information.protected void processElement(Element element, OpenDocumentMetadata metadataResult)
The algorithm depends on reflection; element names must correspond to fields in OpenDocumentMetadata.
element
- the <meta:...>
or
<dc:...>
element.metadataResult
- the metadata object to modify.protected void processStatistic(Element element, OpenDocumentMetadata metadataResult)
The algorithm depends on reflection; attribute names must correspond to fields in OpenDocumentMetadata.
element
- the <meta:document-statistic>
element.metadataResult
- the metadata object to be set.protected void processUserDefined(Element element, OpenDocumentMetadata metadataResult)
This method presumes that the content of the element is its first child, which is a text node.
element
- the <meta:user-defined>
element containing the information.metadataResult
- the metadata object to modify.public static OpenDocumentMetadata analyzeFile(File inputFile)
inputFile
- the File
to analyze.
OpenDocumentMetadata
object.protected void findNamespaces(Element rootElement)
This function presumes that all the namespaces are in the root element. If they aren't, this breaks.
rootElement
- the root element of the document.protected String extractNamespace(String namespaceAttrName)
namespaceAttrName
- an attribute name in the form
xmlns:aaaa
.
protected String getBaseName(Node node)
node
- the Node
whose local name we want.
:
.protected String makeSetMethodName(String elementName)
-letter
sequences to (capitalized) Letter
, prepended
by set
. Thus, an element name of
initial-creator
converts to the method name setInitialCreator
.
elementName
- the name of the element to munge.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |