abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roo...@apache.org
Subject svn commit: r422121 - /incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java
Date Sat, 15 Jul 2006 00:56:48 GMT
Author: rooneg
Date: Fri Jul 14 17:56:48 2006
New Revision: 422121

URL: http://svn.apache.org/viewvc?rev=422121&view=rev
Log:
Clean up the FOMFactory implementation a bit.

[ in parser/src/main/java/org/apache/abdera/parser/stax ]

* FOMFactory.java
  Import some more specific exceptions.
  (FOMFactory.newDocument): Add an @SuppressWarnings("unchecked").
  (FOMFactory.newContent,
   FOMFactory.newDefaultGenerator): Catch a more specific exception, and
   add a comment to indicate that the exception case can't actually happen.
  (FOMFactory.newCategory, FOMFactory.newContent,
   FOMFactory.newContent, FOMFactory.newID,
   FOMFactory.newLink, FOMFactory.newSource,
   FOMFactory.newText, FOMFactory.newElement,
   FOMFactory.newControl, FOMFactory.newPublished,
   FOMFactory.newUpdated, FOMFactory.newIcon,
   FOMFactory.newLogo, FOMFactory.newUri,
   FOMFactory.newAuthor, FOMFactory.newContributor,
   FOMFactory.newTitle, FOMFactory.newSubtitle,
   FOMFactory.newSummary, FOMFactory.newRights,
   FOMFactory.newName, FOMFactory.newEmail): Stop casting null to something
   else, it's not necessary to call the correct method in these cases.
  (FOMFactory.newExtensionElement,
   FOMFactory._newInstance): Remove an unnecessary cast.

Modified:
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMFactory.java

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=422121&r1=422120&r2=422121&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
Fri Jul 14 17:56:48 2006
@@ -21,8 +21,10 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.net.URISyntaxException;
 
 import javax.activation.MimeType;
+import javax.activation.MimeTypeParseException;
 import javax.xml.namespace.QName;
 
 import org.apache.abdera.factory.ExtensionFactory;
@@ -112,6 +114,7 @@
       return _newInstance(FOMDocument.class, CONSTRUCTORS[9], this, parserWrapper);
   }
   
+  @SuppressWarnings("unchecked")
   public <T extends Element>Document<T> newDocument(
     T root, 
     OMXMLParserWrapper parserWrapper) {
@@ -211,7 +214,7 @@
   }
   
   public Category newCategory() {
-    return newCategory((Element)null);
+    return newCategory(null);
   }
   
   public Category newCategory(
@@ -235,7 +238,7 @@
   
   public Content newContent(Type type) {
     if (type == null) type = Content.Type.TEXT;
-    return newContent(type, (Element)null);
+    return newContent(type, null);
   }
   
   public Content newContent(
@@ -248,12 +251,12 @@
       try {
         if (type.equals(Content.Type.XML))
           content.setMimeType("application/xml");
-      } catch (Exception e) {}
+      } catch (MimeTypeParseException e) { /* Can't happen */ }
       return content;
   }
   
   public Content newContent(MimeType mediaType) {
-    return newContent(mediaType, (Element)null);
+    return newContent(mediaType, null);
   }
   
   public Content newContent(
@@ -265,7 +268,7 @@
     Content content = newContent(type, parent);
     try {
       content.setMimeType(mediaType.toString());
-    } catch (Exception e) {}
+    } catch (MimeTypeParseException e) { /* Can't happen */ }
     return content;
   }
 
@@ -300,7 +303,7 @@
       generator.setText(Version.APP_NAME);
       try {
         generator.setUri(Version.URI);
-      } catch (Exception e) {}
+      } catch (URISyntaxException e) { /* Can't happen */ }
       return generator;
   }
   
