1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.directory.api.ldap.model.schema;
21
22
23 import org.apache.directory.api.i18n.I18n;
24 import org.apache.directory.api.util.Strings;
25
26
27
28
29
30
31
32
33 public abstract class LoadableSchemaObject extends AbstractSchemaObject
34 {
35
36 private static final long serialVersionUID = 2L;
37
38
39 private String fqcn;
40
41
42 private String bytecode;
43
44
45
46
47
48
49
50
51 protected LoadableSchemaObject( SchemaObjectType objectType, String oid )
52 {
53 super( objectType, oid );
54
55 fqcn = "";
56 bytecode = null;
57 }
58
59
60
61
62
63
64
65 protected LoadableSchemaObject( SchemaObjectType objectType )
66 {
67 super( objectType );
68
69 fqcn = "";
70 bytecode = null;
71 }
72
73
74
75
76
77 public String getBytecode()
78 {
79 return bytecode;
80 }
81
82
83
84
85
86
87
88
89 public void setBytecode( String bytecode )
90 {
91 if ( locked )
92 {
93 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
94 }
95
96 if ( !isReadOnly )
97 {
98 this.bytecode = bytecode;
99 }
100 }
101
102
103
104
105
106 public String getFqcn()
107 {
108 return fqcn;
109 }
110
111
112
113
114
115
116
117 public void setFqcn( String fqcn )
118 {
119 if ( locked )
120 {
121 throw new UnsupportedOperationException( I18n.err( I18n.ERR_04441, getName() ) );
122 }
123
124 if ( !isReadOnly )
125 {
126 this.fqcn = fqcn;
127 }
128 }
129
130
131
132
133
134 @Override
135 public LoadableSchemaObject copy()
136 {
137 return null;
138 }
139
140
141
142
143
144 @Override
145 public boolean equals( Object o )
146 {
147 if ( !super.equals( o ) )
148 {
149 return false;
150 }
151
152 if ( !( o instanceof LoadableSchemaObject ) )
153 {
154 return false;
155 }
156
157 LoadableSchemaObject that = ( LoadableSchemaObject ) o;
158
159
160
161
162 if ( fqcn == null )
163 {
164 return that.fqcn == null;
165 }
166 else
167 {
168 return fqcn.equals( that.fqcn );
169 }
170 }
171
172
173
174
175
176
177
178
179 public boolean isValid()
180 {
181 String className = this.getClass().getName();
182
183 if ( Strings.isEmpty( fqcn ) )
184 {
185 fqcn = className;
186 return true;
187 }
188 else
189 {
190 return className.equals( fqcn );
191 }
192 }
193 }