Coverage Report - org.apache.ojb.broker.metadata.IndexDescriptor
 
Classes in this File Line Coverage Branch Coverage Complexity
IndexDescriptor
N/A
N/A
1.143
 
 1  
 package org.apache.ojb.broker.metadata;
 2  
 
 3  
 /* Copyright 2002-2005 The Apache Software Foundation
 4  
  *
 5  
  * Licensed under the Apache License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  *     http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 import org.apache.commons.lang.SystemUtils;
 19  
 
 20  
 import java.util.Vector;
 21  
 import java.io.Serializable;
 22  
 
 23  
 /**
 24  
  *
 25  
  *
 26  
  * @version $Id: IndexDescriptor.java,v 1.1 2007-08-24 22:17:29 ewestfal Exp $
 27  
  */
 28  
 public class IndexDescriptor implements XmlCapable, Serializable
 29  
 {
 30  
         private static final long serialVersionUID = -1722513568634970108L;
 31  
     private String name;
 32  
     private boolean unique;
 33  
     private Vector indexColumns = new Vector();
 34  
 
 35  
     public boolean isUnique()
 36  
     {
 37  
         return unique;
 38  
     }
 39  
 
 40  
     public void setUnique(boolean unique)
 41  
     {
 42  
         this.unique = unique;
 43  
     }
 44  
 
 45  
     public String getName()
 46  
     {
 47  
         return name;
 48  
     }
 49  
 
 50  
     public void setName(String name)
 51  
     {
 52  
         this.name = name;
 53  
     }
 54  
 
 55  
     public Vector getIndexColumns()
 56  
     {
 57  
         return this.indexColumns;
 58  
     }
 59  
 
 60  
     public void setIndexColumns(Vector indexColumns)
 61  
     {
 62  
         this.indexColumns = indexColumns;
 63  
     }
 64  
 
 65  
     /*
 66  
      * @see XmlCapable#toXML()
 67  
      */
 68  
     public String toXML()
 69  
     {
 70  
         RepositoryTags tags = RepositoryTags.getInstance();
 71  
         String eol = SystemUtils.LINE_SEPARATOR;
 72  
 
 73  
         //opening tag + attributes
 74  
         StringBuffer result = new StringBuffer( 1024 );
 75  
         result.append( "      <" );
 76  
         result.append( tags.getTagById( INDEX_DESCRIPTOR ) );
 77  
         result.append( " " );
 78  
 
 79  
         // index name
 80  
         result.append( tags.getAttribute( NAME, getName() ) );
 81  
         result.append( " " );
 82  
 
 83  
         // unique attribute
 84  
         result.append( tags.getAttribute( UNIQUE, "" + isUnique() ) );
 85  
         result.append( ">" );
 86  
         result.append( eol );
 87  
 
 88  
         // index columns
 89  
         for( int i = 0; i < indexColumns.size(); i++ )
 90  
         {
 91  
             String l_name = ( String ) indexColumns.elementAt( i );
 92  
             result.append( "                " );
 93  
             result.append( tags.getOpeningTagNonClosingById( INDEX_COLUMN ) );
 94  
             result.append( " " );
 95  
             result.append( tags.getAttribute( NAME, l_name ) );
 96  
             result.append( " />" );
 97  
             result.append( eol );
 98  
         }
 99  
 
 100  
         // closing tag
 101  
         result.append( "      " );
 102  
         result.append( tags.getClosingTagById( INDEX_DESCRIPTOR ) );
 103  
         result.append( " " );
 104  
         result.append( eol );
 105  
 
 106  
         return result.toString();
 107  
     }
 108  
 
 109  
 }