PersistentSearchChangeType.java revision 998747bfaaa3c6b28bbfaf0e282e6c0ccbf46bc0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
* Portions Copyright 2013-2015 ForgeRock AS
*/
/**
* This enumeration defines the set of possible change types that may be used in
* conjunction with the persistent search control, as defined in
* draft-ietf-ldapext-psearch.
* <p>
* It is a different type from {@link ChangeOperationType} to enforce type
* safety, despite mirroring it completely.
*/
public enum PersistentSearchChangeType
{
/** The change type that will be used for add operations. */
ADD(1),
/** The change type that will be used for delete operations. */
DELETE(2),
/** The change type that will be used for modify operations. */
MODIFY(4),
/** The change type that will be used for modify DN operations. */
MODIFY_DN(8);
/** The integer value associated with this change type. */
private int intValue;
/**
* Creates a new instance of a persistent search change type with the provided
* integer value.
*
* @param intValue The integer value associated with this change type.
*/
private PersistentSearchChangeType(int intValue)
{
}
/**
* Retrieves the integer value associated with this change type.
*
* @return The integer value associated with this change type.
*/
public int intValue()
{
return intValue;
}
/**
* Retrieves a string representation of this persistent search change type.
*
* @return A string representation of this persistent search change type, or
* "unknown" if it has an unknown type.
*/
{
switch (intValue)
{
case 1:
return "add";
case 2:
return "delete";
case 4:
return "modify";
case 8:
return "modDN";
default:
return "unknown";
}
}
/**
* Retrieves the change type associated with the provided integer value.
*
* @param intValue The integer value to decode as a change type.
*
* @return The change type corresponding to the provided integer value.
*
* @throws LDAPException If the provided integer value is not associated
* with a valid change type.
*/
throws LDAPException
{
switch (intValue)
{
case 1:
return ADD;
case 2:
return DELETE;
case 4:
return MODIFY;
case 8:
return MODIFY_DN;
default:
}
}
/**
* Decodes the provided int value into a set of change types as per the
* specification in draft-ietf-ldapext-psearch.
*
* @param intValue The integer value representing the encoded change types.
*
* @return The set of change types decoded from the provided integer value.
*
* @throws LDAPException If the provided integer value does not represent a
* valid encoded set of change types.
*/
throws LDAPException
{
switch (intValue)
{
case 0:
// No change types are included. This won't be allowed because it
// doesn't make any sense.
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 6:
break;
case 7:
break;
case 8:
break;
case 9:
break;
case 10:
break;
case 11:
break;
case 12:
break;
case 13:
break;
case 14:
break;
case 15:
break;
default:
}
return changeTypes;
}
/**
* Retrieves the integer representation of the provided set of change types.
*
* @param changeTypes The set of change types to be encoded.
*
* @return The integer representation of the provided set of change types.
*/
{
int intValue = 0;
{
intValue |= 1;
}
{
intValue |= 2;
}
{
intValue |= 4;
}
{
intValue |= 8;
}
return intValue;
}
/**
* Retrieves a string representation of the provided set of change types.
*
* @param changeTypes The set of change types to encode.
*
* @return A string representation of the provided set of change types.
*/
{
}
/**
* Appends a string representation of the specified set of change types to the
* provided buffer.
*
* @param changeTypes The set of change types to encode.
* @param buffer The buffer to which the information should be written.
*/
{
{
{
}
}
}
}