Search in sources :

Example 6 with StrBuilder

use of org.apache.commons.lang.text.StrBuilder in project midpoint by Evolveum.

the class StringPolicyUtils method collectCharacterClass.

/**
	 * Prepare usable list of strings for generator
	 * 
	 */
public static String collectCharacterClass(CharacterClassType cc, QName ref) {
    StrBuilder l = new StrBuilder();
    if (null == cc) {
        throw new IllegalArgumentException("Character class cannot be null");
    }
    if (null != cc.getValue() && (null == ref || ref.equals(cc.getName()))) {
        l.append(cc.getValue());
    } else if (null != cc.getCharacterClass() && !cc.getCharacterClass().isEmpty()) {
        // Process all sub lists
        for (CharacterClassType subClass : cc.getCharacterClass()) {
            // If we found requested name or no name defined
            if (null == ref || ref.equals(cc.getName())) {
                l.append(collectCharacterClass(subClass, null));
            } else {
                l.append(collectCharacterClass(subClass, ref));
            }
        }
    }
    // Remove duplicity in return;
    HashSet<String> h = new HashSet<String>();
    for (String s : l.toString().split("")) {
        h.add(s);
    }
    return new StrBuilder().appendAll(h).toString();
}
Also used : CharacterClassType(com.evolveum.midpoint.xml.ns._public.common.common_3.CharacterClassType) StrBuilder(org.apache.commons.lang.text.StrBuilder) HashSet(java.util.HashSet)

Aggregations

StrBuilder (org.apache.commons.lang.text.StrBuilder)6 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 CharacterClassType (com.evolveum.midpoint.xml.ns._public.common.common_3.CharacterClassType)1 StringLimitType (com.evolveum.midpoint.xml.ns._public.common.common_3.StringLimitType)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Scanner (java.util.Scanner)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 Path (org.apache.hadoop.fs.Path)1 DiskBalancerDataNode (org.apache.hadoop.hdfs.server.diskbalancer.datamodel.DiskBalancerDataNode)1 NodePlan (org.apache.hadoop.hdfs.server.diskbalancer.planner.NodePlan)1 GradleException (org.gradle.api.GradleException)1