db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Sfeir <rob...@codepuccino.com>
Subject Collection StringBuffer Fix
Date Mon, 14 Jun 2004 11:40:37 GMT
Index: CollectionDescriptor.java
===================================================================
RCS file: /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/metadata/CollectionDescriptor.java,v
retrieving revision 1.30
diff -u -r1.30 CollectionDescriptor.java
--- CollectionDescriptor.java	4 Apr 2004 23:53:34 -0000	1.30
+++ CollectionDescriptor.java	14 Jun 2004 11:38:59 -0000
@@ -207,101 +207,145 @@
         String eol = SystemUtils.LINE_SEPARATOR;
 
         // write opening tag
-        String result = "      " + tags.getOpeningTagNonClosingById(COLLECTION_DESCRIPTOR)
+ eol;
+        StringBuffer result = new StringBuffer();
+        result.append( "      " );
+        result.append( tags.getOpeningTagNonClosingById( COLLECTION_DESCRIPTOR ) );
+        result.append( eol );
 
         // write attributes
         // name
-        result       += "        " + tags.getAttribute(FIELD_NAME,this.getAttributeName())
+ eol;
+        result.append( "        " );
+        result.append( tags.getAttribute( FIELD_NAME, this.getAttributeName() ) );
+        result.append( eol );
 
         // collection class is optional
-        if (getCollectionClassName() != null)
+        if( getCollectionClassName() != null )
         {
-            result       += "        " + tags.getAttribute(COLLECTION_CLASS,this.getCollectionClassName())
+ eol;
+            result.append( "        " );
+            result.append( tags.getAttribute( COLLECTION_CLASS, this.getCollectionClassName()
) );
+            result.append( eol );
         }
 
         // element-class-ref
-         result       += "        " + tags.getAttribute(ITEMS_CLASS,this.getItemClassName())
+ eol;
+        result.append( "        " );
+        result.append( tags.getAttribute( ITEMS_CLASS, this.getItemClassName() ) );
+        result.append( eol );
 
         // indirection-table is optional
-        if (isMtoNRelation())
+        if( isMtoNRelation() )
         {
-             result += "        " + tags.getAttribute(INDIRECTION_TABLE,getIndirectionTable())
+ eol;
+            result.append( "        " );
+            result.append( tags.getAttribute( INDIRECTION_TABLE, getIndirectionTable() )
);
+            result.append( eol );
         }
 
         // proxyReference is optional, disabled by default
-        if (isLazy())
+        if( isLazy() )
         {
-            result       += "        " + tags.getAttribute(PROXY_REFERENCE,"true") + eol;
-            result       += "        " + tags.getAttribute(PROXY_PREFETCHING_LIMIT, "" +
this.getProxyPrefetchingLimit()) + eol;
+            result.append( "        " );
+            result.append( tags.getAttribute( PROXY_REFERENCE, "true" ) );
+            result.append( eol );
+            result.append( "        " );
+            result.append( tags.getAttribute( PROXY_PREFETCHING_LIMIT, "" + this.getProxyPrefetchingLimit()
) );
+            result.append( eol );
         }
 
         //reference refresh is optional, disabled by default
-        if (isRefresh())
+        if( isRefresh() )
         {
-             result       += "        " + tags.getAttribute(REFRESH,"true") + eol;
+            result.append( "        " );
+            result.append( tags.getAttribute( REFRESH, "true" ) );
+            result.append( eol );
         }
 
         //auto retrieve
-        result += "        " + tags.getAttribute(AUTO_RETRIEVE, "" + getCascadeRetrieve())
+ eol;
+        result.append( "        " );
+        result.append( tags.getAttribute( AUTO_RETRIEVE, "" + getCascadeRetrieve() ) );
+        result.append( eol );
 
         //auto update
-        result += "        " + tags.getAttribute(AUTO_UPDATE, getCascadeAsString(getCascadingStore()))
+ eol;
+        result.append( "        " );
+        result.append( tags.getAttribute( AUTO_UPDATE, getCascadeAsString( getCascadingStore()
) ) );
+        result.append( eol );
 
         //auto delete
-        result += "        " + tags.getAttribute(AUTO_DELETE, getCascadeAsString(getCascadingDelete()))
+ eol;
+        result.append( "        " );
+        result.append( tags.getAttribute( AUTO_DELETE, getCascadeAsString( getCascadingDelete()
) ) );
+        result.append( eol );
 
         //otm-dependent is optional, disabled by default
