jicarilla-sandbox/platform/components/collections/src/java/org/jicarilla/collections DefaultNode.java,1.2,1.3 DefaultXMLNodeHandler.java,1.2,1.3 Node.java,1.2,1.3 NodeBuilder.java,1.2,1.3 NodeUtil.java,1.2,1.3

[email protected]
Newsgroups gmane.comp.java.jicarilla.cvs
Message-ID <[email protected]>
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/components/collections/src/java/org/jicarilla/collections
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2537/components/collections/src/java/org/jicarilla/collections

Modified Files:
	DefaultNode.java DefaultXMLNodeHandler.java Node.java 
	NodeBuilder.java NodeUtil.java 
Log Message:
Ran some code analysis tools on the code and changed approximately 200 small things based on that. Nothing shocking (I hope!)

Index: DefaultNode.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/collections/src/java/org/jicarilla/collections/DefaultNode.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- DefaultNode.java	4 Jan 2004 16:10:17 -0000	1.2
+++ DefaultNode.java	26 Feb 2004 16:51:54 -0000	1.3
@@ -56,16 +56,16 @@
     //  Constructors
     // ----------------------------------------------------------------------
 
-    public DefaultNode( String name )
+    public DefaultNode( final String name )
     {
         this( name, null );
     }
-    public DefaultNode( String name, List children )
+    public DefaultNode( final String name, final List children )
     {
         this( name, children, null );
     }
 
-    public DefaultNode( String name, List children, Map attributes )
+    public DefaultNode( final String name, final List children, final Map attributes )
     {
         if( children == null )
             m_children = new ArrayList();
@@ -95,7 +95,7 @@
                 m_children.hashCode() + m_attributes.hashCode();
     }
 
