abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r416777 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/ExtensibleElement.java parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
Date Fri, 23 Jun 2006 17:54:58 GMT
Author: jmsnell
Date: Fri Jun 23 10:54:57 2006
New Revision: 416777

URL: http://svn.apache.org/viewvc?rev=416777&view=rev
Log:
Change some of the methods on ExtensibleElement to use generics... 
makes it slightly easier to use extensions with the API when using java5

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElement.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElement.java?rev=416777&r1=416776&r2=416777&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElement.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElement.java
Fri Jun 23 10:54:57 2006
@@ -41,12 +41,12 @@
    * Returns the complete set of extension elements using the specified
    * XML qualified name
    */
-  List<ExtensionElement> getExtensions(QName qname);
+  <T extends ExtensionElement>List<T> getExtensions(QName qname);
   
   /**
    * Returns the first extension element with the XML qualified name
    */
-  ExtensionElement getExtension(QName qname);
+  <T extends ExtensionElement>T getExtension(QName qname);
   
   /**
    * Adds an individual extension element
@@ -56,12 +56,12 @@
   /**
    * Adds an individual extension element
    */
-  ExtensionElement addExtension(QName qname);
+  <T extends ExtensionElement>T addExtension(QName qname);
   
   /**
    * Adds an individual extension element
    */
-  ExtensionElement addExtension(
+  <T extends ExtensionElement>T addExtension(
     String namespace, 
     String localPart,
     String prefix);

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java?rev=416777&r1=416776&r2=416777&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMExtensibleElement.java
Fri Jun 23 10:54:57 2006
@@ -102,29 +102,33 @@
     return matching;
   }
 
-  public List<ExtensionElement> getExtensions(QName qname) {
-    List<ExtensionElement> matching = new ArrayList<ExtensionElement>();
+  @SuppressWarnings("unchecked")
+  public <T extends ExtensionElement>List<T> getExtensions(QName qname) {
+    List<T> matching = new ArrayList<T>();
     for (Iterator i = this.getChildrenWithName(qname); i.hasNext();) {
-      matching.add((ExtensionElement) i.next());
+      matching.add((T) i.next());
     }
     return matching;
   }
 
-  public ExtensionElement getExtension(QName qname) {
-    return (ExtensionElement) this.getFirstChildWithName(qname);
+  @SuppressWarnings("unchecked")
+  public <T extends ExtensionElement>T getExtension(QName qname) {
+    return (T) this.getFirstChildWithName(qname);
   }
   
   public void addExtension(ExtensionElement extension) {
     addChild((OMElement)extension);
   }
   
-  public ExtensionElement addExtension(QName qname) {
+  @SuppressWarnings("unchecked")
+  public <T extends ExtensionElement>T addExtension(QName qname) {
     FOMFactory fomfactory = (FOMFactory) factory;
-    return fomfactory.newExtensionElement(qname, this);
+    return (T)fomfactory.newExtensionElement(qname, this);
   }
   
-  public ExtensionElement addExtension(String namespace, String localpart, String prefix)
{
-    return addExtension(new QName(namespace, localpart, prefix));
+  @SuppressWarnings("unchecked")
+  public <T extends ExtensionElement>T addExtension(String namespace, String localpart,
String prefix) {
+    return (T)addExtension(new QName(namespace, localpart, prefix));
   }
 
   public StringElement addSimpleExtension(QName qname, String value) {



Mime
View raw message