abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r438306 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/factory/ core/src/main/java/org/apache/abdera/model/ core/src/main/java/org/apache/abdera/util/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Wed, 30 Aug 2006 00:12:53 GMT
Author: jmsnell
Date: Tue Aug 29 17:12:52 2006
New Revision: 438306

URL: http://svn.apache.org/viewvc?rev=438306&view=rev
Log:
The Atompub working group just completed another consensus call round with a number
of changes.  

 * A new app:categories element has been introduced to provide a listing of 
   atom:categories available.  

   - Created new Categories interface and FOMCategories impl
   - Added methods to Factory and FOMFactory for creating Categories/FOMCategories
   - Added methods to Collection and FOMCollection for supporting the new element

 * pub:control and pub:draft now use the main APP XML namespace

More coming.

Added:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Collection.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractXPath.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java?rev=438306&r1=438305&r2=438306&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/factory/Factory.java
Tue Aug 29 17:12:52 2006
@@ -21,6 +21,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.abdera.model.Base;
+import org.apache.abdera.model.Categories;
 import org.apache.abdera.model.Category;
 import org.apache.abdera.model.Collection;
 import org.apache.abdera.model.Content;
@@ -441,4 +442,13 @@
    */
   void registerExtension(ExtensionFactory extensionFactory);
     
+  /**
+   * Create a new Categories element 
+   */
+  Categories newCategories();
+  
+  /**
+   * Create a new Categories element as a child of the given Element
+   */
+  Categories newCategories(Element parent);
 }

Added: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java?rev=438306&view=auto
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
(added)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
Tue Aug 29 17:12:52 2006
@@ -0,0 +1,95 @@
+/*
+* 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.model;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+public interface Categories 
+  extends ExtensibleElement {
+
+  /**
+   * Returns the value of the href attribute
+   * @throws URISyntaxException 
+   */
+  URI getHref() throws URISyntaxException;
+  
+  /**
+   * Returns the fully resolved href
+   * @throws URISyntaxException 
+   */
+  URI getResolvedHref() throws URISyntaxException;
+  
+  /**
+   * Sets the value of the href attribute
+   * @throws URISyntaxException 
+   */
+  void setHref(String href) throws URISyntaxException;
+  
+  /**
+   * Specifies whether or not this is a fixed listing of categories
+   */
+  boolean isFixed();
+  
+  /**
+   * Sets whether or not this is a fixed listing of categories
+   */
+  void setFixed(boolean fixed);
+  
+  /**
+   * Returns the common scheme for this listing of categories
+   * @throws URISyntaxException 
+   */
+  URI getScheme() throws URISyntaxException;
+  
+  /**
+   * Sets the common scheme for this listing of categories
+   * @throws URISyntaxException 
+   */
+  void setScheme(String scheme) throws URISyntaxException;
+
+  /**
+   * Lists the complete set of categories listed for the entry
+   */
+  List<Category> getCategories();
+  
+  /**
+   * Lists the complete set of categories using the specified scheme
+   * @throws URISyntaxException 
+   */
+  List<Category> getCategories(String scheme) throws URISyntaxException;
+  
+  /**
+   * Adds an individual category to the entry
+   */
+  void addCategory(Category category);
+
+  /**
+   * Adds a category to the feed
+   */
+  Category addCategory(String term);
+
+  /**
+   * Adds a category to the feed
+   * @throws URISyntaxException 
+   */
+  Category addCategory(String scheme, String term, String label) throws URISyntaxException;
+    
+}
+

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Collection.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Collection.java?rev=438306&r1=438305&r2=438306&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Collection.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Collection.java
Tue Aug 29 17:12:52 2006
@@ -19,6 +19,7 @@
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.List;
 
 import javax.activation.MimeType;
 import javax.activation.MimeTypeParseException;
@@ -96,4 +97,13 @@
    * Returns true if the collection accepts the specified media type
    */
   boolean accepts(MimeType mediaType);
+  
+  List<Categories> getCategories();
+  
+  Categories addCategories();
+  
+  void addCategories(Categories categories);
+  
+  Categories addCategories(List<Category> categories, boolean fixed, String scheme)
throws URISyntaxException;
+  
 }

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractXPath.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractXPath.java?rev=438306&r1=438305&r2=438306&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractXPath.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractXPath.java
Tue Aug 29 17:12:52 2006
@@ -35,7 +35,7 @@
       namespaces = new HashMap<String,String>();
     namespaces.put("a", Constants.ATOM_NS);
     namespaces.put("app", Constants.APP_NS);
