You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2006/07/14 07:26:40 UTC
svn commit: r421809 [2/2] - in /incubator/abdera/java/trunk:
core/src/main/java/org/apache/abdera/model/
examples/src/main/java/org/apache/abdera/examples/appclient/
examples/src/main/java/org/apache/abdera/examples/simple/
extensions/src/main/java/org...
Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMLink.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMLink.java?rev=421809&r1=421808&r2=421809&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMLink.java (original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMLink.java Thu Jul 13 22:26:38 2006
@@ -47,11 +47,6 @@
super(Constants.LINK, null, (OMFactory)Factory.INSTANCE);
}
- public FOMLink(URI href) {
- this();
- setHref(href);
- }
-
public FOMLink(
String href)
throws URISyntaxException {
@@ -60,14 +55,6 @@
}
public FOMLink(
- URI href,
- String rel) {
- this();
- setHref(href);
- setRel(rel);
- }
-
- public FOMLink(
String href,
String rel)
throws URISyntaxException {
@@ -118,65 +105,67 @@
}
public URI getHref() throws URISyntaxException {
- return _getUriValue(_getAttributeValue(HREF));
+ return _getUriValue(getAttributeValue(HREF));
}
public URI getResolvedHref() throws URISyntaxException {
return _resolve(getResolvedBaseUri(), getHref());
}
- public void setHref(URI href) {
- _setAttributeValue(HREF, _getStringValue(href));
- }
-
public void setHref(String href) throws URISyntaxException {
- setHref((href != null) ? new URI(href) : null);
+ if (href != null)
+ setAttributeValue(HREF, (new URI(href)).toString());
+ else
+ removeAttribute(HREF);
}
public String getRel() {
- return _getAttributeValue(REL);
+ return getAttributeValue(REL);
}
public void setRel(String rel) {
- _setAttributeValue(REL, rel);
+ setAttributeValue(REL, rel);
}
public MimeType getMimeType() throws MimeTypeParseException {
- String type = _getAttributeValue(TYPE);
+ String type = getAttributeValue(TYPE);
return (type != null) ? new MimeType(type) : null;
}
public void setMimeType(MimeType type) {
- _setAttributeValue(TYPE, (type != null) ? type.toString() : null);
+ setAttributeValue(TYPE, (type != null) ? type.toString() : null);
}
public void setMimeType(String type) throws MimeTypeParseException {
- setMimeType(new MimeType(type));
+ if (type != null)
+ setAttributeValue(TYPE, (new MimeType(type)).toString());
+ else
+ removeAttribute(TYPE);
}
public String getHrefLang() {
- return _getAttributeValue(HREFLANG);
+ return getAttributeValue(HREFLANG);
}
public void setHrefLang(String lang) {
- _setAttributeValue(HREFLANG, lang);
+ setAttributeValue(HREFLANG, lang);
}
public String getTitle() {
- return _getAttributeValue(ATITLE);
+ return getAttributeValue(ATITLE);
}
public void setTitle(String title) {
- _setAttributeValue(ATITLE, title);
+ setAttributeValue(ATITLE, title);
}
public long getLength() {
- String l = _getAttributeValue(LENGTH);
+ String l = getAttributeValue(LENGTH);
return (l != null) ? Long.valueOf(l) : -1;
}
public void setLength(long length) {
- _setAttributeValue(LENGTH, (length >= 0) ? String.valueOf(length) : "0");
+ setAttributeValue(LENGTH, (length >= 0) ? String.valueOf(length) : "0");
}
Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java?rev=421809&r1=421808&r2=421809&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java (original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMParser.java Thu Jul 13 22:26:38 2006
@@ -31,6 +31,7 @@
import org.apache.abdera.parser.ParseException;
import org.apache.abdera.parser.Parser;
import org.apache.abdera.parser.ParserOptions;
+import org.apache.abdera.parser.stax.util.SniffingInputStream;
import org.apache.abdera.util.AbstractParser;
//import org.apache.abdera.util.SniffingInputStream;
import org.apache.axiom.om.OMDocument;
@@ -54,7 +55,9 @@
URI base,
ParserOptions options) {
Document<T> document = builder.getFomDocument();
- document.setBaseUri(base);
+ try {
+ document.setBaseUri(base.toString());
+ } catch (Exception e) {}
return document;
}
Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMPerson.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMPerson.java?rev=421809&r1=421808&r2=421809&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMPerson.java (original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMPerson.java Thu Jul 13 22:26:38 2006
@@ -54,17 +54,6 @@
QName qname,
String name,
String email,
- URI uri) {
- this(qname);
- setName(name);
- setEmail(email);
- setUri(uri);
- }
-
- public FOMPerson(
- QName qname,
- String name,
- String email,
String uri)
throws URISyntaxException {
this(qname);
@@ -109,7 +98,7 @@
if (element != null)
_setChild(NAME, (OMElement)element);
else
- _removeElement(NAME, false);
+ _removeChildren(NAME, false);
}
public Element setName(String name) {
@@ -120,7 +109,7 @@
_setChild(NAME, (OMElement)el);
return el;
} else {
- _removeElement(NAME, false);
+ _removeChildren(NAME, false);
return null;
}
}
@@ -138,7 +127,7 @@
if (element != null)
_setChild(EMAIL, (OMElement)element);
else
- _removeElement(EMAIL, false);
+ _removeChildren(EMAIL, false);
}
public Element setEmail(String email) {
@@ -149,7 +138,7 @@
_setChild(EMAIL, (OMElement)el);
return el;
} else {
- _removeElement(EMAIL, false);
+ _removeChildren(EMAIL, false);
return null;
}
}
@@ -167,22 +156,9 @@
if (uri != null)
_setChild(URI, (OMElement)uri);
else
- _removeElement(URI, false);
+ _removeChildren(URI, false);
}
- public IRI setUri(URI uri) {
- if (uri != null) {
- FOMFactory fomfactory = (FOMFactory) factory;
- IRI el = fomfactory.newUri(null);
- el.setValue(uri);
- _setChild(URI, (OMElement)el);
- return el;
- } else {
- _removeElement(URI, false);
- return null;
- }
- }
-
public IRI setUri(String uri) throws URISyntaxException {
if (uri != null) {
FOMFactory fomfactory = (FOMFactory) factory;
@@ -191,7 +167,7 @@
_setChild(URI, (OMElement)el);
return el;
} else {
- _removeElement(URI, false);
+ _removeChildren(URI, false);
return null;
}
}
Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java?rev=421809&r1=421808&r2=421809&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java (original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMService.java Thu Jul 13 22:26:38 2006
@@ -99,10 +99,6 @@
return workspace;
}
- public void setWorkspaces(List<Workspace> workspaces) {
- _setChildrenFromSet(WORKSPACE, workspaces);
- }
-
public void addWorkspace(Workspace workspace) {
addChild((OMElement) workspace);
}
Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java?rev=421809&r1=421808&r2=421809&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java (original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMSource.java Thu Jul 13 22:26:38 2006
@@ -19,16 +19,14 @@
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import javax.activation.MimeType;
import javax.activation.MimeTypeParseException;
import javax.xml.namespace.QName;
import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.AtomDate;
import org.apache.abdera.model.Category;
import org.apache.abdera.model.DateTime;
import org.apache.abdera.model.Div;
@@ -38,6 +36,7 @@
import org.apache.abdera.model.Person;
import org.apache.abdera.model.Source;
import org.apache.abdera.model.Text;
+import org.apache.abdera.parser.stax.util.FOMHelper;
import org.apache.abdera.util.Constants;
import org.apache.abdera.util.URIHelper;
import org.apache.axiom.om.OMContainer;
@@ -47,7 +46,6 @@
import org.apache.axiom.om.OMNamespace;
import org.apache.axiom.om.OMXMLParserWrapper;
-
public class FOMSource
extends FOMExtensibleElement
implements Source {
@@ -107,10 +105,6 @@
return _getChildrenAsSet(AUTHOR);
}
- public void setAuthors(List<Person> people) {
- _setChildrenFromSet(AUTHOR, people);
- }
-
public void addAuthor(Person person) {
addChild((OMElement)person);
}
@@ -131,42 +125,14 @@
return person;
}
- public Person addAuthor(String name, String email, URI uri) {
- FOMFactory fomfactory = (FOMFactory) this.factory;
- Person person = fomfactory.newAuthor(this);
- person.setName(name);
- person.setEmail(email);
- person.setUri(uri);
- return person;
- }
-
public List<Category> getCategories() {
return _getChildrenAsSet(CATEGORY);
}
- public List<Category> getCategories(URI scheme) {
- List<Category> categories = getCategories();
- List<Category> matching = new ArrayList<Category>();
- for (Category category : categories) {
- try {
- URI uri = category.getScheme();
- if ((uri != null && uri.equals(scheme)) ||
- (uri == null && scheme == null)) {
- matching.add(category);
- }
- } catch (Exception e) {}
- }
- return matching;
- }
-
public List<Category> getCategories(String scheme) throws URISyntaxException {
- return getCategories((scheme != null) ? new URI(scheme) : null);
+ return FOMHelper.getCategories(this, scheme);
}
- public void setCategories(List<Category> categories) {
- _setChildrenFromSet(CATEGORY, categories);
- }
-
public void addCategory(Category category) {
addChild((OMElement)category);
}
@@ -178,15 +144,6 @@
return category;
}
- public Category addCategory(URI scheme, String term, String label) {
- FOMFactory factory = (FOMFactory) this.factory;
- Category category = factory.newCategory(this);
- category.setTerm(term);
- category.setScheme(scheme);
- category.setLabel(label);
- return category;
- }
-
public Category addCategory(String scheme, String term, String label) throws URISyntaxException {
FOMFactory factory = (FOMFactory) this.factory;
Category category = factory.newCategory(this);
@@ -200,10 +157,6 @@
return _getChildrenAsSet(CONTRIBUTOR);
}
- public void setContributors(List<Person> people) {
- _setChildrenFromSet(CONTRIBUTOR, people);
- }
-
public void addContributor(Person person) {
addChild((OMElement)person);
}
@@ -224,15 +177,6 @@
return person;
}
- public Person addContributor(String name, String email, URI uri) {
- FOMFactory fomfactory = (FOMFactory) this.factory;
- Person person = fomfactory.newContributor(this);
- person.setName(name);
- person.setEmail(email);
- person.setUri(uri);
- return person;
- }
-
public IRI getIdElement() {
return (IRI)getFirstChildWithName(ID);
}
@@ -241,7 +185,7 @@
if (id != null)
_setChild(ID, (OMElement)id);
else
- _removeElement(ID, false);
+ _removeChildren(ID, false);
}
public URI getId() throws URISyntaxException {
@@ -249,17 +193,13 @@
return (id != null) ? id.getValue() : null;
}
- public IRI setId(URI value) throws URISyntaxException {
- return setId(value, false);
- }
-
public IRI setId(String value) throws URISyntaxException {
return setId(value, false);
}
-
- public IRI setId(URI value, boolean normalize) throws URISyntaxException {
+
+ public IRI setId(String value, boolean normalize) throws URISyntaxException {
if (value == null) {
- _removeElement(ID, false);
+ _removeChildren(ID, false);
return null;
}
IRI id = getIdElement();
@@ -274,36 +214,13 @@
return iri;
}
}
-
- public IRI setId(String value, boolean normalize) throws URISyntaxException {
- return setId((value != null) ? new URI(value) : null, normalize);
- }
public List<Link> getLinks() {
return _getChildrenAsSet(LINK);
}
public List<Link> getLinks(String rel) {
- if (rel == null) return getLinks();
- List<Link> links = getLinks();
- List<Link> matching = new ArrayList<Link>();
- for (Link link : links) {
- String value = FOMLink.getRelEquiv(link.getRel());
- rel = FOMLink.getRelEquiv(rel);
- if (rel.equalsIgnoreCase(Link.REL_ALTERNATE) &&
- (value == null ||
- value.equalsIgnoreCase(Link.REL_ALTERNATE) ||
- value.equalsIgnoreCase(Link.REL_ALTERNATE_IANA))) {
- matching.add(link);
- } else if (rel.equalsIgnoreCase(value)) {
- matching.add(link);
- }
- }
- return matching;
- }
-
- public void setLinks(List<Link> links) {
- _setChildrenFromSet(LINK, links);
+ return FOMHelper.getLinks(this, rel);
}
public void addLink(Link link) {
@@ -322,54 +239,6 @@
return link;
}
- public Link addLink(URI href) {
- return addLink(href, null);
- }
-
- public Link addLink(URI href, String rel) {
- FOMFactory fomfactory = (FOMFactory) factory;
- Link link = fomfactory.newLink(this);
- link.setHref(href);
- link.setRel(rel);
- return link;
- }
-
- public Link addLink(URI href, String rel, MimeType type, String title, String hreflang, long length) {
- FOMFactory fomfactory = (FOMFactory) factory;
- Link link = fomfactory.newLink(this);
- link.setHref(href);
- link.setRel(rel);
- link.setMimeType(type);
- link.setTitle(title);
- link.setHrefLang(hreflang);
- link.setLength(length);
- return link;
- }
-
- public Link addLink(String href, String rel, MimeType type, String title, String hreflang, long length) throws URISyntaxException {
- FOMFactory fomfactory = (FOMFactory) factory;
- Link link = fomfactory.newLink(this);
- link.setHref(href);
- link.setRel(rel);
- link.setMimeType(type);
- link.setTitle(title);
- link.setHrefLang(hreflang);
- link.setLength(length);
- return link;
- }
-
- public Link addLink(URI href, String rel, String type, String title, String hreflang, long length) throws MimeTypeParseException {
- FOMFactory fomfactory = (FOMFactory) factory;
- Link link = fomfactory.newLink(this);
- link.setHref(href);
- link.setRel(rel);
- link.setMimeType(type);
- link.setTitle(title);
- link.setHrefLang(hreflang);
- link.setLength(length);
- return link;
- }
-
public Link addLink(String href, String rel, String type, String title, String hreflang, long length) throws URISyntaxException, MimeTypeParseException {
FOMFactory fomfactory = (FOMFactory) factory;
Link link = fomfactory.newLink(this);
@@ -391,13 +260,6 @@
setTextElement(RIGHTS, text, false);
}
- public Text setRights() {
- FOMFactory factory = (FOMFactory)this.factory;
- Text text = factory.newRights(Text.Type.TEXT);
- setRightsElement(text);
- return text;
- }
-
public Text setRights(String value) {
FOMFactory factory = (FOMFactory)this.factory;
Text text = factory.newRights();
@@ -414,13 +276,6 @@
return setRights(value, Text.Type.XHTML);
}
- public Text setRights(Text.Type type) {
- FOMFactory factory = (FOMFactory)this.factory;
- Text text = factory.newRights(type);
- setRightsElement(text);
- return text;
- }
-
public Text setRights(String value, Text.Type type) {
FOMFactory factory = (FOMFactory)this.factory;
Text text = factory.newRights(type);
@@ -440,17 +295,6 @@
return getText(RIGHTS);
}
- public Source getSource() {
- return (Source)getFirstChildWithName(SOURCE);
- }
-
- public void setSource(Source source) {
- if (source != null)
- _setChild(SOURCE, (OMElement)source);
- else
- _removeElement(SOURCE, false);
- }
-
public Text getSubtitleElement() {
return getTextElement(SUBTITLE);
}
@@ -459,13 +303,6 @@
setTextElement(SUBTITLE, text, false);
}
- public Text setSubtitle() {
- FOMFactory factory = (FOMFactory)this.factory;
- Text text = factory.newSubtitle(Text.Type.TEXT);
- setSubtitleElement(text);
- return text;
- }
-
public Text setSubtitle(String value) {
FOMFactory factory = (FOMFactory)this.factory;
Text text = factory.newSubtitle();
@@ -482,13 +319,6 @@
return setSubtitle(value, Text.Type.XHTML);
}
- public Text setSubtitle(Text.Type type) {
- FOMFactory factory = (FOMFactory)this.factory;
- Text text = factory.newSubtitle(type);
- setSubtitleElement(text);
- return text;
- }
-
public Text setSubtitle(String value, Text.Type type) {
FOMFactory factory = (FOMFactory)this.factory;
Text text = factory.newSubtitle(type);
@@ -516,13 +346,6 @@
setTextElement(TITLE, text, false);
}
- public Text setTitle() {
- FOMFactory factory = (FOMFactory)this.factory;
- Text text = factory.newTitle(Text.Type.TEXT);
- setTitleElement(text);
- return text;
- }
-
public Text setTitle(String value) {
FOMFactory factory = (FOMFactory)this.factory;
Text text = factory.newTitle();
@@ -539,13 +362,6 @@
return setTitle(value, Text.Type.XHTML);
}
- public Text setTitle(Text.Type type) {
- FOMFactory factory = (FOMFactory)this.factory;
- Text text = factory.newTitle(type);
- setTitleElement(text);
- return text;
- }
-
public Text setTitle(String value, Text.Type type) {
FOMFactory factory = (FOMFactory)this.factory;
Text text = factory.newTitle(type);
@@ -573,7 +389,7 @@
if (updated != null)
_setChild(UPDATED, (OMElement)updated);
else
- _removeElement(UPDATED, false);
+ _removeChildren(UPDATED, false);
}
public String getUpdatedString() {
@@ -586,68 +402,29 @@
return (dte != null) ? dte.getDate() : null;
}
- public DateTime setUpdated(Date value) {
+ private DateTime setUpdated(AtomDate value) {
if (value == null) {
- _removeElement(UPDATED, false);
+ _removeChildren(UPDATED, false);
return null;
}
DateTime dte = getUpdatedElement();
if (dte != null) {
- dte.setDate(value);
+ dte.setValue(value);
return dte;
} else {
FOMFactory fomfactory = (FOMFactory) factory;
DateTime dt = fomfactory.newUpdated(this);
- dt.setDate(value);
+ dt.setValue(value);
return dt;
}
}
- public DateTime setUpdated(Calendar value) {
- if (value == null) {
- _removeElement(UPDATED, false);
- return null;
- }
- DateTime dte = getUpdatedElement();
- if (dte != null) {
- dte.setCalendar(value);
- return dte;
- } else {
- FOMFactory fomfactory = (FOMFactory) factory;
- DateTime dt = fomfactory.newUpdated(this);
- dt.setCalendar(value);
- return dt;
- }
- }
-
- public DateTime setUpdated(long value) {
- DateTime dte = getUpdatedElement();
- if (dte != null) {
- dte.setTime(value);
- return dte;
- } else {
- FOMFactory fomfactory = (FOMFactory) factory;
- DateTime dt = fomfactory.newUpdated(this);
- dt.setTime(value);
- return dt;
- }
+ public DateTime setUpdated(Date value) {
+ return setUpdated((value != null) ? AtomDate.valueOf(value) : null);
}
public DateTime setUpdated(String value) {
- if (value == null) {
- _removeElement(UPDATED, false);
- return null;
- }
- DateTime dte = getUpdatedElement();
- if (dte != null) {
- dte.setString(value);
- return dte;
- } else {
- FOMFactory fomfactory = (FOMFactory) factory;
- DateTime dt = fomfactory.newUpdated(this);
- dt.setString(value);
- return dt;
- }
+ return setUpdated((value != null) ? AtomDate.valueOf(value) : null);
}
public Generator getGenerator() {
@@ -658,18 +435,9 @@
if (generator != null)
_setChild(GENERATOR, (OMElement) generator);
else
- _removeElement(GENERATOR, false);
+ _removeChildren(GENERATOR, false);
}
- public Generator setGenerator(URI uri, String version, String value) {
- FOMFactory fomfactory = (FOMFactory) factory;
- Generator generator = fomfactory.newGenerator(this);
- generator.setUri(uri);
- generator.setVersion(version);
- generator.setText(value);
- return generator;
- }
-
public Generator setGenerator(
String uri,
String version,
@@ -677,9 +445,9 @@
throws URISyntaxException {
FOMFactory fomfactory = (FOMFactory) factory;
Generator generator = fomfactory.newGenerator(this);
- if (uri != null) generator.setUri(new URI(uri));
- generator.setVersion(version);
- generator.setText(value);
+ if (uri != null) generator.setUri(uri);
+ if (version != null) generator.setVersion(version);
+ if (value != null) generator.setText(value);
return generator;
}
@@ -691,12 +459,12 @@
if (iri != null)
_setChild(ICON, (OMElement) iri);
else
- _removeElement(ICON, false);
+ _removeChildren(ICON, false);
}
public IRI setIcon(String value) throws URISyntaxException {
if (value == null) {
- _removeElement(ICON, false);
+ _removeChildren(ICON, false);
return null;
}
FOMFactory fomfactory = (FOMFactory) factory;
@@ -705,17 +473,6 @@
return iri;
}
- public IRI setIcon(URI value) {
- if (value == null) {
- _removeElement(ICON, false);
- return null;
- }
- FOMFactory fomfactory = (FOMFactory) factory;
- IRI iri = fomfactory.newIcon(this);
- iri.setValue(value);
- return iri;
- }
-
public URI getIcon() throws URISyntaxException {
IRI iri = getIconElement();
return (iri != null) ? iri.getValue() : null;
@@ -729,29 +486,18 @@
if (iri != null)
_setChild(LOGO, (OMElement)iri);
else
- _removeElement(LOGO, false);
+ _removeChildren(LOGO, false);
}
public IRI setLogo(String value) throws URISyntaxException {
if (value == null) {
- _removeElement(LOGO, false);
+ _removeChildren(LOGO, false);
return null;
}
FOMFactory fomfactory = (FOMFactory) factory;
IRI iri = fomfactory.newLogo(this);
iri.setValue(value);
return iri;
- }
-
- public IRI setLogo(URI value) {
- if (value == null) {
- _removeElement(LOGO, false);
- return null;
- }
- FOMFactory fomfactory = (FOMFactory) factory;
- IRI iri = fomfactory.newLogo(this);
- iri.setValue(value);
- return iri;
}
public URI getLogo() throws URISyntaxException {
Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMText.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMText.java?rev=421809&r1=421808&r2=421809&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMText.java (original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMText.java Thu Jul 13 22:26:38 2006
@@ -81,13 +81,13 @@
private void init(Type type) {
this.type = type;
if (Type.TEXT.equals(type))
- _setAttributeValue(TYPE, "text");
+ setAttributeValue(TYPE, "text");
else if (Type.HTML.equals(type))
- _setAttributeValue(TYPE, "html");
+ setAttributeValue(TYPE, "html");
else if (Type.XHTML.equals(type))
- _setAttributeValue(TYPE, "xhtml");
+ setAttributeValue(TYPE, "xhtml");
else
- _removeAttribute(TYPE);
+ removeAttribute(TYPE);
}
public final Type getTextType() {
Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java?rev=421809&r1=421808&r2=421809&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java (original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMWorkspace.java Thu Jul 13 22:26:38 2006
@@ -17,7 +17,6 @@
*/
package org.apache.abdera.parser.stax;
-import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
@@ -92,11 +91,11 @@
}
public String getTitle() {
- return _getAttributeValue(ATITLE);
+ return getAttributeValue(ATITLE);
}
public void setTitle(String title) {
- _setAttributeValue(ATITLE, title);
+ setAttributeValue(ATITLE, title);
}
public List<Collection> getCollections() {
@@ -115,23 +114,15 @@
return col;
}
- public void setCollection(List<Collection> collections) {
- _setChildrenFromSet(COLLECTION, collections);
- }
-
public void addCollection(Collection collection) {
addChild((OMElement)collection);
}
- public Collection addCollection(String title, URI href) {
+ public Collection addCollection(String title, String href) throws URISyntaxException {
FOMFactory fomfactory = (FOMFactory) factory;
Collection collection = fomfactory.newCollection(this);
collection.setTitle(title);
collection.setHref(href);
return collection;
- }
-
- public Collection addCollection(String title, String href) throws URISyntaxException {
- return addCollection(title, (href != null) ? new URI(href) : null);
}
}
Added: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/ElementIterator.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/ElementIterator.java?rev=421809&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/ElementIterator.java (added)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/ElementIterator.java Thu Jul 13 22:26:38 2006
@@ -0,0 +1,118 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.parser.stax.util;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.model.Element;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
+
+public class ElementIterator extends OMChildrenIterator {
+
+ /**
+ * Field givenQName
+ */
+ protected QName attribute = null;
+ protected String value = null;
+ protected String defaultValue = null;
+ protected Class _class = null;
+
+ /**
+ * Field needToMoveForward
+ */
+ private boolean needToMoveForward = true;
+
+ /**
+ * Field isMatchingNodeFound
+ */
+ private boolean isMatchingNodeFound = false;
+
+ /**
+ * Constructor OMChildrenQNameIterator.
+ *
+ * @param currentChild
+ * @param givenQName
+ */
+ public ElementIterator(Element parent, Class _class) {
+ super(((OMElement)parent).getFirstOMChild());
+ this._class = _class;
+ }
+
+ public ElementIterator(Element parent, Class _class, QName attribute, String value, String defaultValue) {
+ this(parent, _class);
+ this.attribute = attribute;
+ this.value = value;
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * Returns <tt>true</tt> if the iteration has more elements. (In other
+ * words, returns <tt>true</tt> if <tt>next</tt> would return an element
+ * rather than throwing an exception.)
+ *
+ * @return Returns <tt>true</tt> if the iterator has more elements.
+ */
+ @SuppressWarnings("unchecked")
+ public boolean hasNext() {
+ while (needToMoveForward) {
+ if (currentChild != null) {
+ // check the current node for the criteria
+ if (currentChild instanceof Element) {
+ if (((_class != null &&
+ _class.isAssignableFrom(currentChild.getClass()))
+ || _class == null) && isMatch((Element)currentChild)) {
+ isMatchingNodeFound = true;
+ needToMoveForward = false;
+ } else {
+ isMatchingNodeFound = false;
+ currentChild = currentChild.getNextOMSibling();
+ }
+ } else {
+ isMatchingNodeFound = false;
+ currentChild = currentChild.getNextOMSibling();
+ }
+ } else {
+ needToMoveForward = false;
+ }
+ }
+ return isMatchingNodeFound;
+ }
+
+ public Object next() {
+
+ // reset the flags
+ needToMoveForward = true;
+ isMatchingNodeFound = false;
+ nextCalled = true;
+ removeCalled = false;
+ lastChild = currentChild;
+ currentChild = currentChild.getNextOMSibling();
+ return lastChild;
+ }
+
+ protected boolean isMatch(Element el) {
+ if (attribute != null) {
+ String val = el.getAttributeValue(attribute);
+ return ((val == null && value == null) ||
+ (val == null && value != null && value.equals(defaultValue)) ||
+ (val != null && val.equals(value)));
+ }
+ return true;
+ }
+}
Added: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java?rev=421809&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java (added)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java Thu Jul 13 22:26:38 2006
@@ -0,0 +1,123 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.parser.stax.util;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.traverse.OMChildrenIterator;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Most of the original code for this class came from the
+ * OMChildrenQNameIterator from Axiom
+ */
+public class FOMExtensionIterator extends OMChildrenIterator {
+
+ /**
+ * Field givenQName
+ */
+ private String namespace = null;
+ private String extns = null;
+
+ /**
+ * Field needToMoveForward
+ */
+ private boolean needToMoveForward = true;
+
+ /**
+ * Field isMatchingNodeFound
+ */
+ private boolean isMatchingNodeFound = false;
+
+ /**
+ * Constructor OMChildrenQNameIterator.
+ *
+ * @param currentChild
+ * @param givenQName
+ */
+ public FOMExtensionIterator(OMElement parent) {
+ super(parent.getFirstOMChild());
+ this.namespace = parent.getQName().getNamespaceURI();
+ }
+
+ public FOMExtensionIterator(OMElement parent, String extns) {
+ this(parent);
+ this.extns = extns;
+ }
+
+ /**
+ * Returns <tt>true</tt> if the iteration has more elements. (In other
+ * words, returns <tt>true</tt> if <tt>next</tt> would return an element
+ * rather than throwing an exception.)
+ *
+ * @return Returns <tt>true</tt> if the iterator has more elements.
+ */
+ public boolean hasNext() {
+ while (needToMoveForward) {
+ if (currentChild != null) {
+
+ // check the current node for the criteria
+ if ((currentChild instanceof OMElement)
+ && (isQNamesMatch(
+ ((OMElement) currentChild).getQName(),
+ this.namespace))) {
+ isMatchingNodeFound = true;
+ needToMoveForward = false;
+ } else {
+
+ // get the next named node
+ currentChild = currentChild.getNextOMSibling();
+ isMatchingNodeFound = needToMoveForward = !(currentChild
+ == null);
+ }
+ } else {
+ needToMoveForward = false;
+ }
+ }
+ return isMatchingNodeFound;
+ }
+
+ public Object next() {
+
+ // reset the flags
+ needToMoveForward = true;
+ isMatchingNodeFound = false;
+ nextCalled = true;
+ removeCalled = false;
+ lastChild = currentChild;
+ currentChild = currentChild.getNextOMSibling();
+ return lastChild;
+ }
+
+ private boolean isQNamesMatch(QName elementQName, String namespace) {
+ String elns = elementQName.getNamespaceURI();
+ boolean namespaceURIMatch =
+ (namespace == null)
+ || (namespace == "")
+ ||
+ ((elementQName != null)
+ &&
+ elns.equals(namespace));
+ if (!namespaceURIMatch && extns != null && !elns.equals(extns))
+ return false;
+ else
+ return !namespaceURIMatch;
+ }
+
+
+}
Added: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMHelper.java?rev=421809&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMHelper.java (added)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMHelper.java Thu Jul 13 22:26:38 2006
@@ -0,0 +1,41 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.parser.stax.util;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.abdera.model.Category;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.util.Constants;
+
+public class FOMHelper implements Constants {
+
+ @SuppressWarnings("unchecked")
+ public static List<Category> getCategories(Element element, String scheme) {
+ Iterator i = new ElementIterator(element, Category.class, SCHEME, scheme, null);
+ return new FOMList<Category>(i);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static List<Link> getLinks(Element element, String rel) {
+ Iterator i = new LinkIterator(element, Link.class, REL, rel, Link.REL_ALTERNATE);
+ return new FOMList<Link>(i);
+ }
+}
Added: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMList.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMList.java?rev=421809&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMList.java (added)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMList.java Thu Jul 13 22:26:38 2006
@@ -0,0 +1,250 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.parser.stax.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * Implements an ElementSet around an internal buffered iterator.
+ * Here's the rationale:
+ * Axiom parses incrementally. Using the iterators provided
+ * by Axiom, we can walk a set of elements while preserving
+ * the incremental parsing model, however, if we went with
+ * just java.util.Iterator, we'd lose the ability to do
+ * things like feed.getEntries().get(0), or use the
+ * new Java5 style iterators for (Entry e : feed.getEntries()).
+ * However, using a regular java.util.List also isn't a great
+ * option because it means we have to iterate through all of the
+ * elements before returning back to the caller. This gives us
+ * a hybrid approach. We create an internal iterator, then
+ * create a List from that, the iterator is consumed as the list
+ * is used.
+ *
+ * The List itself is unmodifiable.
+ */
+public class FOMList<T>
+ extends java.util.AbstractCollection<T>
+ implements List<T> {
+
+ private Iterator<T> i = null;
+ private List<T> buffer = new ArrayList<T>();
+
+ public FOMList(Iterator<T> i) {
+ this.i = i;
+ }
+
+ public List<T> getAsList() {
+ buffer(-1);
+ return java.util.Collections.unmodifiableList(buffer);
+ }
+
+ private boolean finished() {
+ return !i.hasNext();
+ }
+
+ private int buffered() {
+ return buffer.size() - 1;
+ }
+
+ private int buffer(int n) {
+ if (i.hasNext()) {
+ int read = 0;
+ while(i.hasNext() && (read++ < n || n == -1)) {
+ buffer.add(i.next());
+ }
+ }
+ return buffered();
+ }
+
+ @SuppressWarnings("unchecked")
+ public T get(int index) {
+ int n = buffered();
+ if (index > n && (index > buffer(index - n)))
+ throw new ArrayIndexOutOfBoundsException(index);
+ return (T) buffer.get(index);
+ }
+
+ public int size() {
+ return buffer(-1) + 1;
+ }
+
+ public Iterator<T> iterator() {
+ return new BufferIterator<T>(this);
+ }
+
+ private Iterator<T> iterator(int index) {
+ return new BufferIterator<T>(this,index);
+ }
+
+ public boolean add(T o) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void add(int index, T element) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean addAll(Collection c) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean addAll(int index, Collection c) {
+ return false;
+ }
+
+ public void clear() {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean contains(Object o) {
+ buffer(-1);
+ return buffer.contains(o);
+ }
+
+ public boolean containsAll(Collection c) {
+ for(Object o : c)
+ if (contains(o)) return true;
+ return false;
+ }
+
+ public int indexOf(Object o) {
+ buffer(-1);
+ return buffer.indexOf(o);
+ }
+
+ public boolean isEmpty() {
+ buffer(-1);
+ return buffer.isEmpty();
+ }
+
+ public int lastIndexOf(Object o) {
+ buffer(-1);
+ return buffer.lastIndexOf(o);
+ }
+
+ public ListIterator<T> listIterator() {
+ return (ListIterator<T>)iterator();
+ }
+
+ public ListIterator<T> listIterator(int index) {
+ return (ListIterator<T>)iterator(index);
+ }
+
+ public boolean remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ public T remove(int index) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean removeAll(Collection c) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean retainAll(Collection c) {
+ throw new UnsupportedOperationException();
+ }
+
+ public T set(int index, T element) {
+ throw new UnsupportedOperationException();
+ }
+
+ public List<T> subList(int fromIndex, int toIndex) {
+ buffer(-1);
+ return Collections.unmodifiableList(buffer.subList(fromIndex, toIndex));
+ }
+
+ public Object[] toArray() {
+ buffer(-1);
+ return buffer.toArray();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object[] toArray(Object[] a) {
+ buffer(-1);
+ return buffer.toArray(a);
+ }
+
+ private class BufferIterator<M>
+ implements ListIterator<M> {
+
+ private FOMList set = null;
+ private int counter = 0;
+
+ BufferIterator(FOMList set) {
+ this.set = set;
+ }
+
+ BufferIterator(FOMList set, int index) {
+ this.set = set;
+ this.counter = index;
+ }
+
+ public boolean hasNext() {
+ return (!set.finished()) ||
+ (set.finished() && counter < buffer.size());
+ }
+
+ @SuppressWarnings("unchecked")
+ public M next() {
+ return (M) set.get(counter++);
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ public void add(M o) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean hasPrevious() {
+ return counter > 0;
+ }
+
+ public int nextIndex() {
+ if (hasNext())
+ return counter+1;
+ else
+ return buffer.size();
+ }
+
+ @SuppressWarnings("unchecked")
+ public M previous() {
+ return (M) set.get(--counter);
+ }
+
+ public int previousIndex() {
+ if (hasPrevious())
+ return counter-1;
+ else
+ return -1;
+ }
+
+ public void set(M o) {
+ throw new UnsupportedOperationException();
+ }
+
+ }
+}
Added: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/LinkIterator.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/LinkIterator.java?rev=421809&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/LinkIterator.java (added)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/LinkIterator.java Thu Jul 13 22:26:38 2006
@@ -0,0 +1,45 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.parser.stax.util;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.parser.stax.FOMLink;
+
+public class LinkIterator extends ElementIterator {
+
+ public LinkIterator(Element parent, Class _class, QName attribute, String value, String defaultValue) {
+ super(parent, _class, attribute, (value != null) ? FOMLink.getRelEquiv(value) : Link.REL_ALTERNATE, defaultValue);
+ }
+
+ public LinkIterator(Element parent, Class _class) {
+ super(parent, _class);
+ }
+
+ protected boolean isMatch(Element el) {
+ if (attribute != null) {
+ String val = FOMLink.getRelEquiv(el.getAttributeValue(attribute));
+ return ((val == null && value == null) ||
+ (val == null && value != null && value.equalsIgnoreCase(defaultValue)) ||
+ (val != null && val.equalsIgnoreCase(value)));
+ }
+ return true;
+ }
+}
Copied: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/SniffingInputStream.java (from r421658, incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/SniffingInputStream.java)
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/SniffingInputStream.java?p2=incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/SniffingInputStream.java&p1=incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/SniffingInputStream.java&r1=421658&r2=421809&rev=421809&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/SniffingInputStream.java (original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/SniffingInputStream.java Thu Jul 13 22:26:38 2006
@@ -15,7 +15,7 @@
* copyright in this work, please see the NOTICE file in the top level
* directory of this distribution.
*/
-package org.apache.abdera.parser.stax;
+package org.apache.abdera.parser.stax.util;
import java.io.BufferedInputStream;
import java.io.FilterInputStream;
Modified: incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java?rev=421809&r1=421808&r2=421809&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java (original)
+++ incubator/abdera/java/trunk/parser/src/test/java/org/apache/abdera/test/parser/stax/FOMTest.java Thu Jul 13 22:26:38 2006
@@ -296,7 +296,7 @@
author = factory.newAuthor();
author.setName("a");
author.setEmail("b");
- author.setUri(new URI("c"));
+ author.setUri("c");
assertNotNull(author);
assertEquals(author.getName(),"a");
assertEquals(author.getEmail(), "b");
@@ -340,7 +340,7 @@
contributor = factory.newContributor();
contributor.setName("a");
contributor.setEmail("b");
- contributor.setUri(new URI("c"));
+ contributor.setUri("c");
assertNotNull(contributor);
assertEquals(contributor.getName(),"a");
assertEquals(contributor.getEmail(), "b");
@@ -396,7 +396,7 @@
generator = factory.newGenerator();
assertNotNull(generator);
generator = factory.newGenerator();
- generator.setUri(new URI(Version.URI));
+ generator.setUri(Version.URI);
generator.setVersion(Version.VERSION);
generator.setText(Version.APP_NAME);
assertNotNull(generator);
@@ -436,7 +436,7 @@
iri.setValue("http://example.org/foo");
assertEquals(iri.getValue().toString(), "http://example.org/foo");
iri = factory.newIcon();
- iri.setValue(new URI("http://example.org/foo"));
+ iri.setValue("http://example.org/foo");
assertEquals(iri.getValue().toString(), "http://example.org/foo");
iri = factory.newID();
assertNotNull(iri);
@@ -444,7 +444,7 @@
iri.setValue("http://example.org/foo");
assertEquals(iri.getValue().toString(), "http://example.org/foo");
iri = factory.newID();
- iri.setValue(new URI("http://example.org/foo"));
+ iri.setValue("http://example.org/foo");
assertEquals(iri.getValue().toString(), "http://example.org/foo");
iri = factory.newIRIElement(Constants.ID, null);
assertNotNull(iri);
@@ -452,14 +452,14 @@
iri.setValue("http://example.org/foo");
assertEquals(iri.getValue().toString(), "http://example.org/foo");
iri = factory.newIRIElement(Constants.ID, null);
- iri.setValue(new URI("http://example.org/foo"));
+ iri.setValue("http://example.org/foo");
assertEquals(iri.getValue().toString(), "http://example.org/foo");
Link link = factory.newLink();
assertNotNull(link);
link = factory.newLink();
link.setHref("http://example.org/foo");
link.setRel("a");
- link.setMimeType(new MimeType("text/foo"));
+ link.setMimeType("text/foo");
link.setTitle("b");
link.setHrefLang("en");
link.setLength(10);
@@ -470,9 +470,9 @@
assertEquals(link.getHrefLang(), "en");
assertEquals(link.getLength(), 10);
link = factory.newLink();
- link.setHref(new URI("http://example.org/foo"));
+ link.setHref("http://example.org/foo");
link.setRel("a");
- link.setMimeType(new MimeType("text/foo"));
+ link.setMimeType("text/foo");
link.setTitle("b");
link.setHrefLang("en");
link.setLength(10);
@@ -488,10 +488,10 @@
iri.setValue("http://example.org/foo");
assertEquals(iri.getValue().toString(), "http://example.org/foo");
iri = factory.newLogo();
- iri.setValue(new URI("http://example.org/foo"));
+ iri.setValue("http://example.org/foo");
assertEquals(iri.getValue().toString(), "http://example.org/foo");
content = factory.newContent(new MimeType("text/foo"));
- content.setSrc(new URI("foo"));
+ content.setSrc("foo");
assertNotNull(content);
assertEquals(content.getMimeType().toString(), "text/foo");
assertEquals(content.getSrc().toString(), "foo");
@@ -519,7 +519,7 @@
person = factory.newPerson(Constants.AUTHOR, null);
person.setName("a");
person.setEmail("b");
- person.setUri(new URI("c"));
+ person.setUri("c");
assertEquals(person.getName(),"a");
assertEquals(person.getEmail(), "b");
assertEquals(person.getUri().toString(), "c");
@@ -609,7 +609,7 @@
iri.setValue("http://example.org/foo");
assertEquals(iri.getValue().toString(), "http://example.org/foo");
iri = factory.newUri();
- iri.setValue(new URI("http://example.org/foo"));
+ iri.setValue("http://example.org/foo");
assertEquals(iri.getValue().toString(), "http://example.org/foo");
Workspace workspace = factory.newWorkspace();
assertNotNull(workspace);