Package com.softwaremining.util
Class StringUtility
java.lang.Object
com.softwaremining.util.StringUtility
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic longstatic long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringadjustStringLength(String newValue, int expectedSize) static StringadjustStringLength(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 Stringprimarily used in Container objects (Subclasses of AbstractContainerBean)static Stringstatic final Stringcapitalize(String name) Capitalize a string - e.g.static final StringcapitalizeFirstLetter(String name) Capitalize only the first character - and leave everything else as is - e.g.static StringcharToString(long charAsInt) Translation of COBOL's FUNCTION CHAR(int)static intAs in COBOL, trims() the arguments to same size before comparisonstatic intAs in COBOL, trims() the arguments to same size before comparisonstatic intcompare(AbstractDataObject dataObj, String s2) As in COBOL, trims() the arguments to same size before comparisonstatic intAs in COBOL, trims() the arguments to same size before comparisonstatic intcompare(String s2, AbstractDataObject dataObj) As in COBOL, trims() the arguments to same size before comparisonstatic intAs in COBOL, trims() the arguments to same size before comparisonstatic intcompare(String s1, BigDecimal num2) As in COBOL, trims() the arguments to same size before comparisonstatic intcompare(BigDecimal i1, String s2) As in COBOL, trims() the arguments to same size before comparisonstatic intcompareTo(char[] chars1, char[] chars2, int startPos, int len) static StringcreateString(int size) create a SPACE filled stringstatic StringcreateString(int size, char fillChar) create a padded stringstatic StringcreateString(int size, int fillString) create a padded stringstatic StringcreateString(long size, String fillString) create a string using fillStringstatic booleanAs in COBOL, trims() the arguments to same size before comparisonstatic booleanAs in COBOL, trims() the arguments to same size before comparisonstatic booleanAs in COBOL, trims() the arguments to same size before comparisonstatic booleanequals(AbstractDataObject s1, String s2) As in COBOL, trims() the arguments to same size before comparisonstatic booleanAs in COBOL, trims() the arguments to same size before comparisonstatic booleanequals(String s1, AbstractDataObject s2) As in COBOL, trims() the arguments to same size before comparisonstatic booleanright-trim both strings before comparisonstatic Stringstatic StringFormat a string like the original COBOL formatstatic StringFormat a string like the original COBOL formatstatic StringFormat a string like the original COBOL formatstatic StringhexToString(char[] hexValues) static booleanisFilled(double inputVal, int filler) returns true if the string is entirely composed of character cstatic booleanisFilled(AbstractDataObject inputObject, String filler) static booleanreturns true if the string is entirely composed of character cstatic booleanreturns true if the string is entirely composed of character cstatic booleanreturns true if the string is entirely composed of string fillerstatic booleanisHighValues(String currentValue) static booleanisHighValues(String currentValue, int size) Returns true if string contains Hi-Values.static booleanisLowValues(AbstractCBLField currentField, int size) Deprecated.- please use isLowValues(String currentValue, int size)static booleanisLowValues(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 StringprintBytes(byte[] array, int crlf_AfterNChar) static StringprintBytes(char[] array) static StringprintBytes(char[] array, int crlf_AfterNChar) static StringprintBytes(String str) return the char array representation of this structurestatic StringprintBytesAsHex(byte[] array, int crlf_AfterNChar) static StringprintBytesAsHex(char[] array) static StringprintBytesAsHex(char[] array, int crlf_AfterNChar) static StringprintBytesAsHex(String str) static StringprintBytesAsHexMainframeStyle(char[] array, boolean showChars) static StringprintBytesAsHexMainframeStyle(char[] array, int crlf_AfterNChar, boolean showChars) static final StringretrieveSubstring(int offset, int length, String newValue, String currentValue) translation of MOVE 'A' TO ABC (5:4)static final Stringreverse string VALUEstatic Stringstatic StringTrim only on the right sidestatic StringTrim only on the right sidestatic StringFor 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:
cobolFormatPicture-theValue-- 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
-
camelCase
-
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:
newValue-offset-length-
-
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:
-