|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjecteTextReader.OEB.OEBPackageFileImpl
public class OEBPackageFileImpl
An implementation of the methods in the OEBPackageFile interface that works by constructing a DOM model of the package file
Field Summary | |
---|---|
private java.util.List |
contributorList
A List of OEBContributor objects
corresponding to the dc:Contributor elements in the package
file |
private java.util.List |
creatorList
A List of String objects
corresponding to the dc:Creator elements in the package
file |
private java.lang.String |
description
|
private java.lang.String |
documentURI
the URI of the package file this object is currently representing |
private java.net.URL |
documentURL
the URL of the package file this object is current representing |
private java.lang.String |
format
|
private java.util.Map |
identifierMap
A Map of objects
corresponding to the dc:Identifier elements in the package
file. |
private java.lang.String |
language
|
private java.util.HashMap |
manifestItemMap
maps ID's to item #'s |
private java.lang.String |
packageIdentity
|
private org.w3c.dom.Document |
parsedDocument
a DOM Document object representing the package file |
private javax.xml.parsers.DocumentBuilder |
parser
the DOM parser used to parse and store a tree representation of the package file |
private java.lang.String |
publicationTitle
|
private java.lang.String |
publisher
|
private java.lang.String |
rightsDescription
|
private java.lang.String |
source
|
private OEBSpine |
spine
A OEBSpine reference to the package file's spine object |
private java.util.List |
subjectList
A List of String objects
corresponding to the dc:Subject elements in the package
file |
private java.lang.String |
tableOfContents
a string representing the table of contents; generated when the method getTableOfContents() is called. |
private org.w3c.dom.traversal.DocumentTraversal |
traversableDocument
a DOM DocumentTraversal object which facilitates the tree traversal |
private java.util.Map |
urlMap
a set containing the URL's in the spine element; used to support the {link #contains method} |
Constructor Summary | |
---|---|
OEBPackageFileImpl()
|
|
OEBPackageFileImpl(java.lang.String uri)
constructs a package file object from the contents at the specified URI |
Method Summary | |
---|---|
protected void |
createManifest()
reads the information contained in the package's manifest element and stores it so that it is available via the various get methods. |
protected void |
createMetaData()
reads the information contained in the package's metadata element and stores it so that it is accessible via the various get methods |
protected void |
createSpine()
reads the information stored in the package's manifest element and stores it. |
java.util.List |
getContributors()
Retrieves a list of contributors to the publication |
java.util.List |
getCreators()
Retrieves a list of creators for this publication |
java.util.Date |
getDate(java.lang.String event)
Retrieves the specified date specified for the publication Specific dates events are not currently defined by the OEB publication structure |
java.lang.String |
getDescription()
Returns a (perhaps verbose) description of the publication |
OEBItem |
getFirstItem()
Retrieve an OEBItem object corresponding to the
first item referenced in the spine |
java.lang.String |
getFormat()
Retrieves the format of the publication as a whole |
OEBItem |
getGuideTableOfContents()
retrieves the OEBItem corresponding to the "toc" element in the guide, which references an element in the manifest. |
OEBIdentifier |
getIdentifier(java.lang.String scheme)
Retrieves a particular identifier |
java.util.List |
getIdentifiers()
Retrieves a list of identifiers for this publication |
java.lang.String |
getLanguage()
The language of the publication |
OEBItem |
getLastItem()
Retrieve an OEBItem object corresponding to the
last item referenced in the spine |
OEBItem |
getManifestItem(java.lang.String id)
Retrieves a specific item from the manifest |
OEBItem |
getManifestItem(java.lang.String id,
java.util.Set allowedTypes)
Retrieves a specific item from the manifest with a specific media type. |
java.util.List |
getManifestItems()
Retrieves a list of the resources making up this publication |
OEBItem |
getNextItem(java.lang.String id)
Retrieve an OEBItem object corresponding to the
item after the specified item |
protected java.lang.String |
getNodeContent(org.w3c.dom.Node node)
returns a string representation of the content stored in a node. |
protected java.lang.String |
getNodeContent(org.w3c.dom.Node node,
boolean trimLeadingWS,
boolean trimTrailingWS)
returns a string representation of the content stored in a node. |
java.lang.String |
getPackageIdentity()
Returns the unique identifier for this publication |
OEBItem |
getPreviousItem(java.lang.String id)
Retrieve an OEBItem object corresponding to the
item before the specified item |
java.lang.String |
getPublicationTitle()
Retrieves the human readable title of this publication |
java.lang.String |
getPublisher()
Returns a string identifying the publication's publisher |
java.lang.String |
getRights()
Retrieves a description of the user's rights for use of this publication. |
java.lang.String |
getSource()
Retrieves a source this publication is derived from |
OEBSpine |
getSpine()
Retrieves an OEBSpine element for this publication |
java.util.List |
getSubjects()
Retrieves the subjects of the publication |
java.lang.String |
getTableOfContents()
constructs an HTML document representing the table of contents for the package |
boolean |
isFirstItem(java.lang.String id)
Determine whether the OEBItem object identified using the given id is the first item in the spine |
boolean |
isLastItem(java.lang.String id)
Determine whether the OEBItem object identified using the given id is the last item in the spine |
java.util.ListIterator |
listIterator()
Retrieves an object useful for iterating over the spine elements |
OEBItem |
lookupURL(java.lang.String url)
returns the OEB item corresponding to a given URL in the publication |
OEBItem |
lookupURLByPkgID(java.lang.String url)
returns the OEB item corresponding to a given URL in the publication based on the PackageIdentity URL |
static void |
main(java.lang.String[] args)
allows testing of the various methods |
protected static java.lang.StringBuffer |
normalizeWhitespace(java.lang.StringBuffer str,
boolean trimLeadingWS,
boolean trimTrailingWS)
removes leading and consecutive whitespace from a string |
protected void |
parse()
parses the document indicated by the value of the member documentURI |
void |
setURI(java.lang.String uri)
sets the URI this package file object references |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Map identifierMap
Map
of objects
corresponding to the dc:Identifier elements in the package
file. Keys are the scheme Strings and values are OEBIdentifier
objects
private java.util.List contributorList
List
of OEBContributor
objects
corresponding to the dc:Contributor elements in the package
file
private java.util.List creatorList
List
of String objects
corresponding to the dc:Creator elements in the package
file
private java.util.HashMap manifestItemMap
private java.util.Map urlMap
private java.util.List subjectList
List
of String objects
corresponding to the dc:Subject elements in the package
file
private OEBSpine spine
OEBSpine
reference to the package file's spine object
private java.lang.String packageIdentity
private java.lang.String publicationTitle
private java.lang.String description
private java.lang.String publisher
private java.lang.String format
private java.lang.String language
private java.lang.String source
private java.lang.String rightsDescription
private javax.xml.parsers.DocumentBuilder parser
private java.lang.String documentURI
private java.net.URL documentURL
private org.w3c.dom.Document parsedDocument
private org.w3c.dom.traversal.DocumentTraversal traversableDocument
private java.lang.String tableOfContents
getTableOfContents()
is called.
Constructor Detail |
---|
public OEBPackageFileImpl()
public OEBPackageFileImpl(java.lang.String uri) throws java.lang.Exception
uri
- the Uniform Resource Identifier for the package file
java.lang.Exception
- if an error occurs parsing the documentMethod Detail |
---|
public java.lang.String getPackageIdentity()
getPackageIdentity
in interface OEBPackageFile
OEBIdentifier
object corresponding
to the dc:Identifier element whose ID is referenced
by the unique-identifier attribute of the package
elementpublic java.lang.String getPublicationTitle()
getPublicationTitle
in interface OEBPackageFile
public java.util.List getCreators()
getCreators
in interface OEBPackageFile
public java.util.List getSubjects()
getSubjects
in interface OEBPackageFile
List
item containing the subjects of the publicationpublic java.lang.String getDescription()
getDescription
in interface OEBPackageFile
public java.lang.String getPublisher()
getPublisher
in interface OEBPackageFile
public java.util.List getContributors()
getContributors
in interface OEBPackageFile
List
item that contains OEB.OEBContributor
objects describing the creators for the publicationpublic java.util.Date getDate(java.lang.String event)
getDate
in interface OEBPackageFile
event
- a string identifying the date being requested,
such as the publication date, last modification date, etc.public java.lang.String getFormat()
getFormat
in interface OEBPackageFile
public java.lang.String getSource()
getSource
in interface OEBPackageFile
public java.lang.String getLanguage()
getLanguage
in interface OEBPackageFile
public java.lang.String getRights()
getRights
in interface OEBPackageFile
public java.util.List getIdentifiers()
getIdentifiers
in interface OEBPackageFile
List
containing OEBIdentifier
objects corresponding to the dc:Identifier elements in
the publication packagepublic OEBIdentifier getIdentifier(java.lang.String scheme) throws java.util.NoSuchElementException
getIdentifier
in interface OEBPackageFile
scheme
- the particular scheme whose identifier is being requested
OEBIdentifier
object corresponding to the requested
scheme
java.util.NoSuchElementException
- if no identifier matching
the requested scheme can be foundpublic java.util.List getManifestItems()
getManifestItems
in interface OEBPackageFile
List
of OEBItem
objectspublic OEBItem getManifestItem(java.lang.String id) throws java.util.NoSuchElementException
getManifestItem
in interface OEBPackageFile
id
- The unique identifier for the resource
OEBItem
that corresponds to the given id;
the first item found is returned, regardless of its media type
java.util.NoSuchElementException
- if no item corresponding to the
given id exists in the manifestpublic OEBItem getManifestItem(java.lang.String id, java.util.Set allowedTypes) throws java.util.NoSuchElementException
getManifestItem
in interface OEBPackageFile
id
- The unique identifier for the resourceallowedTypes
- a set of allowed media types for the
resource.
OEBItem
that corresponds to the given id,
AND has a media type contained in the allowedTypes Set.
java.util.NoSuchElementException
- if the requested id does not
exist, or if now item with an allowable media type is foundpublic OEBSpine getSpine()
OEBPackageFile
OEBSpine
element for this publication
getSpine
in interface OEBPackageFile
public OEBItem getGuideTableOfContents() throws java.util.NoSuchElementException
OEBPackageFile
getGuideTableOfContents
in interface OEBPackageFile
java.util.NoSuchElementException
public java.lang.String getTableOfContents()
OEBPackageFile
getTableOfContents
in interface OEBPackageFile
public OEBItem getFirstItem()
OEBPackageFile
OEBItem
object corresponding to the
first item referenced in the spine
getFirstItem
in interface OEBPackageFile
public OEBItem getLastItem()
OEBPackageFile
OEBItem
object corresponding to the
last item referenced in the spine
getLastItem
in interface OEBPackageFile
public OEBItem getNextItem(java.lang.String id)
OEBPackageFile
OEBItem
object corresponding to the
item after the specified item
getNextItem
in interface OEBPackageFile
id
- the unique identifier of the item before the requested itempublic OEBItem getPreviousItem(java.lang.String id)
OEBPackageFile
OEBItem
object corresponding to the
item before the specified item
getPreviousItem
in interface OEBPackageFile
id
- the unique identifier of the item after the requested itempublic java.util.ListIterator listIterator()
OEBPackageFile
listIterator
in interface OEBPackageFile
listIterator
object that
can be used to retrieve the spine elements in orderpublic OEBItem lookupURL(java.lang.String url) throws java.util.NoSuchElementException
OEBPackageFile
lookupURL
in interface OEBPackageFile
url
- the fully specified URL to check
OEBItem
for the URL specified by url
java.util.NoSuchElementException
- if the URL url is not contained
in the manifest for this publicationpublic OEBItem lookupURLByPkgID(java.lang.String url) throws java.util.NoSuchElementException
OEBPackageFile
lookupURLByPkgID
in interface OEBPackageFile
url
- the fully specified URL to check
OEBItem
for the URL specified by url
java.util.NoSuchElementException
- if the URL url is not contained
in the manifest for this publicationprotected void parse() throws java.lang.Exception
documentURI
java.lang.Exception
- if no URI has been setpublic void setURI(java.lang.String uri) throws java.net.MalformedURLException, java.lang.Exception
uri
- the URI of the package file
java.net.MalformedURLException
- if the uri
java.lang.Exception
- if an error occurs parsing the document
referenced by the uri parameter
parameter is not a syntactically correct URIprotected void createMetaData()
protected void createManifest() throws java.net.MalformedURLException
OEBItem
objects and stores them
in the manifestItemMap member with their id attribute as the
key
java.net.MalformedURLException
protected void createSpine() throws java.util.NoSuchElementException
getManifestItems()
, getManifestItem(String)
and
getManifestItem(String,java.util.Set)
java.util.NoSuchElementException
- if one of the idref
attributes in the spine's itemref elements does not have
a corresponding entry in the manifestprotected java.lang.String getNodeContent(org.w3c.dom.Node node)
node
- the node whose content is to be returned
node
.OEB.OEBPackageFileImpl#normalizeWhitespace(StringBuffer,boolean,boolean)
protected java.lang.String getNodeContent(org.w3c.dom.Node node, boolean trimLeadingWS, boolean trimTrailingWS)
node
- the node whose content is to be returnedtrimLeadingWS
- indicates whether leading whitespace should be
removedtrimTrailingWS
- indicates whether trailing whitespace should be
removed
node
.OEB.OEBPackageFileImpl#normalizeWhitespace(StringBuffer,boolean,boolean)
protected static java.lang.StringBuffer normalizeWhitespace(java.lang.StringBuffer str, boolean trimLeadingWS, boolean trimTrailingWS)
str
- the content to be normalizedtrimLeadingWS
- indicates whether leading whitespace should be
removedtrimTrailingWS
- indicates whether trailing whitespace should be
removed
str
, except that consecutive whitespace characters
have been removed, and leading and trailing whitespace are gone
if specifiedpublic static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public boolean isFirstItem(java.lang.String id)
OEBPackageFile
isFirstItem
in interface OEBPackageFile
id
- an id identifying the item in the book
public boolean isLastItem(java.lang.String id)
OEBPackageFile
isLastItem
in interface OEBPackageFile
id
- an id identifying the item in the book
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |