KickJava   Java API By Example, From Geeks To Geeks.

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


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
30 public class MatchingRuleDescription extends SchemaPart2
31 {
32
33     private static final long serialVersionUID = -8497098446034593329L;
34
35     private String JavaDoc syntaxDescriptionNumericOID;
36
37
38     public MatchingRuleDescription()
39     {
40         super();
41         this.syntaxDescriptionNumericOID = null;
42     }
43
44
45     public int compareTo( Object JavaDoc o )
46     {
47         if ( o instanceof MatchingRuleDescription )
48         {
49             return this.toString().compareTo( o.toString() );
50         }
51         else
52         {
53             throw new ClassCastException JavaDoc( "Object of type " + this.getClass().getName() + " required." );
54         }
55     }
56
57
58     /**
59      *
60      * @return the syntax description OID, may be null
61      */

62     public String JavaDoc getSyntaxDescriptionNumericOID()
63     {
64         return syntaxDescriptionNumericOID;
65     }
66
67
68     public void setSyntaxDescriptionNumericOID( String JavaDoc syntaxDescriptionNumericOID )
69     {
70         this.syntaxDescriptionNumericOID = syntaxDescriptionNumericOID;
71     }
72
73
74     /**
75      *
76      * @return all attribute type descriptions using this matching rule for
77      * equality, substring or ordering matching
78      */

79     public AttributeTypeDescription[] getUsedFromAttributeTypeDescriptions()
80     {
81         Set JavaDoc usedFromSet = new HashSet JavaDoc();
82         for ( Iterator JavaDoc it = this.getSchema().getAtdMapByName().values().iterator(); it.hasNext(); )
83         {
84             AttributeTypeDescription atd = ( AttributeTypeDescription ) it.next();
85             if ( atd.getEqualityMatchingRuleDescriptionOIDTransitive() != null
86                 && this.getLowerCaseIdentifierSet().contains(
87                     atd.getEqualityMatchingRuleDescriptionOIDTransitive().toLowerCase() ) )
88             {
89                 usedFromSet.add( atd );
90             }
91             if ( atd.getSubstringMatchingRuleDescriptionOIDTransitive() != null
92                 && this.getLowerCaseIdentifierSet().contains(
93                     atd.getSubstringMatchingRuleDescriptionOIDTransitive().toLowerCase() ) )
94             {
95                 usedFromSet.add( atd );
96             }
97             if ( atd.getOrderingMatchingRuleDescriptionOIDTransitive() != null
98                 && this.getLowerCaseIdentifierSet().contains(
99                     atd.getOrderingMatchingRuleDescriptionOIDTransitive().toLowerCase() ) )
100             {
101                 usedFromSet.add( atd );
102             }
103         }
104         AttributeTypeDescription[] atds = ( AttributeTypeDescription[] ) usedFromSet
105             .toArray( new AttributeTypeDescription[0] );
106         Arrays.sort( atds );
107         return atds;
108     }
109
110 }
111
Popular Tags