All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.brettonw.bag.Key Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 5.10.5
Show newest version
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