Package com.softwaremining.util
Class StringUtility
java.lang.Object
com.softwaremining.util.StringUtility
-
Field Summary
Modifier and TypeFieldDescriptionstatic long
static long
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
adjustStringLength
(String newValue, int expectedSize) static String
adjustStringLength
(String newValue, int expectedSize, boolean rightJustified) adjust the size of "newValue" string, if it is less than expectedSize, then append with spaces, if it is more, then apply substring ...static String
primarily used in Container objects (Subclasses of AbstractContainerBean)static final String
capitalize
(String name) Capitalize a string - e.g.static final String
capitalizeFirstLetter
(String name) Capitalize only the first character - and leave everything else as is - e.g.static String
charToString
(long charAsInt) Translation of COBOL's FUNCTION CHAR(int)static int
As in COBOL, trims() the arguments to same size before comparisonstatic int
As in COBOL, trims() the arguments to same size before comparisonstatic int
compare
(AbstractDataObject dataObj, String s2) As in COBOL, trims() the arguments to same size before comparisonstatic int
As in COBOL, trims() the arguments to same size before comparisonstatic int
compare
(String s2, AbstractDataObject dataObj) As in COBOL, trims() the arguments to same size before comparisonstatic int
As in COBOL, trims() the arguments to same size before comparisonstatic int
compare
(String s1, BigDecimal num2) As in COBOL, trims() the arguments to same size before comparisonstatic int
compare
(BigDecimal i1, String s2) As in COBOL, trims() the arguments to same size before comparisonstatic int
compareTo
(char[] chars1, char[] chars2, int startPos, int len) static String
createString
(int size) create a SPACE filled stringstatic String
createString
(int size, char fillChar) create a padded stringstatic String
createString
(int size, int fillString) create a padded stringstatic String
createString
(long size, String fillString) create a string using fillStringstatic boolean
As in COBOL, trims() the arguments to same size before comparisonstatic boolean
As in COBOL, trims() the arguments to same size before comparisonstatic boolean
As in COBOL, trims() the arguments to same size before comparisonstatic boolean
equals
(AbstractDataObject s1, String s2) As in COBOL, trims() the arguments to same size before comparisonstatic boolean
As in COBOL, trims() the arguments to same size before comparisonstatic boolean
equals
(String s1, AbstractDataObject s2) As in COBOL, trims() the arguments to same size before comparisonstatic boolean
right-trim both strings before comparisonstatic String
static String
Format a string like the original COBOL formatstatic String
Format a string like the original COBOL formatstatic String
Format a string like the original COBOL formatstatic String
hexToString
(char[] hexValues) static boolean
isFilled
(double inputVal, int filler) returns true if the string is entirely composed of character cstatic boolean
isFilled
(AbstractDataObject inputObject, String filler) static boolean
returns true if the string is entirely composed of character cstatic boolean
returns true if the string is entirely composed of character cstatic boolean
returns true if the string is entirely composed of string fillerstatic boolean
isHighValues
(String currentValue) static boolean
isHighValues
(String currentValue, int size) Returns true if string contains Hi-Values.static boolean
isLowValues
(AbstractCBLField currentField, int size) Deprecated.- please use isLowValues(String currentValue, int size)static boolean
isLowValues
(String currentValue, int size) Returns true if string contains low-Values.static final String[]
pop "\"B C\" D E F" will return new string[] {"\"B C\", "D E F"}static String
printBytes
(byte[] array, int crlf_AfterNChar) static String
printBytes
(char[] array) static String
printBytes
(char[] array, int crlf_AfterNChar) static String
printBytes
(String str) return the char array representation of this structurestatic String
printBytesAsHex
(byte[] array, int crlf_AfterNChar) static String
printBytesAsHex
(char[] array) static String
printBytesAsHex
(char[] array, int crlf_AfterNChar) static String
printBytesAsHex
(String str) static String
printBytesAsHexMainframeStyle
(char[] array, boolean showChars) static String
printBytesAsHexMainframeStyle
(char[] array, int crlf_AfterNChar, boolean showChars) static final String
retrieveSubstring
(int offset, int length, String newValue, String currentValue) translation of MOVE 'A' TO ABC (5:4)static final String
reverse string VALUEstatic String
static String
Trim only on the right sidestatic String
Trim only on the right sidestatic String
For internal use.
-
Field Details
-
totalTime_append
public static long totalTime_append -
totalTime_adjustStringLength
public static long totalTime_adjustStringLength
-
-
Constructor Details
-
StringUtility
public StringUtility()
-
-
Method Details
-
equals
right-trim both strings before comparison- Parameters:
s1
-s2
-- Returns:
-
equals
As in COBOL, trims() the arguments to same size before comparison -
equals
As in COBOL, trims() the arguments to same size before comparison -
equals
As in COBOL, trims() the arguments to same size before comparison -
equals
As in COBOL, trims() the arguments to same size before comparison- Throws:
NumberFormatException
-
equals
As in COBOL, trims() the arguments to same size before comparison- Throws:
NumberFormatException
-
equals
As in COBOL, trims() the arguments to same size before comparison- Throws:
NumberFormatException
-
compare
As in COBOL, trims() the arguments to same size before comparison -
compare
As in COBOL, trims() the arguments to same size before comparison -
compare
As in COBOL, trims() the arguments to same size before comparison -
compare
As in COBOL, trims() the arguments to same size before comparison -
compare
As in COBOL, trims() the arguments to same size before comparison -
compare
As in COBOL, trims() the arguments to same size before comparison- Throws:
NumberFormatException
-
compare
As in COBOL, trims() the arguments to same size before comparison -
compare
As in COBOL, trims() the arguments to same size before comparison- Throws:
NumberFormatException
-
trimRight
Trim only on the right side- Parameters:
s1
-- Returns:
-
trim
-
trimLeft
Trim only on the right side- Parameters:
s1
-- Returns:
-
compareTo
public static int compareTo(char[] chars1, char[] chars2, int startPos, int len) -
trimRightSpaceAndLowValues
For internal use. Trim only on the right side- Parameters:
s1
-- Returns:
-
format
- Parameters:
theValue
-cobolFormatPicture
-- Returns:
-
format
Format a string like the original COBOL format- Parameters:
theValue
-cobolFormatPicture
-- Returns:
-
format
Format a string like the original COBOL format- Parameters:
theValue
-cobolFormatPicture
-compMode
-- Returns:
-
format
public static String format(double theValue, String cobolFormatPicture, int compMode, boolean alignRight) Format a string like the original COBOL format- Parameters:
theValue
-cobolFormatPicture
-compMode
-alignRight
-- Returns:
-
createString
create a SPACE filled string- Parameters:
size
- - size of the resulting string - NOTE: Although the method allows passing a "long" - java does not allow creation of a char[long], hence the system will internally reduce this to an "int"- Returns:
-
createString
create a string using fillString- Parameters:
size
- - size of the resulting string - NOTE: Although the method allows passing a "long" - java does not allow creation of a char[long], hence the system will internally reduce this to an "int"- Returns:
-
createString
create a padded string- Parameters:
size
- - size of the resulting string - NOTE: Although the method allows passing a "long" - java does not allow creation of a char[long], hence the system will internally reduce this to an "int"- Returns:
-
createString
create a padded string- Parameters:
size
- - size of the resulting string - NOTE: Although the method allows passing a "long" - java does not allow creation of a char[long], hence the system will internally reduce this to an "int"- Returns:
-
reverse
reverse string VALUE- Parameters:
value
-- Returns:
- - value reversed
-
isFilled
returns true if the string is entirely composed of character c- Parameters:
inputString
-c
-- Returns:
-
isFilled
returns true if the string is entirely composed of character c- Parameters:
inputString
-b
-- Returns:
-
isFilled
-
isFilled
returns true if the string is entirely composed of string filler- Parameters:
inputString
-filler
-- Returns:
-
isFilled
public static boolean isFilled(double inputVal, int filler) returns true if the string is entirely composed of character c- Parameters:
inputString
-c
-- Returns:
-
isHighValues
-
isHighValues
Returns true if string contains Hi-Values. Size is ignored !- Parameters:
currentValue
-size
-- Returns:
-
isLowValues
Returns true if string contains low-Values. Size is ignored !- Parameters:
currentValue
-size
-- Returns:
-
isLowValues
Deprecated.- please use isLowValues(String currentValue, int size)- Parameters:
currentField
-size
-- Returns:
-
capitalize
Capitalize a string - e.g. myRecord will become Myrecord- Parameters:
name
-- Returns:
-
capitalizeFirstLetter
Capitalize only the first character - and leave everything else as is - e.g. myRecord will become MyRecord- Parameters:
name
-- Returns:
-
adjustStringLength
-
adjustStringLength
adjust the size of "newValue" string, if it is less than expectedSize, then append with spaces, if it is more, then apply substring ...- Parameters:
newValue
-expectedSize
-
-
append
primarily used in Container objects (Subclasses of AbstractContainerBean)- Parameters:
strings
-- Returns:
-
retrieveSubstring
public static final String retrieveSubstring(int offset, int length, String newValue, String currentValue) translation of MOVE 'A' TO ABC (5:4)- Parameters:
offset
-length
-newValue
-
-
hexToString
-
charToString
Translation of COBOL's FUNCTION CHAR(int)- Parameters:
charAsInt
-- Returns:
-
printBytes
return the char array representation of this structure- Returns:
-
printBytes
-
printBytes
-
printBytesAsHex
-
printBytesAsHex
-
printBytesAsHex
-
printBytes
-
printBytesAsHex
-
printBytesAsHexMainframeStyle
-
printBytesAsHexMainframeStyle
public static String printBytesAsHexMainframeStyle(char[] array, int crlf_AfterNChar, boolean showChars) -
pop
pop "\"B C\" D E F" will return new string[] {"\"B C\", "D E F"}- Parameters:
nextLine
-- Returns:
-