|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.colorful.atom.FeedDoc
public class FeedDoc
This class reads and writes atom documents to and from xml files, objects or Strings. It contains all of the factory methods for building immutable copies of the object elements.
| Nested Class Summary | |
|---|---|
static class |
FeedDoc.ContentType
An enumeration of the different types of supported content. |
| Field Summary | |
|---|---|
static Attribute |
atomBase
the default atom xml namespace attribute of "http://www.w3.org/2005/Atom" |
static java.lang.String |
encoding
the default document encoding of "UTF-8" |
static Attribute |
lang_en
the default library language attribute of "en-US" |
static Attribute |
sort
the Atomsphere sort extension attribute. |
static java.util.Comparator<java.lang.String> |
SORT_ASC
Comparator for sorting feed entries in ascending order. |
static java.util.Comparator<java.lang.String> |
SORT_DESC
Comparator for sorting feed entries in descending order |
static java.lang.String |
xml_version
the default XML version of "1.0" |
| Constructor Summary | |
|---|---|
FeedDoc()
|
|
| Method Summary | |
|---|---|
static Attribute |
buildAttribute(java.lang.String name,
java.lang.String value)
|
static Author |
buildAuthor(Name name,
URI uri,
Email email,
java.util.List<Attribute> attributes,
java.util.List<Extension> extensions)
|
static Category |
buildCategory(java.util.List<Attribute> attributes,
java.lang.String content)
|
static Content |
buildContent(java.lang.String content,
java.util.List<Attribute> attributes)
|
static Contributor |
buildContributor(Name name,
URI uri,
Email email,
java.util.List<Attribute> attributes,
java.util.List<Extension> extensions)
|
static Email |
buildEmail(java.lang.String email)
|
static Entry |
buildEntry(Id id,
Title title,
Updated updated,
Rights rights,
Content content,
java.util.List<Author> authors,
java.util.List<Category> categories,
java.util.List<Contributor> contributors,
java.util.List<Link> links,
java.util.List<Attribute> attributes,
java.util.List<Extension> extensions,
Published published,
Summary summary,
Source source)
|
static Extension |
buildExtension(java.lang.String elementName,
java.util.List<Attribute> attributes,
java.lang.String content)
|
static Feed |
buildFeed(Id id,
Title title,
Updated updated,
Rights rights,
java.util.List<Author> authors,
java.util.List<Category> categories,
java.util.List<Contributor> contributors,
java.util.List<Link> links,
java.util.List<Attribute> attributes,
java.util.List<Extension> extensions,
Generator generator,
Subtitle subtitle,
Icon icon,
Logo logo,
java.util.SortedMap<java.lang.String,Entry> entries)
|
static Generator |
buildGenerator(java.util.List<Attribute> attributes,
java.lang.String text)
|
static Icon |
buildIcon(java.util.List<Attribute> attributes,
java.lang.String atomUri)
|
static Id |
buildId(java.util.List<Attribute> attributes,
java.lang.String atomUri)
|
static Link |
buildLink(java.util.List<Attribute> attributes,
java.lang.String content)
|
static Logo |
buildLogo(java.util.List<Attribute> attributes,
java.lang.String atomUri)
|
static Name |
buildName(java.lang.String name)
|
static Published |
buildPublished(java.util.Date published,
java.util.List<Attribute> attributes)
|
static Rights |
buildRights(java.lang.String rights,
java.util.List<Attribute> attributes)
|
static Source |
buildSource(Id id,
Title title,
Updated updated,
Rights rights,
java.util.List<Author> authors,
java.util.List<Category> categories,
java.util.List<Contributor> contributors,
java.util.List<Link> links,
java.util.List<Attribute> attributes,
java.util.List<Extension> extensions,
Generator generator,
Subtitle subtitle,
Icon icon,
Logo logo)
|
static Subtitle |
buildSubtitle(java.lang.String subtitle,
java.util.List<Attribute> attributes)
|
static Summary |
buildSummary(java.lang.String summary,
java.util.List<Attribute> attributes)
|
static Title |
buildTitle(java.lang.String title,
java.util.List<Attribute> attributes)
|
static Updated |
buildUpdated(java.util.Date updated,
java.util.List<Attribute> attributes)
|
static URI |
buildURI(java.lang.String uri)
|
static Generator |
getAtomsphereVersion()
|
static FeedDoc.ContentType |
getContentType(java.util.List<Attribute> attriubtes)
Convenience method for getting the content type for this element. |
static Entry |
readEntryToBean(java.io.File file)
This method reads an xml File object into an Entry element. |
static Entry |
readEntryToBean(java.io.InputStream inputStream)
This method reads an atom file from an input stream into a Entry element. |
static Entry |
readEntryToBean(java.lang.String xmlString)
This method reads an xml string into a Entry element. |
static Entry |
readEntryToBean(java.net.URL url)
This method reads an atom file from a URL into a Entry element. |
static java.lang.String |
readEntryToString(Entry entry)
This method reads in an atom Entry element and returns the contents as an atom Entry document String containing the entry. |
static java.lang.String |
readEntryToString(Entry entry,
java.lang.String xmlStreamWriter)
This method reads in an Entry element and returns the contents as an atom feed document string |
static Feed |
readFeedToBean(java.io.File file)
This method reads an xml File object into a Feed element. |
static Feed |
readFeedToBean(java.io.InputStream inputStream)
This method reads an atom file from an input stream into a Feed element. |
static Feed |
readFeedToBean(java.lang.String xmlString)
This method reads an xml string into a Feed element. |
static Feed |
readFeedToBean(java.net.URL url)
This method reads an atom file from a URL into a Feed element. |
static java.lang.String |
readFeedToString(Feed feed)
This method reads in a Feed bean and returns the contents as an atom feed string. |
static java.lang.String |
readFeedToString(Feed feed,
java.lang.String xmlStreamWriter)
This method reads in a Feed element and returns the contents as an atom feed string with formatting specified by the fully qualified XMLStreamWriter class name (uses reflection internally). |
static Feed |
sortEntries(Feed feed,
java.util.Comparator<java.lang.String> comparator,
java.lang.Class<?> elementClass)
This method sorts the entries of the feed. |
static void |
writeEntryDoc(java.io.OutputStream output,
Entry entry,
java.lang.String encoding,
java.lang.String version)
|
static void |
writeEntryDoc(java.io.Writer output,
Entry entry,
java.lang.String encoding,
java.lang.String version)
|
static void |
writeEntryDoc(javax.xml.stream.XMLStreamWriter output,
Entry entry,
java.lang.String encoding,
java.lang.String version)
Writes and entry element to a document. |
static void |
writeFeedDoc(java.io.OutputStream output,
Feed feed,
java.lang.String encoding,
java.lang.String version)
|
static void |
writeFeedDoc(java.io.Writer output,
Feed feed,
java.lang.String encoding,
java.lang.String version)
|
static void |
writeFeedDoc(javax.xml.stream.XMLStreamWriter output,
Feed feed,
java.lang.String encoding,
java.lang.String version)
For example: to pass the TXW com.sun.xml.txw2.output.IndentingXMLStreamWriter or the stax-utils javanet.staxutils.IndentingXMLStreamWriter for indented printing do this: |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Attribute atomBase
public static final Attribute lang_en
public static java.lang.String encoding
public static java.lang.String xml_version
public static final Attribute sort
public static final java.util.Comparator<java.lang.String> SORT_ASC
public static final java.util.Comparator<java.lang.String> SORT_DESC
| Constructor Detail |
|---|
public FeedDoc()
| Method Detail |
|---|
public static Generator getAtomsphereVersion()
public static void writeFeedDoc(java.io.OutputStream output,
Feed feed,
java.lang.String encoding,
java.lang.String version)
throws java.lang.Exception
output - the target output for the feed document.feed - the atom feed object containing the content of the feedencoding - the file encoding (default is UTF-8)version - the xml version (default is 1.0)
java.lang.Exception - thrown if the feed cannot be written to the output
public static void writeEntryDoc(java.io.OutputStream output,
Entry entry,
java.lang.String encoding,
java.lang.String version)
throws java.lang.Exception
output - the target output for the entry document.entry - the atom entry object containing the content.encoding - the file encoding (default is UTF-8)version - the xml version (default is 1.0)
java.lang.Exception - thrown if the atom document cannot be written to the output
public static void writeFeedDoc(java.io.Writer output,
Feed feed,
java.lang.String encoding,
java.lang.String version)
throws java.lang.Exception
output - the target output for the document.feed - the atom feed object containing the content of the feedencoding - the file encoding (default is UTF-8)version - the xml version (default is 1.0)
java.lang.Exception - thrown if the feed cannot be written to the output
public static void writeEntryDoc(java.io.Writer output,
Entry entry,
java.lang.String encoding,
java.lang.String version)
throws java.lang.Exception
output - the target output for the entry document.entry - the atom entry object containing the content.encoding - the file encoding (default is UTF-8)version - the xml version (default is 1.0)
java.lang.Exception - thrown if the atom document cannot be written to the output
public static void writeFeedDoc(javax.xml.stream.XMLStreamWriter output,
Feed feed,
java.lang.String encoding,
java.lang.String version)
throws java.lang.Exception
XmlStreamWriter writer =
new IndentingXMLStreamWriter(
XMLOutputFactory.newInstance()
.createXMLStreamWriter(
new FileOutputStream(outputFilePath)
,encoding));
FeedDoc.writeFeedDoc(writer,myFeed,null,null);
output - the target output for the feed.feed - the atom feed object containing the content of the feedencoding - the file encoding (default is UTF-8)version - the xml version (default is 1.0)
java.lang.Exception - thrown if the feed cannot be written to the output
public static void writeEntryDoc(javax.xml.stream.XMLStreamWriter output,
Entry entry,
java.lang.String encoding,
java.lang.String version)
throws java.lang.Exception
output - the target output for the entry document.entry - the atom entry object containing the content of the entryencoding - the file encoding (default is UTF-8)version - the xml version (default is 1.0)
java.lang.Exception - thrown if the feed cannot be written to the output
see writeFeedDoc(XMLStreamWriter output,Feed feed,String encoding,String version)
public static java.lang.String readFeedToString(Feed feed,
java.lang.String xmlStreamWriter)
throws java.lang.Exception
readFeedToString(Feed)if the XMLStreamWriter class cannot be found in the classpath.
feed - the feed to be converted to an atom document string.xmlStreamWriter - the fully qualified XMLStreamWriter class name.
java.lang.Exception - thrown if the feed cannot be returned as a String
public static java.lang.String readEntryToString(Entry entry,
java.lang.String xmlStreamWriter)
throws java.lang.Exception
entry - the entry to be converted to an atom document string.xmlStreamWriter - the XMLStreamWriter to use
java.lang.Exception - if the entry cannot be returned as a String
see readFeedToString(Feed feed, String xmlStreamWriter)
public static java.lang.String readFeedToString(Feed feed)
throws java.lang.Exception
feed - the feed to be converted to an atom string.
java.lang.Exception - thrown if the feed cannot be returned as a String
public static java.lang.String readEntryToString(Entry entry)
throws java.lang.Exception
entry - the entry to be converted to an atom entry document string.
java.lang.Exception - thrown if the feed cannot be returned as a String
public static Feed readFeedToBean(java.lang.String xmlString)
throws java.lang.Exception
xmlString - the xml string to be transformed into a Feed element.
java.lang.Exception - if the string cannot be parsed into a Feed element.
public static Entry readEntryToBean(java.lang.String xmlString)
throws java.lang.Exception
xmlString - the xml string to be transformed into a Entry element.
java.lang.Exception - if the string cannot be parsed into a Entry element.
public static Feed readFeedToBean(java.io.File file)
throws java.lang.Exception
file - the file object representing an atom file.
java.lang.Exception - if the file cannot be parsed into a Feed element.
public static Entry readEntryToBean(java.io.File file)
throws java.lang.Exception
file - the file object representing an atom file.
java.lang.Exception - if the file cannot be parsed into an Entry element.
public static Feed readFeedToBean(java.net.URL url)
throws java.lang.Exception
url - the Internet network location of an atom file.
java.lang.Exception - if the URL cannot be parsed into a Feed element.
public static Entry readEntryToBean(java.net.URL url)
throws java.lang.Exception
url - the Internet network location of an atom file.
java.lang.Exception - if the URL cannot be parsed into a Entry element.
public static Feed readFeedToBean(java.io.InputStream inputStream)
throws java.lang.Exception
inputStream - the input stream containing an atom file.
java.lang.Exception - if the URL cannot be parsed into a Feed element.
public static Entry readEntryToBean(java.io.InputStream inputStream)
throws java.lang.Exception
inputStream - the input stream containing an atom file.
java.lang.Exception - if the URL cannot be parsed into a Feed element.
public static Feed buildFeed(Id id,
Title title,
Updated updated,
Rights rights,
java.util.List<Author> authors,
java.util.List<Category> categories,
java.util.List<Contributor> contributors,
java.util.List<Link> links,
java.util.List<Attribute> attributes,
java.util.List<Extension> extensions,
Generator generator,
Subtitle subtitle,
Icon icon,
Logo logo,
java.util.SortedMap<java.lang.String,Entry> entries)
throws AtomSpecException
id - the unique id element (optional)title - the title element (optional)updated - the updated element (optional)rights - the rights element (optional)authors - a list of author elements (optional)categories - a list of category elements (optional)contributors - a list of contributor elements (optional)links - a list of link elements (optional)attributes - additional attributes (optional)extensions - a list of extension elements (optional)generator - the generator element (optional)subtitle - the subtitle element (optional)icon - the icon element (optional)logo - the logo element (optional)entries - a list of entry elements (optional)
AtomSpecException - if the data violates the
specification.
public static Attribute buildAttribute(java.lang.String name,
java.lang.String value)
name - the attribute name.value - the attribute value.
public static Author buildAuthor(Name name,
URI uri,
Email email,
java.util.List<Attribute> attributes,
java.util.List<Extension> extensions)
throws AtomSpecException
name - the name element. (required)uri - the uri element.email - the email element.attributes - additional attributes.extensions - a list of extension elements.
AtomSpecException - if the data violates the
specification.
public static Category buildCategory(java.util.List<Attribute> attributes,
java.lang.String content)
throws AtomSpecException
attributes - the attributes list which must contain "term"
and may contain "scheme", "label" or otherscontent - the undefined element content.
AtomSpecException - if the data violates the
specification.
public static Content buildContent(java.lang.String content,
java.util.List<Attribute> attributes)
throws AtomSpecException
content - the content of this elementattributes - additional attributes.
AtomSpecException
public static Contributor buildContributor(Name name,
URI uri,
Email email,
java.util.List<Attribute> attributes,
java.util.List<Extension> extensions)
throws AtomSpecException
name - the name element. (required)uri - the uri element.email - the email element.attributes - additional attributes.extensions - a list of extension elements.
AtomSpecException - if the data violates the
specification.public static Email buildEmail(java.lang.String email)
email - a human-readable email for the person
public static Entry buildEntry(Id id,
Title title,
Updated updated,
Rights rights,
Content content,
java.util.List<Author> authors,
java.util.List<Category> categories,
java.util.List<Contributor> contributors,
java.util.List<Link> links,
java.util.List<Attribute> attributes,
java.util.List<Extension> extensions,
Published published,
Summary summary,
Source source)
throws AtomSpecException
id - the id element (required)title - the title element (required)updated - the updated element (required)rights - the rights element (optional)content - the content element (optional)authors - a list of author elements (optional)categories - a list of category elements (optional)contributors - a list of contributor elements (optional)links - a list of link elements (optional)attributes - additional attributes.(optional)extensions - a list of extension elements (optional)published - the published element (optional)summary - the summary element (optional)source - the source element (optional)
AtomSpecException - if the data violates the
specification.
public static Extension buildExtension(java.lang.String elementName,
java.util.List<Attribute> attributes,
java.lang.String content)
elementName - the name of the extension element.attributes - additional attributes.content - the content of the extension element.
public static Generator buildGenerator(java.util.List<Attribute> attributes,
java.lang.String text)
throws AtomSpecException
attributes - the attributes list which can contain "uri" and or "version" or otherstext - the text content.
AtomSpecException
public static Icon buildIcon(java.util.List<Attribute> attributes,
java.lang.String atomUri)
throws AtomSpecException
atomUri - the URI reference.attributes - additional attributes.
AtomSpecException
public static Id buildId(java.util.List<Attribute> attributes,
java.lang.String atomUri)
throws AtomSpecException
atomUri - the URI reference.attributes - additional attributes.
AtomSpecException
public static Link buildLink(java.util.List<Attribute> attributes,
java.lang.String content)
throws AtomSpecException
attributes - the attributes list which must contain "href" and may contain "rel", "type", "hreflang", "title", "length" or otherscontent - the undefined link content.
AtomSpecException - if the data violates the
specification.
public static Logo buildLogo(java.util.List<Attribute> attributes,
java.lang.String atomUri)
throws AtomSpecException
atomUri - the logo uri reference.attributes - additional attributes.
AtomSpecExceptionpublic static Name buildName(java.lang.String name)
name - a human-readable name for the person
public static Published buildPublished(java.util.Date published,
java.util.List<Attribute> attributes)
throws AtomSpecException
published - the date formatted to [RFC3339]
AtomSpecException
public static Rights buildRights(java.lang.String rights,
java.util.List<Attribute> attributes)
throws AtomSpecException
rights - the rights text.attributes - additional attributes.
AtomSpecException
public static Source buildSource(Id id,
Title title,
Updated updated,
Rights rights,
java.util.List<Author> authors,
java.util.List<Category> categories,
java.util.List<Contributor> contributors,
java.util.List<Link> links,
java.util.List<Attribute> attributes,
java.util.List<Extension> extensions,
Generator generator,
Subtitle subtitle,
Icon icon,
Logo logo)
throws AtomSpecException
id - the unique id element (optional)title - the title element (optional)updated - the updated element (optional)rights - the rights element (optional)authors - a list of author elements (optional)categories - a list of category elements (optional)contributors - a list of contributor elements (optional)links - a list of link elements (optional)attributes - additional attributes (optional)extensions - a list of extension elements (optional)generator - the generator element (optional)subtitle - the subtitle element (optional)icon - the icon element (optional)logo - the logo element (optional)
AtomSpecException - if the data violates the
specification.
public static Subtitle buildSubtitle(java.lang.String subtitle,
java.util.List<Attribute> attributes)
throws AtomSpecException
subtitle - the subtitle text.attributes - additional attributes.
AtomSpecException
public static Summary buildSummary(java.lang.String summary,
java.util.List<Attribute> attributes)
throws AtomSpecException
summary - the summary text.attributes - additional attributes.
AtomSpecException
public static Title buildTitle(java.lang.String title,
java.util.List<Attribute> attributes)
throws AtomSpecException
title - the title textattributes - additional attributes.
AtomSpecException
public static Updated buildUpdated(java.util.Date updated,
java.util.List<Attribute> attributes)
throws AtomSpecException
updated - the date formatted to [RFC3339]
AtomSpecExceptionpublic static URI buildURI(java.lang.String uri)
uri - the content of the uri according to Section 7 of [RFC3986]
public static FeedDoc.ContentType getContentType(java.util.List<Attribute> attriubtes)
public static Feed sortEntries(Feed feed,
java.util.Comparator<java.lang.String> comparator,
java.lang.Class<?> elementClass)
throws AtomSpecException
feed - the feed whose entries are to be sortedcomparator - used to determine sort orderelementClass - serves as the key element for the entries collection
AtomSpecException - if the data violates the
specification.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||