From 99a6e557a5644d4686da78c0cb87b54331715dca Mon Sep 17 00:00:00 2001
From: Mark Craig <mark.craig@forgerock.com>
Date: Fri, 11 May 2012 11:54:15 +0000
Subject: [PATCH] Mention the new capabilities coming with OPENDJ-355: Add fluent API for decoding attributes

---
 opendj3/src/main/docbkx/dev-guide/chap-reading.xml |   44 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/opendj3/src/main/docbkx/dev-guide/chap-reading.xml b/opendj3/src/main/docbkx/dev-guide/chap-reading.xml
index 4fa1764..064a4f8 100644
--- a/opendj3/src/main/docbkx/dev-guide/chap-reading.xml
+++ b/opendj3/src/main/docbkx/dev-guide/chap-reading.xml
@@ -457,6 +457,50 @@
   </itemizedlist>
  </section>
 
+ <section xml:id="handle-entry-attributes">
+  <title>Working With Entry Attributes</title>
+
+  <para>When you get an entry object, chances are you want to handle attribute
+  values as objects. The OpenDJ LDAP SDK provides the
+  <literal>Entry.parseAttribute()</literal> method and an
+  <literal>AttributeParser</literal> with methods for a variety of attribute
+  value types. You can use these methods to get attribute values as
+  objects.</para>
+
+  <programlisting language="java">
+// Use Kirsten Vaughan's credentials and her entry.
+String name = "uid=kvaughan,ou=People,dc=example,dc=com";
+char[] password = "bribery".toCharArray();
+connection.bind(name, password);
+
+// Make sure we have a timestamp to play with.
+updateEntry(connection, name, "description");
+
+// Read Kirsten's entry.
+final SearchResultEntry entry = connection.readEntry(name,
+        "cn", "objectClass", "hasSubordinates", "numSubordinates",
+        "isMemberOf", "modifyTimestamp");
+
+// Get the entry DN and some attribute values as objects.
+DN dn = entry.getName();
+
+Set&lt;String&gt; cn = entry.parseAttribute("cn").asSetOfString("");
+Set&lt;AttributeDescription&gt; objectClasses =
+        entry.parseAttribute("objectClass").asSetOfAttributeDescription();
+boolean hasChildren = entry.parseAttribute("hasSubordinates").asBoolean();
+int numChildren = entry.parseAttribute("numSubordinates").asInteger(0);
+Set&lt;DN&gt; groups = entry
+        .parseAttribute("isMemberOf")
+        .usingSchema(Schema.getDefaultSchema()).asSetOfDN();
+Calendar timestamp = entry
+        .parseAttribute("modifyTimestamp")
+        .asGeneralizedTime().toCalendar();
+
+// Do something with the objects.
+// ...
+</programlisting>
+ </section>
+
  <section xml:id="handle-ldap-urls">
   <title>Working With LDAP URLs</title>
 

--
Gitblit v1.10.0