1 package org.apache.ojb.broker.metadata;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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
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
67
68 public String toXML()
69 {
70 RepositoryTags tags = RepositoryTags.getInstance();
71 String eol = SystemUtils.LINE_SEPARATOR;
72
73
74 StringBuffer result = new StringBuffer( 1024 );
75 result.append( " <" );
76 result.append( tags.getTagById( INDEX_DESCRIPTOR ) );
77 result.append( " " );
78
79
80 result.append( tags.getAttribute( NAME, getName() ) );
81 result.append( " " );
82
83
84 result.append( tags.getAttribute( UNIQUE, "" + isUnique() ) );
85 result.append( ">" );
86 result.append( eol );
87
88
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
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 }