abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1220344 - in /abdera/abdera2/core/src/main/java/org/apache/abdera2: model/ parser/axiom/ parser/filter/ writer/
Date Sun, 18 Dec 2011 07:42:36 GMT
Author: jmsnell
Date: Sun Dec 18 07:42:35 2011
New Revision: 1220344

URL: http://svn.apache.org/viewvc?rev=1220344&view=rev
Log:
findbugs fixes

Modified:
    abdera/abdera2/core/src/main/java/org/apache/abdera2/model/DateTimeWrapper.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDateTime.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDiv.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMElement.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMEntry.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMExtensibleElement.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFeed.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMMultipartCollection.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMXPath.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/StaxStreamWriter.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/UnacceptableException.java
    abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriter.java

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/model/DateTimeWrapper.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/model/DateTimeWrapper.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/model/DateTimeWrapper.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/model/DateTimeWrapper.java Sun Dec
18 07:42:35 2011
@@ -92,12 +92,12 @@ public abstract class DateTimeWrapper ex
 
     public Calendar getCalendar() {
         org.joda.time.DateTime ad = getValue();
-        return (ad != null) ? ad.toCalendar(Locale.getDefault()) : null;
+        return ad != null ? ad.toCalendar(Locale.getDefault()) : null;
     }
 
     public long getTime() {
         org.joda.time.DateTime ad = getValue();
-        return (ad != null) ? ad.getMillis() : null;
+        return ad != null ? ad.getMillis() : 0;
     }
 
     public String getString() {

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDateTime.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDateTime.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDateTime.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDateTime.java Sun
Dec 18 07:42:35 2011
@@ -142,12 +142,12 @@ public class FOMDateTime extends FOMElem
 
     public Calendar getCalendar() {
         org.joda.time.DateTime ad = getValue();
-        return (ad != null) ? ad.toCalendar(Locale.getDefault()) : null;
+        return ad != null ? ad.toCalendar(Locale.getDefault()) : null;
     }
 
     public long getTime() {
         org.joda.time.DateTime ad = getValue();
-        return (ad != null) ? ad.getMillis() : null;
+        return ad != null ? ad.getMillis() : 0;
     }
 
     public String getString() {

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDiv.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDiv.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDiv.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMDiv.java Sun Dec
18 07:42:35 2011
@@ -36,6 +36,7 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import static com.google.common.base.Preconditions.checkNotNull;
 
 public class FOMDiv extends FOMExtensibleElement implements Div {
 
@@ -116,7 +117,7 @@ public class FOMDiv extends FOMExtensibl
             } catch (Exception e) {
             }
             List<Object> list = new ArrayList<Object>();
-            for (Iterator<?> i = element.getChildren(); i.hasNext();)
+            for (Iterator<?> i = checkNotNull(element).getChildren(); i.hasNext();)
                 list.add(i.next());
             for (Object o : list) {
               OMNode node = (OMNode)o;
@@ -137,7 +138,8 @@ public class FOMDiv extends FOMExtensibl
             }
             writer.writeEndElement(); 
             return out.getBuffer().toString().substring(2);
-        } catch (Exception e) {
+        } catch (Throwable e) {
+          // ok to ignore
         }
         return "";
     }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMElement.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMElement.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMElement.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMElement.java Sun
Dec 18 07:42:35 2011
@@ -802,7 +802,7 @@ public class FOMElement extends OMElemen
             ByteArrayOutputStream out = new ByteArrayOutputStream();
             writeTo("prettyxml", out);
             return new String(out.toByteArray(), "UTF-8");
-        } catch (Exception e) {
+        } catch (Throwable e) {
             return toString();
         }
     }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMEntry.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMEntry.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMEntry.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMEntry.java Sun Dec
18 07:42:35 2011
@@ -55,6 +55,8 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 
+import com.google.common.collect.Iterables;
+
 import static com.google.common.base.Preconditions.*;
 
 @SuppressWarnings({"deprecation","rawtypes"})
@@ -101,12 +103,9 @@ public class FOMEntry extends FOMExtensi
       return person;
     }
     
-    @SuppressWarnings("unused")
     private boolean is_empty(List<?> list) {
       if (list == null) return true;
-      for (Object o : list)
-        return false;
-      return true;
+      return list.isEmpty();
     }
     
     public List<Person> getAuthorsInherited() {

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMExtensibleElement.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMExtensibleElement.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMExtensibleElement.java
(original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMExtensibleElement.java
Sun Dec 18 07:42:35 2011
@@ -227,6 +227,6 @@ public class FOMExtensibleElement extend
       QName qname = AnnoUtil.getQName(_class);
       if (qname == null)
         throw new IllegalArgumentException();
-      return (T)addExtension(_class,before);
+      return (T)addExtension(qname,before);
     }
 }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFeed.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFeed.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFeed.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMFeed.java Sun Dec
18 07:42:35 2011
@@ -17,6 +17,7 @@
  */
 package org.apache.abdera2.parser.axiom;
 
+import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.Iterator;
@@ -160,8 +161,10 @@ public class FOMFeed extends FOMSource i
         return this;
     }
 
