Class StringUtility

java.lang.Object
com.softwaremining.util.StringUtility

public class StringUtility extends Object
  • Field Details

    • totalTime_append

      public static long totalTime_append
    • totalTime_adjustStringLength

      public static long totalTime_adjustStringLength
  • Constructor Details

    • StringUtility

      public StringUtility()
  • Method Details

    • equals

      public static boolean equals(String s1, String s2)
      right-trim both strings before comparison
      Parameters:
      s1 -
      s2 -
      Returns:
    • equals

      public static boolean equals(AbstractDataObject s1, String s2)
      As in COBOL, trims() the arguments to same size before comparison
    • equals

      public static boolean equals(String s1, AbstractDataObject s2)
      As in COBOL, trims() the arguments to same size before comparison
    • equals

      public static boolean equals(AbstractDataObject s1, AbstractDataObject s2)
      As in COBOL, trims() the arguments to same size before comparison
    • equals

      public static boolean equals(long longValue, String s2) throws NumberFormatException
      As in COBOL, trims() the arguments to same size before comparison
      Throws:
      NumberFormatException
    • equals

      public static boolean equals(String s2, long longValue) throws NumberFormatException
      As in COBOL, trims() the arguments to same size before comparison
      Throws:
      NumberFormatException
    • equals

      public static boolean equals(double dValue, String s2) throws NumberFormatException
      As in COBOL, trims() the arguments to same size before comparison
      Throws:
      NumberFormatException
    • compare

      public static int compare(String s1, String s2)
      As in COBOL, trims() the arguments to same size before comparison
    • compare

      public static int compare(AbstractDataObject dataObj, String s2)
      As in COBOL, trims() the arguments to same size before comparison
    • compare

      public static int compare(String s2, AbstractDataObject dataObj)
      As in COBOL, trims() the arguments to same size before comparison
    • compare

      public static int compare(AbstractDataObject s1, AbstractDataObject s2)
      As in COBOL, trims() the arguments to same size before comparison
    • compare

      public static int compare(String s1, long num2)
      As in COBOL, trims() the arguments to same size before comparison
    • compare

      public static int compare(long i1, String s2) throws NumberFormatException
      As in COBOL, trims() the arguments to same size before comparison
      Throws:
      NumberFormatException
    • compare

      public static int compare(String s1, BigDecimal num2)
      As in COBOL, trims() the arguments to same size before comparison
    • compare

      public static int compare(BigDecimal i1, String s2) throws NumberFormatException
      As in COBOL, trims() the arguments to same size before comparison
      Throws:
      NumberFormatException
    • trimRight

      public static String trimRight(String s1)
      Trim only on the right side
      Parameters:
      s1 -
      Returns:
    • trim

      public static String trim(String s1)
    • trimLeft

      public static String trimLeft(String s1)
      Trim only on the right side
      Parameters:
      s1 -
      Returns:
    • compareTo

      public static int compareTo(char[] chars1, char[] chars2, int startPos, int len)
    • trimRightSpaceAndLowValues

      public static String trimRightSpaceAndLowValues(String s1)
      For internal use. Trim only on the right side
      Parameters:
      s1 -
      Returns:
    • format

      public static String format(double theValue, String cobolFormatPicture)
      Parameters:
      theValue -
      cobolFormatPicture -
      Returns:
    • format

      public static String format(String theValue, String cobolFormatPicture)
      Format a string like the original COBOL format
      Parameters:
      theValue -
      cobolFormatPicture -
      Returns:
    • format

      public static String format(double theValue, String cobolFormatPicture, int compMode)
      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

      public static String createString(int size)
      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

      public static String createString(long size, String fillString)
      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

      public static String createString(int size, int fillString)
      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

      public static String createString(int size, char fillChar)
      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

      public static final String reverse(String value)
      reverse string VALUE
      Parameters:
      value -
      Returns:
      - value reversed
    • isFilled

      public static boolean isFilled(String inputString, char c)
      returns true if the string is entirely composed of character c
      Parameters:
      inputString -
      c -
      Returns:
    • isFilled

      public static boolean isFilled(String inputString, byte b)
      returns true if the string is entirely composed of character c
      Parameters:
      inputString -
      b -
      Returns:
    • isFilled

      public static boolean isFilled(AbstractDataObject inputObject, String filler)
    • isFilled

      public static boolean isFilled(String inputString, String filler)
      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

      public static boolean isHighValues(String currentValue)
    • isHighValues

      public static boolean isHighValues(String currentValue, int size)
      Returns true if string contains Hi-Values. Size is ignored !
      Parameters:
      currentValue -
      size -
      Returns:
    • isLowValues

      public static boolean isLowValues(String currentValue, int size)
      Returns true if string contains low-Values. Size is ignored !
      Parameters:
      currentValue -
      size -
      Returns:
    • isLowValues

      public static boolean isLowValues(AbstractCBLField currentField, int size)
      Deprecated.
      - please use isLowValues(String currentValue, int size)
      Parameters:
      currentField -
      size -
      Returns:
    • capitalize

      public static final String capitalize(String name)
      Capitalize a string - e.g. myRecord will become Myrecord
      Parameters:
      name -
      Returns:
    • capitalizeFirstLetter

      public static final String capitalizeFirstLetter(String name)
      Capitalize only the first character - and leave everything else as is - e.g. myRecord will become MyRecord
      Parameters:
      name -
      Returns:
    • adjustStringLength

      public static String adjustStringLength(String newValue, int expectedSize)
    • adjustStringLength

      public 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 ...
      Parameters:
      newValue -
      expectedSize -
    • append

      public static String append(String[] strings)
      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

      public static String hexToString(char[] hexValues)
    • charToString

      public static String charToString(long charAsInt)
      Translation of COBOL's FUNCTION CHAR(int)
      Parameters:
      charAsInt -
      Returns:
    • printBytes

      public static String printBytes(String str)
      return the char array representation of this structure
      Returns:
    • printBytes

      public static String printBytes(char[] array)
    • printBytes

      public static String printBytes(char[] array, int crlf_AfterNChar)
    • printBytesAsHex

      public static String printBytesAsHex(String str)
    • printBytesAsHex

      public static String printBytesAsHex(char[] array)
    • printBytesAsHex

      public static String printBytesAsHex(char[] array, int crlf_AfterNChar)
    • printBytes

      public static String printBytes(byte[] array, int crlf_AfterNChar)
    • printBytesAsHex

      public static String printBytesAsHex(byte[] array, int crlf_AfterNChar)
    • printBytesAsHexMainframeStyle

      public static String printBytesAsHexMainframeStyle(char[] array, boolean showChars)
    • printBytesAsHexMainframeStyle

      public static String printBytesAsHexMainframeStyle(char[] array, int crlf_AfterNChar, boolean showChars)
    • pop

      public static final String[] pop(String nextLine)
      pop "\"B C\" D E F" will return new string[] {"\"B C\", "D E F"}
      Parameters:
      nextLine -
      Returns: