Author: veithen
Date: Sat Sep 26 12:26:11 2015
New Revision: 1705439

URL: http://svn.apache.org/viewvc?rev=1705439&view=rev
Log:
Transform FOMCategories into mixins.

Added:
    
webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaCategoriesMixin.aj
      - copied, changed from r1705341, 
webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
Modified:
    
webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java

Copied: 
webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaCategoriesMixin.aj
 (from r1705341, 
webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java)
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaCategoriesMixin.aj?p2=webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaCategoriesMixin.aj&p1=webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java&r1=1705341&r2=1705439&rev=1705439&view=diff
==============================================================================
--- 
webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
 (original)
+++ 
webservices/axiom/trunk/aspects/fom-aspects/src/main/java/org/apache/axiom/fom/AbderaCategoriesMixin.aj
 Sat Sep 26 12:26:11 2015
@@ -15,7 +15,11 @@
  * copyright in this work, please see the NOTICE file in the top level
  * directory of this distribution.
  */
-package org.apache.abdera.parser.stax;
+package org.apache.axiom.fom;
+
+import static org.apache.abdera.util.Constants.FIXED;
+import static org.apache.abdera.util.Constants.SCHEME;
+import static org.apache.abdera.util.Constants.YES;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -23,17 +27,14 @@ import java.util.List;
 import org.apache.abdera.i18n.iri.IRI;
 import org.apache.abdera.model.Categories;
 import org.apache.abdera.model.Category;
