Attr.java revision bee2440354b4bc8796e1de0b6cbd60e1f68deba0
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: Attr.java,v 1.4 2009/01/28 05:34:49 ww203982 Exp $
*
* Portions Copyrighted 2011-2015 ForgeRock AS.
*/
/**
* Represents an attribute value pair in UMS. The value of an attribute can be
* of multiple values.
* @supported.api
*/
private List<byte[]> _byteValues;
private Attribute _ldapAttribute;
/**
* Default constructor
* @supported.api
*/
public Attr() {
}
/**
* Constructs an attribute value pair with no value.
*
* @param name
* attribute name
* @supported.api
*/
}
/**
* Construct an attribute value pair with a single string value.
*
* @param name
* the name of attribute
* @param value
* string value of attribute
* @supported.api
*/
}
/**
* Construct an attribute value pair with a multiple string values.
*
* @param name
* the name of attribute
* @param value
* multiple string values of attribute
* @supported.api
*/
for (int i = 0; i < size; i++) {
}
}
/**
* Constructs an attribute value pair with byte array.
*
* @param name
* attribute name
* @param value
* byte array as input for value
* @supported.api
*/
}
/**
* Constructs an attribute value pair with array of byte array.
*
* @param name
* attribute name
* @param value
* array of byte array as input for value
* @supported.api
*/
for (int i = 0; i < size; i++) {
}
}
/**
* Construct an attribute based on a LDAP attribute
*
* @param attr
* ldap attribute to construct from
*/
}
/**
* Map to a ldap attribute
*
* @return an ldap attribute
*/
public Attribute toLDAPAttribute() {
if (_stringValues != null) {
if (size == 0) {
} else if (size == 1) {
} else if (size > 1) {
}
}
} else if (_byteValues != null) {
for (byte[] value : _byteValues) {
}
} else if (_ldapAttribute != null) {
}
return ldapAttribute;
}
/**
* Set value of an attribute
*
* @param value
* the attribute value to be set
* @supported.api
*/
if (_stringValues == null) {
}
}
/**
* Add a string value to the attribute
*
* @param value
* value to be added to the attribute
* @supported.api
*/
if (_stringValues == null) {
}
}
}
/**
* Add mulitple string values to the attribute
*
* @param values
* string values to be added to the attribute
* @supported.api
*/
for (int i = 0; i < size; i++) {
}
}
/**
* Remove a specified string value in the attribute
*
* @param value
* specified value to be remvoed from the value array
* @supported.api
*/
if (_stringValues == null) {
}
for (int i = 0; i < size; i++) {
_stringValues.remove(i);
break;
}
}
}
/**
* Set value of an attribute
*
* @param value
* the attribute value to be set
* @supported.api
*/
if (_byteValues == null) {
}
_byteValues.clear();
}
/**
* Add a byte array value to the attribute
*
* @param value
* byte array value to be added to the attribute
* @supported.api
*/
if (_byteValues == null) {
}
}
/**
* Add a list byte array values to the attribute
*
* @param values
* of byte array values to be added to the attribute
* @supported.api
*/
for (int i = 0; i < size; i++) {
}
}
/**
* Remove a specified string value in the attribute
*
* @param value
* specified value to be remvoed from the value array
* @supported.api
*/
public void removeValue(byte[] value) {
if (_byteValues == null) {
}
for (int i = 0; i < size; i++) {
// we might have to change the logic here to compare each byte
_byteValues.remove(i);
break;
}
}
}
/**
* Get name of an UMS attribute
*
* @return name of an UMS attribute
* @supported.api
*/
return _name;
}
/**
* Get name of attribute in a given Locale
*
* @param locale
* Given locale for the attribute name to return
* @return name of an UMS attribute
* @supported.api
*/
}
/**
* Get attribute name with locale input.
*
* @param attrName
* name of the attribute
* @param locale
* desired locale for the attribute
* @return attribute name with locale attached for retrieval
* @supported.api
*/
} else {
// TODO: ??? check if locale.toString method provides the
// contents in locale.getLanguage, locale.getSubtype, and
// locale.getVariant methods that match the language subtypes
// in LDAP.
//
}
}
return name;
}
/**
* Get base name for the attribute. e.g, the base name
* of "cn;lang-en" or "cn;lang-ja" is "cn"
*
* @return basename of an attribute
* @supported.api
*/
public String getBaseName() {
return getBaseName(getName());
}
return null;
}
/**
* Get base name for an attribute name. e.g, the base
* name of "cn;lang-en" or "cn;lang-ja" is "cn"
*
* @return basename of the given attribute name
* @supported.api
*/
if( st.hasMoreElements() )
// First element is base name
return basename;
}
/**
* Get one string value of the attribute
*
* @return one value of the attribute
* @supported.api
*/
if (_stringValues == null) {
}
if (!_stringValues.isEmpty()) {
}
return value;
}
/**
* Get the string values of the attribute
*
* @return the values in an string array
* @supported.api
*/
public String[] getStringValues() {
// Returning a colletion would be better, but would break existing
// higher level
// code
// com.iplanet.ums.Pauser.pause("10", "_stringValues : " +
// _stringValues);
// com.iplanet.ums.Pauser.pause("10", "_stringValue : " + _stringValue);
// System.out.println("_stringValue : " + _stringValue);
// System.out.println("_stringValues : " + _stringValues);
if (_stringValues == null) {
}
for (int i = 0; i < size; i++) {
}
return stringValues;
}
/**
* Checks whether the given value already exist for
* the attribute
*
* @param value
* the value to check for
* @return <code>true</code> if the value already exists,
* <code>false</code> otherwise
* @supported.api
*/
boolean contained = false;
if (_stringValues == null) {
}
for (int i = 0; i < size; i++) {
contained = true;
break;
}
}
return contained;
}
/**
* Get one byte[] value of the attribute Returning a
* colletion would be better, but will not be consistent with the method
* getStringValues()
*
* @return one byte[] value
* @supported.api
*/
public byte[] getByteValue() {
// Not cloning the value before returning. Do we need to clone?
if (_byteValues == null) {
}
if (!_byteValues.isEmpty()) {
}
return value;
}
/**
* Get the byte[] values of the attribute
*
* @return the byte[] values in array
* @supported.api
*/
public byte[][] getByteValues() {
// Not cloning the values before returning. Do we need to clone?
byte[][] byteValues = null;
if (_byteValues == null) {
}
byteValues = new byte[size][];
for (int i = 0; i < size; i++) {
}
return byteValues;
}
/**
* Checks whether the given value already exist for
* the attribute
*
* @param value
* the value to check for
* @return <code>true</code> if the value already exists,
* <code>false</code> otherwise
* @supported.api
*/
boolean contained = false;
if (_byteValues == null) {
}
for (int i = 0; i < size; i++) {
// we might have to change the logic here to compare each byte
contained = true;
break;
}
}
return contained;
}
/**
* Get the number of values of the attribute
*
* @return The number of values of the attribute
* @supported.api
*/
public int size() {
int size = 0;
if (_stringValues != null) {
} else if (_byteValues != null) {
} else if (_ldapAttribute != null) {
}
return size;
}
/**
* Return a copy of the object
*
* @return A copy of the object
* @supported.api
*/
/*
* TO DO : revisit and do proper deep cloning?
*/
try {
} catch (Exception e) {
}
if (_stringValues != null) {
}
if (_byteValues != null) {
} else if (_ldapAttribute != null) {
}
return theClone;
}
/**
* Retrieves the string representation of an attribute
*
* @return string representation of the attribute.
* @supported.api
*/
if (_stringValues == null) {
}
}
/**
*/
private void setupStringValues() {
if (_ldapAttribute != null) {
for (int i = 0; i < size; i++) {
}
} else {
_stringValues = new ArrayList<>();
}
}
/**
*/
private void setupByteValues() {
if (_ldapAttribute != null) {
for (int i = 0; i < size; i++) {
}
} else {
_byteValues = new ArrayList<>();
}
}
}