com.brettonw.bag.Key Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bag Show documentation
Show all versions of bag Show documentation
Bag provides two container classes for text-based storage of constrained types in
an array (BagArray) or as a map (BagObject), with a means of serializing objects to and from
these container types.
package com.brettonw.bag;
/**
* A helper class for composing paths used in BagObject indexing.
*/
public final class Key {
Key () {}
/**
* Concatenate multiple string components to make a path
* @param components the different levels of the hierarchy to index
* @return a String with the components in path form for indexing into a bag object
*/
public static String cat (Object... components) {
StringBuilder stringBuilder = new StringBuilder ();
if (components.length > 0) {
stringBuilder.append (components[0]);
for (int i = 1; i < components.length; ++i) {
stringBuilder.append (BagObject.PATH_SEPARATOR).append (components[i].toString ());
}
}
return stringBuilder.toString ();
}
static String[] split (String key) {
return key.split (BagObject.PATH_SEPARATOR, 2);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy