abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r416772 - in /incubator/abdera/java/trunk: build/ extensions/ extensions/src/ extensions/src/main/ extensions/src/main/java/ extensions/src/main/java/org/ extensions/src/main/java/org/apache/ extensions/src/main/java/org/apache/abdera/ exte...
Date Fri, 23 Jun 2006 17:35:08 GMT
Author: jmsnell
Date: Fri Jun 23 10:35:06 2006
New Revision: 416772

URL: http://svn.apache.org/viewvc?rev=416772&view=rev
Log:
Adding the extensions module with the Feed Thread support. 
Updates the ant and maven scripts to build a new extensions jar.

Uses the ExtensionFactory mechanism so that the extension is registered 
automatically simply by dropping the extensions jar into the classpath

Added:
    incubator/abdera/java/trunk/extensions/
    incubator/abdera/java/trunk/extensions/pom.xml
    incubator/abdera/java/trunk/extensions/src/
    incubator/abdera/java/trunk/extensions/src/main/
    incubator/abdera/java/trunk/extensions/src/main/java/
    incubator/abdera/java/trunk/extensions/src/main/java/org/
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/InReplyTo.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadConstants.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadExtensionFactory.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadHelper.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/Total.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/FOMInReplyTo.java
    incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/FOMTotal.java
    incubator/abdera/java/trunk/extensions/src/main/resources/
    incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/
    incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/
    incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory
Modified:
    incubator/abdera/java/trunk/build/build.xml

Modified: incubator/abdera/java/trunk/build/build.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/build/build.xml?rev=416772&r1=416771&r2=416772&view=diff
==============================================================================
--- incubator/abdera/java/trunk/build/build.xml (original)
+++ incubator/abdera/java/trunk/build/build.xml Fri Jun 23 10:35:06 2006
@@ -29,6 +29,11 @@
   <property name="parser.test.resources" value="${parser}/src/test/resources" />
   <property name="parser.work" value="${work}/parser" />
   <property name="parser.jar" value="${dist}/${ant.project.name}.parser.${version}.jar"
/>
+	<property name="extensions" value="${basedir}/extensions" />
+	<property name="extensions.src" value="${extensions}/src/main/java" />
+	<property name="extensions.resources" value="${extensions}/src/main/resources" />
+	<property name="extensions.work" value="${work}/extensions" />
+  <property name="extensions.jar" value="${dist}/${ant.project.name}.extensions.${version}.jar"
/>
   <property name="server" value="${basedir}/server" />
   <property name="server.src" value="${server}/src/main/java" />
   <property name="server.work" value="${work}/server" />
@@ -109,6 +114,17 @@
     </copy>
   </target>
 	
+	<target name="compile.extensions" depends="init, compile.core, compile.parser">
+		<mkdir dir="${extensions.work}" />
+		<javac srcdir="${extensions.src}"
+		       destdir="${extensions.work}"
+		       classpathref="jar.dependencies"
+		       classpath="${core.work};${parser.work}" />
+		<copy todir="${extensions.work}">
+			<fileset dir="${extensions.resources}" includes="**/*" />
+		</copy>
+	</target>
+	
   <target name="compile.server" depends="init, compile.core">
     <mkdir dir="${server.work}" />
     <javac srcdir="${server.src}"
@@ -117,7 +133,7 @@
            classpath="${core.work}" />
   </target>	
 
-  <target name="build" depends="init,compile.core,compile.parser,compile.server"></target>
+  <target name="build" depends="init,compile.core,compile.parser,compile.server,compile.extensions"></target>
 
   <target name="docs" depends="init">
     <javadoc packagenames="org.apache.abdera.*"
@@ -153,6 +169,7 @@
     <jar destfile="${core.jar}"   basedir="${core.work}" />
     <jar destfile="${parser.jar}" basedir="${parser.work}" />
     <jar destfile="${server.jar}" basedir="${server.work}" />  	
+  	<jar destfile="${extensions.jar}" basedir="${extensions.work}" />
     <copy todir="${dist_lib}">
       <fileset dir="${dependencies}"  />
     </copy>