-        if (getOtmDependent())
+        if( getOtmDependent() )
         {
-            result += "        " + tags.getAttribute(OTM_DEPENDENT, "true") + eol;
+            result.append( "        " );
+            result.append( tags.getAttribute( OTM_DEPENDENT, "true" ) );
+            result.append( eol );
         }
 
         // close opening tag
-        result       += "      >" + eol;
+        result.append( "      >" );
+        result.append( eol );
 
         // write elements
-         // inverse fk elements
-        for (int i=0;i<getForeignKeyFields().size();i++)
-        {
-        Object obj = getForeignKeyFields().get(i);
-        if (obj instanceof Integer)
+        // inverse fk elements
+        for( int i = 0; i < getForeignKeyFields().size(); i++ )
         {
+            Object obj = getForeignKeyFields().get( i );
+            if( obj instanceof Integer )
+            {
                 String fkId = obj.toString();
-            result += "        " + tags.getOpeningTagNonClosingById(INVERSE_FK) + " ";
-                result += tags.getAttribute(FIELD_ID_REF, fkId) + "/>" + eol;
-        }
-        else
-        {
-                String fk = (String) obj;
-            result += "        " + tags.getOpeningTagNonClosingById(INVERSE_FK) + " ";
-                result += tags.getAttribute(FIELD_REF, fk) + "/>" + eol;
-        }
+                result.append( "        " );
+                result.append( tags.getOpeningTagNonClosingById( INVERSE_FK ) );
+                result.append( " " );
+                result.append( tags.getAttribute( FIELD_ID_REF, fkId ) );
+                result.append( "/>" );
+                result.append( eol );
+            }
+            else
+            {
+                String fk = ( String ) obj;
+                result.append( "        " );
+                result.append( tags.getOpeningTagNonClosingById( INVERSE_FK ) );
+                result.append( " " );
+                result.append( tags.getAttribute( FIELD_REF, fk ) );
+                result.append( "/>" );
+                result.append( eol );
+            }
         }
 
         // write optional M:N elements
         // m:n relationship settings, optional
-        if (isMtoNRelation())
+        if( isMtoNRelation() )
         {
             // foreign keys to this class
-             for (int i=0;i<getFksToThisClass().length;i++)
-             {
-                String fkId = getFksToThisClass()[i];
-                result += "        " + tags.getOpeningTagNonClosingById(FK_POINTING_TO_THIS_CLASS)
+ " ";
-                result += tags.getAttribute(COLUMN_NAME, fkId) + "/>" + eol;
-             }
+            for( int i = 0; i < getFksToThisClass().length; i++ )
+            {
+                String fkId = getFksToThisClass()[ i ];
+                result.append( "        " );
+                result.append( tags.getOpeningTagNonClosingById( FK_POINTING_TO_THIS_CLASS
) );
+                result.append( " " );
+                result.append( tags.getAttribute( COLUMN_NAME, fkId ) );
+                result.append( "/>" );
+                result.append( eol );
+            }
 
             // foreign keys to item class
-             for (int i=0;i<getFksToItemClass().length;i++)
-             {
-                String fkId = getFksToItemClass()[i];
-                result += "        " + tags.getOpeningTagNonClosingById(FK_POINTING_TO_ITEMS_CLASS)
+ " ";
-                result += tags.getAttribute(COLUMN_NAME, fkId) + "/>" + eol;
-             }
+            for( int i = 0; i < getFksToItemClass().length; i++ )
+            {
+                String fkId = getFksToItemClass()[ i ];
+                result.append( "        " );
+                result.append( tags.getOpeningTagNonClosingById( FK_POINTING_TO_ITEMS_CLASS
) );
+                result.append( " " );
+                result.append( tags.getAttribute( COLUMN_NAME, fkId ) );
+                result.append( "/>" );
+                result.append( eol );
+            }
         }
 
         // closing tag
-        result       += "      " + tags.getClosingTagById(COLLECTION_DESCRIPTOR) + eol;
-        return result;
+        result.append( "      " );
+        result.append( tags.getClosingTagById( COLLECTION_DESCRIPTOR ) );
+        result.append( eol );
+        return result.toString();
     }
 
 	/**

Mime
View raw message