| | |
| | | import static org.opends.sdk.schema.SchemaConstants.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.regex.Pattern; |
| | | |
| | | import org.opends.sdk.DecodeException; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | import org.opends.sdk.LocalizableMessage; |
| | | import org.opends.sdk.LocalizedIllegalArgumentException; |
| | | |
| | | import com.sun.opends.sdk.util.*; |
| | | import com.sun.opends.sdk.util.StaticUtils; |
| | | import com.sun.opends.sdk.util.SubstringReader; |
| | | import com.sun.opends.sdk.util.Validator; |
| | | |
| | | |
| | | |
| | |
| | | |
| | | private Schema schema; |
| | | |
| | | // A unique ID which can be used to uniquely identify schemas |
| | | // constructed without a name. |
| | | private final AtomicInteger nextSchemaID = new AtomicInteger(); |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | public SchemaBuilder() |
| | | { |
| | | initBuilder(); |
| | | initBuilder(null); |
| | | } |
| | | |
| | | |
| | |
| | | /** |
| | | * Creates a new schema builder containing all of the schema elements |
| | | * from the provided schema and its compatibility options. |
| | | * |
| | | * |
| | | * @param schema |
| | | * The initial contents of the schema builder. |
| | | * @throws NullPointerException |
| | |
| | | */ |
| | | public SchemaBuilder(Schema schema) throws NullPointerException |
| | | { |
| | | Validator.ensureNotNull(schema); |
| | | initBuilder(); |
| | | initBuilder(schema.getSchemaName()); |
| | | setSchemaCompatOptions(schema.getSchemaCompatOptions()); |
| | | addSchema(schema, true); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * Creates a new schema builder with no schema elements and default |
| | | * compatibility options. |
| | | * |
| | | * @param schemaName |
| | | * The user-friendly name of this schema which may be used |
| | | * for debugging purposes. |
| | | */ |
| | | public SchemaBuilder(String schemaName) |
| | | { |
| | | initBuilder(schemaName); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Adds the provided attribute type definition to this schema builder. |
| | | * |
| | | * |
| | | * @param definition |
| | | * The attribute type definition. |
| | | * @param overwrite |
| | |
| | | |
| | | /** |
| | | * Adds the provided attribute type definition to this schema builder. |
| | | * |
| | | * |
| | | * @param oid |
| | | * The OID of the attribute type definition. |
| | | * @param names |
| | |
| | | /** |
| | | * Adds the provided DIT content rule definition to this schema |
| | | * builder. |
| | | * |
| | | * |
| | | * @param definition |
| | | * The DIT content rule definition. |
| | | * @param overwrite |
| | |
| | | /** |
| | | * Adds the provided DIT content rule definition to this schema |
| | | * builder. |
| | | * |
| | | * |
| | | * @param structuralClass |
| | | * The name of the structural object class to which the DIT |
| | | * content rule applies. |
| | |
| | | /** |
| | | * Adds the provided DIT structure rule definition to this schema |
| | | * builder. |
| | | * |
| | | * |
| | | * @param ruleID |
| | | * The rule identifier of the DIT structure rule. |
| | | * @param names |
| | |
| | | /** |
| | | * Adds the provided DIT structure rule definition to this schema |
| | | * builder. |
| | | * |
| | | * |
| | | * @param definition |
| | | * The DIT structure rule definition. |
| | | * @param overwrite |
| | |
| | | /** |
| | | * Adds the provided enumeration syntax definition to this schema |
| | | * builder. |
| | | * |
| | | * |
| | | * @param oid |
| | | * The OID of the enumeration syntax definition. |
| | | * @param description |
| | |
| | | |
| | | /** |
| | | * Adds the provided matching rule definition to this schema builder. |
| | | * |
| | | * |
| | | * @param definition |
| | | * The matching rule definition. |
| | | * @param overwrite |
| | |
| | | |
| | | /** |
| | | * Adds the provided matching rule definition to this schema builder. |
| | | * |
| | | * |
| | | * @param oid |
| | | * The OID of the matching rule definition. |
| | | * @param names |
| | |
| | | /** |
| | | * Adds the provided matching rule use definition to this schema |
| | | * builder. |
| | | * |
| | | * |
| | | * @param definition |
| | | * The matching rule use definition. |
| | | * @param overwrite |
| | |
| | | /** |
| | | * Adds the provided matching rule use definition to this schema |
| | | * builder. |
| | | * |
| | | * |
| | | * @param oid |
| | | * The OID of the matching rule use definition. |
| | | * @param names |
| | |
| | | |
| | | /** |
| | | * Adds the provided name form definition to this schema builder. |
| | | * |
| | | * |
| | | * @param definition |
| | | * The name form definition. |
| | | * @param overwrite |
| | |
| | | |
| | | /** |
| | | * Adds the provided name form definition to this schema builder. |
| | | * |
| | | * |
| | | * @param oid |
| | | * The OID of the name form definition. |
| | | * @param names |
| | |
| | | |
| | | /** |
| | | * Adds the provided object class definition to this schema builder. |
| | | * |
| | | * |
| | | * @param definition |
| | | * The object class definition. |
| | | * @param overwrite |
| | |
| | | |
| | | /** |
| | | * Adds the provided object class definition to this schema builder. |
| | | * |
| | | * |
| | | * @param oid |
| | | * The OID of the object class definition. |
| | | * @param names |
| | |
| | | |
| | | /** |
| | | * Adds the provided pattern syntax definition to this schema builder. |
| | | * |
| | | * |
| | | * @param oid |
| | | * The OID of the pattern syntax definition. |
| | | * @param description |
| | |
| | | /** |
| | | * Adds all of the schema elements in the provided schema to this |
| | | * schema builder. |
| | | * |
| | | * |
| | | * @param schema |
| | | * The schema to be copied into this schema builder. |
| | | * @param overwrite |
| | |
| | | /** |
| | | * Adds the provided substitution syntax definition to this schema |
| | | * builder. |
| | | * |
| | | * |
| | | * @param oid |
| | | * The OID of the substitution syntax definition. |
| | | * @param description |
| | |
| | | |
| | | /** |
| | | * Adds the provided syntax definition to this schema builder. |
| | | * |
| | | * |
| | | * @param definition |
| | | * The syntax definition. |
| | | * @param overwrite |
| | |
| | | |
| | | /** |
| | | * Adds the provided syntax definition to this schema builder. |
| | | * |
| | | * |
| | | * @param oid |
| | | * The OID of the syntax definition. |
| | | * @param description |
| | |
| | | |
| | | /** |
| | | * Removes the named attribute type from this schema builder. |
| | | * |
| | | * |
| | | * @param name |
| | | * The name or OID of the attribute type to be removed. |
| | | * @return {@code true} if the attribute type was found. |
| | |
| | | |
| | | /** |
| | | * Removes the named DIT content rule from this schema builder. |
| | | * |
| | | * |
| | | * @param name |
| | | * The name or OID of the DIT content rule to be removed. |
| | | * @return {@code true} if the DIT content rule was found. |
| | |
| | | |
| | | /** |
| | | * Removes the specified DIT structure rule from this schema builder. |
| | | * |
| | | * |
| | | * @param ruleID |
| | | * The ID of the DIT structure rule to be removed. |
| | | * @return {@code true} if the DIT structure rule was found. |
| | |
| | | |
| | | /** |
| | | * Removes the named matching rule from this schema builder. |
| | | * |
| | | * |
| | | * @param name |
| | | * The name or OID of the matching rule to be removed. |
| | | * @return {@code true} if the matching rule was found. |
| | |
| | | |
| | | /** |
| | | * Removes the named matching rule use from this schema builder. |
| | | * |
| | | * |
| | | * @param name |
| | | * The name or OID of the matching rule use to be removed. |
| | | * @return {@code true} if the matching rule use was found. |
| | |
| | | |
| | | /** |
| | | * Removes the named name form from this schema builder. |
| | | * |
| | | * |
| | | * @param name |
| | | * The name or OID of the name form to be removed. |
| | | * @return {@code true} if the name form was found. |
| | |
| | | |
| | | /** |
| | | * Removes the named object class from this schema builder. |
| | | * |
| | | * |
| | | * @param name |
| | | * The name or OID of the object class to be removed. |
| | | * @return {@code true} if the object class was found. |
| | |
| | | |
| | | /** |
| | | * Removes the named syntax from this schema builder. |
| | | * |
| | | * |
| | | * @param numericOID |
| | | * The name of the syntax to be removed. |
| | | * @return {@code true} if the syntax was found. |
| | |
| | | * schema builder maintains its own set of compatibility options, so |
| | | * subsequent changes to the provided set of options will not impact |
| | | * this schema builder. |
| | | * |
| | | * |
| | | * @param options |
| | | * The set of schema compatibility options that this schema |
| | | * builder should use. |
| | |
| | | * <p> |
| | | * When this method returns this schema builder is empty and contains |
| | | * a default set of compatibility options. |
| | | * |
| | | * |
| | | * @return A {@code Schema} containing all of the schema elements |
| | | * contained in this schema builder as well as the same set of |
| | | * schema compatibility options |
| | |
| | | { |
| | | validate(); |
| | | final Schema builtSchema = schema; |
| | | initBuilder(); |
| | | initBuilder(null); |
| | | return builtSchema; |
| | | } |
| | | |
| | | |
| | | |
| | | void addWarning(LocalizableMessage warning) |
| | | { |
| | | warnings.add(warning); |
| | | } |
| | | |
| | | |
| | | |
| | | private synchronized void addAttributeType(AttributeType attribute, |
| | | boolean overwrite) throws ConflictingSchemaElementException |
| | | { |
| | |
| | | |
| | | |
| | | |
| | | private void initBuilder() |
| | | private void initBuilder(String schemaName) |
| | | { |
| | | numericOID2Syntaxes = new HashMap<String, Syntax>(); |
| | | numericOID2MatchingRules = new HashMap<String, MatchingRule>(); |
| | |
| | | options = SchemaCompatOptions.defaultOptions(); |
| | | warnings = new LinkedList<LocalizableMessage>(); |
| | | |
| | | schema = new Schema(numericOID2Syntaxes, numericOID2MatchingRules, |
| | | numericOID2MatchingRuleUses, numericOID2AttributeTypes, |
| | | numericOID2ObjectClasses, numericOID2NameForms, |
| | | numericOID2ContentRules, id2StructureRules, name2MatchingRules, |
| | | name2MatchingRuleUses, name2AttributeTypes, name2ObjectClasses, |
| | | name2NameForms, name2ContentRules, name2StructureRules, |
| | | objectClass2NameForms, nameForm2StructureRules, options, |
| | | warnings); |
| | | if (schemaName == null) |
| | | { |
| | | schemaName = String.format("Schema#%d", nextSchemaID |
| | | .getAndIncrement()); |
| | | } |
| | | |
| | | schema = new Schema(schemaName, numericOID2Syntaxes, |
| | | numericOID2MatchingRules, numericOID2MatchingRuleUses, |
| | | numericOID2AttributeTypes, numericOID2ObjectClasses, |
| | | numericOID2NameForms, numericOID2ContentRules, |
| | | id2StructureRules, name2MatchingRules, name2MatchingRuleUses, |
| | | name2AttributeTypes, name2ObjectClasses, name2NameForms, |
| | | name2ContentRules, name2StructureRules, objectClass2NameForms, |
| | | nameForm2StructureRules, options, warnings); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | void addWarning(LocalizableMessage warning) |
| | | { |
| | | warnings.add(warning); |
| | | } |
| | | } |