Added: incubator/abdera/java/trunk/extensions/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/pom.xml?rev=416772&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/pom.xml (added)
+++ incubator/abdera/java/trunk/extensions/pom.xml Fri Jun 23 10:35:06 2006
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project 
+  xmlns="http://maven.apache.org/POM/4.0.0" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.abdera</groupId>
+    <artifactId>abdera</artifactId>
+    <version>0.1.0-incubating-SNAPSHOT</version>
+  </parent>  
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>abdera-extensions</artifactId>
+  <packaging>jar</packaging>
+  <name>Abdera Extensions</name>
+  <version>0.1.0-incubating-SNAPSHOT</version>
+  <description>Atom Specification Extensions</description>
+  <inceptionYear>2006</inceptionYear>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-core</artifactId>
+      <version>0.1.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>    
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-parser</artifactId>
+      <version>0.1.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>   
+    <dependency>
+      <groupId>ws-commons</groupId>
+      <artifactId>axiom-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>ws-commons</groupId>
+      <artifactId>axiom-impl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>wstx</groupId>
+      <artifactId>wstx-asl</artifactId>
+    </dependency> 
+  </dependencies>
+</project>

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/InReplyTo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/InReplyTo.java?rev=416772&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/InReplyTo.java
(added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/InReplyTo.java
Fri Jun 23 10:35:06 2006
@@ -0,0 +1,113 @@
+/*
+* 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.ext.thread;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+
+import org.apache.abdera.model.ExtensionElement;
+
+/**
+ * Provides an interface for the Atom Threading Extension in-reply-to
+ * element.  The in-reply-to element allows an entry to be marked as 
+ * a response to another resource.
+ */
+public interface InReplyTo 
+  extends ExtensionElement {
+  
+  /**
+   * Returns the persistent and universally unique identifier of the 
+   * resource the entry is a response to.
+   */
+  URI getRef() throws URISyntaxException;
+  
+  /**
+   * Sets the persistent and universally unique identifier of the 
+   * resource that this entry is a response to
+   */
+  void setRef(URI ref);
+
+  /**
+   * Sets the persistent and universally unique identifier of the 
+   * resource that this entry is a response to
+   */
+  void setRef(String ref) throws URISyntaxException;
+  
+  /**
+   * Returns the resolved value of the href attribute
+   */
+  URI getResolvedHref() throws URISyntaxException;
+  
+  /**
+   * Returns a dereferenceable URI indicating where a representation of the 
+   * resource being responded to may be retrieved
+   */
+  URI getHref() throws URISyntaxException;
+  
+  /**
+   * Sets a dereferenceable URI indicating where a representation of the 
+   * resource being responded to may be retrieved
+   */
+  void setHref(URI ref);
+  
+  /**
+   * Sets a dereferenceable URI indicating where a representation of the 
+   * resource being responded to may be retrieved
+   */
+  void setHref(String ref) throws URISyntaxException;
+  
+  /**
+   * Returns the media type of the resource referenced by the href attribute
+   */
+  MimeType getMimeType() throws MimeTypeParseException;
+
+  /**
+   * Sets the media type of the resource referenced by the href attribute
+   */
+  void setMimeType(MimeType mimeType);
+  
+  /**
+   * Sets the media type of the resource referenced by the href attribute
+   */
+  void setMimeType(String mimeType) throws MimeTypeParseException;
+  
+  /**
+   * Returns a dereferenceable URI of an Atom Feed or Entry Document resolved
+   * against the in-scope Base URI
+   */
+  URI getResolvedSource() throws URISyntaxException;
+  
+  /**
+   * Returns a dereferenceable URI of an Atom Feed or Entry Document
+   */
+  URI getSource() throws URISyntaxException;
+  
+  /**
+   * Sets a dereferenceable URI of an Atom Feed or Entry Document
+   */
+  void setSource(URI source);
+  
+  /**
+   * Sets a dereferenceable URI of an Atom Feed or Entry Document
+   */
+  void setSource(String source) throws URISyntaxException;
+  
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadConstants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadConstants.java?rev=416772&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadConstants.java
(added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadConstants.java
Fri Jun 23 10:35:06 2006
@@ -0,0 +1,42 @@
+/*
+* 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.ext.thread;
+
+import javax.xml.namespace.QName;
+import org.apache.abdera.util.Constants;
+
+public interface ThreadConstants extends Constants {
+
+  public static final String THR_NS = "http://purl.org/syndication/thread/1.0";
+  public static final String LN_INREPLYTO = "in-reply-to";
+  public static final String LN_REF = "ref";
+  public static final String LN_COUNT = "count";
+  public static final String LN_WHEN = "when";
+  public static final String LN_TOTAL = "total";
+  public static final String THR_PREFIX = "thr";
+  public static final QName IN_REPLY_TO = new QName(THR_NS, LN_INREPLYTO, THR_PREFIX);
+  public static final QName THRCOUNT = new QName(THR_NS, LN_COUNT, THR_PREFIX);
+  /** @deprecated Use Constants.THRUPDATED */
+  public static final QName THRWHEN = new QName(THR_NS, LN_WHEN, THR_PREFIX);
+  public static final QName THRUPDATED = new QName(THR_NS, LN_UPDATED, THR_PREFIX);
+  public static final QName THRTOTAL = new QName(THR_NS, LN_TOTAL, THR_PREFIX);
+  public static final QName THRREF = new QName(LN_REF);
+  public static final QName THRSOURCE = new QName(LN_SOURCE);
+
+  
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadExtensionFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadExtensionFactory.java?rev=416772&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadExtensionFactory.java
(added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadExtensionFactory.java
Fri Jun 23 10:35:06 2006
@@ -0,0 +1,84 @@
+/*
+* 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.ext.thread;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.thread.impl.FOMInReplyTo;
+import org.apache.abdera.ext.thread.impl.FOMTotal;
+import org.apache.abdera.factory.ExtensionFactory;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Base;
+import org.apache.abdera.model.ExtensionElement;
+import org.apache.abdera.parser.stax.FOMExtensionFactory;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+
+public class ThreadExtensionFactory 
+  implements ExtensionFactory,
+    FOMExtensionFactory {
+
+  public boolean handlesNamespace(String namespace) {
+    return (ThreadConstants.THR_NS.equals(namespace));
+  }
+
+  public String getNamespace() {
+    return ThreadConstants.THR_NS;
+  }
+
+  @SuppressWarnings("unchecked")
+  public <T extends ExtensionElement> T newExtensionElement(
+    QName qname,
+    Base parent, 
+    Factory factory) {
+      if (ThreadConstants.IN_REPLY_TO.equals(qname)) 
+        return (T)new FOMInReplyTo(
+          qname, 
+          (OMContainer)parent, 
+          (OMFactory)factory);
+      else if (ThreadConstants.THRTOTAL.equals(qname))
+        return (T)new FOMTotal(
+          qname, 
+          (OMContainer)parent, 
+          (OMFactory)factory);
+      else return null;
+  }
+
+  @SuppressWarnings("unchecked")
+  public <T extends ExtensionElement> T newExtensionElement(
+    QName qname,
+    Base parent, 
+    Factory factory, 
+    OMXMLParserWrapper parserWrapper) {
+      if (ThreadConstants.IN_REPLY_TO.equals(qname)) 
+        return (T)new FOMInReplyTo(
+          qname, 
+          (OMContainer)parent, 
+          (OMFactory)factory,
+          parserWrapper);
+      else if (ThreadConstants.THRTOTAL.equals(qname))
+        return (T)new FOMTotal(
+          qname, 
+          (OMContainer)parent, 
+          (OMFactory)factory,
+          parserWrapper);
+      else return null;
+  }
+
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadHelper.java?rev=416772&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadHelper.java
(added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/ThreadHelper.java
Fri Jun 23 10:35:06 2006
@@ -0,0 +1,204 @@
+/*
+* 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.ext.thread;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+
+import org.apache.abdera.ext.thread.impl.FOMInReplyTo;
+import org.apache.abdera.ext.thread.impl.FOMTotal;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.AtomDate;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.model.Source;
+
+public final class ThreadHelper {
+
+  ThreadHelper() {}
+  
+  public static int getCount(Link link) {
+    String val = link.getAttributeValue(ThreadConstants.THRCOUNT);
+    return (val != null) ? Integer.parseInt(val) : 0;
+  }
+  
+  @SuppressWarnings("deprecation")
+  public static AtomDate getUpdated(Link link) {
+    String val = link.getAttributeValue(ThreadConstants.THRUPDATED);
+    if (val == null) // thr:when was updated to thr:updated, some old impls may still be
using thr:when
+      val = link.getAttributeValue(ThreadConstants.THRWHEN);
+    return (val != null) ? AtomDate.valueOf(val) : null;
+  }
+  
+  public static void setCount(
+    Link link, 
+    int count) {
+      link.setAttributeValue(
+        ThreadConstants.THRCOUNT, 
+        String.valueOf(count).trim());
+  }
+  
+  public static void setUpdated(
+    Link link, 
+    Date when) {
+      link.setAttributeValue(
+        ThreadConstants.THRUPDATED, 
+        AtomDate.valueOf(when).getValue());
+  }
+  
+  public static void setUpdated(
+    Link link, 
+    Calendar when) {
+      link.setAttributeValue(
+        ThreadConstants.THRUPDATED, 
+        AtomDate.valueOf(when).getValue());
+  }
+  
+  public static void setUpdated(
+    Link link, 
+    long when) {
+      link.setAttributeValue(
+        ThreadConstants.THRUPDATED, 
+        AtomDate.valueOf(when).getValue());
+  }
+  
+  public static void setUpdated(
+    Link link, 
+    String when) {
+      link.setAttributeValue(
+        ThreadConstants.THRUPDATED, 
+        AtomDate.valueOf(when).getValue());
+  }
+  
+  
+  public static Total addTotal(Entry entry, int total) {
+    Factory factory = entry.getFactory();
+    Total totalelement = 
+      (Total)factory.newExtensionElement(
+        ThreadConstants.THRTOTAL, entry);
+    totalelement.setValue(total);
+    return totalelement;
+  }
+  
+  public static Total getTotal(Entry entry) {
+    return entry.getFirstChild(ThreadConstants.THRTOTAL);
+  }
+  
+  public static void addInReplyTo(Entry entry, InReplyTo replyTo) {
+    entry.addExtension(replyTo);
+  }
+  
+  public static InReplyTo addInReplyTo(Entry entry) {
+    Factory factory = entry.getFactory();
+    InReplyTo replyTo = 
+      (InReplyTo) factory.newExtensionElement(
+        ThreadConstants.IN_REPLY_TO, entry);
+    return replyTo;
+  }
+
+  public static InReplyTo addInReplyTo(Entry entry, Entry ref) {
+    if (ref.equals(entry)) return null;
+    InReplyTo irt = addInReplyTo(entry); 
+    try {
+      irt.setRef(ref.getId());
+      Link altlink = ref.getAlternateLink();
+      if (altlink != null) {
+        irt.setHref(altlink.getResolvedHref());
+        if (altlink.getMimeType() != null) 
+          irt.setMimeType(altlink.getMimeType());
+      }
+      Source src = ref.getSource();
+      if (src != null) {
+        Link selflink = src.getSelfLink();
+        if (selflink != null)
+          irt.setSource(selflink.getResolvedHref());
+      }
+    } catch (Exception e) {}
+    return irt;
+  }
+
+  public static InReplyTo addInReplyTo(Entry entry, URI ref) {
+    try {
+      if (entry.getId() != null && entry.getId().equals(ref)) return null;
+    } catch (Exception e) {}
+    InReplyTo irt = addInReplyTo(entry);
+    irt.setRef(ref);
+    return irt;
+  }
+
+  public static InReplyTo addInReplyTo(Entry entry, String ref) throws URISyntaxException
{
+    return addInReplyTo(entry, new URI(ref));
+  }
+
+  public static InReplyTo addInReplyTo(
+    Entry entry,
+    URI ref, 
+    URI source, 
+    URI href, 
+    MimeType type) {
+      InReplyTo irt = addInReplyTo(entry, ref);
+      if (irt != null) {
+        if (source != null) irt.setSource(source);
+        if (href != null) irt.setHref(href);
+        if (type != null) irt.setMimeType(type);
+      }
+      return irt;
+  }
+
+  public static InReplyTo addInReplyTo(
+    Entry entry,
+    String ref, 
+    String source, 
+    String href, 
+    String type) 
+      throws URISyntaxException, 
+             MimeTypeParseException {
+    InReplyTo irt = addInReplyTo(entry, ref);
+    if (irt != null) {
+      if (source != null) irt.setSource(source);
+      if (href != null) irt.setHref(href);
+      if (type != null) irt.setMimeType(type);
+    }
+    return irt;
+  }
+
+  public static InReplyTo getInReplyTo(Entry entry) {
+    return entry.getFirstChild(ThreadConstants.IN_REPLY_TO);
+  }
+
+  @SuppressWarnings("unchecked")
+  public static List<InReplyTo> getInReplyTos(Entry entry) {
+    List list = entry.getExtensions(ThreadConstants.IN_REPLY_TO);
+    return list;
+  }
+
+  public static InReplyTo newInReplyTo() {
+    return new FOMInReplyTo();
+  }
+  
+  public static Total newTotal() {
+    return new FOMTotal();
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/Total.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/Total.java?rev=416772&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/Total.java
(added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/Total.java
Fri Jun 23 10:35:06 2006
@@ -0,0 +1,15 @@
+package org.apache.abdera.ext.thread;
+
+import org.apache.abdera.model.ExtensionElement;
+
+/**
+ * Provides an interface for the Atom Threading Extension total
+ * element.
+ */
+public interface Total extends ExtensionElement {
+
+  int getValue();
+  
+  void setValue(int value);
+  
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/FOMInReplyTo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/FOMInReplyTo.java?rev=416772&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/FOMInReplyTo.java
(added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/FOMInReplyTo.java
Fri Jun 23 10:35:06 2006
@@ -0,0 +1,151 @@
+/*
+* 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.ext.thread.impl;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.thread.InReplyTo;
+import org.apache.abdera.ext.thread.ThreadConstants;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.parser.stax.FOMExtensionElement;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMXMLParserWrapper;
+
+
+public class FOMInReplyTo 
+  extends FOMExtensionElement 
+  implements InReplyTo {
+
+  private static final long serialVersionUID = 7805672826003392693L;
+
+  public FOMInReplyTo() {
+    super(ThreadConstants.IN_REPLY_TO, null, (OMFactory)Factory.INSTANCE);
+  }
+  
+  public FOMInReplyTo(URI ref) {
+    this();
+    setRef(ref);
+  }
+  
+  public FOMInReplyTo(String ref) throws URISyntaxException {
+    this();
+    setRef(ref);
+  }
+  
+  public FOMInReplyTo(
+    String name,
+    OMNamespace namespace,
+    OMContainer parent,
+    OMFactory factory)
+      throws OMException {
+    super(name, namespace, parent, factory);
+  }
+  
+  public FOMInReplyTo(
+    QName qname,
+    OMContainer parent,
+    OMFactory factory) {
+      super(qname, parent, factory);
+  }
+  
+  public FOMInReplyTo( 
+    OMContainer parent, 
+    OMFactory factory)
+      throws OMException {
+    super(ThreadConstants.IN_REPLY_TO, parent, factory);
+  }
+
+  public FOMInReplyTo(
+    QName qname, 
+    OMContainer parent, 
+    OMFactory factory,
+    OMXMLParserWrapper builder) 
+      throws OMException {
+    super(qname, parent, factory, builder);
+  }
+
+  public URI getRef() throws URISyntaxException {
+    return _getUriValue(getAttributeValue(ThreadConstants.THRREF));
+  }
+
+  public void setRef(URI ref) {
+    this._setAttributeValue(ThreadConstants.THRREF, ref.toString());
+  }
+  
+  public void setRef(String ref) throws URISyntaxException {
+    setRef(new URI(ref));
+  }
+
+  public URI getResolvedHref() throws URISyntaxException {
+    return _resolve(getResolvedBaseUri(), getHref());
+  }
+  
+  public URI getHref() throws URISyntaxException {
+    return _getUriValue(getAttributeValue(HREF));
+  }
+
+  public void setHref(URI ref) {
+    this._setAttributeValue(HREF, ref.toString());
+  }
+
+  public void setHref(String ref) throws URISyntaxException {
+    setHref(new URI(ref));
+  }
+  
+  public MimeType getMimeType() throws MimeTypeParseException {
+    MimeType type = null;
+    String value = _getAttributeValue(TYPE);
+    if (value != null) {
+      type = new MimeType(value);
+    }
+    return type;
+  }
+
+  public void setMimeType(MimeType mimeType) {
+    this._setAttributeValue(TYPE, mimeType.toString());
+  }
+  
+  public void setMimeType(String mimeType) throws MimeTypeParseException {
+    setMimeType(new MimeType(mimeType));
+  }
+  
+  public URI getResolvedSource() throws URISyntaxException {
+    return _resolve(getResolvedBaseUri(), getSource());
+  }
+  
+  public URI getSource() throws URISyntaxException {
+    return _getUriValue(getAttributeValue(ThreadConstants.THRSOURCE));
+  }
+
+  public void setSource(URI source) {
+    this._setAttributeValue(ThreadConstants.THRSOURCE, source.toString());
+  }
+  
+  public void setSource(String source) throws URISyntaxException {
+    setSource(new URI(source));
+  }
+
+}

Added: incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/FOMTotal.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/FOMTotal.java?rev=416772&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/FOMTotal.java
(added)
+++ incubator/abdera/java/trunk/extensions/src/main/java/org/apache/abdera/ext/thread/impl/FOMTotal.java
Fri Jun 23 10:35:06 2006
@@ -0,0 +1,63 @@
+package org.apache.abdera.ext.thread.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.thread.ThreadConstants;
+import org.apache.abdera.ext.thread.Total;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.parser.stax.FOMExtensionElement;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMException;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMXMLParserWrapper;
+
+public class FOMTotal extends FOMExtensionElement implements Total {
+
+  private static final long serialVersionUID = 241599118592917827L;
+
+  public FOMTotal() {
+    super(ThreadConstants.THRTOTAL, null, (OMFactory)Factory.INSTANCE);
+  }
+  
+  public FOMTotal(
+    String name,
+    OMNamespace namespace,
+    OMContainer parent,
+    OMFactory factory)
+      throws OMException {
+    super(name, namespace, parent, factory);
+  }
+  
+  public FOMTotal(
+    QName qname,
+    OMContainer parent,
+    OMFactory factory) {
+      super(qname, parent, factory);
+  }
+  
+  public FOMTotal( 
+    OMContainer parent, 
+    OMFactory factory)
+      throws OMException {
+    super(ThreadConstants.THRTOTAL, parent, factory);
+  }
+
+  public FOMTotal(
+    QName qname, 
+    OMContainer parent, 
+    OMFactory factory,
+    OMXMLParserWrapper builder) 
+      throws OMException {
+    super(qname, parent, factory, builder);
+  }
+  
+  public int getValue() {
+    return Integer.parseInt(getText());
+  }
+
+  public void setValue(int value) {
+    setText(String.valueOf(value));
+  }
+
+}

Added: incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory?rev=416772&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory
(added)
+++ incubator/abdera/java/trunk/extensions/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory
Fri Jun 23 10:35:06 2006
@@ -0,0 +1 @@
+org.apache.abdera.ext.thread.ThreadExtensionFactory
\ No newline at end of file



Mime
View raw message