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();
}
Aggregations