commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r509378 [1/2] - in /jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath: ./ ri/ ri/axes/ ri/compiler/ ri/model/ ri/model/beans/ ri/model/container/ ri/model/dom/ ri/model/dynabeans/ ri/model/dynamic/ ri/model/jdom/ servle...
Date Mon, 19 Feb 2007 23:24:49 GMT
Author: mbenson
Date: Mon Feb 19 15:24:43 2007
New Revision: 509378

URL: http://svn.apache.org/viewvc?view=rev&rev=509378
Log:
bulled through JXPath codebase to get a little better familiarity; tiny refactorings and removals of unnecessary elses, etc. along the way

Modified:
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/FunctionLibrary.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContextFactoryConfigurationError.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathException.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/Parser.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/QName.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/InitialContext.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Constant.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreOperation.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreOperationCompare.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Expression.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExpressionPath.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExtensionFunction.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/LocationPath.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/TreeCompiler.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/VariablePointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanAttributeIterator.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointerFactory.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/LangAttributePointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyIterator.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/container/ContainerPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/container/ContainerPointerFactory.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributeIterator.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMAttributePointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodeIterator.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMNodePointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dom/DOMPointerFactory.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPointerFactory.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynabeans/DynaBeanPropertyPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/dynamic/DynamicPropertyPointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMAttributeIterator.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMAttributePointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNamespacePointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMNodePointer.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/jdom/JDOMPointerFactory.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/KeywordVariables.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/servlet/ServletRequestAndContext.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/BasicTypeConverter.java
    jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/util/ValueUtils.java

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/FunctionLibrary.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/FunctionLibrary.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/FunctionLibrary.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/FunctionLibrary.java Mon Feb 19 15:24:43 2007
@@ -81,7 +81,7 @@
                 name,
                 parameters);
         }
