Enum Class Separator
- All Implemented Interfaces:
Serializable,Comparable<Separator>,Constable
Used to separate row qualifiers, column qualifiers and compound fields.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionseparator in key or column qualifier fields.separator in values, often used to avoid having these in qualifiers and names.separator in values, often used to avoid having these in qualifiers and names.separator in values, and/or compound key/column qualifier fields. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final byte[]empty bytes.static final Stringempty string.static final intIndicator for variable size of an individual segment in a split. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringDecode the given separators in the token with their decoding equivalents.Decode the token encoded usingencode(String).static StringDecode the given separators in the token with their decoding equivalents.Used to make token safe to be used with this separator without collisions.static byte[]Encode the given separators in the token with their encoding equivalents.getValue()byte[]join(byte[]... components) Returns a single byte array containing all of the individual arrays components separated by this separator.joinEncoded(Iterable<?> items) Concatenates items (as String), using this separator.joinEncoded(String... items) Concatenates items (as String), using this separator.byte[][]split(byte[] source) Splits the source array into multiple array segments using this separator, as many times as splits are found.byte[][]split(byte[] source, int limit) Splits the source array into multiple array segments using this separator, up to a maximum of count items.byte[][]split(byte[] source, int[] sizes) Splits the source array into multiple array segments using this separator.splitEncoded(String compoundValue) static SeparatorReturns the enum constant of this class with the specified name.static Separator[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
QUALIFIERS
separator in key or column qualifier fields. -
VALUES
separator in values, and/or compound key/column qualifier fields. -
SPACE
separator in values, often used to avoid having these in qualifiers and names. Note that if we use HTML form encoding through URLEncoder, we end up getting a + for a space, which may already occur in strings, so we don't want that. -
TAB
separator in values, often used to avoid having these in qualifiers and names.
-
-
Field Details
-
VARIABLE_SIZE
public static final int VARIABLE_SIZEIndicator for variable size of an individual segment in a split. The segment ends wherever separator is encountered. Typically used for string. Also used to indicate that there is no fixed number of splits which need to be returned. If split limit is specified as this, all possible splits are returned.- See Also:
-
EMPTY_STRING
empty string.- See Also:
-
EMPTY_BYTES
public static final byte[] EMPTY_BYTESempty bytes.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getValue
- Returns:
- the original value of the separator
-
encode
Used to make token safe to be used with this separator without collisions. It must be paired withdecode(String)for it to be decoded correctly.If you need to encode a given string for multiple separators,
encode(String, Separator...)should be used over successive invocations of this method. It will result in a more compact version of the encoded value.- Parameters:
token- Token to be encoded.- Returns:
- the token with any occurrences of this separator URLEncoded.
-
decode
Decode the token encoded usingencode(String). It must be used for the result encoded withencode(String)to be able to recover the original.- Parameters:
token- Token to be decoded.- Returns:
- the token with any occurrences of the encoded separator replaced by the separator itself.
-
encode
Encode the given separators in the token with their encoding equivalents. It must be paired withdecode(byte[], Separator...)ordecode(String, Separator...)with the same separators for it to be decoded correctly.If you need to encode a given string for multiple separators, this form of encoding should be used over successive invocations of
encode(String). It will result in a more compact version of the encoded value.- Parameters:
token- containing possible separators that need to be encoded.separators- to be encoded in the token with their URLEncoding equivalent.- Returns:
- non-null byte representation of the token with occurrences of the separators encoded.
-
decode
Decode the given separators in the token with their decoding equivalents. It must be used for the result encoded withencode(String, Separator...)with the same separators to be able to recover the original.- Parameters:
token- containing possible separators that need to be encoded.separators- to be encoded in the token with their URLEncoding equivalent.- Returns:
- String representation of the token with occurrences of the URL encoded separators decoded.
-
decode
Decode the given separators in the token with their decoding equivalents. It must be used for the result encoded withencode(String, Separator...)with the same separators to be able to recover the original.- Parameters:
token- containing possible separators that need to be encoded.separators- to be encoded in the token with their URLEncoding equivalent.- Returns:
- String representation of the token with occurrences of the URL encoded separators decoded.
-
join
public byte[] join(byte[]... components) Returns a single byte array containing all of the individual arrays components separated by this separator.- Parameters:
components- Byte array components to be joined together.- Returns:
- byte array after joining the components
-
joinEncoded
Concatenates items (as String), using this separator.- Parameters:
items- Items join,toString()will be called in each item. Any occurrence of the separator in the individual strings will be first encoded. Cannot be null.- Returns:
- non-null joined result. Note that when separator is null
the result is simply all items concatenated and the process is not
reversible through
splitEncoded(String)
-
joinEncoded
Concatenates items (as String), using this separator.- Parameters:
items- Items join,toString()will be called in each item. Any occurrence of the separator in the individual strings will be first encoded. Cannot be null.- Returns:
- non-null joined result. Note that when separator is null
the result is simply all items concatenated and the process is not
reversible through
splitEncoded(String)
-
splitEncoded
- Parameters:
compoundValue- containing individual values separated by this separator, which have that separator encoded.- Returns:
- non-null set of values from the compoundValue with the separator decoded.
-
split
public byte[][] split(byte[] source, int limit) Splits the source array into multiple array segments using this separator, up to a maximum of count items. This will naturally produce copied byte arrays for each of the split segments.- Parameters:
source- to be splitlimit- on how many segments are supposed to be returned. A non-positive value indicates no limit on number of segments.- Returns:
- source split by this separator.
-
split
public byte[][] split(byte[] source, int[] sizes) Splits the source array into multiple array segments using this separator. The sizes indicate the sizes of the relative components/segments. In case one of the segments contains this separator before the specified size is reached, the separator will be considered part of that segment and we will continue till size is reached. Variable length strings cannot contain this separator and are indiced with a size of 0. Such strings are encoded for this separator and decoded after the results from split is returned.- Parameters:
source- byte array to be split.sizes- sizes of relative components/segments.- Returns:
- source split by this separator as per the sizes specified..
-
split
public byte[][] split(byte[] source) Splits the source array into multiple array segments using this separator, as many times as splits are found. This will naturally produce copied byte arrays for each of the split segments.- Parameters:
source- byte array to be split- Returns:
- source split by this separator.
-