-    namespaces.put("pub", Constants.CONTROL_NS);
+    //namespaces.put("pub", Constants.CONTROL_NS);
     return namespaces;
   }
 

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java?rev=438306&r1=438305&r2=438306&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/Constants.java Tue
Aug 29 17:12:52 2006
@@ -36,6 +36,7 @@
   
   public static final String ATOM_NS              = "http://www.w3.org/2005/Atom";
   public static final String APP_NS               = "http://purl.org/atom/app#";
+  /** @deprecated **/
   public static final String CONTROL_NS           = "http://example.net/appns/";
   public static final String XML_NS               = "http://www.w3.org/XML/1998/namespace";
   public static final String XHTML_NS             = "http://www.w3.org/1999/xhtml";
@@ -82,10 +83,13 @@
   public static final String LN_COLLECTION        = "collection";
   public static final String LN_CONTROL           = "control";
   public static final String LN_DRAFT             = "draft";
+  public static final String LN_CATEGORIES        = "categories";
+  public static final String LN_FIXED             = "fixed";
   
   public static final QName DIV                   = new QName(XHTML_NS, LN_DIV, "");
-  public static final QName CONTROL               = new QName(CONTROL_NS, LN_CONTROL, CONTROL_PREFIX);
-  public static final QName DRAFT                 = new QName(CONTROL_NS, LN_DRAFT, CONTROL_PREFIX);
+  public static final QName CONTROL               = new QName(APP_NS, LN_CONTROL, "app");
+  public static final QName DRAFT                 = new QName(APP_NS, LN_DRAFT, "app");
+  public static final QName CATEGORIES            = new QName(APP_NS, LN_CATEGORIES, "app");
   public static final QName FEED                  = new QName(ATOM_NS, LN_FEED, PREFIX);
   public static final QName SERVICE               = new QName(APP_NS, LN_SERVICE, "app");
   public static final QName AUTHOR                = new QName(ATOM_NS, LN_AUTHOR, PREFIX);
@@ -107,6 +111,7 @@
   public static final QName ENTRY                 = new QName(ATOM_NS, LN_ENTRY, PREFIX);
   public static final QName TERM                  = new QName(LN_TERM);
   public static final QName SCHEME                = new QName(LN_SCHEME);
+  public static final QName FIXED                 = new QName(LN_FIXED);
   public static final QName LABEL                 = new QName(LN_LABEL);
   public static final QName ATITLE                = new QName(LN_TITLE);
   public static final QName HREF                  = new QName(LN_HREF);

Added: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java?rev=438306&view=auto
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
(added)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
Tue Aug 29 17:12:52 2006
@@ -0,0 +1,167 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.parser.stax;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.model.Categories;
+import org.apache.abdera.model.Category;
+import org.apache.abdera.parser.stax.util.FOMHelper;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
+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 FOMCategories 
+  extends FOMExtensibleElement 
+  implements Categories {
+
+  private static final long serialVersionUID = 5480273546375102411L;
+
+  public FOMCategories() {
+    super(CATEGORIES, new FOMDocument(), new FOMFactory());
+    init();
+  }
+  
+  public FOMCategories(
+    String name,
+    OMNamespace namespace,
+    OMContainer parent,
+    OMFactory factory)
+      throws OMException {
+    super(name, namespace, parent, factory);
+    init();
+  }
+  
+  public FOMCategories(
+    QName qname,
+    OMContainer parent,
+    OMFactory factory) {
+      super(qname, parent, factory);
+      init();
+  }
+  
+  public FOMCategories(
+    QName qname,
+    OMContainer parent, 
+    OMFactory factory,
+    OMXMLParserWrapper builder) {
+      super(qname, parent, factory, builder);
+  }
+  
+  public FOMCategories(
+    OMContainer parent, 
+    OMFactory factory) 
+      throws OMException {
+    super(CATEGORIES, parent, factory);
+    init();
+  }
+
+  public FOMCategories(
+    OMContainer parent, 
+    OMFactory factory,
+    OMXMLParserWrapper builder) 
+      throws OMException {
+    super(CATEGORIES, parent, factory, builder);
+  }
+
+  private void init() {
+    this.declareNamespace(ATOM_NS, "atom");
+  }
+  
+  public void addCategory(Category category) {
+    addChild((OMElement)category);
+  }
+
+  public Category addCategory(String term) {
+    FOMFactory factory = (FOMFactory) this.factory;
+    Category category = factory.newCategory(this);
+    category.setTerm(term);
+    return category;
+  }
+
+  public Category addCategory(
+    String scheme, 
+    String term, 
+    String label)
+      throws URISyntaxException {
+    FOMFactory factory = (FOMFactory) this.factory;
+    Category category = factory.newCategory(this);
+    category.setTerm(term);
+    category.setScheme(scheme);
+    category.setLabel(label);
+    return category;    
+
+  }
+
+  public List<Category> getCategories() {
+    return _getChildrenAsSet(CATEGORY);
+  }
+
+  public List<Category> getCategories(String scheme) throws URISyntaxException {
+    return FOMHelper.getCategories(this, scheme);
+  }
+
+  public java.net.URI getScheme() throws URISyntaxException {
+    String value = getAttributeValue(SCHEME);
+    return (value != null) ? new URI(value) : null;
+  }
+
+  public boolean isFixed() {
+    String value = getAttributeValue(FIXED);
+    return (value != null && value.equals(YES));
+  }
+
+  public void setFixed(boolean fixed) {
+    if (fixed && !isFixed())
+      setAttributeValue(FIXED, YES);
+    else if (!fixed && isFixed())
+      removeAttribute(FIXED);
+  }
+
+  public void setScheme(String scheme) throws URISyntaxException {
+    if (scheme != null)
+      setAttributeValue(SCHEME, new URI(scheme).toString());
+    else 
+      removeAttribute(SCHEME);
+  }
+  
+  public URI getHref() throws URISyntaxException {
+    return _getUriValue(getAttributeValue(HREF));
+  }
+
+  public URI getResolvedHref() throws URISyntaxException {
+    return _resolve(getResolvedBaseUri(), getHref());
+  }
+  
+  public void setHref(String href) throws URISyntaxException {
+    if (href != null)
+      setAttributeValue(HREF, (new URI(href)).toString());
+    else 
+      removeAttribute(HREF);
+  }
+  
+
+
+}

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java?rev=438306&r1=438305&r2=438306&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCollection.java
Tue Aug 29 17:12:52 2006
@@ -19,14 +19,18 @@
 
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.List;
 
 import javax.activation.MimeType;
 import javax.xml.namespace.QName;
 
