1 17 package org.apache.ldap.server.schema.bootstrap; 18 19 20 import org.apache.ldap.common.schema.*; 21 import org.apache.ldap.server.schema.*; 22 23 import javax.naming.NamingException ; 24 import java.util.Comparator ; 25 26 27 33 public abstract class AbstractBootstrapProducer implements BootstrapProducer 34 { 35 36 protected static final String [] EMPTY = new String [0]; 37 38 private final ProducerTypeEnum type; 39 40 41 46 protected AbstractBootstrapProducer( ProducerTypeEnum type ) 47 { 48 this.type = type; 49 } 50 51 52 55 public ProducerTypeEnum getType() 56 { 57 return type; 58 } 59 60 61 protected static BootstrapSyntax 62 newSyntax( String oid, BootstrapRegistries registries ) 63 { 64 return new BootstrapSyntax( oid, registries.getSyntaxCheckerRegistry() ); 65 } 66 67 68 69 protected static BootstrapAttributeType 70 newAttributeType( String oid, BootstrapRegistries registries ) 71 { 72 return new BootstrapAttributeType( oid, registries ); 73 } 74 75 76 77 protected static BootstrapObjectClass 78 newObjectClass( String oid, BootstrapRegistries registries ) 79 { 80 return new BootstrapObjectClass( oid, registries ); 81 } 82 83 84 85 89 public static class BootstrapSyntax extends AbstractSyntax 90 { 91 final SyntaxCheckerRegistry registry; 92 93 94 protected BootstrapSyntax( String oid, SyntaxCheckerRegistry registry ) 95 { 96 super( oid ); 97 this.registry = registry; 98 } 99 100 101 public void setDescription( String description ) 102 { 103 super.setDescription( description ); 104 } 105 106 107 public void setHumanReadible( boolean isHumanReadible ) 108 { 109 super.setHumanReadible( isHumanReadible ); 110 } 111 112 113 public void setNames( String [] names ) 114 { 115 super.setNames( names ); 116 } 117 118 119 public SyntaxChecker getSyntaxChecker( ) throws NamingException 120 { 121 return registry.lookup( getOid() ); 122 } 123 124 125 public boolean isObsolete() 126 { 127 return false; 128 } 129 } 130 131 132 public static class BootstrapMatchingRule extends AbstractMatchingRule 133 { 134 final SyntaxRegistry syntaxRegistry; 135 final NormalizerRegistry normalizerRegistry; 136 final ComparatorRegistry comparatorRegistry; 137 String syntaxOid; 138 139 140 protected BootstrapMatchingRule( String oid, BootstrapRegistries registries ) 141 { 142 super( oid ); 143 this.syntaxRegistry = registries.getSyntaxRegistry(); 144 this.normalizerRegistry = registries.getNormalizerRegistry(); 145 this.comparatorRegistry = registries.getComparatorRegistry(); 146 } 147 148 149 public void setNames( String [] names ) 150 { 151 super.setNames( names ); 152 } 153 154 public void setSyntaxOid( String syntaxOid ) 155 { 156 this.syntaxOid = syntaxOid; 157 } 158 159 public void setDescription( String description ) 160 { 161 super.setDescription( description ); 162 } 163 164 public void setObsolete( boolean isObsolete ) 165 { 166 super.setObsolete( isObsolete ); 167 } 168 169 170 172 173 public Syntax getSyntax() throws NamingException 174 { 175 return syntaxRegistry.lookup( syntaxOid ); 176 } 177 178 public Comparator getComparator() throws NamingException 179 { 180 return comparatorRegistry.lookup( getOid() ); 181 } 182 183 public Normalizer getNormalizer() throws NamingException 184 { 185 return normalizerRegistry.lookup( getOid() ); 186 } 187 } 188 189 190 194 public static class BootstrapAttributeType extends AbstractAttributeType 195 { 196 private static final long serialVersionUID = 4050205236738471984L; 197 198 private final SyntaxRegistry syntaxRegistry; 199 private final MatchingRuleRegistry matchingRuleRegistry; 200 private final AttributeTypeRegistry attributeTypeRegistry; 201 private String superiorId; 202 private String equalityId; 203 private String substrId; 204 private String orderingId; 205 private String syntaxId; 206 207 208 protected BootstrapAttributeType( String oid, BootstrapRegistries registries ) 209 { 210 super( oid ); 211 212 syntaxRegistry = registries.getSyntaxRegistry(); 213 matchingRuleRegistry = registries.getMatchingRuleRegistry(); 214 attributeTypeRegistry = registries.getAttributeTypeRegistry(); 215 } 216 217 public void setSuperiorId( String superiorId ) 218 { 219 this.superiorId = superiorId; 220 } 221 222 public AttributeType getSuperior() throws NamingException 223 { 224 if ( superiorId == null ) 225 { 226 return null; 227 } 228 229 return this.attributeTypeRegistry.lookup( superiorId ); 230 } 231 232 public void setNames( String [] names ) 233 { 234 super.setNames( names ); 235 } 236 237 public MatchingRule getEquality() throws NamingException 238 { 239 if ( equalityId != null ) 240 { 241 return this.matchingRuleRegistry.lookup( equalityId ); 242 } 243 244 if ( superiorId != null ) 245 { 246 return getSuperior().getEquality(); 247 } 248 249 return null; 250 } 251 252 public void setEqualityId( String equalityId ) 253 { 254 this.equalityId = equalityId; 255 } 256 257 public MatchingRule getSubstr() throws NamingException 258 { 259 if ( substrId != null ) 260 { 261 return this.matchingRuleRegistry.lookup( substrId ); 262 } 263 264 if ( superiorId != null ) 265 { 266 return getSuperior().getSubstr(); 267 } 268 269 return null; 270 } 271 272 public void setSubstrId( String substrId ) 273 { 274 this.substrId = substrId; 275 } 276 277 public MatchingRule getOrdering() throws NamingException 278 { 279 if ( orderingId != null ) 280 { 281 return this.matchingRuleRegistry.lookup( orderingId ); 282 } 283 284 if ( superiorId != null ) 285 { 286 return getSuperior().getOrdering(); 287 } 288 289 return null; 290 } 291 292 public void setOrderingId( String orderingId ) 293 { 294 this.orderingId = orderingId; 295 } 296 297 public void setSyntaxId( String syntaxId ) 298 { 299 this.syntaxId = syntaxId; 300 } 301 302 public Syntax getSyntax() throws NamingException 303 { 304 if ( syntaxId != null ) 305 { 306 return this.syntaxRegistry.lookup( syntaxId ); 307 } 308 309 if ( superiorId != null ) 310 { 311 return getSuperior().getSyntax(); 312 } 313 314 return null; 315 } 316 317 public void setSingleValue( boolean singleValue ) 318 { 319 super.setSingleValue( singleValue ); 320 } 321 322 public void setCollective( boolean collective ) 323 { 324 super.setCollective( collective ); 325 } 326 327 public void setCanUserModify( boolean canUserModify ) 328 { 329 super.setCanUserModify( canUserModify ); 330 } 331 332 public void setObsolete( boolean obsolete ) 333 { 334 super.setObsolete( obsolete ); 335 } 336 337 public void setDescription( String description ) 338 { 339 super.setDescription( description ); 340 } 341 342 public void setUsage( UsageEnum usage ) 343 { 344 super.setUsage( usage ); 345 } 346 347 public void setLength( int length ) 348 { 349 super.setLength( length ); 350 } 351 } 352 353 354 358 public static class BootstrapObjectClass extends AbstractSchemaObject 359 implements ObjectClass 360 { 361 private final ObjectClassRegistry objectClassRegistry; 362 private final AttributeTypeRegistry attributeTypeRegistry; 363 364 private String [] superClassIds = EMPTY; 365 private ObjectClass[] superClasses; 366 private ObjectClassTypeEnum type = ObjectClassTypeEnum.STRUCTURAL; 367 368 private String [] mayListIds = EMPTY; 369 private AttributeType[] mayList; 370 371 private String [] mustListIds = EMPTY; 372 private AttributeType[] mustList; 373 374 375 381 protected BootstrapObjectClass( String oid, BootstrapRegistries registries ) 382 { 383 super( oid ); 384 385 objectClassRegistry = registries.getObjectClassRegistry(); 386 attributeTypeRegistry = registries.getAttributeTypeRegistry(); 387 } 388 389 390 394 395 public ObjectClass[] getSuperClasses() throws NamingException 396 { 397 if ( superClasses == null ) 398 { 399 superClasses = new ObjectClass[superClassIds.length]; 400 } 401 402 for( int ii = 0; ii < superClassIds.length; ii++ ) 403 { 404 superClasses[ii] = objectClassRegistry.lookup( superClassIds[ii] ); 405 } 406 407 return superClasses; 408 } 409 410 411 public void setSuperClassIds( String [] superClassIds ) 412 { 413 this.superClassIds = superClassIds; 414 } 415 416 417 public ObjectClassTypeEnum getType() 418 { 419 return type; 420 } 421 422 423 public void setType( ObjectClassTypeEnum type ) 424 { 425 this.type = type; 426 } 427 428 429 public AttributeType[] getMustList() throws NamingException 430 { 431 if ( mustList == null ) 432 { 433 mustList = new AttributeType[mustListIds.length]; 434 } 435 436 for( int ii = 0; ii < mustListIds.length; ii++ ) 437 { 438 mustList[ii] = attributeTypeRegistry.lookup( mustListIds[ii] ); 439 } 440 441 return mustList; 442 } 443 444 445 public void setMustListIds( String [] mustListIds ) 446 { 447 this.mustListIds = mustListIds; 448 } 449 450 451 public AttributeType[] getMayList() throws NamingException 452 { 453 if ( mayList == null ) 454 { 455 mayList = new AttributeType[mayListIds.length]; 456 } 457 458 for( int ii = 0; ii < mayListIds.length; ii++ ) 459 { 460 mayList[ii] = attributeTypeRegistry.lookup( mayListIds[ii] ); 461 } 462 463 return mayList; 464 } 465 466 467 public void setMayListIds( String [] mayListIds ) 468 { 469 this.mayListIds = mayListIds; 470 } 471 472 473 477 478 public void setObsolete( boolean obsolete ) 479 { 480 super.setObsolete( obsolete ); 481 } 482 483 public void setNames( String [] names ) 484 { 485 super.setNames( names ); 486 } 487 488 public void setDescription( String description ) 489 { 490 super.setDescription( description ); 491 } 492 493 494 } 495 } 496 | Popular Tags |