From e3b8d5e3dbf22f89d86c11def28c466ab45909e3 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Tue, 15 May 2012 16:14:54 +0000
Subject: [PATCH] Fix OPENDJ-497: Add support for user defined parsing: AttributeParser.as() and AttributeParser.asSetOf()
---
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Functions.java | 45 ++++++++++++++++++++++++---------------------
1 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Functions.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Functions.java
similarity index 93%
rename from opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Functions.java
rename to opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Functions.java
index 87302c0..408e18a 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/Functions.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Functions.java
@@ -25,7 +25,7 @@
* Portions copyright 2012 ForgeRock AS.
*/
-package com.forgerock.opendj.util;
+package org.forgerock.opendj.ldap;
import static org.forgerock.opendj.ldap.CoreMessages.FUNCTIONS_TO_INTEGER_FAIL;
import static org.forgerock.opendj.ldap.CoreMessages.FUNCTIONS_TO_LONG_FAIL;
@@ -33,14 +33,17 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
-import org.forgerock.opendj.ldap.AttributeDescription;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.DN;
-import org.forgerock.opendj.ldap.GeneralizedTime;
import org.forgerock.opendj.ldap.schema.Schema;
+import com.forgerock.opendj.util.StaticUtils;
+
/**
- * Common {@link Function} implementations.
+ * Common {@link Function} implementations which may be used when parsing
+ * attributes.
+ *
+ * @see Entry#parseAttribute
+ * @see Attribute#parse
+ * @see AttributeParser
*/
public final class Functions {
@@ -156,22 +159,22 @@
};
private static final Function<ByteString, AttributeDescription, Schema> BYTESTRING_TO_ATTRIBUTE_DESCRIPTION =
- composeSecondP(valueToString(), STRING_TO_ATTRIBUTE_DESCRIPTION);
+ composeSecondP(byteStringToString(), STRING_TO_ATTRIBUTE_DESCRIPTION);
private static final Function<ByteString, Boolean, Void> BYTESTRING_TO_BOOLEAN = compose(
- valueToString(), STRING_TO_BOOLEAN);
+ byteStringToString(), STRING_TO_BOOLEAN);
private static final Function<ByteString, DN, Schema> BYTESTRING_TO_DN = composeSecondP(
- valueToString(), STRING_TO_DN);
+ byteStringToString(), STRING_TO_DN);
private static final Function<ByteString, GeneralizedTime, Void> BYTESTRING_TO_GENERALIZED_TIME =
- compose(valueToString(), STRING_TO_GENERALIZED_TIME);
+ compose(byteStringToString(), STRING_TO_GENERALIZED_TIME);
private static final Function<ByteString, Integer, Void> BYTESTRING_TO_INTEGER = compose(
- valueToString(), STRING_TO_INTEGER);
+ byteStringToString(), STRING_TO_INTEGER);
private static final Function<ByteString, Long, Void> BYTESTRING_TO_LONG = compose(
- valueToString(), STRING_TO_LONG);
+ byteStringToString(), STRING_TO_LONG);
/**
* Returns the composition of two functions. The result of the first
@@ -422,7 +425,7 @@
*
* @return A function which parses {@code AttributeDescription}s.
*/
- public static Function<ByteString, AttributeDescription, Void> valueToAttributeDescription() {
+ public static Function<ByteString, AttributeDescription, Void> byteStringToAttributeDescription() {
return fixedFunction(BYTESTRING_TO_ATTRIBUTE_DESCRIPTION, Schema.getDefaultSchema());
}
@@ -435,7 +438,7 @@
* The schema to use for decoding attribute descriptions.
* @return A function which parses {@code AttributeDescription}s.
*/
- public static Function<ByteString, AttributeDescription, Void> valueToAttributeDescription(
+ public static Function<ByteString, AttributeDescription, Void> byteStringToAttributeDescription(
final Schema schema) {
return fixedFunction(BYTESTRING_TO_ATTRIBUTE_DESCRIPTION, schema);
}
@@ -448,7 +451,7 @@
*
* @return A function which parses {@code Boolean} values.
*/
- public static Function<ByteString, Boolean, Void> valueToBoolean() {
+ public static Function<ByteString, Boolean, Void> byteStringToBoolean() {
return BYTESTRING_TO_BOOLEAN;
}
@@ -459,7 +462,7 @@
*
* @return A function which parses {@code DN}s.
*/
- public static Function<ByteString, DN, Void> valueToDN() {
+ public static Function<ByteString, DN, Void> byteStringToDN() {
return fixedFunction(BYTESTRING_TO_DN, Schema.getDefaultSchema());
}
@@ -472,7 +475,7 @@
* The schema to use for decoding DNs.
* @return A function which parses {@code DN}s.
*/
- public static Function<ByteString, DN, Void> valueToDN(final Schema schema) {
+ public static Function<ByteString, DN, Void> byteStringToDN(final Schema schema) {
return fixedFunction(BYTESTRING_TO_DN, schema);
}
@@ -482,7 +485,7 @@
*
* @return A function which parses generalized time strings.
*/
- public static Function<ByteString, GeneralizedTime, Void> valueToGeneralizedTime() {
+ public static Function<ByteString, GeneralizedTime, Void> byteStringToGeneralizedTime() {
return BYTESTRING_TO_GENERALIZED_TIME;
}
@@ -492,7 +495,7 @@
*
* @return A function which parses {@code Integer} string values.
*/
- public static Function<ByteString, Integer, Void> valueToInteger() {
+ public static Function<ByteString, Integer, Void> byteStringToInteger() {
return BYTESTRING_TO_INTEGER;
}
@@ -502,7 +505,7 @@
*
* @return A function which parses {@code Long} string values.
*/
- public static Function<ByteString, Long, Void> valueToLong() {
+ public static Function<ByteString, Long, Void> byteStringToLong() {
return BYTESTRING_TO_LONG;
}
@@ -513,7 +516,7 @@
* @return A function which parses the string representation of a
* {@code ByteString} as a UTF-8 encoded {@code String}.
*/
- public static Function<ByteString, String, Void> valueToString() {
+ public static Function<ByteString, String, Void> byteStringToString() {
return BYTESTRING_TO_STRING;
}
--
Gitblit v1.10.0