CollectionHelper.java revision 89fd04babb277ae294172d6fa5c28c1b775cfa9f
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 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: CollectionHelper.java,v 1.6 2010/01/06 22:31:55 veiming Exp $
*
* Portions Copyrighted 2010-2015 ForgeRock AS.
*/
/**
* This class contains various Collection manipulation methods.
*/
public class CollectionHelper {
/**
* Returns String from a map of string of set of string.
*
* @param map Map of string of set of string.
* @param name Key of the map entry.
* @return String from a map of string of set of string
*/
}
/**
* Returns String from a map of string of set of string.
*
* @param map Map of string of set of string.
* @param name Key of the map entry.
* @param defaultValue Default value if the string is not found.
* @return String from a map of string of set of string
*/
}
/**
* Return String from a map of strings to set of strings.
* @param map
* @param key
* @return the String value from a map of strings to set of strings.
* @throws ValueNotFoundException if no value is found for the key.
*
*/
}
return str;
}
/**
* Gets a boolean attribute from a {@code Map<String, Set<String>>}, defaulting to the given default value if
* the attribute is not present.
*
* @param map the attribute map.
* @param name the name of the attribute to retrieve.
* @param defaultValue the value to use if the attribute is not present.
* @return the boolean value using {@link Boolean#parseBoolean(String)}.
*/
}
/**
* Gets a boolean attribute from a {@code Map<String, Set<String>>}, throwing an exception if no boolean value (case
* insensitive comparisons against "true" or "false") is found for the given key.
*
* @param map
* the attribute map.
* @param name
* the name of the attribute to retrieve.
* @return the boolean value using {@link Boolean#parseBoolean(String)}.
* @throws ValueNotFoundException
* if no boolean value is found for the given key.
*/
throws ValueNotFoundException {
return boolValue;
}
/**
* Returns integer value from a Map of String of Set of String.
*
* @param map Map of String of Set of String.
* @param name Kye of the map entry.
* @param defaultValue Default value if the integer value is not found.
* @param debug Debug object.
* @return integer value from a Map of String of Set of String.
*/
public static int getIntMapAttr(
) {
try {
} catch (NumberFormatException nfe) {
}
}
/**
* Returns integer value from a Map of String of Set of String.
*
* @param map Map of String of Set of String.
* @param name Key of the map entry.
* @param defaultValue Default value if the integer value is not found.
* @param debug Debug object.
* @return integer value from a Map of String of Set of String.
*/
public static int getIntMapAttr(
int defaultValue,
) {
try {
} catch (NumberFormatException nfe) {
return defaultValue;
}
}
/**
* Returns integer value from a Map of String of Set of String.
*
* @param map
* Map of String of Set of String.
* @param name
* Key of the map entry.
* @return integer value from a Map of String of Set of String.
* @throws ValueNotFoundException
* if there is no value for the key provided.
*/
throws ValueNotFoundException {
try {
} catch (NumberFormatException nfe) {
}
}
/**
* Returns a long value from the given configuration map.
*
* @param config the map of attribute values.
* @param name the attribute name to get.
* @param defaultValue the default value to use if the attribute is not set or is not a long.
* @param debug the debug object to report format errors to.
*/
public static long getLongMapAttr(Map<String, Set<String>> config, String name, long defaultValue, Debug debug) {
try {
} catch (NumberFormatException nfe) {
return defaultValue;
}
}
/**
* Given the map attempts to return the named value as a long.
*
* @param map
* the map
* @param name
* the named value
*
* @return the corresponding long value
*
* @throws ValueNotFoundException
* should the value fail to parse
*/
public static long getLongMapAttrThrows(Map<String, Set<String>> map, String name) throws ValueNotFoundException {
try {
} catch (NumberFormatException nfe) {
}
}
/**
* Returns the first attribute value for the corresponding name in the config map and parses it to a long.
*
* @param config The map where the attribute should be retrieved from.
* @param name The name of the attribute that should be retrieved from the map.
* @return The attribute from the map corresponding to the provided attribute name, parsed to a long.
* If the attribute does not exist the current date time will be returned.
*/
public static long getMapAttrAsDateLong(Map<String, Set<String>> config, String name, Logger logger) {
try {
} catch (NumberFormatException nfe) {
}
}
/**
* This convenience method is for getting server specific attributes from a
* list attribute. Server specific is determined by prefixing a list
* attribute value with DSAME local server name followed by the | character.
* If the list has more than one entry but no matching local server prefixes
* than null is returned as this is an invalid configuration for these type
* of attributes. This allows services like authentication to support a
* geographic directory configuration.
*
* @param map Map of String of Set of String.
* @param attrName Key of the map entry of interest.
* @return the server name.
*/
}
return strServer;
}
) {
if (index != -1) {
} else {
}
} else {
}
}
}
}
return result;
}
/**
* This convenience method is for getting server specific attributes from a
* list attribute. Server specific is determined by prefixing a list
* attribute value with DSAME local server name followed by the | character.
* The priority order of the attributes as follows.
* 1- LDAP Servers belong to current OpenAM Server, localDsameServer is prefixed with the attribute
* 2- LDAP Servers belong to no OpenAM Server, no server prefix
* 3- All other servers - LDAP Servers prefixed with other OpenAM Servers
* This allows services like authentication to support a geographic directory configuration.
*
* @param map Map of String of Set of String.
* @param attrName Key of the map entry of interest.
* @return attributes based on the prioritization.
*/
if (index == -1) {
} else {
} else {
}
}
}
}
return ret;
}
}