KickJava   Java API By Example, From Geeks To Geeks.

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


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.Arrays JavaDoc;
25 import java.util.HashSet JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.Set JavaDoc;
28
29 import org.apache.directory.ldapstudio.browser.core.BrowserCorePlugin;
30
31
32 /*
33  * Value being represented H-R OBJECT IDENTIFIER
34  * ================================================================= ACI Item N
35  * 1.3.6.1.4.1.1466.115.121.1.1 Access Point Y 1.3.6.1.4.1.1466.115.121.1.2
36  * Attribute Type Description Y 1.3.6.1.4.1.1466.115.121.1.3 Audio N
37  * 1.3.6.1.4.1.1466.115.121.1.4 Binary N 1.3.6.1.4.1.1466.115.121.1.5 Bit String
38  * Y 1.3.6.1.4.1.1466.115.121.1.6 Boolean Y 1.3.6.1.4.1.1466.115.121.1.7
39  * Certificate N 1.3.6.1.4.1.1466.115.121.1.8 Certificate List N
40  * 1.3.6.1.4.1.1466.115.121.1.9 Certificate Pair N 1.3.6.1.4.1.1466.115.121.1.10
41  * Country String Y 1.3.6.1.4.1.1466.115.121.1.11 DN Y
42  * 1.3.6.1.4.1.1466.115.121.1.12 Data Quality Syntax Y
43  * 1.3.6.1.4.1.1466.115.121.1.13 Delivery Method Y 1.3.6.1.4.1.1466.115.121.1.14
44  * Directory String Y 1.3.6.1.4.1.1466.115.121.1.15 DIT Content Rule Description
45  * Y 1.3.6.1.4.1.1466.115.121.1.16 DIT Structure Rule Description Y
46  * 1.3.6.1.4.1.1466.115.121.1.17 DL Submit Permission Y
47  * 1.3.6.1.4.1.1466.115.121.1.18 DSA Quality Syntax Y
48  * 1.3.6.1.4.1.1466.115.121.1.19 DSE Type Y 1.3.6.1.4.1.1466.115.121.1.20
49  * Enhanced Guide Y 1.3.6.1.4.1.1466.115.121.1.21 Facsimile Telephone Number Y
50  * 1.3.6.1.4.1.1466.115.121.1.22 Fax N 1.3.6.1.4.1.1466.115.121.1.23 Generalized
51  * Time Y 1.3.6.1.4.1.1466.115.121.1.24 Guide Y 1.3.6.1.4.1.1466.115.121.1.25
52  * IA5 String Y 1.3.6.1.4.1.1466.115.121.1.26 INTEGER Y
53  * 1.3.6.1.4.1.1466.115.121.1.27 JPEG N 1.3.6.1.4.1.1466.115.121.1.28 LDAP
54  * Syntax Description Y 1.3.6.1.4.1.1466.115.121.1.54 LDAP Schema Definition Y
55  * 1.3.6.1.4.1.1466.115.121.1.56 LDAP Schema Description Y
56  * 1.3.6.1.4.1.1466.115.121.1.57 Master And Shadow Access Points Y
57  * 1.3.6.1.4.1.1466.115.121.1.29 Matching Rule Description Y
58  * 1.3.6.1.4.1.1466.115.121.1.30 Matching Rule Use Description Y
59  * 1.3.6.1.4.1.1466.115.121.1.31 Mail Preference Y 1.3.6.1.4.1.1466.115.121.1.32
60  * MHS OR Address Y 1.3.6.1.4.1.1466.115.121.1.33 Modify Rights Y
61  * 1.3.6.1.4.1.1466.115.121.1.55 Name And Optional UID Y
62  * 1.3.6.1.4.1.1466.115.121.1.34 Name Form Description Y
63  * 1.3.6.1.4.1.1466.115.121.1.35 Numeric String Y 1.3.6.1.4.1.1466.115.121.1.36
64  * Object Class Description Y 1.3.6.1.4.1.1466.115.121.1.37 Octet String Y
65  * 1.3.6.1.4.1.1466.115.121.1.40 OID Y 1.3.6.1.4.1.1466.115.121.1.38 Other
66  * Mailbox Y 1.3.6.1.4.1.1466.115.121.1.39 Postal Address Y
67  * 1.3.6.1.4.1.1466.115.121.1.41 Protocol Information Y
68  * 1.3.6.1.4.1.1466.115.121.1.42 Presentation Address Y
69  * 1.3.6.1.4.1.1466.115.121.1.43 Printable String Y
70  * 1.3.6.1.4.1.1466.115.121.1.44 Substring Assertion Y
71  * 1.3.6.1.4.1.1466.115.121.1.58 Subtree Specification Y
72  * 1.3.6.1.4.1.1466.115.121.1.45 Supplier Information Y
73  * 1.3.6.1.4.1.1466.115.121.1.46 Supplier Or Consumer Y
74  * 1.3.6.1.4.1.1466.115.121.1.47 Supplier And Consumer Y
75  * 1.3.6.1.4.1.1466.115.121.1.48 Supported Algorithm N
76  * 1.3.6.1.4.1.1466.115.121.1.49 Telephone Number Y
77  * 1.3.6.1.4.1.1466.115.121.1.50 Teletex Terminal Identifier Y
78  * 1.3.6.1.4.1.1466.115.121.1.51 Telex Number Y 1.3.6.1.4.1.1466.115.121.1.52
79  * UTC Time Y 1.3.6.1.4.1.1466.115.121.1.53
80  */