-        else if (candidates instanceof List) {
+        if (candidates instanceof List) {
             List list = (List) candidates;
             int count = list.size();
             for (int i = 0; i < count; i++) {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContext.java Mon Feb 19 15:24:43 2007
@@ -530,7 +530,7 @@
      * affected by the locale.  By default, JXPath uses
      * <code>Locale.getDefault()</code>
      */
-    public void setLocale(Locale locale) {
+    public synchronized void setLocale(Locale locale) {
         this.locale = locale;
     }
 
@@ -539,14 +539,12 @@
      * the context has a parent, returns the parent's locale.
      * Otherwise, returns Locale.getDefault().
      */
-    public Locale getLocale() {
+    public synchronized Locale getLocale() {
         if (locale == null) {
             if (parentContext != null) {
                 return parentContext.getLocale();
             }
-            else {
-                locale = Locale.getDefault();
-            }
+            locale = Locale.getDefault();
         }
         return locale;
     }
@@ -559,7 +557,7 @@
      * 
      * @param name the format name or null for default format.
      */
-    public void setDecimalFormatSymbols(
+    public synchronized void setDecimalFormatSymbols(
         String name,
         DecimalFormatSymbols symbols) 
     {
@@ -572,12 +570,9 @@
     /**
      * @see #setDecimalFormatSymbols(String, DecimalFormatSymbols)
      */
-    public DecimalFormatSymbols getDecimalFormatSymbols(String name) {
+    public synchronized DecimalFormatSymbols getDecimalFormatSymbols(String name) {
         if (decimalFormats == null) {
-            if (parentContext != null) {
-                return parentContext.getDecimalFormatSymbols(name);
-            }
-            return null;
+            return parentContext == null ? null : parentContext.getDecimalFormatSymbols(name);
         }
         return (DecimalFormatSymbols) decimalFormats.get(name);
     }
@@ -591,7 +586,7 @@
      * <p>
      * By default, lenient = false
      */
-    public void setLenient(boolean lenient) {
+    public synchronized void setLenient(boolean lenient) {
         this.lenient = lenient;
         lenientSet = true;
     }
@@ -599,7 +594,7 @@
     /**
      * @see #setLenient(boolean)
      */
-    public boolean isLenient() {
+    public synchronized boolean isLenient() {
         if (!lenientSet && parentContext != null) {
             return parentContext.isLenient();
         }
@@ -638,10 +633,7 @@
 	 */
     public Object selectSingleNode(String xpath) {
     	Pointer pointer = getPointer(xpath);
-    	if (pointer == null) {
-    		return null;
-    	}
-		return pointer.getNode();
+        return pointer == null ? null : pointer.getNode();
     }
     
     /**
@@ -769,11 +761,9 @@
         if (manager != null) {
             return manager.getPointerByID(this, id);
         }
-        else {
-            throw new JXPathException(
-                "Cannot find an element by ID - "
-                    + "no IdentityManager has been specified");
-        }
+        throw new JXPathException(
+            "Cannot find an element by ID - "
+                + "no IdentityManager has been specified");
     }
 
     /**
@@ -803,11 +793,9 @@
         if (manager != null) {
             return manager.getPointerByKey(this, key, value);
         }
-        else {
-            throw new JXPathException(
-                "Cannot find an element by key - "
-                    + "no KeyManager has been specified");
-        }
+        throw new JXPathException(
+            "Cannot find an element by key - "
+                + "no KeyManager has been specified");
     }
 
     /**

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContextFactoryConfigurationError.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContextFactoryConfigurationError.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContextFactoryConfigurationError.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathContextFactoryConfigurationError.java Mon Feb 19 15:24:43 2007
@@ -91,12 +91,10 @@
      */
 
     public String getMessage () {
-        String message = super.getMessage ();
-
+        String message = super.getMessage();
         if (message == null && exception != null) {
             return exception.getMessage();
         }
-
         return message;
     }
 

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathException.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathException.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathException.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/JXPathException.java Mon Feb 19 15:24:43 2007
@@ -86,27 +86,16 @@
      */
     public String getMessage() {
         String message = super.getMessage();
-
-        if (exception != null) {
-            if (message == null) {
-                if (exception.getMessage() != null) {
-                    return exception.getMessage();
-                }
-                else {
-                    return exception.getClass().getName();
-                }
-            }
-            else {
-                if (exception.getMessage() != null) {
-                    return message + "; " + exception.getMessage();
-                }
-                else {
-                    return message + "; " + exception.getClass().getName();
-                }
-            }
+        if (exception == null) {
+            return message;
         }
-
-        return message;
+        StringBuffer buf = new StringBuffer();
+        if (message == null) {
+            buf.append(message).append("; ");
+        }
+        String eMsg = exception.getMessage();
+        buf.append(eMsg == null ? exception.getClass().getName() : eMsg);
+        return buf.toString();
     }
 
     /**

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/EvalContext.java Mon Feb 19 15:24:43 2007
@@ -75,10 +75,7 @@
      *  0 - does not require ordering
      */
     public int getDocumentOrder() {
-        if (parentContext != null && parentContext.isChildOrderingRequired()) {
-            return 1;
-        }
-        return 0;
+        return parentContext != null && parentContext.isChildOrderingRequired() ? 1 : 0;
     }
     
     /**
@@ -89,10 +86,7 @@
     public boolean isChildOrderingRequired() {
         // Default behavior: if this context needs to be ordered,
         // the children need to be ordered too
-        if (getDocumentOrder() != 0) {
-            return true;
-        }
-        return false;
+        return getDocumentOrder() != 0;
     }
 
     /**
@@ -102,16 +96,13 @@
         if (pointerIterator != null) {
             return pointerIterator.hasNext();
         }
-
         if (getDocumentOrder() != 0) {
             return constructIterator();
         }
-        else {
-            if (!done && !hasPerformedIteratorStep) {
-                performIteratorStep();
-            }
-            return !done;
+        if (!done && !hasPerformedIteratorStep) {
+            performIteratorStep();
         }
+        return !done;
     }
 
     /**
@@ -128,16 +119,14 @@
             }
             return pointerIterator.next();
         }
-        else {
-            if (!done && !hasPerformedIteratorStep) {
-                performIteratorStep();
-            }
-            if (done) {
-                throw new NoSuchElementException();
-            }
-            hasPerformedIteratorStep = false;
-            return getCurrentNodePointer();
+        if (!done && !hasPerformedIteratorStep) {
+            performIteratorStep();
+        }
+        if (done) {
+            throw new NoSuchElementException();
         }
+        hasPerformedIteratorStep = false;
+        return getCurrentNodePointer();
     }
 
     /**
@@ -174,7 +163,6 @@
             while (nextNode()) {
                 NodePointer pointer = getCurrentNodePointer();
                 if (!set.contains(pointer)) {
-//                    Pointer cln = (Pointer) pointer.clone();
                     set.add(pointer);
                     list.add(pointer);
                 }
@@ -249,12 +237,8 @@
 
     public String toString() {
         Pointer ptr = getContextNodePointer();
-        if (ptr == null) {
-            return "Empty expression context";
-        }
-        else {
-            return "Expression context [" + getPosition() + "] " + ptr.asPath();
-        }
+        return ptr == null ? "Empty expression context" : "Expression context [" + getPosition()
+                + "] " + ptr.asPath();
     }
 
     /**

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/InfoSetUtil.java Mon Feb 19 15:24:43 2007
@@ -40,30 +40,24 @@
         if (object instanceof String) {
             return (String) object;
         }
-        else if (object instanceof Number) {
+        if (object instanceof Number) {
             double d = ((Number) object).doubleValue();
             long l = ((Number) object).longValue();
-            if (d == l) {
-                return String.valueOf(l);
-            }
-            return String.valueOf(d);
+            return d == l ? String.valueOf(l) : String.valueOf(d);
         }
-        else if (object instanceof Boolean) {
+        if (object instanceof Boolean) {
             return ((Boolean) object).booleanValue() ? "true" : "false";
         }
-        else if (object == null) {
+        if (object == null) {
             return "";
         }
-        else if (object instanceof NodePointer) {
+        if (object instanceof NodePointer) {
             return stringValue(((NodePointer) object).getValue());
         }
-        else if (object instanceof EvalContext) {
+        if (object instanceof EvalContext) {
             EvalContext ctx = (EvalContext) object;
             Pointer ptr = ctx.getSingleNodePointer();
-            if (ptr != null) {
-                return stringValue(ptr);
-            }
-            return "";
+            return ptr == null ? "" : stringValue(ptr);
         }
         return String.valueOf(object);
     }
@@ -75,28 +69,23 @@
         if (object instanceof Number) {
             return (Number) object;
         }
-        else if (object instanceof Boolean) {
+        if (object instanceof Boolean) {
             return ((Boolean) object).booleanValue() ? ONE : ZERO;
         }
-        else if (object instanceof String) {
-            Double value;
+        if (object instanceof String) {
             try {
-                value = new Double((String) object);
+                return new Double((String) object);
             }
             catch (NumberFormatException ex) {
-                value = NOT_A_NUMBER;
+                return NOT_A_NUMBER;
             }
-            return value;
         }
-        else if (object instanceof EvalContext) {
+        if (object instanceof EvalContext) {
             EvalContext ctx = (EvalContext) object;
             Pointer ptr = ctx.getSingleNodePointer();
-            if (ptr != null) {
-                return number(ptr);
-            }
-            return NOT_A_NUMBER;
+            return ptr == null ? NOT_A_NUMBER : number(ptr);
         }
-        else if (object instanceof NodePointer) {
+        if (object instanceof NodePointer) {
             return number(((NodePointer) object).getValue());
         }
         return number(stringValue(object));
@@ -109,33 +98,27 @@
         if (object instanceof Number) {
             return ((Number) object).doubleValue();
         }
-        else if (object instanceof Boolean) {
+        if (object instanceof Boolean) {
             return ((Boolean) object).booleanValue() ? 0.0 : 1.0;
         }
-        else if (object instanceof String) {
+        if (object instanceof String) {
             if (object.equals("")) {
                 return 0.0;
             }
-
-            double value;
             try {
-                value = Double.parseDouble((String) object);
+                return Double.parseDouble((String) object);
             }
             catch (NumberFormatException ex) {
-                value = Double.NaN;
+                return Double.NaN;
             }
-            return value;
         }
-        else if (object instanceof NodePointer) {
+        if (object instanceof NodePointer) {
             return doubleValue(((NodePointer) object).getValue());
         }
-        else if (object instanceof EvalContext) {
+        if (object instanceof EvalContext) {
             EvalContext ctx = (EvalContext) object;
             Pointer ptr = ctx.getSingleNodePointer();
-            if (ptr != null) {
-                return doubleValue(ptr);
-            }
-            return Double.NaN;
+            return ptr == null ? Double.NaN : doubleValue(ptr);
         }
         return doubleValue(stringValue(object));
     }
@@ -148,21 +131,18 @@
             double value = ((Number) object).doubleValue();
             return value != 0 && value != -0 && !Double.isNaN(value);
         }
-        else if (object instanceof Boolean) {
+        if (object instanceof Boolean) {
             return ((Boolean) object).booleanValue();
         }
-        else if (object instanceof EvalContext) {
+        if (object instanceof EvalContext) {
             EvalContext ctx = (EvalContext) object;
             Pointer ptr = ctx.getSingleNodePointer();
-            if (ptr == null) {
-                return false;
-            }
-            return booleanValue(ptr);
+            return ptr == null ? false : booleanValue(ptr);
         }
-        else if (object instanceof String) {
+        if (object instanceof String) {
             return ((String) object).length() != 0;
         }
-        else if (object instanceof NodePointer) {
+        if (object instanceof NodePointer) {
             NodePointer pointer = (NodePointer) object;
             if (pointer instanceof VariablePointer) {
                 return booleanValue(pointer.getNode());
@@ -170,9 +150,6 @@
             pointer = pointer.getValuePointer();
             return pointer.isActual();
         }
-        else if (object == null) {
-            return false;
-        }
-        return true;
+        return object != null;
     }
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/JXPathContextReferenceImpl.java Mon Feb 19 15:24:43 2007
@@ -418,16 +418,13 @@
             }
             return (Pointer) result;
         }
-        else {
-            return NodePointer.newNodePointer(null, result, getLocale());
-        }
+        return NodePointer.newNodePointer(null, result, getLocale());
     }
 
     public void setValue(String xpath, Object value) {
         setValue(xpath, compileExpression(xpath), value);
     }
 
-
     public void setValue(String xpath, Expression expr, Object value) {
         try {
             setValue(xpath, expr, value, false);
@@ -700,7 +697,6 @@
         if (parentContext != null) {
             return parentContext.getDefaultNamespaceURI();
         }
-        
         return null;
     }
 
@@ -723,7 +719,6 @@
             catch (ClassNotFoundException ex) {
                 return null;
             }
-
             Class cls = Class.forName(className);
             return cls.newInstance();
         }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/NamespaceResolver.java Mon Feb 19 15:24:43 2007
@@ -86,7 +86,6 @@
         if (uri == null && parent != null) {
             return parent.getNamespaceURI(prefix);
         }
-//        System.err.println("For prefix " + prefix + " URI=" + uri);
         return uri;
     }
     

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/Parser.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/Parser.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/Parser.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/Parser.java Mon Feb 19 15:24:43 2007
@@ -74,13 +74,11 @@
         if (position <= 0) {
             return "at the beginning of the expression";
         }
-        else if (position >= expression.length()) {
+        if (position >= expression.length()) {
             return "- expression incomplete";
         }
-        else {
-            return "after: '"
-                + addEscapes(expression.substring(0, position)) + "'";
-        }
+        return "after: '"
+            + addEscapes(expression.substring(0, position)) + "'";
     }
 
     private static String addEscapes(String string) {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/QName.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/QName.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/QName.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/QName.java Mon Feb 19 15:24:43 2007
@@ -27,22 +27,19 @@
 public class QName {
     private String prefix;
     private String name;
+    private String qualifiedName;
 
     public QName(String qualifiedName) {
+        this.qualifiedName = qualifiedName;
         int index = qualifiedName.indexOf(':');
-        if (index == -1) {
-            prefix = null;
-            name = qualifiedName;
-        }
-        else {
-            prefix = qualifiedName.substring(0, index);
-            name = qualifiedName.substring(index + 1);
-        }
+        prefix = index < 0 ? null : qualifiedName.substring(0, index);
+        name = index < 0 ? qualifiedName : qualifiedName.substring(index + 1);
     }
 
     public QName(String prefix, String localName) {
         this.prefix = prefix;
         this.name = localName;
+        this.qualifiedName = prefix == null ? localName : prefix + ':' + localName;
     }
 
     public String getPrefix() {
@@ -54,10 +51,7 @@
     }
 
     public String toString() {
-        if (prefix != null) {
-            return prefix + ':' + name;
-        }
-        return name;
+        return qualifiedName;
     }
 
     public int hashCode() {
@@ -65,22 +59,12 @@
     }
 
     public boolean equals(Object object) {
-        if (!(object instanceof QName)) {
-            return false;
-        }
         if (this == object) {
             return true;
         }
-        QName that = (QName) object;
-        if (!this.name.equals(that.name)) {
-            return false;
-        }
-
-        if ((this.prefix == null && that.prefix != null)
-            || (this.prefix != null && !this.prefix.equals(that.prefix))) {
+        if (!(object instanceof QName)) {
             return false;
         }
-
-        return true;
+        return qualifiedName.equals(((QName) object).qualifiedName);
     }
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/ChildContext.java Mon Feb 19 15:24:43 2007
@@ -53,12 +53,7 @@
                 return null;
             }
         }
-        if (iterator != null) {
-            return iterator.getNodePointer();
-        }
-        else {
-            return null;
-        }
+        return iterator == null ? null : iterator.getNodePointer();
     }
 
     /**
@@ -101,10 +96,7 @@
         if (oldPosition == 0) {
             prepare();
         }
-        if (iterator == null) {
-            return false;
-        }
-        return iterator.setPosition(position);
+        return iterator == null ? false : iterator.setPosition(position);
     }
 
     /**
@@ -115,12 +107,7 @@
         if (parent == null) {
             return;
         }
-        if (startFromParentLocation) {
-            NodePointer pointer = parent.getParent();
-            iterator = pointer.childIterator(nodeTest, reverse, parent);
-        }
-        else {
-            iterator = parent.childIterator(nodeTest, reverse, null);
-        }
+        iterator = (startFromParentLocation ? parent.getParent() : parent).childIterator(nodeTest,
+                reverse, startFromParentLocation ? parent : null);
     }
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/InitialContext.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/InitialContext.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/InitialContext.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/InitialContext.java Mon Feb 19 15:24:43 2007
@@ -68,9 +68,7 @@
             }
             return false;
         }
-        else {
-            return position == 1;
-        }
+        return position == 1;
     }
 
     public boolean nextSet() {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/PredicateContext.java Mon Feb 19 15:24:43 2007
@@ -97,7 +97,7 @@
                     done = true;
                     return parentContext.setPosition(pos);
                 }
-                else if (InfoSetUtil.booleanValue(pred)) {
+                if (InfoSetUtil.booleanValue(pred)) {
                     position++;
                     return true;
                 }
@@ -158,9 +158,7 @@
         if (dynamicPropertyPointer != null) {
             return dynamicPropertyPointer.getValuePointer();
         }
-        else {
-            return parentContext.getCurrentNodePointer();
-        }
+        return parentContext.getCurrentNodePointer();
     }
 
     public void reset() {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/SimplePathInterpreter.java Mon Feb 19 15:24:43 2007
@@ -146,30 +146,24 @@
                     steps,
                     currentStep);
             }
-            else {
-                return doStepPredicatesPropertyOwner(
-                    context,
-                    (PropertyOwnerPointer) parent,
-                    steps,
-                    currentStep);
-            }
+            return doStepPredicatesPropertyOwner(
+                context,
+                (PropertyOwnerPointer) parent,
+                steps,
+                currentStep);
         }
-        else {
-            if (predicates == null || predicates.length == 0) {
-                return doStepNoPredicatesStandard(
-                    context,
-                    parent,
-                    steps,
-                    currentStep);
-            }
-            else {
-                return doStepPredicatesStandard(
-                    context,
-                    parent,
-                    steps,
-                    currentStep);
-            }
+        if (predicates == null || predicates.length == 0) {
+            return doStepNoPredicatesStandard(
+                context,
+                parent,
+                steps,
+                currentStep);
         }
+        return doStepPredicatesStandard(
+            context,
+            parent,
+            steps,
+            currentStep);
     }
 
     /**
@@ -197,11 +191,11 @@
                 steps,
                 currentStep);
         }
-        else if (currentStep == steps.length - 1) {
+        if (currentStep == steps.length - 1) {
             // If this is the last step - we are done, we found it
             return childPointer;
         }
-        else if (childPointer.isCollection()) {
+        if (childPointer.isCollection()) {
             // Iterate over all values and
             // execute remaining steps for each node,
             // looking for the best quality match
@@ -228,10 +222,8 @@
             // This step did not find anything - return a null pointer
             return createNullPointer(context, childPointer, steps, currentStep);
         }
-        else {
-            // Evaluate subsequent steps
-            return doStep(context, childPointer, steps, currentStep + 1);
-        }
+        // Evaluate subsequent steps
+        return doStep(context, childPointer, steps, currentStep + 1);
     }
 
     /**
@@ -268,19 +260,14 @@
                 if (quality == PERFECT_MATCH) {
                     return pointer;
                 }
-                else if (quality > bestQuality) {
+                if (quality > bestQuality) {
                     bestQuality = quality;
                     bestMatch = (NodePointer) pointer.clone();
                 }
             }
         }
-
-        if (bestMatch != null) {
-            return bestMatch;
-        }
-
-        return createNullPointer(
-                context, parentPointer, steps, currentStep);
+        return bestMatch != null ? bestMatch
+                : createNullPointer(context, parentPointer, steps, currentStep);
     }
 
     /**
@@ -334,9 +321,7 @@
             }
             return childPointer;
         }
-        else {
-            return parentPointer;
-        }
+        return parentPointer;
     }
 
     /**
@@ -440,15 +425,14 @@
                 predicates,
                 currentPredicate);
         }
-        else { // [index]
-            return doPredicateIndex(
-                context,
-                parent,
-                steps,
-                currentStep,
-                predicates,
-                currentPredicate);
-        }
+        // else [index]
+        return doPredicateIndex(
+            context,
+            parent,
+            steps,
+            currentStep,
+            predicates,
+            currentPredicate);
     }
 
     private static NodePointer doPredicateName(
@@ -668,11 +652,7 @@
         if (value instanceof Number) {
             return (int) (InfoSetUtil.doubleValue(value) + 0.5) - 1;
         }
-        else if (InfoSetUtil.booleanValue(value)) {
-            return 0;
-        }
-
-        return -1;
+        return InfoSetUtil.booleanValue(value) ? 0 : -1;
     }
 
     /**
@@ -824,15 +804,14 @@
             }
             return pointer.childIterator(nodeTest, false, null);
         }
-        else { // Compiler.AXIS_ATTRIBUTE
-            if (!(step.getNodeTest() instanceof NodeNameTest)) {
-                throw new UnsupportedOperationException(
-                    "Not supported node test for attributes: "
-                        + step.getNodeTest());
-            }
-            return pointer.attributeIterator(
-                ((NodeNameTest) step.getNodeTest()).getNodeName());
+        // else Compiler.AXIS_ATTRIBUTE
+        if (!(step.getNodeTest() instanceof NodeNameTest)) {
+            throw new UnsupportedOperationException(
+                "Not supported node test for attributes: "
+                    + step.getNodeTest());
         }
+        return pointer.attributeIterator(
+            ((NodeNameTest) step.getNodeTest()).getNodeName());
     }
 
     private static boolean isLangAttribute(QName name) {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/axes/UnionContext.java Mon Feb 19 15:24:43 2007
@@ -31,7 +31,7 @@
  */
 public class UnionContext extends NodeSetContext {
     private EvalContext contexts[];
-    private boolean prepared = false;
+    private boolean prepared;
 
     public UnionContext(EvalContext parentContext, EvalContext contexts[]) {
         super(parentContext, new BasicNodeSet());
@@ -39,10 +39,7 @@
     }
 
     public int getDocumentOrder() {
-        if (contexts.length > 1) {
-            return 1;
-        }
-        return super.getDocumentOrder();
+        return contexts.length > 1 ? 1 : super.getDocumentOrder();
     }
 
     public boolean setPosition(int position) {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Constant.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Constant.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Constant.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Constant.java Mon Feb 19 15:24:43 2007
@@ -17,6 +17,7 @@
 package org.apache.commons.jxpath.ri.compiler;
 
 import org.apache.commons.jxpath.ri.EvalContext;
+import org.apache.commons.jxpath.ri.InfoSetUtil;
 
 /**
  * A compile tree element containing a constant number or string.
@@ -63,17 +64,8 @@
 
     public String toString() {
         if (value instanceof Number) {
-            double doubleValue = ((Number) value).doubleValue();
-            long longValue = ((Number) value).longValue();
-            if (doubleValue == longValue) {
-                return String.valueOf(longValue);
-            }
-            else {
-                return String.valueOf(doubleValue);
-            }
-        }
-        else {
-            return "'" + value + "'";
+            return InfoSetUtil.stringValue(value);
         }
+        return "'" + value + "'";
     }
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreFunction.java Mon Feb 19 15:24:43 2007
@@ -483,31 +483,29 @@
             }
             return s1.substring((int) from - 1);
         }
-        else {
-            double length =
-                InfoSetUtil.doubleValue(getArg3().computeValue(context));
-            length = Math.round(length);
-            if (length < 0) {
-                return "";
-            }
-
-            double to = from + length;
-            if (to < 1) {
-                return "";
-            }
+        double length =
+            InfoSetUtil.doubleValue(getArg3().computeValue(context));
+        length = Math.round(length);
+        if (length < 0) {
+            return "";
+        }
 
-            if (to > s1.length() + 1) {
-                if (from < 1) {
-                    from = 1;
-                }
-                return s1.substring((int) from - 1);
-            }
+        double to = from + length;
+        if (to < 1) {
+            return "";
+        }
 
+        if (to > s1.length() + 1) {
             if (from < 1) {
                 from = 1;
             }
-            return s1.substring((int) from - 1, (int) (to - 1));
+            return s1.substring((int) from - 1);
+        }
+
+        if (from < 1) {
+            from = 1;
         }
+        return s1.substring((int) from - 1, (int) (to - 1));
     }
 
     protected Object functionStringLength(EvalContext context) {
@@ -618,7 +616,7 @@
         if (v == null) {
             return ZERO;
         }
-        else if (v instanceof EvalContext) {
+        if (v instanceof EvalContext) {
             double sum = 0.0;
             EvalContext ctx = (EvalContext) v;
             while (ctx.hasNext()) {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreOperation.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreOperation.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreOperation.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreOperation.java Mon Feb 19 15:24:43 2007
@@ -57,46 +57,31 @@
         if (args.length == 1) {
             return getSymbol() + parenthesize(args[0], false);
         }
-        else {
-            StringBuffer buffer = new StringBuffer();
-            for (int i = 0; i < args.length; i++) {
-                if (i > 0) {
-                    buffer.append(' ');
-                    buffer.append(getSymbol());
-                    buffer.append(' ');
-                }
-                buffer.append(parenthesize(args[i], i == 0));
+        StringBuffer buffer = new StringBuffer();
+        for (int i = 0; i < args.length; i++) {
+            if (i > 0) {
+                buffer.append(' ');
+                buffer.append(getSymbol());
+                buffer.append(' ');
             }
-            return buffer.toString();
+            buffer.append(parenthesize(args[i], i == 0));
         }
+        return buffer.toString();
     }
     
     private String parenthesize(Expression expression, boolean left) {
+        String s = expression.toString();
         if (!(expression instanceof CoreOperation)) {
-            return expression.toString();
+            return s;
         }
-        CoreOperation op = (CoreOperation) expression;
-        int myPrecedence = getPrecedence();
-        int thePrecedence = op.getPrecedence();
+        int compared = getPrecedence() - ((CoreOperation) expression).getPrecedence();
 
-        boolean needParens = true;
-        if (myPrecedence < thePrecedence) {
-            needParens = false;
+        if (compared < 0) {
+            return s;
         }
-        else if (myPrecedence == thePrecedence) {
-            if (isSymmetric()) {
-                needParens = false;
-            }
-            else {
-                needParens = !left;
-            }
-        }
-
-        if (needParens) {
-            return "(" + expression.toString() + ")";
-        }
-        else {
-            return expression.toString();
+        if (compared == 0 && (isSymmetric() || left)) {
+            return s;
         }
+        return '(' + s + ')';
     }    
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreOperationCompare.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreOperationCompare.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreOperationCompare.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/CoreOperationCompare.java Mon Feb 19 15:24:43 2007
@@ -73,13 +73,12 @@
         if ((l instanceof Iterator) && !(r instanceof Iterator)) {
             return contains((Iterator) l, r);
         }
-        else if (!(l instanceof Iterator) && (r instanceof Iterator)) {
+        if (!(l instanceof Iterator) && (r instanceof Iterator)) {
             return contains((Iterator) r, l);
         }
-        else if (l instanceof Iterator && r instanceof Iterator) {
+        if (l instanceof Iterator && r instanceof Iterator) {
             return findMatch((Iterator) l, (Iterator) r);
         }
-
         return equal(l, r);
     }
 
@@ -129,17 +128,14 @@
         if (l instanceof Boolean || r instanceof Boolean) {
             return (InfoSetUtil.booleanValue(l) == InfoSetUtil.booleanValue(r));
         }
-        else if (l instanceof Number || r instanceof Number) {
+        if (l instanceof Number || r instanceof Number) {
             return (InfoSetUtil.doubleValue(l) == InfoSetUtil.doubleValue(r));
         }
-        else if (l instanceof String || r instanceof String) {
+        if (l instanceof String || r instanceof String) {
             return (
                 InfoSetUtil.stringValue(l).equals(InfoSetUtil.stringValue(r)));
         }
-        else if (l == null) {
-            return r == null;
-        }
-        return l.equals(r);
+        return l != null && l.equals(r);
     }
 
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Expression.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Expression.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Expression.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Expression.java Mon Feb 19 15:24:43 2007
@@ -141,10 +141,7 @@
 
         public Object next() {
             Object o = iterator.next();
-            if (o instanceof Pointer) {
-                return ((Pointer) o).getValue();
-            }
-            return o;
+            return o instanceof Pointer ? ((Pointer) o).getValue() : o;
         }
 
         public void remove() {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExpressionPath.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExpressionPath.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExpressionPath.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExpressionPath.java Mon Feb 19 15:24:43 2007
@@ -180,11 +180,6 @@
                 context = new PredicateContext(context, predicates[j]);
             }
         }
-        if (firstMatch) {
-            return getSingleNodePointerForSteps(context);
-        }
-        else {
-            return evalSteps(context);
-        }
+        return firstMatch ? getSingleNodePointerForSteps(context) : evalSteps(context);
     }
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExtensionFunction.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExtensionFunction.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExtensionFunction.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/ExtensionFunction.java Mon Feb 19 15:24:43 2007
@@ -24,7 +24,7 @@
 import org.apache.commons.jxpath.ri.QName;
 
 /**
- * Represents  an element of the parse tree representing an extension function
+ * Represents an element of the parse tree representing an extension function
  * call.
  *
  * @author Dmitri Plotnikov
@@ -92,9 +92,6 @@
     }
     
     private Object convert(Object object) {
-        if (object instanceof EvalContext) {
-            return ((EvalContext) object).getValue();
-        }
-        return object;
+        return object instanceof EvalContext ? ((EvalContext) object).getValue() : object;
     }  
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/LocationPath.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/LocationPath.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/LocationPath.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/LocationPath.java Mon Feb 19 15:24:43 2007
@@ -37,11 +37,7 @@
     }
 
     public boolean computeContextDependent() {
-        if (!absolute) {
-            return true;
-        }
-
-        return super.computeContextDependent();
+        return !absolute || super.computeContextDependent();
     }
 
     public String toString() {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/Path.java Mon Feb 19 15:24:43 2007
@@ -60,7 +60,6 @@
                 }
             }
         }
-
         return false;
     }
 
@@ -101,13 +100,12 @@
             }
             return areBasicPredicates(step.getPredicates());
         }
-        else if (step.getAxis() == Compiler.AXIS_CHILD
+        if (step.getAxis() == Compiler.AXIS_CHILD
                 || step.getAxis() == Compiler.AXIS_ATTRIBUTE) {
             NodeTest nodeTest = step.getNodeTest();
             if (!(nodeTest instanceof NodeNameTest)){
                 return false;
             }
-            
             if (((NodeNameTest) nodeTest).isWildcard()) {
                 return false;
             }
@@ -157,9 +155,7 @@
                 ptr,
                 steps);
         }
-        else {
-            return searchForPath(context);
-        }
+        return searchForPath(context);
     }
 
     /**

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/TreeCompiler.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/TreeCompiler.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/TreeCompiler.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/compiler/TreeCompiler.java Mon Feb 19 15:24:43 2007
@@ -84,20 +84,13 @@
     }
 
     public Object equal(Object left, Object right) {
-        if (isNameAttributeTest((Expression) left)) {
-            return new NameAttributeTest((Expression) left, (Expression) right);
-        }
-        else {
-            return new CoreOperationEqual(
-                (Expression) left,
-                (Expression) right);
-        }
+        return isNameAttributeTest((Expression) left)
+                ? new NameAttributeTest((Expression) left, (Expression) right)
+                : new CoreOperationEqual((Expression) left, (Expression) right);
     }
 
     public Object notEqual(Object left, Object right) {
-        return new CoreOperationNotEqual(
-            (Expression) left,
-            (Expression) right);
+        return new CoreOperationNotEqual((Expression) left, (Expression) right);
     }
 
     public Object minus(Object argument) {
@@ -117,18 +110,15 @@
     }
 
     public Object and(Object arguments[]) {
-        return new CoreOperationAnd(
-            toExpressionArray(arguments));
+        return new CoreOperationAnd(toExpressionArray(arguments));
     }
 
     public Object or(Object arguments[]) {
-        return new CoreOperationOr(
-            toExpressionArray(arguments));
+        return new CoreOperationOr(toExpressionArray(arguments));
     }
 
     public Object union(Object[] arguments) {
-        return new CoreOperationUnion(
-            toExpressionArray(arguments));
+        return new CoreOperationUnion(toExpressionArray(arguments));
     }
 
     public Object locationPath(boolean absolute, Object[] steps) {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/NodePointer.java Mon Feb 19 15:24:43 2007
@@ -237,10 +237,7 @@
      */
     public NodePointer getValuePointer() {
         NodePointer ivp = getImmediateValuePointer();
-        if (ivp != this) {
-            return ivp.getValuePointer();
-        }
-        return this;
+        return ivp == this ? this : ivp.getValuePointer();
     }
 
     /**
@@ -267,12 +264,7 @@
      * a Pointer for this path cannot be obtained at all - actual or otherwise.
      */
     public boolean isActual() {
-        if (index == WHOLE_COLLECTION) {
-            return true;
-        }
-        else {
-            return index >= 0 && index < getLength();
-        }
+        return index == WHOLE_COLLECTION || index >= 0 && index < getLength();
     }
 
     /**
@@ -308,12 +300,7 @@
     
     public Object getRootNode() {
         if (rootNode == null) {
-            if (parent != null) {
-                rootNode = parent.getRootNode();
-            }
-            else {
-                rootNode = getImmediateNode();
-            }
+            rootNode = parent == null ? getImmediateNode() : parent.getRootNode();
         }
         return rootNode;
     }
@@ -344,7 +331,7 @@
         if (test == null) {
             return true;
         }
-        else if (test instanceof NodeNameTest) {
+        if (test instanceof NodeNameTest) {
             if (isContainer()) {
                 return false;
             }
@@ -369,23 +356,12 @@
             }
             return testName.getName().equals(nodeName.getName());
         }
-        else if (test instanceof NodeTypeTest) {
-            if (((NodeTypeTest) test).getNodeType()
-                == Compiler.NODE_TYPE_NODE) {
-                return isNode();
-            }
-        }
-        return false;
+        return test instanceof NodeTypeTest
+                && ((NodeTypeTest) test).getNodeType() == Compiler.NODE_TYPE_NODE && isNode();
     }
 
     private static boolean equalStrings(String s1, String s2) {
-        if (s1 == null && s2 != null) {
-            return false;
-        }
-        if (s1 != null && !s1.equals(s2)) {
-            return false;
-        }
-        return true;
+        return s1 == s2 || s1 != null && s1.equals(s2);
     }
 
     /**
@@ -509,10 +485,8 @@
         NodePointer startWith) 
     {
         NodePointer valuePointer = getValuePointer();
-        if (valuePointer != null && valuePointer != this) {
-            return valuePointer.childIterator(test, reverse, startWith);
-        }
-        return null;
+        return valuePointer == null || valuePointer == this ? null
+                : valuePointer.childIterator(test, reverse, startWith);
     }
 
     /**
@@ -522,10 +496,8 @@
      */
     public NodeIterator attributeIterator(QName qname) {
         NodePointer valuePointer = getValuePointer();
-        if (valuePointer != null && valuePointer != this) {
-            return valuePointer.attributeIterator(qname);
-        }
-        return null;
+        return valuePointer == null || valuePointer == this ? null
+                : valuePointer.attributeIterator(qname);
     }
 
     /**
@@ -570,11 +542,7 @@
         }
 
         String namespace = getNamespaceURI(prefix);
-        if (namespace == null) {
-            return false; // undefined namespace
-        }
-
-        return namespace.equals(getDefaultNamespaceURI());
+        return namespace != null && namespace.equals(getDefaultNamespaceURI());
     }
 
     protected String getDefaultNamespaceURI() {
@@ -652,10 +620,7 @@
         // Let it throw a ClassCastException
         NodePointer pointer = (NodePointer) object;
         if (parent == pointer.parent) {
-            if (parent == null) {
-                return 0;
-            }
-            return parent.compareChildNodePointers(this, pointer);
+            return parent == null ? 0 : parent.compareChildNodePointers(this, pointer);
         }
 
         // Task 1: find the common parent
@@ -682,17 +647,11 @@
     {
         if (depth1 < depth2) {
             int r = compareNodePointers(p1, depth1, p2.parent, depth2 - 1);
-            if (r != 0) {
-                return r;
-            }
-            return -1;
+            return r == 0 ? -1 : r;
         }
-        else if (depth1 > depth2) {
+        if (depth1 > depth2) {
             int r = compareNodePointers(p1.parent, depth1 - 1, p2, depth2);
-            if (r != 0) {
-                return r;
-            }
-            return 1;
+            return r == 0 ? 1 : r;
         }
         if (p1 == null && p2 == null) {
             return 0;
@@ -707,8 +666,7 @@
                     "Cannot compare pointers that do not belong to the same tree: '"
                             + p1 + "' and '" + p2 + "'");
         }
-        int r =
-            compareNodePointers(p1.parent, depth1 - 1, p2.parent, depth2 - 1);
+        int r = compareNodePointers(p1.parent, depth1 - 1, p2.parent, depth2 - 1);
         if (r != 0) {
             return r;
         }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/VariablePointer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/VariablePointer.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/VariablePointer.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/VariablePointer.java Mon Feb 19 15:24:43 2007
@@ -70,8 +70,7 @@
     
     public boolean isLeaf() {
         Object value = getNode();
-        return value == null
-            || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic();
+        return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic();
     }
     
     public boolean isCollection() {
@@ -81,12 +80,8 @@
 
     public Object getImmediateNode() {
         Object value = getBaseValue();
-        if (index != WHOLE_COLLECTION) {
-            return ValueUtils.getValue(value, index);
-        }
-        else {
-            return ValueUtils.getValue(value);
-        }
+        return index == WHOLE_COLLECTION ? ValueUtils.getValue(value)
+                : ValueUtils.getValue(value, index);
     }
 
     public void setValue(Object value) {
@@ -135,10 +130,7 @@
     public int getLength() {
         if (actual) {
             Object value = getBaseValue();
-            if (value == null) {
-                return 1;
-            }
-            return ValueUtils.getLength(value);
+            return value == null ? 1 : ValueUtils.getLength(value);
         }
         return 0;
     }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanAttributeIterator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanAttributeIterator.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanAttributeIterator.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanAttributeIterator.java Mon Feb 19 15:24:43 2007
@@ -48,12 +48,7 @@
     }
 
     public NodePointer getNodePointer() {
-        if (includeXmlLang && position == 1) {
-            return new LangAttributePointer(parent);
-        }
-        else {
-            return super.getNodePointer();
-        }
+        return includeXmlLang && position == 1 ? new LangAttributePointer(parent) : super.getNodePointer();
     }
 
     public int getPosition() {
@@ -63,16 +58,8 @@
     public boolean setPosition(int position) {
         this.position = position;
         if (includeXmlLang) {
-            if (position == 1) {
-                return true;
-            }
-            else {
-                return super.setPosition(position - 1);
-            }
-        }
-        else {
-            this.position = position;
-            return super.setPosition(position);
+            return position == 1 || super.setPosition(position - 1);
         }
+        return super.setPosition(position);
     }
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPointer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPointer.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPointer.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/BeanPointer.java Mon Feb 19 15:24:43 2007
@@ -148,20 +148,20 @@
         if (parent != null) {
             return super.asPath();
         }
-        else if (bean == null) {
+        if (bean == null) {
             return "null()";
         }
-        else if (bean instanceof Number) {
+        if (bean instanceof Number) {
             String string = bean.toString();
             if (string.endsWith(".0")) {
                 string = string.substring(0, string.length() - 2);
             }
             return string;
         }
-        else if (bean instanceof Boolean) {
+        if (bean instanceof Boolean) {
             return ((Boolean) bean).booleanValue() ? "true()" : "false()";
         }
-        else if (bean instanceof String) {
+        if (bean instanceof String) {
             return "'" + bean + "'";
         }
         return "/";

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointer.java Mon Feb 19 15:24:43 2007
@@ -67,8 +67,7 @@
 
     public boolean isLeaf() {
         Object value = getNode();
-        return value == null
-            || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic();
+        return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic();
     }
 
     public boolean isContainer() {
@@ -76,12 +75,8 @@
     }
 
     public Object getImmediateNode() {
-        if (index != WHOLE_COLLECTION) {
-            return ValueUtils.getValue(collection, index);
-        }
-        else {
-            return ValueUtils.getValue(collection);
-        }
+        return index == WHOLE_COLLECTION ? ValueUtils.getValue(collection)
+                : ValueUtils.getValue(collection, index);
     }
 
     public void setValue(Object value) {
@@ -174,30 +169,20 @@
                 reverse,
                 startWith);
         }
-        else {
-            return getValuePointer().childIterator(test, reverse, startWith);
-        }
+        return getValuePointer().childIterator(test, reverse, startWith);
     }
 
     public NodeIterator attributeIterator(QName name) {
-        if (index == WHOLE_COLLECTION) {
-            return new CollectionAttributeNodeIterator(this, name);
-        }
-        return getValuePointer().attributeIterator(name);
+        return index == WHOLE_COLLECTION ? new CollectionAttributeNodeIterator(this, name)
+                : getValuePointer().attributeIterator(name);
     }
 
     public NodeIterator namespaceIterator() {
-        if (index == WHOLE_COLLECTION) {
-            return null;
-        }
-        return getValuePointer().namespaceIterator();
+        return index == WHOLE_COLLECTION ? null : getValuePointer().namespaceIterator();
     }
 
     public NodePointer namespacePointer(String namespace) {
-        if (index == WHOLE_COLLECTION) {
-            return null;
-        }
-        return getValuePointer().namespacePointer(namespace);
+        return index == WHOLE_COLLECTION ? null : getValuePointer().namespacePointer(namespace);
     }
 
     public boolean testNode(NodeTest test) {
@@ -205,15 +190,10 @@
             if (test == null) {
                 return true;
             }
-            else if (test instanceof NodeNameTest) {
+            if (test instanceof NodeNameTest) {
                 return false;
             }
-            else if (test instanceof NodeTypeTest) {
-                if (((NodeTypeTest) test).getNodeType() == Compiler.NODE_TYPE_NODE) {
-                    return true;
-                }
-            }
-            return false;
+            return test instanceof NodeTypeTest && ((NodeTypeTest) test).getNodeType() == Compiler.NODE_TYPE_NODE;
         }
         return getValuePointer().testNode(test);
     }
@@ -248,7 +228,6 @@
                 buffer.append("/");
             }
         }
-        
         return buffer.toString();
     }
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointerFactory.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointerFactory.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointerFactory.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/CollectionPointerFactory.java Mon Feb 19 15:24:43 2007
@@ -42,10 +42,7 @@
         Object bean,
         Locale locale) 
     {
-        if (ValueUtils.isCollection(bean)) {
-            return new CollectionPointer(bean, locale);
-        }
-        return null;
+        return ValueUtils.isCollection(bean) ? new CollectionPointer(bean, locale) : null;
     }
 
     public NodePointer createNodePointer(
@@ -53,9 +50,6 @@
         QName name,
         Object bean) 
     {
-        if (ValueUtils.isCollection(bean)) {
-            return new CollectionPointer(parent, bean);
-        }
-        return null;
+        return ValueUtils.isCollection(bean) ? new CollectionPointer(parent, bean) : null;
     }
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/LangAttributePointer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/LangAttributePointer.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/LangAttributePointer.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/LangAttributePointer.java Mon Feb 19 15:24:43 2007
@@ -88,15 +88,7 @@
     }
 
     public boolean equals(Object object) {
-        if (object == this) {
-            return true;
-        }
-
-        if (!(object instanceof LangAttributePointer)) {
-            return false;
-        }
-
-        return true;
+        return object instanceof LangAttributePointer;
     }
 
     public boolean testNode(NodeTest test) {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPointer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPointer.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPointer.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPointer.java Mon Feb 19 15:24:43 2007
@@ -76,20 +76,16 @@
         if (parent != null) {
             return parent.createPath(context, value).getValuePointer();
         }
-        else {
-            throw new UnsupportedOperationException(
-                "Cannot create the root object: " + asPath());
-        }
+        throw new UnsupportedOperationException(
+            "Cannot create the root object: " + asPath());
     }
 
     public NodePointer createPath(JXPathContext context) {
         if (parent != null) {
             return parent.createPath(context).getValuePointer();
         }
-        else {
-            throw new UnsupportedOperationException(
-                "Cannot create the root object: " + asPath());
-        }
+        throw new UnsupportedOperationException(
+            "Cannot create the root object: " + asPath());
     }
 
     public NodePointer createChild(
@@ -123,19 +119,14 @@
         }
 
         NullPointer other = (NullPointer) object;
-        return (name == null && other.name == null)
-            || (name != null && name.equals(other.name));
+        return name == other.name || name != null && name.equals(other.name);
     }
 
     public String asPath() {
         if (id != null) {
             return "id(" + id + ")";
         }
-
-        if (parent != null) {
-            return super.asPath();
-        }
-        return "null()";
+        return parent == null ? "null()" : super.asPath();
     }
 
     public int getLength() {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/NullPropertyPointer.java Mon Feb 19 15:24:43 2007
@@ -84,7 +84,7 @@
                     + asPath()
                     + ", the target object is null");
         }
-        else if (parent instanceof PropertyOwnerPointer &&
+        if (parent instanceof PropertyOwnerPointer &&
                 ((PropertyOwnerPointer) parent).
                     isDynamicPropertyDeclarationSupported()){
             // If the parent property owner can create
@@ -107,29 +107,27 @@
         if (isAttribute()) {
             return newParent.createAttribute(context, getName());
         }
-        else {
-            if (parent instanceof NullPointer && parent.equals(newParent)) {
-                throw createBadFactoryException(context.getFactory());
-            }
-            // Consider these two use cases:
-            // 1. The parent pointer of NullPropertyPointer is 
-            //    a PropertyOwnerPointer other than NullPointer. When we call 
-            //    createPath on it, it most likely returns itself. We then
-            //    take a PropertyPointer from it and get the PropertyPointer
-            //    to expand the collection for the corresponding property.
-            //
-            // 2. The parent pointer of NullPropertyPointer is a NullPointer.
-            //    When we call createPath, it may return a PropertyOwnerPointer
-            //    or it may return anything else, like a DOMNodePointer.
-            //    In the former case we need to do exactly what we did in use 
-            //    case 1.  In the latter case, we simply request that the 
-            //    non-property pointer expand the collection by itself.
-            if (newParent instanceof PropertyOwnerPointer) {
-                PropertyOwnerPointer pop = (PropertyOwnerPointer) newParent;
-                newParent = pop.getPropertyPointer();
-            }
-            return newParent.createChild(context, getName(), getIndex());
+        if (parent instanceof NullPointer && parent.equals(newParent)) {
+            throw createBadFactoryException(context.getFactory());
+        }
+        // Consider these two use cases:
+        // 1. The parent pointer of NullPropertyPointer is 
+        //    a PropertyOwnerPointer other than NullPointer. When we call 
+        //    createPath on it, it most likely returns itself. We then
+        //    take a PropertyPointer from it and get the PropertyPointer
+        //    to expand the collection for the corresponding property.
+        //
+        // 2. The parent pointer of NullPropertyPointer is a NullPointer.
+        //    When we call createPath, it may return a PropertyOwnerPointer
+        //    or it may return anything else, like a DOMNodePointer.
+        //    In the former case we need to do exactly what we did in use 
+        //    case 1.  In the latter case, we simply request that the 
+        //    non-property pointer expand the collection by itself.
+        if (newParent instanceof PropertyOwnerPointer) {
+            PropertyOwnerPointer pop = (PropertyOwnerPointer) newParent;
+            newParent = pop.getPropertyPointer();
         }
+        return newParent.createChild(context, getName(), getIndex());
     }
 
     public NodePointer createPath(JXPathContext context, Object value) {
@@ -139,16 +137,14 @@
             pointer.setValue(value);
             return pointer;
         }
-        else {
-            if (parent instanceof NullPointer && parent.equals(newParent)) {
-                throw createBadFactoryException(context.getFactory());
-            }
-            if (newParent instanceof PropertyOwnerPointer) {
-                PropertyOwnerPointer pop = (PropertyOwnerPointer) newParent;
-                newParent = pop.getPropertyPointer();
-            }
-            return newParent.createChild(context, getName(), index, value);
+        if (parent instanceof NullPointer && parent.equals(newParent)) {
+            throw createBadFactoryException(context.getFactory());
         }
+        if (newParent instanceof PropertyOwnerPointer) {
+            PropertyOwnerPointer pop = (PropertyOwnerPointer) newParent;
+            newParent = pop.getPropertyPointer();
+        }
+        return newParent.createChild(context, getName(), index, value);
     }
     
     public NodePointer createChild(
@@ -197,17 +193,15 @@
         if (!byNameAttribute) {
             return super.asPath();
         }
-        else {
-            StringBuffer buffer = new StringBuffer();
-            buffer.append(getImmediateParentPointer().asPath());
-            buffer.append("[@name='");
-            buffer.append(escape(getPropertyName()));
-            buffer.append("']");
-            if (index != WHOLE_COLLECTION) {
-                buffer.append('[').append(index + 1).append(']');
-            }
-            return buffer.toString();
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(getImmediateParentPointer().asPath());
+        buffer.append("[@name='");
+        buffer.append(escape(getPropertyName()));
+        buffer.append("']");
+        if (index != WHOLE_COLLECTION) {
+            buffer.append('[').append(index + 1).append(']');
         }
+        return buffer.toString();
     }
 
     private String escape(String string) {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyIterator.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyIterator.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyIterator.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyIterator.java Mon Feb 19 15:24:43 2007
@@ -123,12 +123,7 @@
     }
 
     public boolean setPosition(int position) {
-        if (name != null) {
-            return setPositionIndividualProperty(position);
-        }
-        else {
-            return setPositionAllProperties(position);
-        }
+        return name == null ? setPositionAllProperties(position) : setPositionIndividualProperty(position);
     }
 
     private boolean setPositionIndividualProperty(int position) {

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyOwnerPointer.java Mon Feb 19 15:24:43 2007
@@ -45,28 +45,17 @@
         if (test == null) {
             return createNodeIterator(null, reverse, startWith);
         }
-        else if (test instanceof NodeNameTest) {
+        if (test instanceof NodeNameTest) {
             NodeNameTest nodeNameTest = (NodeNameTest) test;
             QName testName = nodeNameTest.getNodeName();
-            String property;
             if (!isDefaultNamespace(testName.getPrefix())) {
                 return null;
             }
-            else if (nodeNameTest.isWildcard()) {
-                property = null;
-            }
-            else {
-                property = testName.getName();
-            }
+            String property = nodeNameTest.isWildcard() ? null : testName.getName();
             return createNodeIterator(property, reverse, startWith);
         }
-        else if (test instanceof NodeTypeTest) {
-            if (((NodeTypeTest) test).getNodeType()
-                == Compiler.NODE_TYPE_NODE) {
-                return createNodeIterator(null, reverse, startWith);
-            }
-        }
-        return null;
+        return test instanceof NodeTypeTest && ((NodeTypeTest) test).getNodeType() == Compiler.NODE_TYPE_NODE
+                ? createNodeIterator(null, reverse, startWith) : null;
     }
 
     public NodeIterator createNodeIterator(
@@ -101,12 +90,8 @@
     private Object value = UNINITIALIZED;
     public Object getImmediateNode() {
         if (value == UNINITIALIZED) {
-            if (index == WHOLE_COLLECTION) {
-                value = ValueUtils.getValue(getBaseValue());
-            }
-            else {
-                value = ValueUtils.getValue(getBaseValue(), index);
-            }
+            value = index == WHOLE_COLLECTION ? ValueUtils.getValue(getBaseValue())
+                    : ValueUtils.getValue(getBaseValue(), index);
         }
         return value;
     }
@@ -128,10 +113,8 @@
                     "Cannot setValue of an object that is not "
                         + "some other object's property");
             }
-            else {
-                throw new JXPathInvalidAccessException(
-                    "The specified collection element does not exist: " + this);
-            }
+            throw new JXPathInvalidAccessException(
+                "The specified collection element does not exist: " + this);
         }
         else {
             throw new UnsupportedOperationException(
@@ -170,12 +153,7 @@
         NodePointer pointer1,
         NodePointer pointer2) 
     {
-        int r =
-            pointer1.getName().toString().compareTo(
-                pointer2.getName().toString());
-        if (r != 0) {
-            return r;
-        }
-        return pointer1.getIndex() - pointer2.getIndex();
+        int r = pointer1.getName().toString().compareTo(pointer2.getName().toString());
+        return r == 0 ? pointer1.getIndex() - pointer2.getIndex() : r;
     }
 }

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/beans/PropertyPointer.java Mon Feb 19 15:24:43 2007
@@ -91,12 +91,8 @@
     private Object value = UNINITIALIZED;
     public Object getImmediateNode() {
         if (value == UNINITIALIZED) {
-            if (index == WHOLE_COLLECTION) {
-                value = ValueUtils.getValue(getBaseValue());
-            }
-            else {
-                value = ValueUtils.getValue(getBaseValue(), index);
-            }
+            value = index == WHOLE_COLLECTION ? ValueUtils.getValue(getBaseValue())
+                    : ValueUtils.getValue(getBaseValue(), index);
         }
         return value;
     }
@@ -108,9 +104,8 @@
     
     public boolean isLeaf() {
         Object value = getNode();
-        return value == null
-            || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic();
-    }    
+        return value == null || JXPathIntrospector.getBeanInfo(value.getClass()).isAtomic();
+    }
 
     /**
      * If the property contains a collection, then the length of that
@@ -201,10 +196,8 @@
         }
 
         PropertyPointer other = (PropertyPointer) object;
-        if (parent != other.parent) {
-            if (parent == null || !parent.equals(other.parent)) {
-                return false;
-            }
+        if (parent != other.parent && (parent == null || !parent.equals(other.parent))) {
+            return false;
         }
 
         if (getPropertyIndex() != other.getPropertyIndex()

Modified: jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/container/ContainerPointer.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/container/ContainerPointer.java?view=diff&rev=509378&r1=509377&r2=509378
==============================================================================
--- jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/container/ContainerPointer.java (original)
+++ jakarta/commons/proper/jxpath/trunk/src/java/org/apache/commons/jxpath/ri/model/container/ContainerPointer.java Mon Feb 19 15:24:43 2007
@@ -69,11 +69,8 @@
     
     public int getLength() {
         Object value = getBaseValue();
-        if (value == null) {
-            return 1;
-        }
-        return ValueUtils.getLength(value);
-    }    
+        return value == null ? 1 : ValueUtils.getLength(value);
+    }
 
     public boolean isLeaf() {
         return getValuePointer().isLeaf();
@@ -82,16 +79,9 @@
     public Object getImmediateNode() {
         Object value = getBaseValue();
         if (index != WHOLE_COLLECTION) {
-            if (index >= 0 && index < getLength()) {
-                return ValueUtils.getValue(value, index);
-            }
-            else {
-                return null;
-            }
-        }
-        else {
-            return ValueUtils.getValue(value);
+            return index >= 0 && index < getLength() ? ValueUtils.getValue(value, index) : null;
         }
+        return ValueUtils.getValue(value);
     }
 
     public void setValue(Object value) {
@@ -102,8 +92,7 @@
     public NodePointer getImmediateValuePointer() {
         if (valuePointer == null) {
             Object value = getImmediateNode();
-            valuePointer =
-                NodePointer.newChildNodePointer(this, getName(), value);
+            valuePointer = NodePointer.newChildNodePointer(this, getName(), value);
         }
         return valuePointer;
     }
@@ -161,9 +150,6 @@
     }
     
     public String asPath() {
-        if (parent != null) {
-            return parent.asPath();
-        }
-        return "/";
+        return parent == null ? "/" : parent.asPath();
     }
  }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message