-import org.apache.axiom.fom.AbderaCategories;
-import org.apache.axiom.fom.IRIUtil;
-import org.apache.axiom.om.OMElement;
-
-public class FOMCategories extends FOMExtensibleElement implements 
AbderaCategories {
-    public Categories addCategory(Category category) {
-        addChild((OMElement)category);
+
+public aspect AbderaCategoriesMixin {
+    public final Categories AbderaCategories.addCategory(Category category) {
+        coreAppendChild((AbderaCategory)category, false);
         return this;
     }
 
-    private List<Category> copyCategoriesWithScheme(List<Category> cats) {
+    private List<Category> 
AbderaCategories.copyCategoriesWithScheme(List<Category> cats) {
         List<Category> newcats = new ArrayList<Category>();
         IRI scheme = getScheme();
         for (Category cat : cats) {
@@ -45,25 +46,25 @@ public class FOMCategories extends FOMEx
         return newcats;
     }
 
-    public List<Category> getCategoriesWithScheme() {
+    public final List<Category> AbderaCategories.getCategoriesWithScheme() {
         return copyCategoriesWithScheme(getCategories());
     }
 
-    public List<Category> getCategoriesWithScheme(String scheme) {
+    public final List<Category> 
AbderaCategories.getCategoriesWithScheme(String scheme) {
         return copyCategoriesWithScheme(getCategories(scheme));
     }
 
-    public IRI getScheme() {
+    public final IRI AbderaCategories.getScheme() {
         String value = getAttributeValue(SCHEME);
         return (value != null) ? new IRI(value) : null;
     }
 
-    public boolean isFixed() {
+    public final boolean AbderaCategories.isFixed() {
         String value = getAttributeValue(FIXED);
         return (value != null && value.equals(YES));
     }
 
-    public Categories setFixed(boolean fixed) {
+    public final Categories AbderaCategories.setFixed(boolean fixed) {
         if (fixed && !isFixed())
             setAttributeValue(FIXED, YES);
         else if (!fixed && isFixed())
@@ -71,21 +72,21 @@ public class FOMCategories extends FOMEx
         return this;
     }
 
-    public Categories setScheme(String scheme) {
+    public final Categories AbderaCategories.setScheme(String scheme) {
         setAttributeValue(SCHEME, IRIUtil.normalize(scheme));
         return this;
     }
 
-    public Categories setHref(String href) {
+    public final Categories AbderaCategories.setHref(String href) {
         internalSetHref(href);
         return this;
     }
 
-    public boolean contains(String term) {
+    public final boolean AbderaCategories.contains(String term) {
         return contains(term, null);
     }
 
-    public boolean contains(String term, String scheme) {
+    public final boolean AbderaCategories.contains(String term, String scheme) 
{
         List<Category> categories = getCategories();
         IRI catscheme = getScheme();
         IRI uri = (scheme != null) ? new IRI(scheme) : catscheme;
@@ -98,7 +99,7 @@ public class FOMCategories extends FOMEx
         return false;
     }
 
-    public boolean isOutOfLine() {
+    public final boolean AbderaCategories.isOutOfLine() {
         boolean answer = false;
         try {
             answer = getHref() != null;

Modified: 
webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
URL: 
http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java?rev=1705439&r1=1705438&r2=1705439&view=diff
==============================================================================
--- 
webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
 (original)
+++ 
webservices/axiom/trunk/implementations/fom-impl/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
 Sat Sep 26 12:26:11 2015
@@ -17,94 +17,8 @@
  */
 package org.apache.abdera.parser.stax;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.abdera.i18n.iri.IRI;
-import org.apache.abdera.model.Categories;
-import org.apache.abdera.model.Category;
 import org.apache.axiom.fom.AbderaCategories;
-import org.apache.axiom.fom.IRIUtil;
-import org.apache.axiom.om.OMElement;
 
 public class FOMCategories extends FOMExtensibleElement implements 
AbderaCategories {
-    public Categories addCategory(Category category) {
-        addChild((OMElement)category);
-        return this;
-    }
-
-    private List<Category> copyCategoriesWithScheme(List<Category> cats) {
-        List<Category> newcats = new ArrayList<Category>();
-        IRI scheme = getScheme();
-        for (Category cat : cats) {
-            Category newcat = (Category)cat.clone();
-            if (newcat.getScheme() == null && scheme != null)
-                newcat.setScheme(scheme.toString());
-            newcats.add(newcat);
-        }
-        return newcats;
-    }
-
-    public List<Category> getCategoriesWithScheme() {
-        return copyCategoriesWithScheme(getCategories());
-    }
-
-    public List<Category> getCategoriesWithScheme(String scheme) {
-        return copyCategoriesWithScheme(getCategories(scheme));
-    }
-
-    public IRI getScheme() {
-        String value = getAttributeValue(SCHEME);
-        return (value != null) ? new IRI(value) : null;
-    }
-
-    public boolean isFixed() {
-        String value = getAttributeValue(FIXED);
-        return (value != null && value.equals(YES));
-    }
-
-    public Categories setFixed(boolean fixed) {
-        if (fixed && !isFixed())
-            setAttributeValue(FIXED, YES);
-        else if (!fixed && isFixed())
-            removeAttribute(FIXED);
-        return this;
-    }
-
-    public Categories setScheme(String scheme) {
-        setAttributeValue(SCHEME, IRIUtil.normalize(scheme));
-        return this;
-    }
-
-    public Categories setHref(String href) {
-        internalSetHref(href);
-        return this;
-    }
-
-    public boolean contains(String term) {
-        return contains(term, null);
-    }
-
-    public boolean contains(String term, String scheme) {
-        List<Category> categories = getCategories();
-        IRI catscheme = getScheme();
-        IRI uri = (scheme != null) ? new IRI(scheme) : catscheme;
-        for (Category category : categories) {
-            String t = category.getTerm();
-            IRI s = (category.getScheme() != null) ? category.getScheme() : 
catscheme;
-            if (t.equals(term) && ((uri != null) ? uri.equals(s) : s == null))
-                return true;
-        }
-        return false;
-    }
-
-    public boolean isOutOfLine() {
-        boolean answer = false;
-        try {
-            answer = getHref() != null;
-        } catch (Exception e) {
-        }
-        return answer;
-    }
 
 }


Reply via email to