81
82 public class LdapSyntaxDescription extends SchemaPart
83 {
84
85     private static final long serialVersionUID = 2740623603305997234L;
86
87     public static final String JavaDoc DN_OID = "1.3.6.1.4.1.1466.115.121.1.12";
88
89     public static final LdapSyntaxDescription DUMMY;
90     static
91     {
92         DUMMY = new LdapSyntaxDescription();
93         DUMMY.setSchema( Schema.DEFAULT_SCHEMA );
94         DUMMY.setNumericOID( "" );
95         DUMMY.setDesc( "" );
96     }
97
98
99     public LdapSyntaxDescription()
100     {
101         super();
102     }
103
104
105     public int compareTo( Object JavaDoc o )
106     {
107         if ( o instanceof LdapSyntaxDescription )
108         {
109             return this.toString().compareTo( o.toString() );
110         }
111         else
112         {
113             throw new ClassCastException JavaDoc( "Object of type " + this.getClass().getName() + " required." );
114         }
115     }
116
117
118     /**
119      *
120      * @return the string representation of this syntax description, either
121      * desc or numericOID
122      */

123     public String JavaDoc toString()
124     {
125         if ( this.desc != null && this.desc.length() > 0 )
126         {
127             return this.desc;
128         }
129         else if ( numericOID != null )
130         {
131             return this.numericOID;
132         }
133         else
134         {
135             return "";
136         }
137     }
138
139
140     /**
141      * Convenience method to !isBinary().
142      *
143      * @return true if the syntax is defined as string
144      */

145     public boolean isString()
146     {
147         return !isBinary();
148     }
149
150
151     /**
152      * Checks the pre-defined and user-defined binary syntax oids. If this
153      * syntax OID is defned as binary true is returned, false otherwise.
154      *
155      * @return true if the syntax is defined as binary
156      */

157     public boolean isBinary()
158     {
159         // check user-defined binary syntaxes
160
Set JavaDoc binarySyntaxOids = BrowserCorePlugin.getDefault().getCorePreferences().getBinarySyntaxOids();
161         if ( binarySyntaxOids.contains( this.numericOID ) )
162         {
163             return true;
164         }
165
166         // default: not binary
167
return false;
168     }
169
170
171     /**
172      *
173      * @return all attribute type description using this syntax description
174      */

175     public AttributeTypeDescription[] getUsedFromAttributeTypeDescription()
176     {
177         Set JavaDoc usedFromSet = new HashSet JavaDoc();
178         for ( Iterator JavaDoc it = this.getSchema().getAtdMapByName().values().iterator(); it.hasNext(); )
179         {
180             AttributeTypeDescription atd = ( AttributeTypeDescription ) it.next();
181             if ( atd.getSyntaxDescriptionNumericOIDTransitive() != null && this.numericOID != null
182                 && atd.getSyntaxDescriptionNumericOIDTransitive().toLowerCase().equals( this.numericOID.toLowerCase() ) )
183             {
184                 usedFromSet.add( atd );
185             }
186         }
187         AttributeTypeDescription[] atds = ( AttributeTypeDescription[] ) usedFromSet
188             .toArray( new AttributeTypeDescription[0] );
189         Arrays.sort( atds );
190         return atds;
191     }
192
193 }
194
Popular Tags