@@ -321,7 +324,7 @@
   }
   
   public IRI newID() {
-    return newID((Element)null);
+    return newID(null);
   }
   
   public IRI newID(
@@ -354,7 +357,7 @@
   }
   
   public Link newLink() {
-    return newLink((Element)null);
+    return newLink(null);
   }
   
   public Link newLink(
@@ -385,7 +388,7 @@
   }
   
   public Source newSource() {
-    return newSource((Element)null);
+    return newSource(null);
   }
   
   public Source newSource(
@@ -406,7 +409,7 @@
   public Text newText(
     QName qname,
     Text.Type type) {
-    return newText(qname, type, (Element)null);
+    return newText(qname, type, null);
   }
   
   public Text newText(
@@ -419,7 +422,7 @@
   }
   
   public Element newElement(QName qname) {
-    return newElement(qname, (Element)null);
+    return newElement(qname, null);
   }
   
   public Element newElement(
@@ -470,8 +473,7 @@
               element = ((FOMExtensionFactory)factory).newExtensionElement(
                 qname, (Base)parent, this, parserWrapper);
             } else {
-              element = ((FOMExtensionFactory)factory).newExtensionElement(
-                qname, (Base)parent, this); 
+              element = factory.newExtensionElement(qname, (Base)parent, this); 
             }
         }
       }
@@ -496,7 +498,7 @@
   }
   
   public Control newControl() {
-    return newControl((Element)null);
+    return newControl(null);
   }
    
   public Control newControl(Element parent) {
@@ -511,7 +513,7 @@
   }
 
   public DateTime newPublished() {
-    return newPublished((Element)null);
+    return newPublished(null);
   }
   
   public DateTime newPublished(Element parent) {
@@ -519,7 +521,7 @@
   }
 
   public DateTime newUpdated() {
-    return newUpdated((Element)null);
+    return newUpdated(null);
   }
   
   public DateTime newUpdated(Element parent) {
@@ -527,7 +529,7 @@
   }
 
   public IRI newIcon() {
-    return newIcon((Element)null);
+    return newIcon(null);
   }
   
   public IRI newIcon(Element parent) {
@@ -535,7 +537,7 @@
   }
 
   public IRI newLogo() {
-    return newLogo((Element)null);
+    return newLogo(null);
   }
   
   public IRI newLogo(Element parent) {
@@ -543,7 +545,7 @@
   }
 
   public IRI newUri() {
-    return newUri((Element)null);
+    return newUri(null);
   }
   
   public IRI newUri(Element parent) {
@@ -551,7 +553,7 @@
   }
 
   public Person newAuthor() {
-    return newAuthor((Element)null);
+    return newAuthor(null);
   }
   
   public Person newAuthor(Element parent) {
@@ -559,7 +561,7 @@
   }
 
   public Person newContributor() {
-    return newContributor((Element)null);
+    return newContributor(null);
   }
 
   public Person newContributor(
@@ -576,7 +578,7 @@
   }
   
   public Text newTitle(Text.Type type) {
-    return newTitle(type, (Element)null);
+    return newTitle(type, null);
   }
   
   public Text newTitle(Text.Type type, Element parent) {
@@ -592,7 +594,7 @@
   }
   
   public Text newSubtitle(Text.Type type) {
-    return newSubtitle(type, (Element)null);
+    return newSubtitle(type, null);
   }
   
   public Text newSubtitle(Text.Type type, Element parent) {
@@ -608,7 +610,7 @@
   }
   
   public Text newSummary(Text.Type type) {
-    return newSummary(type, (Element)null);
+    return newSummary(type, null);
   }
   
   public Text newSummary(Text.Type type, Element parent) {
@@ -624,7 +626,7 @@
   }
   
   public Text newRights(Text.Type type) {
-    return newRights(type, (Element)null);
+    return newRights(type, null);
   }
   
   public Text newRights(Text.Type type, Element parent) {
@@ -632,7 +634,7 @@
   }
   
   public Element newName() {
-    return newName((Element)null);
+    return newName(null);
   }
   
   public Element newName(Element parent) {
@@ -640,7 +642,7 @@
   }
 
   public Element newEmail() {
-    return newEmail((Element)null);
+    return newEmail(null);
   }
   
   public Element newEmail(Element parent) {
@@ -850,7 +852,7 @@
       return (T) _altclass.getConstructor(argtypes).newInstance(args);
     } catch (Exception e) {
       try {
-        return (T) _class.getConstructor(argtypes).newInstance(args);
+        return _class.getConstructor(argtypes).newInstance(args);
       } catch (Exception ex) {
         ex.printStackTrace();
       }



Mime
View raw message