Class SimpleDBUtils
java.lang.Object
com.amazonaws.services.simpledb.util.SimpleDBUtils
Provides collection of static functions for conversion of various values into strings that may be
compared lexicographically.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Date
decodeDate
(String value) Decodes date value from the string representation created using encodeDate(..) function.static float
decodeRealNumberRangeFloat
(String value, int maxDigitsRight, int offsetValue) Decodes float value from the string representation that was created by using encodeRealNumberRange(..) function.static int
decodeRealNumberRangeInt
(String value, int offsetValue) Decodes integer value from the string representation that was created by using encodeRealNumberRange(..) function.static long
decodeRealNumberRangeLong
(String value, long offsetValue) Decodes a long value from the string representation that was created by using encodeRealNumberRange(..) function.static float
decodeZeroPaddingFloat
(String value) Decodes zero-padded positive float value from the string representationstatic int
decodeZeroPaddingInt
(String value) Decodes zero-padded positive integer value from the string representationstatic long
decodeZeroPaddingLong
(String value) Decodes a zero-padded positive long value from the string representationstatic String
encodeDate
(Date date) Encodes date value into string format that can be compared lexicographicallystatic String
encodeRealNumberRange
(float number, int maxDigitsLeft, int maxDigitsRight, int offsetValue) Encodes real float value into a string by offsetting and zero-padding number up to the specified number of digits.static String
encodeRealNumberRange
(int number, int maxNumDigits, int offsetValue) Encodes real integer value into a string by offsetting and zero-padding number up to the specified number of digits.static String
encodeRealNumberRange
(long number, int maxNumDigits, long offsetValue) Encodes a positive or negative long value into a string by offsetting and zero-padding the number up to the specified number of digits.static String
encodeZeroPadding
(float number, int maxNumDigits) Encodes positive float value into a string by zero-padding number up to the specified number of digitsstatic String
encodeZeroPadding
(int number, int maxNumDigits) Encodes positive integer value into a string by zero-padding number up to the specified number of digits.static String
encodeZeroPadding
(long number, int maxNumDigits) Encodes positive long value into a string by zero-padding the value up to the specified number of digits.static String
Quotes and escapes an attribute name or domain name by wrapping it with backticks and escaping any backticks inside the name.static String
quoteValue
(String value) Quotes and escapes an attribute value by wrapping it with single quotes and escaping any single quotes inside the value.static String
quoteValues
(Collection<String> values) Quotes and escapes a list of values so that they can be used in a SimpleDB query.protected static String
replaceChar
(String value, String termToFind, String replacementTerm)
-
Constructor Details
-
SimpleDBUtils
public SimpleDBUtils()
-
-
Method Details
-
encodeZeroPadding
Encodes positive integer value into a string by zero-padding number up to the specified number of digits.- Parameters:
number
- positive integer to be encodedmaxNumDigits
- maximum number of digits in the largest value in the data set- Returns:
- string representation of the zero-padded integer
-
encodeZeroPadding
Encodes positive long value into a string by zero-padding the value up to the specified number of digits.- Parameters:
number
- positive long to be encodedmaxNumDigits
- maximum number of digits in the largest value in the data set- Returns:
- string representation of the zero-padded long
-
encodeZeroPadding
Encodes positive float value into a string by zero-padding number up to the specified number of digits- Parameters:
number
- positive float value to be encodedmaxNumDigits
- maximum number of digits preceding the decimal point in the largest value in the data set- Returns:
- string representation of the zero-padded float value
-
decodeZeroPaddingInt
Decodes zero-padded positive integer value from the string representation- Parameters:
value
- zero-padded string representation of the integer- Returns:
- original integer value
-
decodeZeroPaddingLong
Decodes a zero-padded positive long value from the string representation- Parameters:
value
- zero-padded string representation of the long- Returns:
- original long value
-
decodeZeroPaddingFloat
Decodes zero-padded positive float value from the string representation- Parameters:
value
- zero-padded string representation of the float value- Returns:
- original float value
-
encodeRealNumberRange
Encodes real integer value into a string by offsetting and zero-padding number up to the specified number of digits. Use this encoding method if the data range set includes both positive and negative values.- Parameters:
number
- integer to be encodedmaxNumDigits
- maximum number of digits in the largest absolute value in the data setoffsetValue
- offset value, has to be greater than absolute value of any negative number in the data set.- Returns:
- string representation of the integer
-
encodeRealNumberRange
Encodes a positive or negative long value into a string by offsetting and zero-padding the number up to the specified number of digits. Use this encoding method if the data set includes both positive and negative values.- Parameters:
number
- positive or negative long value to be encodedmaxNumDigits
- maximum number of digits in the largest absolute value in the data setoffsetValue
- offset value, has to be greater than absolute value of any negative number in the data set.- Returns:
- string representation of the long
-
encodeRealNumberRange
public static String encodeRealNumberRange(float number, int maxDigitsLeft, int maxDigitsRight, int offsetValue) Encodes real float value into a string by offsetting and zero-padding number up to the specified number of digits. Use this encoding method if the data range set includes both positive and negative values.- Parameters:
number
- float to be encodedmaxDigitsLeft
- maximum number of digits left of the decimal point in the largest absolute value in the data setmaxDigitsRight
- maximum number of digits right of the decimal point in the largest absolute value in the data set, i.e. precisionoffsetValue
- offset value, has to be greater than absolute value of any negative number in the data set.- Returns:
- string representation of the integer
-
decodeRealNumberRangeInt
Decodes integer value from the string representation that was created by using encodeRealNumberRange(..) function.- Parameters:
value
- string representation of the integer valueoffsetValue
- offset value that was used in the original encoding- Returns:
- original integer value
-
decodeRealNumberRangeLong
Decodes a long value from the string representation that was created by using encodeRealNumberRange(..) function.- Parameters:
value
- string representation of the long valueoffsetValue
- offset value that was used in the original encoding- Returns:
- original long value
-
decodeRealNumberRangeFloat
Decodes float value from the string representation that was created by using encodeRealNumberRange(..) function.- Parameters:
value
- string representation of the integer valuemaxDigitsRight
- maximum number of digits left of the decimal point in the largest absolute value in the data set (must be the same as the one used for encoding).offsetValue
- offset value that was used in the original encoding- Returns:
- original float value
-
encodeDate
Encodes date value into string format that can be compared lexicographically- Parameters:
date
- date value to be encoded- Returns:
- string representation of the date value
-
decodeDate
Decodes date value from the string representation created using encodeDate(..) function.- Parameters:
value
- string representation of the date value- Returns:
- original date value
- Throws:
ParseException
-
quoteValues
Quotes and escapes a list of values so that they can be used in a SimpleDB query.- Parameters:
values
- The collection of attribute values that will be quoted, escaped, and included in the returned string list.- Returns:
- A string representation of the list of specified values, with individual values properly quoted and escaped.
-
quoteValue
Quotes and escapes an attribute value by wrapping it with single quotes and escaping any single quotes inside the value.- Parameters:
value
- The attribute value to quote and escape.- Returns:
- The properly quoted and escaped attribute value, ready to be used in a SimpleDB select query.
-
quoteName
Quotes and escapes an attribute name or domain name by wrapping it with backticks and escaping any backticks inside the name.- Parameters:
name
- The attribute name or domain name to quote and escape.- Returns:
- The properly quoted and escaped attribute name or domain name, ready to be used in a SimpleDB select query.
-
replaceChar
-