From 54c2799f45256fef4a981fa2a6a7c97a9708ac8b Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Thu, 26 Jul 2007 12:01:44 +0000
Subject: [PATCH] Partial fix for issue 1831 - dsconfig interactive mode.
---
opends/src/server/org/opends/server/admin/ManagedObjectPath.java | 71 ++++++++++++++++++++++++++++++++++-
1 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/opends/src/server/org/opends/server/admin/ManagedObjectPath.java b/opends/src/server/org/opends/server/admin/ManagedObjectPath.java
index eb164e1..d81a34c 100644
--- a/opends/src/server/org/opends/server/admin/ManagedObjectPath.java
+++ b/opends/src/server/org/opends/server/admin/ManagedObjectPath.java
@@ -150,6 +150,18 @@
/**
+ * Get the name associated with this element if applicable.
+ *
+ * @return Returns the name associated with this element if
+ * applicable.
+ */
+ public String getName() {
+ return null;
+ }
+
+
+
+ /**
* Get the relation definition associated with this element.
*
* @return Returns the relation definition associated with this
@@ -211,6 +223,16 @@
* {@inheritDoc}
*/
@Override
+ public String getName() {
+ return name;
+ }
+
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public InstantiableRelationDefinition<? super C, ? super S>
getRelationDefinition() {
return r;
@@ -395,8 +417,8 @@
// Common element serialization.
- private <M, N> void serializeElement(RelationDefinition r,
- AbstractManagedObjectDefinition d) {
+ private <M, N> void serializeElement(RelationDefinition<?, ?> r,
+ AbstractManagedObjectDefinition<?, ?> d) {
// Always specify the relation name.
builder.append("/relation=");
builder.append(r.getName());
@@ -636,6 +658,49 @@
/**
+ * Creates a new managed object path which has the same structure as
+ * this path except that the final path element is associated with
+ * the specified managed object definition.
+ *
+ * @param <CC>
+ * The type of client managed object configuration that
+ * this path will reference.
+ * @param <SS>
+ * The type of server managed object configuration that
+ * this path will reference.
+ * @param nd
+ * The new managed object definition.
+ * @return Returns a new managed object path which has the same
+ * structure as this path except that the final path element
+ * is associated with the specified managed object
+ * definition.
+ */
+ @SuppressWarnings("unchecked")
+ public <CC extends C, SS extends S> ManagedObjectPath<CC, SS> asSubType(
+ AbstractManagedObjectDefinition<CC, SS> nd) {
+ if (r instanceof InstantiableRelationDefinition) {
+ InstantiableRelationDefinition<? super C, ? super S> ir =
+ (InstantiableRelationDefinition<? super C, ? super S>) r;
+ if (elements.size() == 0) {
+ return parent().child(ir, nd, null);
+ } else {
+ return parent().child(ir, nd,
+ elements.get(elements.size() - 1).getName());
+ }
+ } else if (r instanceof OptionalRelationDefinition) {
+ OptionalRelationDefinition<? super C, ? super S> or =
+ (OptionalRelationDefinition<? super C, ? super S>) r;
+ return parent().child(or, nd);
+ } else {
+ SingletonRelationDefinition<? super C, ? super S> sr =
+ (SingletonRelationDefinition<? super C, ? super S>) r;
+ return parent().child(sr, nd);
+ }
+ }
+
+
+
+ /**
* Creates a new child managed object path beneath the provided
* parent path having the specified managed object definition.
*
@@ -804,7 +869,7 @@
if (obj == this) {
return true;
} else if (obj instanceof ManagedObjectPath) {
- ManagedObjectPath other = (ManagedObjectPath) obj;
+ ManagedObjectPath<?, ?> other = (ManagedObjectPath<?, ?>) obj;
return toString().equals(other.toString());
} else {
return false;
--
Gitblit v1.10.0