1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.server.core.schema;
21
22
23 import javax.naming.NamingException;
24
25 import org.apache.directory.server.schema.registries.Registries;
26 import org.apache.directory.shared.ldap.schema.AbstractSchemaObject;
27 import org.apache.directory.shared.ldap.schema.AttributeType;
28 import org.apache.directory.shared.ldap.schema.MatchingRule;
29 import org.apache.directory.shared.ldap.schema.MatchingRuleUse;
30 import org.apache.directory.shared.ldap.schema.MutableSchemaObject;
31
32
33
34
35
36
37
38
39
40 public class MatchingRuleUseImpl extends AbstractSchemaObject implements MatchingRuleUse, MutableSchemaObject
41 {
42 private static final long serialVersionUID = 1L;
43
44 private static final AttributeType[] EMPTY_ATTRIBUTES = new AttributeType[0];
45 private static final String[] EMPTY_STRINGS = new String[0];
46
47 private final Registries registries;
48 private AttributeType[] applicableAttributes = EMPTY_ATTRIBUTES;
49 private String[] applicableAttributesOids;
50
51
52
53
54
55
56
57
58 protected MatchingRuleUseImpl( String oid, Registries registries )
59 {
60 super( oid );
61 this.registries = registries;
62 }
63
64
65
66
67
68 public MatchingRule getMatchingRule() throws NamingException
69 {
70 return registries.getMatchingRuleRegistry().lookup( getOid() );
71 }
72
73
74
75
76
77 public AttributeType[] getApplicableAttributes() throws NamingException
78 {
79 if ( applicableAttributesOids == null || applicableAttributesOids == EMPTY_STRINGS )
80 {
81 return EMPTY_ATTRIBUTES;
82 }
83
84 for ( int ii = 0; ii < applicableAttributesOids.length; ii++ )
85 {
86 applicableAttributes[ii] = registries.getAttributeTypeRegistry().lookup( applicableAttributesOids[ii] );
87 }
88
89 return applicableAttributes;
90 }
91
92
93
94
95
96
97
98 public void setApplicableAttributesOids( final String[] applicableAttributesOids )
99 {
100 this.applicableAttributesOids = applicableAttributesOids;
101 if ( applicableAttributesOids == null )
102 {
103 this.applicableAttributesOids = EMPTY_STRINGS;
104 this.applicableAttributes = EMPTY_ATTRIBUTES;
105 }
106 else
107 {
108 this.applicableAttributesOids = applicableAttributesOids;
109 this.applicableAttributes = new AttributeType[applicableAttributesOids.length];
110 }
111 }
112
113
114
115
116
117 public void setNames( String[] names )
118 {
119 super.setNames( names );
120 }
121
122
123
124
125
126 public void setDescription( String description )
127 {
128 super.setDescription( description );
129 }
130
131
132
133
134
135 public void setObsolete( boolean obsolete )
136 {
137 super.setObsolete( obsolete );
138 }
139
140
141
142
143
144 public void setSchema( String schemaName )
145 {
146 super.setSchema( schemaName );
147 }
148 }