-    private static class EditedComparator implements Comparator<Entry> {
-        private boolean new_first = true;
+    private static class EditedComparator 
+      implements Comparator<Entry>, Serializable {
+        private static final long serialVersionUID = -6721982957226015713L;
+        private final boolean new_first;
 
         EditedComparator(boolean new_first) {
             this.new_first = new_first;
@@ -185,8 +188,10 @@ public class FOMFeed extends FOMSource i
         }
     };
 
-    private static class UpdatedComparator implements Comparator<Entry> {
-        private boolean new_first = true;
+    private static class UpdatedComparator 
+      implements Comparator<Entry>, Serializable {
+        private static final long serialVersionUID = 8969184110080320529L;
+        private final boolean new_first;
 
         UpdatedComparator(boolean new_first) {
             this.new_first = new_first;

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMMultipartCollection.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMMultipartCollection.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMMultipartCollection.java
(original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMMultipartCollection.java
Sun Dec 18 07:42:35 2011
@@ -123,13 +123,15 @@ public class FOMMultipartCollection exte
         if (mediaRanges != null) {
             for (Map.Entry<String, String> entry : mediaRanges.entrySet()) {
                 if (!accepts(entry.getKey())) {
-                    try {
-                        Element accept = addSimpleExtension(ACCEPT, new MimeType(entry.getKey()).toString());
-                        if (entry.getValue() != null) {
-                            accept.setAttributeValue(ALTERNATE, entry.getValue());
-                        }
-                    } catch (Exception e) {
-                    }
+                    Element accept = 
+                      addSimpleExtension(
+                        ACCEPT,
+                        MimeTypeHelper.create(
+                          entry.getKey()).toString());
+                    if (entry.getValue() != null)
+                      accept.setAttributeValue(
+                        ALTERNATE, 
+                        entry.getValue());
                 }
             }
         }

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMXPath.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMXPath.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMXPath.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/FOMXPath.java Sun Dec
18 07:42:35 2011
@@ -86,20 +86,22 @@ public class FOMXPath extends AbstractXP
     private static FunctionContext getFunctionContext(Map<QName, Function> functions,
SimpleFunctionContext context) {
         if (context == null)
             context = new SimpleFunctionContext();
-        for (QName qname : functions.keySet()) {
-            Function function = functions.get(qname);
-            context.registerFunction(qname.getNamespaceURI(), qname.getLocalPart(), function);
-        }
+        for (Map.Entry<QName,Function> qname : functions.entrySet())
+          context.registerFunction(
+            qname.getKey().getNamespaceURI(), 
+            qname.getKey().getLocalPart(), 
+            qname.getValue());
         return context;
     }
 
     private static VariableContext getVariableContext(Map<QName, Object> variables,
SimpleVariableContext context) {
         if (context == null)
             context = new SimpleVariableContext();
-        for (QName qname : variables.keySet()) {
-            Object value = variables.get(qname);
-            context.setVariableValue(qname.getNamespaceURI(), qname.getLocalPart(), value);
-        }
+        for (Map.Entry<QName,Object> entry : variables.entrySet())
+          context.setVariableValue(
+            entry.getKey().getNamespaceURI(), 
+            entry.getKey().getLocalPart(), 
+            entry.getValue());
         return context;
     }
 
@@ -248,7 +250,7 @@ public class FOMXPath extends AbstractXP
         return numericValueOf(path, base, namespaces, functions, variables);
     }
 
-    public Map<QName, Function> getDefaultFunctions() {
+    public synchronized Map<QName, Function> getDefaultFunctions() {
         return new HashMap<QName, Function>(functions);
     }
 
@@ -257,7 +259,7 @@ public class FOMXPath extends AbstractXP
         this.functions.putAll(functions);
     }
 
-    public Map<QName, Object> getDefaultVariables() {
+    public synchronized Map<QName, Object> getDefaultVariables() {
         return new HashMap<QName, Object>(variables);
     }
 

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/StaxStreamWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/StaxStreamWriter.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/StaxStreamWriter.java
(original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/axiom/StaxStreamWriter.java
Sun Dec 18 07:42:35 2011
@@ -298,8 +298,7 @@ public class StaxStreamWriter extends Ab
                 writer.writeAttribute(prefix, namespace, name, value);
             } else if (namespace != null) {
                 if (!namespace.equals(Constants.XML_NS))
-                    ;
-                writeNamespace(prefix, namespace, true);
+                  writeNamespace(prefix, namespace, true);
                 writer.writeAttribute(namespace, name, value);
             } else {
                 writer.writeAttribute(name, value);

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/UnacceptableException.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/UnacceptableException.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/UnacceptableException.java
(original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/parser/filter/UnacceptableException.java
Sun Dec 18 07:42:35 2011
@@ -3,6 +3,7 @@ package org.apache.abdera2.parser.filter
 import javax.xml.namespace.QName;
 
 import org.apache.abdera2.common.misc.MoreFunctions;
+import static com.google.common.base.Preconditions.checkNotNull;
 
 public class UnacceptableException extends RuntimeException {
 
@@ -31,11 +32,11 @@ public class UnacceptableException exten
     else if (attribute == null)
       return String.format(
         "Unacceptable element [%s]", 
-        element.toString());
+        checkNotNull(element).toString());
     else 
       return String.format(
         "Unacceptable element [%s,%s]", 
-        element.toString(), 
+        checkNotNull(element).toString(), 
         attribute.toString());
   }
 

Modified: abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriter.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriter.java?rev=1220344&r1=1220343&r2=1220344&view=diff
==============================================================================
--- abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriter.java (original)
+++ abdera/abdera2/core/src/main/java/org/apache/abdera2/writer/AbstractWriter.java Sun Dec
18 07:42:35 2011
@@ -45,7 +45,7 @@ public abstract class AbstractWriter imp
         this.formats.add(format);
     }
 
-    public WriterOptions getDefaultWriterOptions() {
+    public synchronized WriterOptions getDefaultWriterOptions() {
         if (options == null)
             options = initDefaultWriterOptions();
 



Mime
View raw message