-    public boolean equals( Object o )
+    public boolean equals( final Object o )
     {
         try
         {
@@ -104,7 +104,7 @@
                 return true;
             if( !(o instanceof Node) )
                 return false;
-            Node n = (Node)o;
+            final Node n = (Node)o;
 
             // complex
             if(     !equalSizes( n ) ||
@@ -126,7 +126,7 @@
         }
     }
 
-    protected boolean equalAttributes( Node n )
+    protected boolean equalAttributes( final Node n )
     {
         if( entrySet().size() != n.entrySet().size() )
             return false;
@@ -154,7 +154,7 @@
         return true;
     }
 
-    protected boolean equalChildren( Node n )
+    protected boolean equalChildren( final Node n )
     {
         final List myChildren = childrenToList();
         final List otherChildren = n.childrenToList();
@@ -171,7 +171,7 @@
         return true;
     }
 
-    protected boolean equalNames( Node n )
+    protected boolean equalNames( final Node n )
     {
         boolean result = true;
 
@@ -188,7 +188,7 @@
         return result;
     }
 
-    protected boolean equalContents( Node n )
+    protected boolean equalContents( final Node n )
     {
         boolean result = true;
         if( getContents() != null )
@@ -204,7 +204,7 @@
         return result;
     }
 
-    protected boolean equalSizes( Node n )
+    protected boolean equalSizes( final Node n )
     {
         return n.size() == size();
     }
@@ -238,7 +238,7 @@
     {
         return m_name;
     }
-    public String setName( String s )
+    public String setName( final String s )
     {
         final String old = getName();
         m_name = s;
@@ -249,7 +249,7 @@
     {
         return m_contents;
     }
-    public Object setContents( Object o )
+    public Object setContents( final Object o )
     {
         final Object old = getContents();
         m_contents = o;
@@ -260,22 +260,22 @@
     //  Interface: Node / List
     // ----------------------------------------------------------------------
 
-    public boolean addChild( Node n )
+    public boolean addChild( final Node n )
     {
         return m_children.add( n );
     }
 
-    public boolean addChildren( Collection c )
+    public boolean addChildren( final Collection c )
     {
         return m_children.addAll( c );
     }
 
-    public boolean containsChild( Node n )
+    public boolean containsChild( final Node n )
     {
         return m_children.contains( n );
     }
 
-    public boolean containsChildren( Collection c )
+    public boolean containsChildren( final Collection c )
     {
         return m_children.containsAll( c );
     }
@@ -285,7 +285,7 @@
         return (Node[])m_children.toArray( new Node[m_children.size()] );
     }
 
-    public Node[] childrenToArray( Object[] o )
+    public Node[] childrenToArray( final Object[] o )
     {
         return (Node[])m_children.toArray( o );
     }
@@ -300,12 +300,12 @@
         return m_children.iterator();
     }
 
-    public boolean removeChild( Node n )
+    public boolean removeChild( final Node n )
     {
         return m_children.remove( n );
     }
 
-    public boolean removeChildren( Collection c )
+    public boolean removeChildren( final Collection c )
     {
         return m_children.removeAll( c );
     }
@@ -314,32 +314,32 @@
     //  Interface: Map
     // ----------------------------------------------------------------------
 
-    public boolean containsKey( Object key )
+    public boolean containsKey( final Object key )
     {
         return m_attributes.containsKey( key );
     }
 
-    public boolean containsValue( Object value )
+    public boolean containsValue( final Object value )
     {
         return m_attributes.containsValue( value );
     }
 
-    public Object get( Object key )
+    public Object get( final Object key )
     {
         return m_attributes.get( key );
     }
 
-    public Object put( Object key, Object value )
+    public Object put( final Object key, final Object value )
     {
         return m_attributes.put( key, value );
     }
 
-    public Object remove( Object key )
+    public Object remove( final Object key )
     {
         return m_attributes.remove( key );
     }
 
-    public void putAll( Map t )
+    public void putAll( final Map t )
     {
         m_attributes.putAll( t );
     }

Index: DefaultXMLNodeHandler.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/collections/src/java/org/jicarilla/collections/DefaultXMLNodeHandler.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- DefaultXMLNodeHandler.java	4 Jan 2004 16:10:17 -0000	1.2
+++ DefaultXMLNodeHandler.java	26 Feb 2004 16:51:54 -0000	1.3
@@ -63,6 +63,7 @@
 import java.util.ArrayList;
 import java.util.BitSet;
 import java.util.Iterator;
+import java.util.List;
 
 /**
  * Helps {@link NodeBuilder} build {@link Node} Trees out of sax events.
@@ -91,9 +92,9 @@
     protected final static String PRESERVE_SPACE_ON = "preserve";
 
     /** Element stack. */
-    protected final ArrayList m_elements = new ArrayList( EXPECTED_DEPTH );
+    protected final List m_elements = new ArrayList( EXPECTED_DEPTH );
     /** Value stack. */
-    protected final ArrayList m_values = new ArrayList( EXPECTED_DEPTH );
+    protected final List m_values = new ArrayList( EXPECTED_DEPTH );
     /**
      * Contains true at index <code>n</code> if space in the context with depth
      * <code>n</code> is to be preserved.
@@ -143,7 +144,7 @@
      * 
      * @throws org.xml.sax.SAXException if an error occurs
      */
-    public void characters( final char[] ch, int start, int end )
+    public void characters( final char[] ch, final int start, final int end )
             throws SAXException
     {
         // it is possible to play micro-optimization here by doing
@@ -189,7 +190,7 @@
         if( node.childrenToList().size() == 0 )
         {
             // leaf node; always add contents
-            String finishedValue;
+            final String finishedValue;
             if( m_preserveSpace.get( depth ) )
             {
                 finishedValue = accumulatedValue;
@@ -256,7 +257,7 @@
         final int depth = m_elements.size();
 
         // add to parent
-        boolean hasParent = (depth > 0);
+        final boolean hasParent = (depth > 0);
         if( hasParent )
         {
             addChildToParent( (DefaultNode)m_elements.get( depth - 1 ), node );
@@ -286,10 +287,10 @@
         parent.addChild( node );
     }
 
-    private void handleSpacePreservation( DefaultNode node, boolean hasParent )
+    private void handleSpacePreservation( final DefaultNode node, final boolean hasParent )
     {
         // depth of new node (node has been added)
-        int depth = m_elements.size() - 1;
+        final int depth = m_elements.size() - 1;
         boolean preserveSpace;
 
         if( hasParent ) // inherits parent's space preservation policy
@@ -302,14 +303,14 @@
         }
 
         // look for xml:space attribute
-        Iterator it = node.keySet().iterator();
+        final Iterator it = node.keySet().iterator();
         while( it.hasNext() )
         {
-            String name = (String)it.next();
+            final String name = (String)it.next();
 
             if( name.equals( PRESERVE_SPACE_KEY ) )
             {
-                String value = (String)node.get( name );
+                final String value = (String)node.get( name );
                 it.remove();
                 preserveSpace = PRESERVE_SPACE_ON.equals( value );
             }

Index: Node.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/collections/src/java/org/jicarilla/collections/Node.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Node.java	4 Jan 2004 16:10:17 -0000	1.2
+++ Node.java	26 Feb 2004 16:51:54 -0000	1.3
@@ -49,9 +49,9 @@
     Object setContents( Object o );
 
     // override Map
-    boolean isEmpty();
-    void clear();
-    int size();
+    //boolean isEmpty();
+    //void clear();
+    //int size();
 
     // List
     boolean addChild( Node n );

Index: NodeBuilder.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/collections/src/java/org/jicarilla/collections/NodeBuilder.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- NodeBuilder.java	4 Jan 2004 16:10:17 -0000	1.2
+++ NodeBuilder.java	26 Feb 2004 16:51:54 -0000	1.3
@@ -53,10 +53,10 @@
     public final static String HANDLER_CONTEXT_KEY =
             "urn:jicarilla:context-key:org.jicarilla.collections.AbstractXMLContextHandler:handler";*/
 
-    private SAXParser m_parser = null;
-    private AbstractXMLNodeHandler m_handler = null;
+    private SAXParser m_parser;
+    private AbstractXMLNodeHandler m_handler;
 
-    public NodeBuilder( SAXParser parser, AbstractXMLNodeHandler handler )
+    public NodeBuilder( final SAXParser parser, final AbstractXMLNodeHandler handler )
     {
         Assert.assertNotNull( "parser argument may not be null", parser );
         Assert.assertNotNull( "handler argument may not be null", handler );
@@ -65,7 +65,7 @@
         m_handler = handler;
     }
 
-    public Node treeFromXML( InputStream stream )
+    public Node treeFromXML( final InputStream stream )
             throws SAXException, IOException
     {
         getHandler().recycle();

Index: NodeUtil.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/collections/src/java/org/jicarilla/collections/NodeUtil.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- NodeUtil.java	4 Jan 2004 16:10:17 -0000	1.2
+++ NodeUtil.java	26 Feb 2004 16:51:54 -0000	1.3
@@ -57,7 +57,7 @@
      * @param node
      * @return
      */
-    public static Context toAvalonContext( Node node )
+    public static Context toAvalonContext( final Node node )
     {
         final DefaultContext c = new DefaultContext();
 
@@ -85,11 +85,11 @@
         return c;
     }
 
-    public static Node fromAvalonConfiguration( Configuration c )
+    public static Node fromAvalonConfiguration( final Configuration c )
     {
         return fromAvalonConfiguration( c, "value" );
     }
-    public static Node fromAvalonConfiguration( Configuration c, Object valueKey )
+    public static Node fromAvalonConfiguration( final Configuration c, final Object valueKey )
     {
         final DefaultNode node = new DefaultNode( c.getName() );
 
@@ -102,7 +102,7 @@
         catch( ConfigurationException ce ) {}
 
         // copy attributes as values
-        String[] names = c.getAttributeNames();
+        final String[] names = c.getAttributeNames();
         for( int i = 0; i < names.length; i++ )
         {
             try
@@ -113,7 +113,7 @@
         }
 
         // copy children as children
-        Configuration[] children = c.getChildren();
+        final Configuration[] children = c.getChildren();
         for( int i = 0; i < children.length; i++ )
         {
             // recurse
@@ -123,7 +123,7 @@
         return node;
     }
 
-    public static Configuration toAvalonConfiguration( Node node )
+    public static Configuration toAvalonConfiguration( final Node node )
     {
         final DefaultConfiguration c = new DefaultConfiguration( node.getName() );
 
@@ -150,23 +150,23 @@
         return c;
     }
 
-    public static Parameters toParameters( Node node )
+    public static Parameters toParameters( final Node node )
     {
         return Parameters.fromProperties( NodeUtil.toProperties( node ) );
     }
-    public static Node fromParameters( Parameters parameters )
+    public static Node fromParameters( final Parameters parameters )
     {
         return NodeUtil.fromProperties( Parameters.toProperties( parameters ) );
     }
 
-    public static Element toElement( Node node )
+    public static Element toElement( final Node node )
     {
         // defer to the implementation of this stuff in avalon-framework
         return ConfigurationUtil.toElement(
                 NodeUtil.toAvalonConfiguration( node ) );
     }
 
-    public static Node fromElement( Element element )
+    public static Node fromElement( final Element element )
     {
         // defer to the implementation of this stuff in avalon-framework
         return NodeUtil.fromAvalonConfiguration(
@@ -185,7 +185,7 @@
      * @param node
      * @return
      */
-    public static Properties toProperties( Node node )
+    public static Properties toProperties( final Node node )
     {
         final Properties p = new Properties();
 
@@ -228,34 +228,38 @@
      * @param p
      * @return
      */
-    public static Node fromProperties( Properties p )
+    public static Node fromProperties( final Properties p )
     {
         return fromProperties( p, null, "." );
     }
 
-    public static Node fromProperties( Properties p, String prefix, String separator )
+    public static Node fromProperties( final Properties p, final String prefix, final String separator )
     {
-        DefaultNode root = new DefaultNode("");
+        final DefaultNode root = new DefaultNode("");
 
-        Iterator it = p.keySet().iterator();
+        final Iterator it = p.keySet().iterator();
         while( it.hasNext() )
         {
             String key = it.next().toString();
             key = key.trim();
-            if( key != null && key.startsWith(prefix) )
+
+            if( key == null )
+                continue;
+
+            if( key.startsWith(prefix) )
                 key = key.substring( prefix.length() );
 
-            String[] path = key.split( separator );
-            Object value = p.get(key);
+            final String[] path = key.split( separator );
+            final Object value = p.get(key);
             addNodeAtLocation( path, value, root );
         }
         return root;
     }
 
-    private static void addNodeAtLocation( String[] path, Object value,
-            DefaultNode root )
+    private static void addNodeAtLocation( final String[] path, final Object value,
+            final DefaultNode root )
     {
-        DefaultNode node = new DefaultNode( path[0] );
+        final DefaultNode node = new DefaultNode( path[0] );
 
         if( path.length == 0 )
         {
@@ -268,7 +272,7 @@
             root.addChild(node);
         }
 
-        String[] subpath = new String[path.length-1];
+        final String[] subpath = new String[path.length-1];
         System.arraycopy( path, 1, subpath, 0, subpath.length );
 
         addNodeAtLocation( subpath, value, node );
@@ -282,7 +286,7 @@
      * @param separator
      * @param node
      */
-    public static void toProperties( Properties p, String prefix, String separator, Node node )
+    public static void toProperties( final Properties p, final String prefix, final String separator, final Node node )
     {
         // copy values
         Iterator it = node.entrySet().iterator();
@@ -367,7 +371,7 @@
  * information on the Apache Software Foundation, please see
  * <http://www.apache.org/>.
  */
-    private static Configuration elementToAvalonConfiguration( Element element )
+    private static Configuration elementToAvalonConfiguration( final Element element )
     {
         final DefaultConfiguration configuration =
             new DefaultConfiguration( element.getNodeName(), "dom-created" );
@@ -399,7 +403,7 @@
             }
         }
 
-        if( null != content )
+        if( content != null )
         {
             configuration.setValue( content );
         }



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.