public final class TextParameter extends Object
Constructor and Description |
---|
TextParameter() |
Modifier and Type | Method and Description |
---|---|
static String |
booleanToTextValue(boolean value)
Translates boolean values to either
Yes (true ) or No (false ). |
static boolean |
checkTextValueFormat(String value)
Checks if the value parameter is a properly formatted String value, i.e.
|
static String |
concatenateKeyValuePairs(Collection<String> keyValuePairs)
Concatenates the key-value pair elements from the specified
Collection to a
null-character-separated String that can be sent as a text parameter data segment. |
static String |
getSuffix(String string,
String prefix)
Returns the suffix of a specified
String . |
static String[] |
intersect(String[] a,
String[] b)
Returns an array of Strings containing only those String values present in both input String arrays a and
b.
|
static Boolean |
parseBooleanValue(String value)
A methods for parsing boolean values from the value part of a key=value pair String.
|
static String[] |
splitKeyValuePair(String keyValuePair)
Splits a key=value pair and returns an array with the separated key and value parts.
|
static String[] |
splitValues(String values)
Splits a String of (one or more) values at the ',' signs and returns the values in an array of Strings.
|
static List<String> |
tokenizeKeyValuePairs(String keyValuePairs)
Returns the key-value pairs contained in a null character-separated text data segment in an array of
String s. |
static String |
toKeyValuePair(String key,
String value)
Joins a key and a value
String to a key=value pair as required by iSCSI text
parameter negotiation and returns the result. |
public static String concatenateKeyValuePairs(Collection<String> keyValuePairs)
Collection
to a
null-character-separated String
that can be sent as a text parameter data segment.keyValuePairs
- a Collection
of key-value pairsString
containing all elementspublic static String getSuffix(String string, String prefix)
String
. The length of the suffix is equal to the length of
string minus the lenght of prefix, but of course only if the beginning of string does equal
prefix. If prefix is not a prefix of string, null
is returned.string
- the String
whose suffix we want to have returnedprefix
- a prefix of stringnull
public static String[] splitKeyValuePair(String keyValuePair)
If the parameter does not match this required pattern, then null
will be returned.
keyValuePair
- a String
with a key prefix of length > 0, a '=' in the middle and a
value suffix of length > 0null
.public static String[] splitValues(String values)
Returns null
if values parameter is null
.
values
- a comma-separated String of text parameter valuesnull
public static String[] intersect(String[] a, String[] b)
The order of elements in the returned array equals that in array a.
If a or b or one of their elements is null
, null
is returned.
a
- an array of Strings (element order will be preserved)b
- an array of Stringsnull
public static Boolean parseBooleanValue(String value)
true
will be returned, if value equals "No",
then false
will be returned. In all other cases the method will return null
.value
- a String containingtrue
, false
, or null
public static boolean checkTextValueFormat(String value)
If those constraints are violated, the method returns null
.
value
- the value part of a key=value pair, which is a String text parameternull
public static String toKeyValuePair(String key, String value)
String
to a key=value pair as required by iSCSI text
parameter negotiation and returns the result.key
- the key partvalue
- the value partpublic static String booleanToTextValue(boolean value)
Yes
(true
) or No
(false
).value
- the value to translateYes
or No
Copyright © 2013 University of Konstanz, Distributed Systems Group. All Rights Reserved.