+import org.apache.abdera.model.Categories;
+import org.apache.abdera.model.Category;
 import org.apache.abdera.model.Collection;
 import org.apache.abdera.util.Constants;
 import org.apache.abdera.util.MimeTypeHelper;
 import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
@@ -149,6 +153,35 @@
 
   public boolean accepts(MimeType mediaType) {
     return accepts(mediaType.toString());
+  }
+
+  public Categories addCategories() {
+    return ((FOMFactory)factory).newCategories(this);
+  }
+  
+  public void addCategories(Categories categories) {
+    addChild((OMElement)categories);
+  }
+
+  public Categories addCategories(
+    List<Category> categories, 
+    boolean fixed, 
+    String scheme) 
+      throws URISyntaxException {
+      Categories cats = ((FOMFactory)factory).newCategories();
+      cats.setFixed(fixed);
+      if (scheme != null) cats.setScheme(scheme);
+      if (categories != null) {
+        for (Category category : categories) {
+          cats.addCategory(category);
+        }
+      }
+      addCategories(cats);
+      return cats;
+  }
+
+  public List<Categories> getCategories() {
+    return _getChildrenAsSet(CATEGORIES);
   }
 
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java?rev=438306&r1=438305&r2=438306&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
Tue Aug 29 17:12:52 2006
@@ -31,6 +31,7 @@
 import org.apache.abdera.factory.ExtensionFactory;
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.model.Base;
+import org.apache.abdera.model.Categories;
 import org.apache.abdera.model.Category;
 import org.apache.abdera.model.Collection;
 import org.apache.abdera.model.Content;
@@ -699,6 +700,8 @@
         element = new FOMControl(qname.getLocalPart(), namespace, parent, factory);
       } else if (DIV.equals(qname)) {
         element = new FOMDiv(qname.getLocalPart(), namespace, parent, factory);
+      } else if (CATEGORIES.equals(qname)) {
+        element = new FOMCategories(qname.getLocalPart(), namespace, parent, factory);
       } else if (parent instanceof ExtensibleElement || 
                  parent instanceof Document) {
         element = (OMElement) newExtensionElement(qname, parent);
@@ -769,6 +772,8 @@
       element = (OMElement) newControl(qname, parent, builder);
     } else if (DIV.equals(qname)) {
       element = (OMElement) newDiv(qname, parent, builder);
+    } else if (CATEGORIES.equals(qname)) {
+      element = (OMElement) newCategories(qname, parent, builder);
     } else if (parent instanceof ExtensibleElement || parent instanceof Document) {
       element = (OMElement) newExtensionElement(qname, parent, builder);
     }
@@ -849,5 +854,20 @@
       }
       return null;
   }
-  
+
+  public Categories newCategories() {
+    return newCategories(null);
+  }
+
+  public Categories newCategories(Element parent) {
+    return new FOMCategories((OMContainer)parent, this);
+  }
+
+  public Categories newCategories(
+      QName qname,
+      OMContainer parent, 
+      OMXMLParserWrapper parserWrapper) {
+        return new FOMCategories(qname,parent, this, parserWrapper);
+    }
+
 }



Mime
View raw message