KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > browser > core > model > schema > SchemaPart2


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20
21 package org.apache.directory.ldapstudio.browser.core.model.schema;
22
23
24 import java.util.HashSet JavaDoc;
25 import java.util.Set JavaDoc;
26
27
28 public abstract class SchemaPart2 extends SchemaPart
29 {
30
31     protected String JavaDoc[] names;
32
33     protected boolean isObsolete;
34
35
36     protected SchemaPart2()
37     {
38         super();
39         this.names = new String JavaDoc[0];
40         this.isObsolete = false;
41     }
42
43
44     public Set JavaDoc getLowerCaseIdentifierSet()
45     {
46         Set JavaDoc idSet = new HashSet JavaDoc();
47         if ( this.numericOID != null )
48         {
49             idSet.add( this.numericOID.toLowerCase() );
50         }
51         idSet.addAll( toLowerCaseSet( this.names ) );
52         return idSet;
53     }
54
55
56     /**
57      *
58      * @return the string representation of this schema part, a
59      * comma-separated list of names.
60      */

61     public String JavaDoc toString()
62     {
63         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
64         for ( int i = 0; i < names.length; i++ )
65         {
66             sb.append( names[i] ).append( ", " );
67         }
68         if ( sb.length() > 2 )
69         {
70             sb.delete( sb.length() - 2, sb.length() );
71         }
72         return sb.toString();
73     }
74
75
76     /**
77      *
78      * @return the names, may be an empty array
79      */

80     public String JavaDoc[] getNames()
81     {
82         return names;
83     }
84
85
86     public void setNames( String JavaDoc[] names )
87     {
88         this.names = names;
89     }
90
91
92     /**
93      *
94      * @return the obsolete flag
95      */

96     public boolean isObsolete()
97     {
98         return isObsolete;
99     }
100
101
102     public void setObsolete( boolean isObsolete )
103     {
104         this.isObsolete = isObsolete;
105     }
106
107
108     protected Set JavaDoc toLowerCaseSet( String JavaDoc[] names )
109     {
110         Set JavaDoc set = new HashSet JavaDoc();
111         if ( names != null )
112         {
113             for ( int i = 0; i < names.length; i++ )
114             {
115                 set.add( names[i].toLowerCase() );
116             }
117         }
118         return set;
119     }
120
121 }
122
Popular Tags