Package org.hpccsystems.commons.utils
Class Utils
- java.lang.Object
-
- org.hpccsystems.commons.utils.Utils
-
public class Utils extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Utils.EclTypes
-
Field Summary
Fields Modifier and Type Field Description static Pattern
AGGFUNCPATTERN
static Pattern
BOOLEANPATTERN
static String
DOTSEPERATORREGEX
static String
EscapedSingleQuote
static String
fileSep
static String
newLine
static NumberFormat
USNumberFormat
static String
workingDir
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
Base64Encode(byte[] input, boolean addLineBreaks)
Base 64 encode.static int
convertECLtypeCode2SQLtype(Utils.EclTypes ecltype)
Translates an ecltype element to sql type int (java.sql.Types value)static String
convertSQLtype2JavaClassName(int type)
Translates a data type from an integer (java.sql.Types value) to a string that represents the corresponding class.static boolean
doesNotRequireQuotes(Object obj)
Determines if entry represented by obj does not require single quote encapsulation.static BigInteger
extractUnsigned8Val(long unsigned8)
Extracts raw (8 byte unsigned value) from Long typestatic <T extends Enum<T>>
TfindEnumValFromString(Class<T> enumclass, String strvalue)
Attempts to map a string value to an enum value of a given enum class.static String
getParenContents(String parenstring)
Gets the paren contents.static String
handleQuotedIdentifier(String quotedString)
static String
handleQuotedString(String quotedString)
Handle quoted string.static boolean
hasPossibleEscapedQuoteLiteral(String quotedString)
Checks for possible escaped quote literal.static boolean
isAggFunction(String aggfunstr)
Checks if is agg function.static boolean
isBooleanKeyWord(String str)
Checks if is boolean key word.static boolean
isCommaList(String commastring)
static boolean
isInParenthesis(String parenstring)
Checks if is in parenthesis.static boolean
isLiteralString(String str)
Checks if is literal string.static boolean
isNumeric(String str)
Checks if value represented in string is numeric.static boolean
isParameterizedStr(String value)
Checks if is parameterized str.static boolean
isSQLLiteralString(String str)
Checks if is SQL literal string.static String
removeAllNewLines(String str)
Removes the all new lines.static String
replaceAll(String input, String forReplace, String replaceWith)
Replace all.static String
replaceSQLwithECLEscapeChar(String quotedString)
Replace SQ lwith ECL escape char.static int
stringToInt(String str, int uponError)
String to int.static long
stringToLong(String str, long uponError)
String to long.
-
-
-
Field Detail
-
DOTSEPERATORREGEX
public static final String DOTSEPERATORREGEX
- See Also:
- Constant Field Values
-
newLine
public static String newLine
-
fileSep
public static String fileSep
-
workingDir
public static final String workingDir
-
USNumberFormat
public static NumberFormat USNumberFormat
-
AGGFUNCPATTERN
public static final Pattern AGGFUNCPATTERN
-
EscapedSingleQuote
public static final String EscapedSingleQuote
- See Also:
- Constant Field Values
-
BOOLEANPATTERN
public static final Pattern BOOLEANPATTERN
-
-
Method Detail
-
Base64Encode
public static String Base64Encode(byte[] input, boolean addLineBreaks)
Base 64 encode.- Parameters:
input
- the inputaddLineBreaks
- the add line breaks- Returns:
- the string
-
removeAllNewLines
public static String removeAllNewLines(String str)
Removes the all new lines.- Parameters:
str
- the str- Returns:
- the string
-
isLiteralString
public static boolean isLiteralString(String str)
Checks if is literal string.- Parameters:
str
- the str- Returns:
- true, if is literal string
-
isSQLLiteralString
public static boolean isSQLLiteralString(String str)
Checks if is SQL literal string.- Parameters:
str
- the str- Returns:
- true, if is literal string
-
isNumeric
public static boolean isNumeric(String str)
Checks if value represented in string is numeric.- Parameters:
str
- the value to test- Returns:
- true, if is numeric
-
doesNotRequireQuotes
public static boolean doesNotRequireQuotes(Object obj)
Determines if entry represented by obj does not require single quote encapsulation.- Parameters:
obj
- the entry- Returns:
- true, if single quotes not required
-
isInParenthesis
public static boolean isInParenthesis(String parenstring)
Checks if is in parenthesis.- Parameters:
parenstring
- the parenstring- Returns:
- true, if is in parenthesis
-
isCommaList
public static boolean isCommaList(String commastring)
-
isAggFunction
public static boolean isAggFunction(String aggfunstr)
Checks if is agg function.- Parameters:
aggfunstr
- the aggfunstr- Returns:
- true, if is agg function
-
getParenContents
public static String getParenContents(String parenstring)
Gets the paren contents.- Parameters:
parenstring
- the parenstring- Returns:
- the paren contents
-
stringToLong
public static long stringToLong(String str, long uponError)
String to long.- Parameters:
str
- the struponError
- the upon error- Returns:
- the long
-
stringToInt
public static int stringToInt(String str, int uponError)
String to int.- Parameters:
str
- the struponError
- the upon error- Returns:
- the int
-
replaceAll
public static String replaceAll(String input, String forReplace, String replaceWith)
Replace all.- Parameters:
input
- the inputforReplace
- the for replacereplaceWith
- the replace with- Returns:
- the string
-
handleQuotedString
public static String handleQuotedString(String quotedString)
Handle quoted string.- Parameters:
quotedString
- the quoted string- Returns:
- the string
-
isParameterizedStr
public static boolean isParameterizedStr(String value)
Checks if is parameterized str.- Parameters:
value
- the value- Returns:
- true, if is parameterized str
-
hasPossibleEscapedQuoteLiteral
public static boolean hasPossibleEscapedQuoteLiteral(String quotedString) throws Exception
Checks for possible escaped quote literal.- Parameters:
quotedString
- the quoted string- Returns:
- true, if successful
- Throws:
Exception
- the exception
-
replaceSQLwithECLEscapeChar
public static String replaceSQLwithECLEscapeChar(String quotedString) throws Exception
Replace SQ lwith ECL escape char.- Parameters:
quotedString
- the quoted string- Returns:
- the string
- Throws:
Exception
- the exception
-
convertECLtypeCode2SQLtype
public static int convertECLtypeCode2SQLtype(Utils.EclTypes ecltype)
Translates an ecltype element to sql type int (java.sql.Types value)- Parameters:
ecltype
- The ecl type enumerated value.- Returns:
- The java.sql.Types value to convert to a string representation.
-
convertSQLtype2JavaClassName
public static String convertSQLtype2JavaClassName(int type)
Translates a data type from an integer (java.sql.Types value) to a string that represents the corresponding class.- Parameters:
type
- The java.sql.Types value to convert to a string representation.- Returns:
- The class name that corresponds to the given java.sql.Types value, or "java.lang.Object" if the type has no known mapping.
-
findEnumValFromString
public static <T extends Enum<T>> T findEnumValFromString(Class<T> enumclass, String strvalue)
Attempts to map a string value to an enum value of a given enum class. Iterates through all enum values of given enum class, and compares to given string. Returns enum value if it finds match, otherwise throws Exception- Type Parameters:
T
- the generic type- Parameters:
enumclass
- reference to target enumarationstrvalue
- string value to be mapped to enum value- Returns:
- The corresponding enum value if found
- Throws:
IllegalArgumentException
- if strvalue cannot be mapped to given enum
-
isBooleanKeyWord
public static boolean isBooleanKeyWord(String str)
Checks if is boolean key word.- Parameters:
str
- the str- Returns:
- true, if is boolean key word
-
extractUnsigned8Val
public static BigInteger extractUnsigned8Val(long unsigned8)
Extracts raw (8 byte unsigned value) from Long type- Parameters:
unsigned8
- - 8 byte unsigned value stored in Long type- Returns:
- raw 8 byte unsigned value stored in BigInteger
-
-