abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roo...@apache.org
Subject svn commit: r434209 - in /incubator/abdera/java/trunk: client/src/main/java/org/apache/abdera/protocol/cache/ parser/src/main/java/org/apache/abdera/parser/stax/ parser/src/main/java/org/apache/abdera/parser/stax/util/
Date Wed, 23 Aug 2006 22:06:54 GMT
Author: rooneg
Date: Wed Aug 23 15:06:51 2006
New Revision: 434209

URL: http://svn.apache.org/viewvc?rev=434209&view=rev
Log:
Remove some redundant null checks found by FindBugs.

[ in parser/src/main/java ]

* org/apache/abdera/parser/stax/FOMCategory.java
  (setScheme): Remove redundant check for null scheme.

* org/apache/abdera/parser/stax/FOMDateTime.java
  (setValue,
   setDate,
   setCalendar,
   setString): Remove redundant null checks.

* org/apache/abdera/parser/stax/FOMElement.java
  (getResolvedBaseUri): Remove useless null check and block that could never
   be run.

* org/apache/abdera/parser/stax/util/FOMExtensionIterator.java
  (isQNamesMatch): Don't dereference elementQName and then later on
   check for it to be null.

[ in client/src/main/java ]

* org/apache/abdera/protocol/cache/CacheBase.java
  (getDisposition): Move check for null options up before we dereference it.

Modified:
    incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CacheBase.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategory.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDateTime.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java

Modified: incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CacheBase.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CacheBase.java?rev=434209&r1=434208&r2=434209&view=diff
==============================================================================
--- incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CacheBase.java
(original)
+++ incubator/abdera/java/trunk/client/src/main/java/org/apache/abdera/protocol/cache/CacheBase.java
Wed Aug 23 15:06:51 2006
@@ -35,14 +35,14 @@
     RequestOptions options) {
       CacheKey key = getCacheKey(uri, options);
       CachedResponse response = get(key);
-      if (response != null) {
+      if (response != null && options != null) {
         String[] pragma = options.getHeaders("Pragma");
         for (String s: pragma) {
           if (s.equalsIgnoreCase("no-cache")) {
             return CacheDisposition.TRANSPARENT;
           }
         }
-        if (options != null && options.getNoCache()) 
+        if (options.getNoCache()) 
           return CacheDisposition.TRANSPARENT;
         else if (response.isNoCache())
           return CacheDisposition.STALE;
@@ -52,14 +52,14 @@
           return CacheDisposition.STALE;
         else if (response.getCachedTime() != -1) {
           if (response.isFresh()) {
-            long maxAge = (options != null) ? options.getMaxAge() : -1;
+            long maxAge = options.getMaxAge();
             long currentAge = response.getCurrentAge();
             if (maxAge != -1) {
               return (maxAge > currentAge) ? 
                 CacheDisposition.FRESH:
                 CacheDisposition.STALE;
             }
-            long minFresh = (options != null) ? options.getMinFresh() : -1;
+            long minFresh = options.getMinFresh();
             if (minFresh != -1) {
               long lifetime = response.getFreshnessLifetime();
               long age = currentAge;
@@ -69,7 +69,7 @@
             }
             return CacheDisposition.FRESH;
           } else {
-            long maxStale = (options != null) ? options.getMaxStale() : -1;
+            long maxStale = options.getMaxStale();
             if (maxStale != -1) {
               long howStale = response.getHowStale();
               return (maxStale < howStale) ? 

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategory.java?rev=434209&r1=434208&r2=434209&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategory.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategory.java
Wed Aug 23 15:06:51 2006
@@ -112,7 +112,7 @@
 
   public void setScheme(String scheme) throws URISyntaxException {
     if (scheme != null)
-      setAttributeValue(SCHEME, (scheme != null) ? new URI(scheme).toString() : null);
+      setAttributeValue(SCHEME, new URI(scheme).toString());
     else 
       removeAttribute(SCHEME);
   }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDateTime.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDateTime.java?rev=434209&r1=434208&r2=434209&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDateTime.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDateTime.java
Wed Aug 23 15:06:51 2006
@@ -102,21 +102,21 @@
 
   public void setValue(AtomDate dateTime) {
     if (dateTime != null)
-      setText((dateTime != null) ? dateTime.getValue() : null);
+      setText(dateTime.getValue());
     else 
       _removeAllChildren();
   }
 
   public void setDate(Date date) {
     if (date != null)
-      setText((date != null) ? AtomDate.valueOf(date).getValue() : null);
+      setText(AtomDate.valueOf(date).getValue());
     else 
       _removeAllChildren();
   }
 
   public void setCalendar(Calendar date) {
     if (date != null)
-      setText((date != null) ? AtomDate.valueOf(date).getValue() : null);
+      setText(AtomDate.valueOf(date).getValue());
     else 
       _removeAllChildren();
   }
@@ -127,7 +127,7 @@
 
   public void setString(String date) {
     if (date != null)
-      setText((date != null) ? AtomDate.valueOf(date).getValue() : null);
+      setText(AtomDate.valueOf(date).getValue());
     else 
       _removeAllChildren();
   }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java?rev=434209&r1=434208&r2=434209&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Wed Aug 23 15:06:51 2006
@@ -199,11 +199,7 @@
     else if (parent instanceof Document)
       baseUri = ((Document)parent).getBaseUri();
     if (uri != null && baseUri != null) {
-      if (baseUri != null) {
-        uri = baseUri.resolve(uri);
-      } else {
-        return getBaseUri();
-      }
+      uri = baseUri.resolve(uri);
     } else if (uri == null) {
       uri = baseUri;
     }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java?rev=434209&r1=434208&r2=434209&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/FOMExtensionIterator.java
Wed Aug 23 15:06:51 2006
@@ -105,14 +105,11 @@
   }
 
   private boolean isQNamesMatch(QName elementQName, String namespace) {
-      String elns = elementQName.getNamespaceURI();
+      String elns = elementQName == null ? "" : elementQName.getNamespaceURI();
       boolean namespaceURIMatch =
               (namespace == null)
               || (namespace == "")
-              ||
-              ((elementQName != null)
-              &&
-              elns.equals(namespace));
+              || elns.equals(namespace);
       if (!namespaceURIMatch && extns != null && !elns.equals(extns))
         return false;
       else 



Mime
View raw message