From 6439bba5cc09d6febc59bdc9e0d9bc25f1f1eb18 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Wed, 01 Sep 2010 09:04:15 +0000
Subject: [PATCH] Various improvements:
---
sdk/src/org/opends/sdk/schema/SchemaBuilder.java | 150 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 147 insertions(+), 3 deletions(-)
diff --git a/sdk/src/org/opends/sdk/schema/SchemaBuilder.java b/sdk/src/org/opends/sdk/schema/SchemaBuilder.java
index 2dcd5ce..3509ec4 100644
--- a/sdk/src/org/opends/sdk/schema/SchemaBuilder.java
+++ b/sdk/src/org/opends/sdk/schema/SchemaBuilder.java
@@ -42,9 +42,7 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
-import org.opends.sdk.DecodeException;
-import org.opends.sdk.LocalizableMessage;
-import org.opends.sdk.LocalizedIllegalArgumentException;
+import org.opends.sdk.*;
import com.sun.opends.sdk.util.StaticUtils;
import com.sun.opends.sdk.util.SubstringReader;
@@ -116,6 +114,152 @@
/**
+ * Creates a new schema builder containing all of the schema elements
+ * contained in the provided a subschema subentry. Any problems encountered
+ * while parsing the entry can be retrieved using the returned schema's
+ * {@link Schema#getWarnings()} method.
+ *
+ * @param entry
+ * The subschema subentry to be parsed.
+ * @throws NullPointerException
+ * If {@code entry} was {@code null}.
+ */
+ public SchemaBuilder(final Entry entry) throws NullPointerException
+ {
+ initBuilder(entry.getName().toString());
+
+ Attribute attr = entry.getAttribute(Schema.ATTR_LDAP_SYNTAXES);
+ if (attr != null)
+ {
+ for (final ByteString def : attr)
+ {
+ try
+ {
+ addSyntax(def.toString(), true);
+ }
+ catch (final LocalizedIllegalArgumentException e)
+ {
+ addWarning(e.getMessageObject());
+ }
+ }
+ }
+
+ attr = entry.getAttribute(Schema.ATTR_ATTRIBUTE_TYPES);
+ if (attr != null)
+ {
+ for (final ByteString def : attr)
+ {
+ try
+ {
+ addAttributeType(def.toString(), true);
+ }
+ catch (final LocalizedIllegalArgumentException e)
+ {
+ addWarning(e.getMessageObject());
+ }
+ }
+ }
+
+ attr = entry.getAttribute(Schema.ATTR_OBJECT_CLASSES);
+ if (attr != null)
+ {
+ for (final ByteString def : attr)
+ {
+ try
+ {
+ addObjectClass(def.toString(), true);
+ }
+ catch (final LocalizedIllegalArgumentException e)
+ {
+ addWarning(e.getMessageObject());
+ }
+ }
+ }
+
+ attr = entry.getAttribute(Schema.ATTR_MATCHING_RULE_USE);
+ if (attr != null)
+ {
+ for (final ByteString def : attr)
+ {
+ try
+ {
+ addMatchingRuleUse(def.toString(), true);
+ }
+ catch (final LocalizedIllegalArgumentException e)
+ {
+ addWarning(e.getMessageObject());
+ }
+ }
+ }
+
+ attr = entry.getAttribute(Schema.ATTR_MATCHING_RULES);
+ if (attr != null)
+ {
+ for (final ByteString def : attr)
+ {
+ try
+ {
+ addMatchingRule(def.toString(), true);
+ }
+ catch (final LocalizedIllegalArgumentException e)
+ {
+ addWarning(e.getMessageObject());
+ }
+ }
+ }
+
+ attr = entry.getAttribute(Schema.ATTR_DIT_CONTENT_RULES);
+ if (attr != null)
+ {
+ for (final ByteString def : attr)
+ {
+ try
+ {
+ addDITContentRule(def.toString(), true);
+ }
+ catch (final LocalizedIllegalArgumentException e)
+ {
+ addWarning(e.getMessageObject());
+ }
+ }
+ }
+
+ attr = entry.getAttribute(Schema.ATTR_DIT_STRUCTURE_RULES);
+ if (attr != null)
+ {
+ for (final ByteString def : attr)
+ {
+ try
+ {
+ addDITStructureRule(def.toString(), true);
+ }
+ catch (final LocalizedIllegalArgumentException e)
+ {
+ addWarning(e.getMessageObject());
+ }
+ }
+ }
+
+ attr = entry.getAttribute(Schema.ATTR_NAME_FORMS);
+ if (attr != null)
+ {
+ for (final ByteString def : attr)
+ {
+ try
+ {
+ addNameForm(def.toString(), true);
+ }
+ catch (final LocalizedIllegalArgumentException e)
+ {
+ addWarning(e.getMessageObject());
+ }
+ }
+ }
+ }
+
+
+
+ /**
* Creates a new schema builder containing all of the schema elements from the
* provided schema and its compatibility options.
*
--
Gitblit v1.10.0