You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by si...@apache.org on 2006/12/13 13:40:04 UTC
svn commit: r486627 [3/9] - in
/lucene/java/trunk/contrib/gdata-server/src/gom: java/org/ java/org/apache/
java/org/apache/lucene/ java/org/apache/lucene/gdata/
java/org/apache/lucene/gdata/gom/ java/org/apache/lucene/gdata/gom/core/
java/org/apache/lu...
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMFeedImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMFeedImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMFeedImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMFeedImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,381 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMAttribute;
+import org.apache.lucene.gdata.gom.GOMAuthor;
+import org.apache.lucene.gdata.gom.GOMCategory;
+import org.apache.lucene.gdata.gom.GOMEntry;
+import org.apache.lucene.gdata.gom.GOMExtension;
+import org.apache.lucene.gdata.gom.GOMFeed;
+import org.apache.lucene.gdata.gom.GOMLink;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.core.extension.GOMExtensionFactory;
+import org.apache.lucene.gdata.gom.core.utils.GOMUtils;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * atom:feed { atomCommonAttributes, (atomAuthor* & atomCategory* &
+ * atomContributor* & atomGenerator? & atomIcon? & atomId & atomLink* &
+ * atomLogo? & atomRights? & atomSubtitle? & atomTitle & atomUpdated &
+ * extensionElement*), atomEntry* }
+ *
+ * @author Simon Willnauer
+ */
+class GOMFeedImpl extends GOMSourceImpl implements GOMFeed {
+ // TODO add totalResults OS namespace
+
+ static final int DEFAULT_START_INDEX = 1;
+
+ static final int DEFAULT_ITEMS_PER_PAGE = 25;
+
+ private static final GOMAttribute RSS_VERSION_ATTRIBUTE = new GOMAttributeImpl(
+ "version", "2.0");
+
+ protected List<GOMEntry> entries = new LinkedList<GOMEntry>();
+
+ protected List<GOMExtension> extensions = new LinkedList<GOMExtension>();
+
+ protected List<GOMNamespace> namespaces = new LinkedList<GOMNamespace>();
+
+ private SimpleGOMElementImpl startIndexElement;
+
+ private SimpleGOMElementImpl itemsPerPageElement;
+
+ private GOMExtensionFactory extensionFactory;
+
+ private GOMNamespace defaultNamespace = GOMNamespace.ATOM_NAMESPACE;
+
+ GOMFeedImpl() {
+ this.localName = GOMFeed.LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+ startIndexElement = new SimpleGOMElementImpl(
+ SimpleGOMElementImpl.ELEMENT_OS_START_INDEX,
+ GOMNamespace.OPENSEARCH_NAMESPACE);
+ itemsPerPageElement = new SimpleGOMElementImpl(
+ SimpleGOMElementImpl.ELEMENT_OS_ITEMS_PER_PAGE,
+ GOMNamespace.OPENSEARCH_NAMESPACE);
+ itemsPerPageElement.setTextValue(Integer
+ .toString(DEFAULT_ITEMS_PER_PAGE));
+ startIndexElement.setTextValue(Integer.toString(DEFAULT_START_INDEX));
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#addEntry(org.apache.lucene.gdata.gom.GOMEntry)
+ */
+ public void addEntry(GOMEntry aEntry) {
+ if (aEntry != null)
+ this.entries.add(aEntry);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#getEntries()
+ */
+ public List<GOMEntry> getEntries() {
+ return this.entries;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#getItemsPerPage()
+ */
+ public int getItemsPerPage() {
+ return Integer.parseInt(this.itemsPerPageElement.getTextValue());
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#getStartIndex()
+ */
+ public int getStartIndex() {
+ return Integer.parseInt(this.startIndexElement.getTextValue());
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#setStartIndex(int)
+ */
+ public void setStartIndex(int aIndex) {
+ if (aIndex < 1)
+ return;
+ this.startIndexElement.textValue = Integer.toString(aIndex);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#setItemsPerPage(int)
+ */
+ public void setItemsPerPage(int aInt) {
+ if (aInt < 0)
+ return;
+ this.itemsPerPageElement.textValue = Integer.toString(aInt);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#addNamespace(org.apache.lucene.gdata.gom.GOMNamespace)
+ */
+ public void addNamespace(GOMNamespace aNamespace) {
+ if (aNamespace == null)
+ return;
+ // namespace overrides hash / equals
+ if (this.namespaces.contains(aNamespace))
+ return;
+ if ("".equals(aNamespace.getNamespacePrefix())
+ || aNamespace.getNamespaceUri()
+ .equals(GOMNamespace.ATOM_NS_URI))
+ return;
+ else
+ this.namespaces.add(aNamespace);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#getDefaultNamespace()
+ */
+ public GOMNamespace getDefaultNamespace() {
+ return this.defaultNamespace;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#getNamespaces()
+ *
+ */
+ public List<GOMNamespace> getNamespaces() {
+ return this.namespaces;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#getChildParser(javax.xml.namespace.QName)
+ */
+ public AtomParser getChildParser(QName aName) {
+ if (aName.getNamespaceURI().equals(GOMNamespace.OPENSEARCH_NS_URI)) {
+ if (aName.getLocalPart().equals(
+ SimpleGOMElementImpl.ELEMENT_OS_ITEMS_PER_PAGE)) {
+
+ this.itemsPerPageElement = new SimpleGOMElementImpl(
+ SimpleGOMElementImpl.ELEMENT_OS_ITEMS_PER_PAGE,
+ GOMNamespace.OPENSEARCH_NAMESPACE);
+ this.itemsPerPageElement
+ .setValidator(new PositiveIntegerValidator(
+ SimpleGOMElementImpl.ELEMENT_OS_ITEMS_PER_PAGE));
+ return this.itemsPerPageElement;
+ }
+ if (aName.getLocalPart().equals(
+ SimpleGOMElementImpl.ELEMENT_OS_START_INDEX)) {
+ this.startIndexElement = new SimpleGOMElementImpl(
+ SimpleGOMElementImpl.ELEMENT_OS_START_INDEX,
+ GOMNamespace.OPENSEARCH_NAMESPACE);
+ this.startIndexElement
+ .setValidator(new PositiveIntegerValidator(
+ SimpleGOMElementImpl.ELEMENT_OS_START_INDEX));
+ return this.startIndexElement;
+ }
+
+ }
+ if (aName.getNamespaceURI().equals(GOMNamespace.ATOM_NS_URI)
+ && aName.getLocalPart().equals(GOMEntry.LOCALNAME)) {
+ GOMEntry entry = new GOMEntryImpl();
+ this.entries.add(entry);
+ return entry;
+
+ }
+ if (this.extensionFactory != null) {
+ GOMExtension extension = this.extensionFactory
+ .canHandleExtensionElement(aName);
+ if (extension != null) {
+ this.extensions.add(extension);
+ return extension;
+ }
+ }
+ return super.getChildParser(aName);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeAtomOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeAtomOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ aStreamWriter.writeStartElement(this.localName,
+ this.extensionAttributes);
+ if (this.defaultNamespace != null)
+ aStreamWriter.writeDefaultNamespace(this.defaultNamespace);
+ for (GOMNamespace namespace : this.namespaces) {
+ aStreamWriter.writeNamespace(namespace);
+ }
+ List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
+ for (GOMAttribute attribute : xmlNamespaceAttributes) {
+ aStreamWriter.writeAttribute(attribute);
+ }
+ writeInnerAtomOutput(aStreamWriter);
+ if (this.itemsPerPageElement != null)
+ this.itemsPerPageElement.writeAtomOutput(aStreamWriter);
+ if (this.startIndexElement != null)
+ this.startIndexElement.writeAtomOutput(aStreamWriter);
+ for (GOMExtension extension : this.extensions) {
+ extension.writeAtomOutput(aStreamWriter);
+ }
+ for (GOMEntry entry : this.entries) {
+ entry.writeAtomOutput(aStreamWriter);
+ }
+
+ aStreamWriter.writeEndElement();
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ aStreamWriter
+ .writeStartElement(LOCALNAME_RSS, this.extensionAttributes);
+ List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
+ for (GOMAttribute attribute : xmlNamespaceAttributes) {
+ aStreamWriter.writeAttribute(attribute);
+ }
+ if (this.defaultNamespace != null)
+ aStreamWriter.writeNamespace(this.defaultNamespace);
+ for (GOMNamespace namespace : this.namespaces) {
+ aStreamWriter.writeNamespace(namespace);
+ }
+ aStreamWriter.writeAttribute(RSS_VERSION_ATTRIBUTE);
+
+ aStreamWriter.writeStartElement(RSS_CHANNEL_ELEMENT_NAME);
+
+ if (this.id != null)
+ this.id.writeRssOutput(aStreamWriter);
+ if (this.title != null)
+ this.title.writeRssOutput(aStreamWriter);
+ if (this.subtitle != null)
+ this.subtitle.writeRssOutput(aStreamWriter);
+ if (this.rights != null)
+ this.rights.writeRssOutput(aStreamWriter);
+ for (GOMAuthor authors : this.authors) {
+ authors.writeRssOutput(aStreamWriter, "managingEditor");
+ }
+ for (GOMCategory category : this.categories) {
+ category.writeRssOutput(aStreamWriter);
+ }
+ for (GOMLink link : this.links) {
+ link.writeRssOutput(aStreamWriter);
+ }
+ if (this.updated != null) {
+ // udated.getDate can not be null
+ aStreamWriter.writeSimpleXMLElement("lastBuildDate", GOMUtils
+ .buildRfc822Date(this.updated.getDate().getTime()), null);
+ }
+
+ if (this.logo != null || this.icon != null) {
+ aStreamWriter.writeStartElement("image");
+ if (this.logo != null)
+ this.logo.writeRssOutput(aStreamWriter);
+ else
+ this.icon.writeRssOutput(aStreamWriter);
+ aStreamWriter.writeEndElement();
+
+ }
+
+ if (this.generator != null)
+ this.generator.writeRssOutput(aStreamWriter);
+ if (this.itemsPerPageElement != null)
+ this.itemsPerPageElement.writeRssOutput(aStreamWriter);
+ if (this.startIndexElement != null)
+ this.startIndexElement.writeRssOutput(aStreamWriter);
+ for (GOMExtension extension : this.extensions) {
+ extension.writeRssOutput(aStreamWriter);
+ }
+ for (GOMExtension extension : this.extensions) {
+ extension.writeRssOutput(aStreamWriter);
+ }
+ for (GOMEntry entry : this.entries) {
+ entry.writeRssOutput(aStreamWriter);
+ }
+ // channel
+ aStreamWriter.writeEndElement();
+ // rss
+ aStreamWriter.writeEndElement();
+
+ }
+
+ static class PositiveIntegerValidator extends
+ SimpleGOMElementImpl.SimpleValidator {
+
+ protected PositiveIntegerValidator(String aLocalName) {
+ super(aLocalName);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.SimpleGOMElementImpl.SimpleValidator#validate(java.lang.String)
+ */
+ @Override
+ protected void validate(String aTextValue) {
+ super.validate(aTextValue);
+ try {
+ int i = Integer.parseInt(aTextValue);
+ if (i < 0)
+ throw new GDataParseException(String.format(
+ AtomParser.INVALID_ELEMENT_VALUE, this.localName,
+ "positive integer value"));
+ } catch (NumberFormatException e) {
+ throw new GDataParseException(String.format(
+ AtomParser.INVALID_ELEMENT_VALUE, this.localName,
+ "positive integer value"));
+ }
+
+ }
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#getExtensions()
+ */
+ public List<GOMExtension> getExtensions() {
+ return this.extensions;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#setExtensionFactory(org.apache.lucene.gdata.gom.core.extension.GOMExtensionFactory)
+ */
+ public void setExtensionFactory(GOMExtensionFactory aFactory) {
+ if (extensionFactory != null) {
+ List<GOMNamespace> namespaces2 = extensionFactory.getNamespaces();
+ if (namespaces2 != null)
+ for (GOMNamespace namespace : namespaces2) {
+ this.addNamespace(namespace);
+ }
+
+ }
+
+ this.extensionFactory = aFactory;
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMFeed#addLink(org.apache.lucene.gdata.gom.GOMLink)
+ */
+ public void addLink(GOMLink aLink) {
+ if (aLink == null)
+ return;
+ this.links.add(aLink);
+
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMGeneratorImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMGeneratorImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMGeneratorImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMGeneratorImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,158 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import java.net.URISyntaxException;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMAttribute;
+import org.apache.lucene.gdata.gom.GOMGenerator;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.core.utils.AtomParserUtils;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class GOMGeneratorImpl extends AbstractGOMElement implements
+ GOMGenerator {
+
+ private String generatorVersion;
+
+ private String uri;
+
+ /**
+ *
+ */
+ public GOMGeneratorImpl() {
+ super();
+ this.localName = GOMGenerator.LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMGenerator#setUri(java.lang.String)
+ */
+ public void setUri(String aUri) {
+ this.uri = aUri;
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMGenerator#setGeneratorVersion(java.lang.String)
+ */
+ public void setGeneratorVersion(String aVersion) {
+ this.generatorVersion = aVersion;
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMGenerator#getGeneratorVersion()
+ */
+ public String getGeneratorVersion() {
+ return this.generatorVersion;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMGenerator#getUri()
+ */
+ public String getUri() {
+ return this.uri;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#processAttribute(javax.xml.namespace.QName,
+ * java.lang.String)
+ */
+ @Override
+ public void processAttribute(QName aQName, String aValue) {
+ if (aQName == null)
+ throw new IllegalArgumentException("Qname must not be null");
+ if (aValue == null)
+ throw new IllegalArgumentException("Value must not be null");
+ if (aQName.getNamespaceURI().equals(GOMNamespace.ATOM_NS_URI)) {
+ if (aQName.getLocalPart().equals("uri")) {
+ if (this.uri != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ATTRIBUTE, "uri"));
+ this.uri = aValue;
+ } else if (aQName.getLocalPart().equals("version")) {
+ if (this.generatorVersion != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ATTRIBUTE, "version"));
+ this.generatorVersion = aValue;
+ }
+ }
+ super.processAttribute(aQName, aValue);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#processElementValue(java.lang.String)
+ */
+ @Override
+ public void processElementValue(String aValue) {
+ if (this.textValue != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT_VALUE, this.localName));
+ this.textValue = aValue;
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#processEndElement()
+ */
+ @Override
+ public void processEndElement() {
+ if (this.uri != null)
+ try {
+ AtomParserUtils.getAbsolutAtomURI(this.xmlBase, this.uri);
+ } catch (URISyntaxException e) {
+ throw new GDataParseException(String.format(
+ AtomParser.INVALID_ELEMENT_VALUE, this.localName,
+ "absolute uri"));
+ }
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeAtomOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeAtomOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ List<GOMAttribute> list = getXmlNamespaceAttributes();
+ if (this.uri != null)
+ list.add(new GOMAttributeImpl("uri", this.uri));
+ if (this.generatorVersion != null)
+ list.add(new GOMAttributeImpl("version", this.generatorVersion));
+
+ aStreamWriter.writeSimpleXMLElement(this.qname, list, this.textValue);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ aStreamWriter.writeSimpleXMLElement(this.localName,
+ getXmlNamespaceAttributes(), this.textValue);
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMIconImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMIconImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMIconImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMIconImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMIcon;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class GOMIconImpl extends AtomUriElement implements GOMIcon {
+
+ /**
+ *
+ */
+ public GOMIconImpl() {
+ this.localName = GOMIcon.LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.SimpleGOMElementImpl#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ @Override
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ aStreamWriter.writeSimpleXMLElement("url", getXmlNamespaceAttributes(),
+ this.textValue);
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMIdImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMIdImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMIdImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMIdImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMId;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+class GOMIdImpl extends AbstractGOMElement implements GOMId {
+
+ protected static final QName ATOM_QNAME = new QName(
+ GOMNamespace.ATOM_NS_URI, LOCALNAME, GOMNamespace.ATOM_NS_PREFIX);
+
+ GOMIdImpl() {
+ this.localName = LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#getLocalName()
+ */
+ @Override
+ public String getLocalName() {
+ return this.localName;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processElementValue(java.lang.String)
+ */
+ public void processElementValue(String aValue) {
+ this.textValue = aValue;
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processEndElement()
+ */
+ public void processEndElement() {
+ if (this.textValue == null)
+ throw new GDataParseException(
+ "Element id must have a unique id value -- is null");
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeAtomOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeAtomOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ if (aStreamWriter == null)
+ throw new GDataParseException("GOMWriter must not be null");
+ aStreamWriter.writeSimpleXMLElement(LOCALNAME,
+ getXmlNamespaceAttributes(), this.textValue);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ if (aStreamWriter == null)
+ throw new GDataParseException("GOMWriter must not be null");
+ aStreamWriter.writeSimpleXMLElement(ATOM_QNAME,
+ getXmlNamespaceAttributes(), this.textValue);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMOutputWriter,
+ * java.lang.String)
+ */
+ @Override
+ public void writeRssOutput(GOMOutputWriter aStreamWriter, String aRssName)
+ throws XMLStreamException {
+ if (aStreamWriter == null)
+ throw new GDataParseException("GOMWriter must not be null");
+ aStreamWriter.writeSimpleXMLElement(aRssName,
+ getXmlNamespaceAttributes(), this.textValue);
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMLinkImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMLinkImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMLinkImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMLinkImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,270 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import java.net.URISyntaxException;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMAttribute;
+import org.apache.lucene.gdata.gom.GOMLink;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.core.utils.AtomParserUtils;
+import org.apache.lucene.gdata.gom.core.utils.GOMUtils;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * element atom:link { atomCommonAttributes, attribute href { atomUri },
+ * attribute rel { atomNCName | atomUri }?, attribute type { atomMediaType }?,
+ * attribute hreflang { atomLanguageTag }?, attribute title { text }?, attribute
+ * length { text }?, undefinedContent }
+ *
+ * @author Simon Willnauer
+ *
+ */
+public class GOMLinkImpl extends AbstractGOMElement implements GOMLink {
+ private String href;
+
+ private String rel;
+
+ private String type;
+
+ private String hrefLang;
+
+ private String title;
+
+ private Integer length;
+
+ /**
+ *
+ */
+ public GOMLinkImpl() {
+ super();
+ this.localName = LOCALNAME;
+ this.qname = new QName(this.localName);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#getHref()
+ */
+ public String getHref() {
+ return this.href;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#setHref(java.lang.String)
+ */
+ public void setHref(String aHref) {
+ href = aHref;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#getHrefLang()
+ */
+ public String getHrefLang() {
+ return this.hrefLang;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#setHrefLang(java.lang.String)
+ */
+ public void setHrefLang(String aHrefLang) {
+ hrefLang = aHrefLang;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#getLength()
+ */
+ public Integer getLength() {
+ return this.length;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#setLength(java.lang.String)
+ */
+ public void setLength(Integer aLength) {
+ length = aLength;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#getRel()
+ */
+ public String getRel() {
+ return this.rel;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#setRel(java.lang.String)
+ */
+ public void setRel(String aRel) {
+ rel = aRel;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#getTitle()
+ */
+ public String getTitle() {
+ return this.title;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#setTitle(java.lang.String)
+ */
+ public void setTitle(String aTitle) {
+ title = aTitle;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#getType()
+ */
+ public String getType() {
+ return this.type;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMLink#setType(java.lang.String)
+ */
+ public void setType(String aType) {
+ type = aType;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#processAttribute(javax.xml.namespace.QName,
+ * java.lang.String)
+ */
+ @Override
+ public void processAttribute(QName aQName, String aValue) {
+ if (aQName == null)
+ throw new IllegalArgumentException("QName must not be null");
+
+ if (aQName.getNamespaceURI().equals(GOMNamespace.ATOM_NS_URI)
+ || aQName.getNamespaceURI().equals("")) {
+ String localName = aQName.getLocalPart();
+
+ if (localName.equals("href")) {
+ if (this.href != null)
+ throw new GDataParseException(String.format(
+ DUPLICATE_ATTRIBUTE, "href"));
+ this.href = aValue;
+ } else if (localName.equals("type")) {
+ if (this.type != null)
+ throw new GDataParseException(String.format(
+ DUPLICATE_ATTRIBUTE, "type"));
+ this.type = aValue;
+ } else if (localName.equals("rel")) {
+ if (this.rel != null)
+ throw new GDataParseException(String.format(
+ DUPLICATE_ATTRIBUTE, "rel"));
+ this.rel = aValue;
+ } else if (localName.equals("title")) {
+ if (this.title != null)
+ throw new GDataParseException(String.format(
+ DUPLICATE_ATTRIBUTE, "title"));
+ this.title = aValue;
+
+ } else if (localName.equals("hreflang")) {
+ if (this.hrefLang != null)
+ throw new GDataParseException(String.format(
+ DUPLICATE_ATTRIBUTE, "hreflang"));
+ this.hrefLang = aValue;
+ } else if (localName.equals("length")) {
+ if (this.length != null)
+ throw new GDataParseException(String.format(
+ DUPLICATE_ATTRIBUTE, "length"));
+ try {
+ this.length = new Integer(Integer.parseInt(aValue));
+ } catch (NumberFormatException e) {
+ throw new GDataParseException(
+ "attribute lenght must be an integer");
+ }
+ }
+
+ }
+ super.processAttribute(aQName, aValue);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#processEndElement()
+ */
+ @Override
+ public void processEndElement() {
+ if (this.href == null)
+ throw new GDataParseException(String.format(
+ MISSING_ELEMENT_ATTRIBUTE, this.localName, "href"));
+ try {
+ AtomParserUtils.getAbsolutAtomURI(this.xmlBase, this.href);
+ } catch (URISyntaxException e) {
+ throw new GDataParseException(String.format(INVALID_ATTRIBUTE,
+ "href", "absolute uri"), e);
+ }
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeAtomOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeAtomOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ List<GOMAttribute> attList = getXmlNamespaceAttributes();
+ attList.add(GOMUtils.buildDefaultNamespaceAttribute(
+ this.href == null ? "" : this.href, "href"));
+ if (this.rel != null)
+ attList.add(GOMUtils
+ .buildDefaultNamespaceAttribute(this.rel, "rel"));
+ if (this.title != null)
+ attList.add(GOMUtils.buildDefaultNamespaceAttribute(this.title,
+ "title"));
+ if (this.type != null)
+ attList.add(GOMUtils.buildDefaultNamespaceAttribute(this.type,
+ "type"));
+ if (this.hrefLang != null)
+ attList.add(GOMUtils.buildDefaultNamespaceAttribute(this.hrefLang,
+ "hreflang"));
+ if (this.length != null)
+ attList.add(GOMUtils.buildDefaultNamespaceAttribute(this.length
+ .toString(), "length"));
+
+ aStreamWriter.writeSimpleXMLElement(this.qname, attList, null);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
+ if (this.rel != null && rel.equalsIgnoreCase("enclosure")) {
+ if (type != null)
+ xmlNamespaceAttributes.add(GOMUtils
+ .buildDefaultNamespaceAttribute(type, "type"));
+ if (href != null)
+ xmlNamespaceAttributes.add(GOMUtils
+ .buildDefaultNamespaceAttribute(href, "href"));
+
+ aStreamWriter.writeSimpleXMLElement("enclosure",
+ xmlNamespaceAttributes, null);
+ } else if ("comments".equalsIgnoreCase(this.rel))
+ aStreamWriter.writeSimpleXMLElement("comments", null, this.href);
+
+ else if ("alternate".equalsIgnoreCase(this.rel))
+ aStreamWriter.writeSimpleXMLElement("link", null, this.href);
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMLogoImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMLogoImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMLogoImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMLogoImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMLogo;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class GOMLogoImpl extends AtomUriElement implements GOMLogo {
+
+ /**
+ * default class constructor
+ */
+ public GOMLogoImpl() {
+ this.localName = GOMLogo.LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.SimpleGOMElementImpl#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ @Override
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ aStreamWriter.writeSimpleXMLElement("url", getXmlNamespaceAttributes(),
+ this.textValue);
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMPersonImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMPersonImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMPersonImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMPersonImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,245 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMAttribute;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.core.utils.GOMUtils;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class GOMPersonImpl extends AbstractGOMElement implements
+ org.apache.lucene.gdata.gom.GOMPerson {
+
+ private final static String NAME_LOCAL_NAME = "name";
+
+ private final static String EMAIL_LOCAL_NAME = "email";
+
+ private final static String URI_LOCAL_NAME = "uri";
+
+ protected String uri;
+
+ protected String email;
+
+ protected String name;
+
+ /**
+ *
+ */
+ public GOMPersonImpl() {
+ super();
+ this.localName = LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMPerson#setName(java.lang.String)
+ */
+ public void setName(String aName) {
+ this.name = aName;
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMPerson#setEmail(java.lang.String)
+ */
+ public void setEmail(String aEmail) {
+ this.email = aEmail;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMPerson#setUri(java.lang.String)
+ */
+ public void setUri(String aUri) {
+ this.uri = aUri;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMPerson#getName()
+ */
+ public String getName() {
+
+ return this.name;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMPerson#getEmail()
+ */
+ public String getEmail() {
+ return this.email;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMPerson#getUri()
+ */
+ public String getUri() {
+
+ return this.uri;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeAtomOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeAtomOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ if (aStreamWriter == null)
+ throw new GDataParseException("GOMWriter must not be null");
+ List<GOMAttribute> list = getXmlNamespaceAttributes();
+ if (this.xmlLang != null) {
+ list = new ArrayList<GOMAttribute>(1);
+ list.add(GOMUtils
+ .buildXMLNamespaceAttribute(this.xmlLang, XML_LANG));
+ }
+ aStreamWriter.writeStartElement(this.qname, list);
+ aStreamWriter.writeSimpleXMLElement(NAME_LOCAL_NAME, this.name, null);
+ if (this.email != null)
+ aStreamWriter.writeSimpleXMLElement(EMAIL_LOCAL_NAME, this.email,
+ null);
+ if (this.uri != null)
+ aStreamWriter.writeSimpleXMLElement(URI_LOCAL_NAME, this.uri, null);
+
+ aStreamWriter.writeEndElement();
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ //
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#getChildParser(javax.xml.namespace.QName)
+ */
+ @Override
+ public AtomParser getChildParser(QName aName) {
+ if (aName == null)
+ throw new GDataParseException("QName must not be null");
+ if (aName.getNamespaceURI().equals(GOMNamespace.ATOM_NS_URI)) {
+ if (aName.getLocalPart().equals(NAME_LOCAL_NAME))
+ return this.new NameParser();
+ if (aName.getLocalPart().equals(URI_LOCAL_NAME))
+ return this.new UriParser();
+ if (aName.getLocalPart().equals(EMAIL_LOCAL_NAME))
+ return this.new EmailParser();
+ }
+ return super.getChildParser(aName);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#processEndElement()
+ */
+ @Override
+ public void processEndElement() {
+ if (this.name == null)
+ throw new GDataParseException(String.format(
+ AtomParser.MISSING_ELEMENT_CHILD, this.localName,
+ NAME_LOCAL_NAME));
+ }
+
+ class NameParser extends SimpleElementParser {
+
+ NameParser() {
+ this.localname = NAME_LOCAL_NAME;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processEndElement()
+ */
+ public void processEndElement() {
+ if (name != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT, this.localname));
+ if (this.aString != null)
+ name = this.aString;
+
+ }
+
+ }
+
+ class UriParser extends SimpleElementParser {
+
+ UriParser() {
+ this.localname = URI_LOCAL_NAME;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processEndElement()
+ */
+ public void processEndElement() {
+ if (uri != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT, this.localname));
+ if (this.aString != null)
+ uri = this.aString;
+
+ }
+
+ }
+
+ class EmailParser extends SimpleElementParser {
+
+ EmailParser() {
+ this.localname = EMAIL_LOCAL_NAME;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processEndElement()
+ */
+ public void processEndElement() {
+ if (email != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT, this.localname));
+ if (this.aString != null)
+ email = this.aString;
+
+ }
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMOutputWriter,
+ * java.lang.String)
+ */
+ @Override
+ public void writeRssOutput(GOMOutputWriter aStreamWriter, String aRssName)
+ throws XMLStreamException {
+ if (aStreamWriter == null)
+ throw new GDataParseException("GOMWriter must not be null");
+ StringBuilder builder = new StringBuilder("");
+ if (this.email != null)
+ builder.append(this.email);
+ if (this.name != null)
+ builder.append("(").append(this.name).append(")");
+ aStreamWriter.writeSimpleXMLElement(aRssName,
+ getXmlNamespaceAttributes(), builder.toString());
+
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMPublishedImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMPublishedImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMPublishedImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMPublishedImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMPublished;
+import org.apache.lucene.gdata.gom.core.utils.GOMUtils;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class GOMPublishedImpl extends GOMDateConstructImpl implements
+ GOMPublished {
+ protected static final QName RSS_QNAME = new QName("pubDate");
+
+ /**
+ *
+ */
+ public GOMPublishedImpl() {
+ this.localName = GOMPublished.LOCALNAME;
+ this.qname = new QName(this.localName);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ String rssRFC3339Date = GOMUtils
+ .buildRfc822Date(this.date == 0 ? System.currentTimeMillis()
+ : this.date);
+ aStreamWriter.writeSimpleXMLElement(RSS_QNAME,
+ getXmlNamespaceAttributes(), rssRFC3339Date);
+
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMRightsImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMRightsImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMRightsImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMRightsImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.GOMRights;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class GOMRightsImpl extends GOMTextContructImpl implements GOMRights {
+
+ /**
+ *
+ */
+ public GOMRightsImpl() {
+ this.localName = GOMRights.LOCALNAME;
+ this.rssLocalName = GOMRights.LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.GOMTextContructImpl#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ @Override
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ aStreamWriter.writeSimpleXMLElement("copyright", null, this.textValue);
+ }
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSourceImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSourceImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSourceImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSourceImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,544 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMAttribute;
+import org.apache.lucene.gdata.gom.GOMAuthor;
+import org.apache.lucene.gdata.gom.GOMCategory;
+import org.apache.lucene.gdata.gom.GOMContributor;
+import org.apache.lucene.gdata.gom.GOMGenerator;
+import org.apache.lucene.gdata.gom.GOMIcon;
+import org.apache.lucene.gdata.gom.GOMId;
+import org.apache.lucene.gdata.gom.GOMLink;
+import org.apache.lucene.gdata.gom.GOMLogo;
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.GOMRights;
+import org.apache.lucene.gdata.gom.GOMSource;
+import org.apache.lucene.gdata.gom.GOMSubtitle;
+import org.apache.lucene.gdata.gom.GOMTitle;
+import org.apache.lucene.gdata.gom.GOMUpdated;
+import org.apache.lucene.gdata.gom.core.utils.AtomParserUtils;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class GOMSourceImpl extends AbstractGOMElement implements GOMSource {
+
+ protected List<GOMAuthor> authors = new LinkedList<GOMAuthor>();
+
+ protected List<GOMCategory> categories = new LinkedList<GOMCategory>();
+
+ protected List<GOMLink> links = new LinkedList<GOMLink>();
+
+ protected List<GOMContributor> contributors = new LinkedList<GOMContributor>();
+
+ protected GOMGenerator generator;
+
+ protected GOMId id;
+
+ protected GOMLogo logo;
+
+ protected GOMRights rights;
+
+ protected GOMSubtitle subtitle;
+
+ protected GOMTitle title;
+
+ protected GOMUpdated updated;
+
+ protected GOMIcon icon;
+
+ GOMSourceImpl() {
+ this.localName = LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#getLocalName()
+ */
+ @Override
+ public String getLocalName() {
+ return this.localName;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#addAuthor(org.apache.lucene.gdata.gom.GOMAuthor)
+ */
+ public void addAuthor(GOMAuthor aAuthor) {
+ if (aAuthor != null)
+ this.authors.add(aAuthor);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#addCategory(org.apache.lucene.gdata.gom.GOMCategory)
+ */
+ public void addCategory(GOMCategory aCategory) {
+ if (aCategory != null)
+ this.categories.add(aCategory);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#addContributor(org.apache.lucene.gdata.gom.GOMContributor)
+ */
+ public void addContributor(GOMContributor aContributor) {
+ if (aContributor != null)
+ this.contributors.add(aContributor);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#getAuthors()
+ *
+ */
+ public List<GOMAuthor> getAuthors() {
+ return this.authors;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#getCategories()
+ *
+ */
+ public List<GOMCategory> getCategories() {
+ return this.categories;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#getContributor()
+ */
+ public List<GOMContributor> getContributor() {
+ return this.contributors;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#getGenerator()
+ *
+ */
+ public GOMGenerator getGenerator() {
+ return this.generator;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#getId()
+ *
+ */
+ public GOMId getId() {
+ return this.id;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#setGenerator(org.apache.lucene.gdata.gom.GOMGenerator)
+ *
+ */
+ public void setGenerator(GOMGenerator aGenerator) {
+ this.generator = aGenerator;
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#setIcon(org.apache.lucene.gdata.gom.GOMIcon)
+ *
+ */
+ public void setIcon(GOMIcon aIcon) {
+ this.icon = aIcon;
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#setId(org.apache.lucene.gdata.gom.GOMId)
+ *
+ */
+ public void setId(GOMId aId) {
+ this.id = aId;
+
+ }
+
+ /**
+ * @return the logo
+ *
+ */
+ public GOMLogo getLogo() {
+ return this.logo;
+ }
+
+ /**
+ * @param aLogo
+ * the logo to set
+ *
+ */
+ public void setLogo(GOMLogo aLogo) {
+ this.logo = aLogo;
+ }
+
+ /**
+ * @return the rights
+ *
+ */
+ public GOMRights getRights() {
+ return this.rights;
+ }
+
+ /**
+ * @param aRights
+ * the rights to set
+ *
+ */
+ public void setRights(GOMRights aRights) {
+ rights = aRights;
+ }
+
+ /**
+ * @return the subtitle
+ *
+ */
+ public GOMSubtitle getSubtitle() {
+ return this.subtitle;
+ }
+
+ /**
+ * @param aSubtitle
+ * the subtitle to set
+ *
+ */
+ public void setSubtitle(GOMSubtitle aSubtitle) {
+ this.subtitle = aSubtitle;
+ }
+
+ /**
+ * @return the title
+ *
+ */
+ public GOMTitle getTitle() {
+ return this.title;
+ }
+
+ /**
+ * @param aTitle
+ * the title to set
+ *
+ */
+ public void setTitle(GOMTitle aTitle) {
+ this.title = aTitle;
+ }
+
+ /**
+ * @return the updated
+ *
+ */
+ public GOMUpdated getUpdated() {
+ return this.updated;
+ }
+
+ /**
+ * @param aUpdated
+ * the updated to set
+ *
+ */
+ public void setUpdated(GOMUpdated aUpdated) {
+ this.updated = aUpdated;
+ }
+
+ /**
+ * @return the icon
+ *
+ */
+ public GOMIcon getIcon() {
+ return this.icon;
+ }
+
+ /**
+ * @return the links
+ *
+ */
+ public List<GOMLink> getLinks() {
+ return this.links;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMSource#addLink(org.apache.lucene.gdata.gom.GOMLink)
+ */
+ public void addLink(GOMLink aLink) {
+ if (aLink == null)
+ return;
+ this.links.add(aLink);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processElementValue(java.lang.String)
+ */
+ public void processElementValue(String aValue) {
+ throw new GDataParseException(String.format(
+ AtomParser.UNEXPECTED_ELEMENT_VALUE, this.localName));
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processEndElement()
+ */
+ public void processEndElement() {
+ /*
+ * atom:feed elements MUST contain exactly one atom:id element.
+ */
+ if (this.id == null)
+ throw new GDataParseException(String.format(
+ MISSING_ELEMENT_CHILD, this.localName, GOMId.LOCALNAME));
+ /*
+ * atom:feed elements MUST contain exactly one atom:title element.
+ */
+ if (this.title == null)
+ throw new GDataParseException(String
+ .format(MISSING_ELEMENT_CHILD, this.localName,
+ GOMTitle.LOCALNAME));
+ /*
+ * atom:feed elements MUST contain exactly one atom:updated element.
+ */
+ if (this.updated == null)
+ throw new GDataParseException(String.format(
+ MISSING_ELEMENT_CHILD, this.localName,
+ GOMUpdated.LOCALNAME));
+ /*
+ * atom:feed elements MUST contain one or more atom:author elements,
+ * unless all of the
+ */
+ if (this.authors.size() < 1)
+ throw new GDataParseException(String.format(
+ MISSING_ELEMENT_CHILD, this.localName,
+ GOMAuthor.LOCALNAME));
+
+ /*
+ * atom:feed elements MUST NOT contain more than one atom:link element
+ * with a rel attribute value of "alternate" that has the same
+ * combination of type and hreflang attribute values.
+ */
+ List<GOMLink> alternateLinks = new LinkedList<GOMLink>();
+ for (GOMLink link : this.links) {
+ /*
+ * atom:link elements MAY have a "rel" attribute that indicates the
+ * link relation type. If the "rel" attribute is not present, the
+ * link element MUST be interpreted as if the link relation type is
+ * "alternate".
+ */
+ if (link.getRel() == null
+ || link.getRel().equalsIgnoreCase("alternate"))
+ alternateLinks.add(link);
+ }
+
+ /*
+ * atom:feed elements MUST NOT contain more than one atom:link element
+ * with a rel attribute value of "alternate" that has the same
+ * combination of type and hreflang attribute values.
+ */
+ if (alternateLinks.size() > 1) {
+ for (GOMLink link : alternateLinks) {
+ for (GOMLink link2 : alternateLinks) {
+ if (link != link2)
+ if (AtomParserUtils.compareAlternateLinks(link, link2))
+ throw new GDataParseException(
+ String
+ .format(DUPLICATE_ELEMENT,
+ "link with rel=\"alternate\" and same href and type attributes"));
+
+ }
+ }
+ }
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#getChildParser(javax.xml.namespace.QName)
+ */
+ public AtomParser getChildParser(QName aName) {
+ if (aName.getNamespaceURI().equals(GOMNamespace.ATOM_NS_URI)) {
+ if (aName.getLocalPart().equals(GOMId.LOCALNAME)) {
+ // atom:feed / atom:source elements MUST contain exactly one
+ // atom:id element.
+ if (this.id != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT, GOMId.LOCALNAME));
+ this.id = new GOMIdImpl();
+ return this.id;
+ }
+ if (aName.getLocalPart().equals(GOMTitle.LOCALNAME)) {
+ // atom:feed / atom:source elements MUST contain exactly one
+ // atom:title
+ // element.
+ if (this.title != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT, GOMTitle.LOCALNAME));
+ this.title = new GOMTitleImpl();
+ return this.title;
+ }
+ if (aName.getLocalPart().equals(GOMAuthor.LOCALNAME)) {
+ GOMAuthor author = new GOMAuthorImpl();
+ this.authors.add(author);
+ return author;
+ }
+ if (aName.getLocalPart().equals(GOMCategory.LOCALNAME)) {
+ GOMCategory category = new GOMCategoryImpl();
+ this.categories.add(category);
+ return category;
+ }
+ if (aName.getLocalPart().equals(GOMContributor.LOCALNAME)) {
+ GOMContributorImpl impl = new GOMContributorImpl();
+ this.contributors.add(impl);
+ return impl;
+ }
+ if (aName.getLocalPart().equals(GOMLink.LOCALNAME)) {
+ GOMLinkImpl impl = new GOMLinkImpl();
+ this.links.add(impl);
+ return impl;
+ }
+ if (aName.getLocalPart().equals(GOMSubtitle.LOCALNAME)) {
+ GOMSubtitleImpl impl = new GOMSubtitleImpl();
+ /*
+ * atom:feed elements MUST NOT contain more than one
+ * atom:subtitle element.
+ */
+ if (this.subtitle != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT,
+ GOMSubtitle.LOCALNAME));
+ this.subtitle = impl;
+ return this.subtitle;
+ }
+ if (aName.getLocalPart().equals(GOMUpdated.LOCALNAME)) {
+ if (this.updated != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT,
+ GOMUpdated.LOCALNAME));
+ GOMUpdated updatedImpl = new GOMUpdatedImpl();
+ this.updated = updatedImpl;
+ return this.updated;
+
+ }
+ if (aName.getLocalPart().equals(GOMLogo.LOCALNAME)) {
+ if (this.logo != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT, GOMLogo.LOCALNAME));
+
+ this.logo = new GOMLogoImpl();
+ return this.logo;
+
+ }
+ if (aName.getLocalPart().equals(GOMIcon.LOCALNAME)) {
+ if (this.icon != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT, GOMIcon.LOCALNAME));
+
+ this.icon = new GOMIconImpl();
+ return this.icon;
+
+ }
+ if (aName.getLocalPart().equals(GOMGenerator.LOCALNAME)) {
+ if (this.generator != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT,
+ GOMGenerator.LOCALNAME));
+
+ this.generator = new GOMGeneratorImpl();
+ return this.generator;
+
+ }
+ if (aName.getLocalPart().equals(GOMRights.LOCALNAME)) {
+ if (this.rights != null)
+ throw new GDataParseException(String
+ .format(AtomParser.DUPLICATE_ELEMENT,
+ GOMRights.LOCALNAME));
+
+ this.rights = new GOMRightsImpl();
+ return this.rights;
+
+ }
+
+ }
+ throw new GDataParseException(String.format(
+ AtomParser.URECOGNIZED_ELEMENT_CHILD, this.localName, aName
+ .getLocalPart()));
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeAtomOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeAtomOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ aStreamWriter.writeStartElement(this.localName,
+ this.extensionAttributes);
+ List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
+ for (GOMAttribute attribute : xmlNamespaceAttributes) {
+ aStreamWriter.writeAttribute(attribute);
+ }
+ writeInnerAtomOutput(aStreamWriter);
+ aStreamWriter.writeEndElement();
+
+ }
+
+ /**
+ * @param aStreamWriter
+ * @throws XMLStreamException
+ */
+ protected void writeInnerAtomOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ if (this.id != null)
+ this.id.writeAtomOutput(aStreamWriter);
+ if (this.title != null)
+ this.title.writeAtomOutput(aStreamWriter);
+ if (this.subtitle != null)
+ this.subtitle.writeAtomOutput(aStreamWriter);
+ for (GOMAuthor authors : this.authors) {
+ authors.writeAtomOutput(aStreamWriter);
+ }
+ for (GOMCategory category : this.categories) {
+ category.writeAtomOutput(aStreamWriter);
+ }
+ for (GOMContributor contributor : this.contributors) {
+ contributor.writeAtomOutput(aStreamWriter);
+ }
+ for (GOMLink link : this.links) {
+ link.writeAtomOutput(aStreamWriter);
+ }
+ if (this.rights != null)
+ this.rights.writeAtomOutput(aStreamWriter);
+ if (this.updated != null)
+ this.updated.writeAtomOutput(aStreamWriter);
+ if (this.logo != null)
+ this.logo.writeAtomOutput(aStreamWriter);
+ if (this.icon != null)
+ this.icon.writeAtomOutput(aStreamWriter);
+ if (this.generator != null)
+ this.generator.writeAtomOutput(aStreamWriter);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ // no rss output
+
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSubtitleImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSubtitleImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSubtitleImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSubtitleImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.GOMSubtitle;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class GOMSubtitleImpl extends GOMTextContructImpl implements GOMSubtitle {
+
+ /**
+ *
+ */
+ public GOMSubtitleImpl() {
+ this.localName = GOMSubtitle.LOCALNAME;
+ this.rssLocalName = GOMSubtitle.RSS_LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSummaryImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSummaryImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSummaryImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMSummaryImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,57 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.GOMSummary;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class GOMSummaryImpl extends GOMTextContructImpl implements GOMSummary {
+ protected static final QName ATOM_QNAME = new QName(
+ GOMNamespace.ATOM_NS_URI, LOCALNAME, GOMNamespace.ATOM_NS_PREFIX);
+
+ /**
+ *
+ */
+ public GOMSummaryImpl() {
+ this.localName = GOMSummary.LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.GOMTextContructImpl#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ @Override
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ /*
+ * RSS does not support markup as child elements StaX Writer will encode
+ * all containing markup into valid xml entities
+ */
+ aStreamWriter.writeSimpleXMLElement(ATOM_QNAME,
+ getXmlNamespaceAttributes(), this.textValue);
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMTextContructImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMTextContructImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMTextContructImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMTextContructImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,270 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import java.io.StringWriter;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.lucene.gdata.gom.ContentType;
+import org.apache.lucene.gdata.gom.GOMAttribute;
+import org.apache.lucene.gdata.gom.GOMTextConstruct;
+import org.apache.lucene.gdata.gom.core.utils.GOMUtils;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public abstract class GOMTextContructImpl extends AbstractGOMElement implements
+ GOMTextConstruct {
+
+ protected ContentType contentType;
+
+ protected String rssLocalName;
+
+ /*
+ * parses the xhtml content
+ */
+ protected transient XMLBlobContentParser blobParser = null;
+
+ /*
+ * this string builder contains the html while parsing the incoming text
+ * contruct. process element value will be called multiple times
+ */
+ protected transient StringBuilder htmlBuilder = null;
+
+ /**
+ * @return the contentType
+ *
+ */
+ public ContentType getContentType() {
+ return this.contentType;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processElementValue(java.lang.String)
+ */
+ public void processElementValue(String aValue) {
+ if (this.htmlBuilder != null)
+ this.htmlBuilder.append(aValue);
+ else {
+ this.textValue = aValue;
+ }
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processAttribute(javax.xml.namespace.QName,
+ * java.lang.String)
+ */
+ public void processAttribute(QName aQName, String aValue) {
+ if (aQName == null)
+ throw new GDataParseException("QName must not be null");
+ if ("type".equals(aQName.getLocalPart()) && aValue != null) {
+ if (this.contentType != null)
+ throw new GDataParseException(String.format(
+ DUPLICATE_ATTRIBUTE, "type"));
+ this.contentType = ContentType.valueOf(aValue.toUpperCase());
+ if (this.contentType == ContentType.HTML)
+ this.htmlBuilder = new StringBuilder();
+ }
+ super.processAttribute(aQName, aValue);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processEndElement()
+ */
+ public void processEndElement() {
+ if (this.contentType == null)
+ throw new GDataParseException(String.format(
+ MISSING_ELEMENT_ATTRIBUTE, this.qname, "type"));
+ switch (this.contentType) {
+ case XHTML:
+ if (this.blobParser != null) {
+ this.textValue = this.blobParser.toString();
+ this.blobParser.close();
+ this.blobParser = null;
+ }
+
+ break;
+ case HTML:
+ if (this.htmlBuilder != null) {
+ this.textValue = this.htmlBuilder.toString();
+ this.htmlBuilder = null;
+ }
+
+ default:
+ break;
+ }
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeAtomOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeAtomOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ List<GOMAttribute> xmlNamespaceAttributes = getXmlNamespaceAttributes();
+ xmlNamespaceAttributes.add(GOMUtils
+ .getAttributeByContentTypeDefaultNs(this.contentType));
+ if (this.contentType == ContentType.XHTML) {
+ /*
+ * if the content is xhtml write it unescaped
+ */
+ aStreamWriter.writeStartElement(this.localName,
+ xmlNamespaceAttributes);
+ aStreamWriter.writeContentUnescaped(this.textValue);
+ aStreamWriter.writeEndElement();
+
+ } else {
+ // html and text will be escaped by stax writer
+ aStreamWriter.writeSimpleXMLElement(this.localName,
+ xmlNamespaceAttributes, this.textValue);
+ }
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ /*
+ * RSS does not support markup as child elements StaX Writer will encode
+ * all containing markup into valid xml entities
+ */
+ aStreamWriter.writeSimpleXMLElement(this.rssLocalName,
+ getXmlNamespaceAttributes(), this.textValue);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#getChildParser(javax.xml.namespace.QName)
+ */
+ @Override
+ public AtomParser getChildParser(QName aName) {
+ if (aName == null)
+ throw new GDataParseException("QName must not be null");
+ if (this.contentType == ContentType.XHTML
+ && aName.getLocalPart().equals("div")) {
+ if (this.blobParser != null)
+ throw new GDataParseException(String.format(
+ DUPLICATE_ELEMENT, "div"));
+ this.blobParser = new XMLBlobContentParser();
+ return this.blobParser.getChildParser(aName);
+ }
+
+ return super.getChildParser(aName);
+
+ }
+
+ class XMLBlobContentParser implements AtomParser {
+ private StringWriter writer;
+
+ private XMLStreamWriter xmlWriter;
+
+ /**
+ *
+ */
+ public XMLBlobContentParser() {
+ super();
+ this.writer = new StringWriter();
+ try {
+ this.xmlWriter = XMLOutputFactory.newInstance()
+ .createXMLStreamWriter(this.writer);
+ } catch (Exception e) {
+ throw new GDataParseException(e);
+ }
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processElementValue(java.lang.String)
+ */
+ public void processElementValue(String aValue) {
+ try {
+ this.xmlWriter.writeCharacters(aValue);
+ } catch (XMLStreamException e) {
+ throw new GDataParseException(e);
+ }
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processAttribute(javax.xml.namespace.QName,
+ * java.lang.String)
+ */
+ public void processAttribute(QName aQName, String aValue) {
+ try {
+ this.xmlWriter.writeAttribute(aQName.getNamespaceURI(), aQName
+ .getLocalPart(), aQName.getPrefix(), aValue);
+ } catch (XMLStreamException e) {
+ throw new GDataParseException(e);
+ }
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processEndElement()
+ */
+ public void processEndElement() {
+ try {
+ this.xmlWriter.writeEndElement();
+ } catch (XMLStreamException e) {
+ throw new GDataParseException(e);
+ }
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#getChildParser(javax.xml.namespace.QName)
+ */
+ public AtomParser getChildParser(QName aName) {
+ try {
+ this.xmlWriter.writeStartElement(aName.getNamespaceURI(), aName
+ .getLocalPart(), aName.getPrefix());
+ } catch (XMLStreamException e) {
+ throw new GDataParseException(e);
+ }
+ return this;
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return this.writer.toString();
+ }
+
+ /**
+ *
+ */
+ public void close() {
+ try {
+ this.xmlWriter.close();
+ this.writer.close();
+ } catch (Exception e) {
+ throw new GDataParseException(e);
+ }
+ }
+
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMTitleImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMTitleImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMTitleImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMTitleImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.GOMTitle;
+
+/**
+ * @author Simon Willnauer
+ */
+public class GOMTitleImpl extends GOMTextContructImpl implements GOMTitle {
+ /**
+ *
+ */
+ public GOMTitleImpl() {
+ super();
+ this.localName = LOCALNAME;
+ this.rssLocalName = LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMUpdatedImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMUpdatedImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMUpdatedImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/GOMUpdatedImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.GOMUpdated;
+import org.apache.lucene.gdata.gom.core.utils.GOMUtils;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class GOMUpdatedImpl extends GOMDateConstructImpl implements GOMUpdated {
+ protected static final QName ATOM_QNAME = new QName(
+ GOMNamespace.ATOM_NS_URI, LOCALNAME, GOMNamespace.ATOM_NS_PREFIX);
+
+ /**
+ *
+ */
+ public GOMUpdatedImpl() {
+ super();
+ this.localName = LOCALNAME;
+ this.qname = new QName(GOMNamespace.ATOM_NS_URI, this.localName);
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ if (this.rfc3339String == null)
+ this.rfc3339String = GOMUtils
+ .buildRfc3339DateFormat(this.date == 0 ? System
+ .currentTimeMillis() : this.date);
+ aStreamWriter.writeSimpleXMLElement(ATOM_QNAME,
+ getXmlNamespaceAttributes(), this.rfc3339String);
+
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/SimpleElementParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/SimpleElementParser.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/SimpleElementParser.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/SimpleElementParser.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+abstract class SimpleElementParser implements AtomParser {
+ protected String aString = null;
+
+ protected String localname = null;
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processElementValue(java.lang.String)
+ */
+ public void processElementValue(String aValue) {
+ this.aString = aValue;
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processAttribute(javax.xml.namespace.QName,
+ * java.lang.String)
+ */
+ public void processAttribute(QName aQName, String aValue) {
+ //
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#processEndElement()
+ */
+ public abstract void processEndElement();
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AtomParser#getChildParser(javax.xml.namespace.QName)
+ */
+ public AtomParser getChildParser(QName aName) {
+ if (aName == null)
+ throw new GDataParseException("QName must not be null");
+ throw new GDataParseException(String.format(
+ AtomParser.UNEXPECTED_ELEMENT_CHILD, this.localname));
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/SimpleGOMElementImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/SimpleGOMElementImpl.java?view=auto&rev=486627
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/SimpleGOMElementImpl.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/SimpleGOMElementImpl.java Wed Dec 13 04:39:54 2006
@@ -0,0 +1,121 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ */
+package org.apache.lucene.gdata.gom.core;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.lucene.gdata.gom.GOMNamespace;
+import org.apache.lucene.gdata.gom.writer.GOMOutputWriter;
+
+/**
+ * @author Simon Willnauer
+ *
+ */
+public class SimpleGOMElementImpl extends AbstractGOMElement {
+ public static final String ELEMENT_OS_ITEMS_PER_PAGE = "itemsPerPage";
+
+ public static final String ELEMENT_OS_START_INDEX = "startIndex";
+
+ private SimpleValidator validator;
+
+ /**
+ *
+ */
+ public SimpleGOMElementImpl(String aLocalName, GOMNamespace aNamespace) {
+ super();
+ if (aLocalName == null)
+ throw new IllegalArgumentException("localname must not be null");
+ if (aNamespace == null)
+ throw new IllegalArgumentException("Namespace must not be null");
+ this.localName = aLocalName;
+ this.qname = new QName(aNamespace.getNamespaceUri(), this.localName,
+ aNamespace.getNamespacePrefix());
+ }
+
+ SimpleGOMElementImpl() {
+ // for subclasses
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#processElementValue(java.lang.String)
+ */
+ @Override
+ public void processElementValue(String aValue) {
+ if (this.textValue != null)
+ throw new GDataParseException(String.format(
+ AtomParser.DUPLICATE_ELEMENT_VALUE, this.localName));
+ this.textValue = aValue;
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.core.AbstractGOMElement#processEndElement()
+ */
+ @Override
+ public void processEndElement() {
+ if (this.validator != null)
+ this.validator.validate(this.textValue);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeAtomOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeAtomOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ aStreamWriter.writeSimpleXMLElement(this.qname,
+ getXmlNamespaceAttributes(), this.textValue);
+
+ }
+
+ /**
+ * @see org.apache.lucene.gdata.gom.GOMElement#writeRssOutput(org.apache.lucene.gdata.gom.writer.GOMStaxWriter)
+ */
+ public void writeRssOutput(GOMOutputWriter aStreamWriter)
+ throws XMLStreamException {
+ writeAtomOutput(aStreamWriter);
+
+ }
+
+ protected abstract static class SimpleValidator {
+ String localName;
+
+ protected SimpleValidator(String aLocalName) {
+ this.localName = aLocalName;
+ }
+
+ /**
+ * @param aTextValue
+ */
+ protected void validate(String aTextValue) {
+ if (aTextValue == null)
+ throw new GDataParseException(String.format(
+ AtomParser.MISSING_ELEMENT_VALUE_PLAIN,
+ this.localName));
+ }
+
+ }
+
+ /**
+ * @param aValidator
+ * The validator to set.
+ */
+ public void setValidator(SimpleValidator aValidator) {
+ validator = aValidator;
+ }
+
+}
Added: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/core-aid.gif
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/core-aid.gif?view=auto&rev=486627
==============================================================================
Binary file - no diff available.
Propchange: lucene/java/trunk/contrib/gdata-server/src/gom/java/org/apache/lucene/gdata/gom/core/core-aid.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream