KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > metadata > IndexDescriptor


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 JavaDoc;
21 import java.io.Serializable JavaDoc;
22
23 /**
24  *
25  *
26  * @version $Id: IndexDescriptor.java,v 1.12.2.1 2005/12/21 22:26:10 tomdz Exp $
27  */

28 public class IndexDescriptor implements XmlCapable, Serializable JavaDoc
29 {
30     private static final long serialVersionUID = -1722513568634970108L;
31     private String JavaDoc name;
32     private boolean unique;
33     private Vector JavaDoc indexColumns = new Vector JavaDoc();
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 JavaDoc getName()
46     {
47         return name;
48     }
49
50     public void setName(String JavaDoc name)
51     {
52         this.name = name;
53     }
54
55     public Vector JavaDoc getIndexColumns()
56     {
57         return this.indexColumns;
58     }
59
60     public void setIndexColumns(Vector JavaDoc indexColumns)
61     {
62         this.indexColumns = indexColumns;
63     }
64
65     /*
66      * @see XmlCapable#toXML()
67      */

68     public String JavaDoc toXML()
69     {
70         RepositoryTags tags = RepositoryTags.getInstance();
71         String JavaDoc eol = SystemUtils.LINE_SEPARATOR;
72
73         //opening tag + attributes
74
StringBuffer JavaDoc result = new StringBuffer JavaDoc( 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 JavaDoc l_name = ( String JavaDoc ) 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 }
110
Popular Tags