Class STRING

java.lang.Object
parser.STRING

public class STRING extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    contains(String str, String substr)
    contains allows you to verify if an input string contains a given substring.
    private static String
     
    private static double
     
    static int
    Counts how many times a given single character string occurs in a given String object.
    static String
    delete(String u, int i)
    method delete takes 2 arguments,the string to be modified and the index of the character to be deleted
    static String
    delete(String u, int i, int j)
    method delete takes 3 arguments,the string to be modified, the index at which deleting is to begin and the index one after the point where deletion is to end.
    static String
    delete(String u, String str)
    method delete takes 2 arguments,the string to be modified and the substring to be removed from it.
    static String
    deleteCharsAfter(String str, int i, int num)
    method delete takes 3 arguments,the string to be modified, the index at which deleting is to begin and the index one after the point where deletion is to end.
    static String
    doubleToString(double num)
     
    static String
    method firstElement takes one argument and that is the string to be modified.
    static int
    method getFirstIndexOfDigit takes a String object and returns the index of the first occurence of a number character in the String.
    static int
    method getFirstIndexOfDigit takes a String object and returns the index of the first occurence of a number character in the String.
    static String
    method getFirstNumberSubstring takes a String object and returns the first number string in the String.
    static String
    method getFirstOccurenceOfDigit takes a String object and returns the first occurence of a number character in the String.
    static boolean
     
    static boolean
     
    static boolean
    boolean Method isDigit can be used to check for single digits i.e 0-9.
    static boolean
    boolean Method isDouble(Object a) detects if a string entry is in double number format or not.
    static boolean
    Method isDouble1 is specially built for parsing number strings in my parser.Please do not use it for your own purposes.
    static boolean
    isEven(double a)
    Checks if a given number is even
    static boolean
    isEven(float a)
    Checks if a given number is even
    static boolean
    isEven(int a)
    Checks if a given number is even
    static boolean
     
    static boolean
     
    static boolean
    isfullyDouble allows you to verify if an input string is in double number format or not.
    static boolean
     
    static boolean
    method isLowerCaseWord takes one argument and that is the string whose case we wish to know.
    static boolean
    boolean Method isNumberComponent(args) detects if a string entry is a buiding block for a valid number or not For our purposes,the building blocks are the digits,the "." symbol,the E symbol,the - symbol,but not the addition one.
    static boolean
    isOnlyDigits allows you to verify if an input string consists of just digits and the exponential symbol.
    static boolean
     
    static boolean
    method isUpperCaseWord takes one argument and that is the string whose case we wish to know.
    static boolean
     
    static String
    method lastElement takes one argument and that is the string to be modified.
    static void
    main(String[] args)
     
    static int
    nextIndexOf(String str, int index, String str2)
    nextIndexOf allows you to get the next occurence of a substring searching from a point in the string forwards
    static int
    prevIndexOf(String str, int index, String str2)
    prevIndexOf allows you to get the previous occurence of a substring searching from a point in the string backwards
    static String
    purifier allows you to remove all white spaces in a given string,which it receives as its argument
    static String
    purifier(String h, int fromIndex)
    purifier allows you to remove all white spaces in a given string,which it receives as its argument
    static String
    removeAll(String str, String unwanted)
    removeAll allows you to remove all occurrences of an unwanted string from a given string, which it receives as its argument
    static String
    Allows you to remove commas from a string.
    static String
     
    static String
    method replace takes 4 arguments,the string to be modified, the replacing string, the index at which replacement is to begin and the index where replacement ends plus one i.e replacement ends at index j-1.
    static String
    replaceAll(String str, String replaced, String replacing)
    The Technology: 1.
    static String
    method reverse takes 1 argument and that is the string to be reversed
    split(String stringTosplit, String splittingObject)
    This is an optimized specialized substitute for String.split in the Java API.
    static String[]
    splits(String stringTosplit, String splittingObject)
    This is an highly optimized specialized substitute for String.split in the Java API.
    static String[]
    splits(String stringTosplit, String[] splittingObjects)
    This is an highly optimized specialized substitute for String.split in the Java API.
    static String
    method toLowerCase takes one argument only and that is input string to be converted to lower case
    static String
    method toUpperCase takes one argument only and that is the input string to be converted to upper case

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • STRING

      public STRING()
  • Method Details

    • contains

      public static boolean contains(String str, String substr)
      contains allows you to verify if an input string contains a given substring.
      Parameters:
      str - : the string to check
      substr - : the substring to check for
      Returns:
      true or false depending on if or not the input consists of digits alone or otherwise.
    • isOnlyDigits

      public static boolean isOnlyDigits(String h)
      isOnlyDigits allows you to verify if an input string consists of just digits and the exponential symbol. So the method will return true for 32000 but not for 3.2E4.It will also return true for 32E3.No decimal points are allowed
      Parameters:
      h - ..The string to be analyzed.
      Returns:
      true or false depending on if or not the input consists of digits alone or otherwise.
    • isLetter

      public static boolean isLetter(String aChar)
      Parameters:
      aChar - The single character string to be examined if it is a letter of the alphabet or not.
      Returns:
      true if the parameter is a valid letter of the English alphabet.
    • removeNewLineChar

      public static String removeNewLineChar(String input)
      Parameters:
      input - The string from which we wish to remove all new line characters.
      Returns:
      a string like the input but free of all new line characters.
    • isfullyDouble

      public static boolean isfullyDouble(String num)
      isfullyDouble allows you to verify if an input string is in double number format or not.
      Parameters:
      num - ..The string to be analyzed.
      Returns:
      true or false depending on if or not the input represents a valid double number
    • firstElement

      public static String firstElement(String u)
      method firstElement takes one argument and that is the string to be modified.
      Parameters:
      u - the string to be modified
      Returns:
      the first element of the string
      Throws:
      StringIndexOutOfBoundsException
    • lastElement

      public static String lastElement(String u)
      method lastElement takes one argument and that is the string to be modified.
      Parameters:
      u - the string to be modified
      Returns:
      the last element of the string
      Throws:
      StringIndexOutOfBoundsException
    • nextIndexOf

      public static int nextIndexOf(String str, int index, String str2)
      nextIndexOf allows you to get the next occurence of a substring searching from a point in the string forwards
      Parameters:
      str - ..The String being analyzed.
      index - ..The starting point of the search.
      str2 - ..The string whose next occurence we desire.
      Returns:
      the next index of the str2 if found or -1 if not found
    • prevIndexOf

      public static int prevIndexOf(String str, int index, String str2)
      prevIndexOf allows you to get the previous occurence of a substring searching from a point in the string backwards
      Parameters:
      str - ..The String being analyzed.
      index - ..The starting point of the search.
      str2 - ..The string whose previous occurence we desire.
      Returns:
      the previous index of the str2 if found or -1 if not found
    • isSign

      public static boolean isSign(String val)
      Parameters:
      val - the entry being analyzed.
      Returns:
      true if the entry is a + sign or a minus sign
    • isDecimalPoint

      public static boolean isDecimalPoint(String val)
      Parameters:
      val - the entry being analyzed.
      Returns:
      true if the entry is a floating point
    • isExponentOf10

      public static boolean isExponentOf10(String val)
      Parameters:
      val - the entry being analyzed.
      Returns:
      true if the entry is the power of 10 symbol i.e E
    • getFirstOccurenceOfDigit

      public static String getFirstOccurenceOfDigit(String value) throws StringIndexOutOfBoundsException
      method getFirstOccurenceOfDigit takes a String object and returns the first occurence of a number character in the String.
      Parameters:
      value - the string to analyze
      Returns:
      the first occurence of a number character in the sequence.
      Throws:
      StringIndexOutOfBoundsException
    • getFirstIndexOfDigit

      public static int getFirstIndexOfDigit(String val) throws StringIndexOutOfBoundsException
      method getFirstIndexOfDigit takes a String object and returns the index of the first occurence of a number character in the String.
      Parameters:
      val - the string to analyze
      Returns:
      the index of the first occurence of a number character in the sequence.
      Throws:
      StringIndexOutOfBoundsException
    • getFirstIndexOfDigitOrPoint

      public static int getFirstIndexOfDigitOrPoint(String val) throws StringIndexOutOfBoundsException
      method getFirstIndexOfDigit takes a String object and returns the index of the first occurence of a number character in the String.
      Parameters:
      val - the string to analyze
      Returns:
      the index of the first occurence of a number character in the sequence.
      Throws:
      StringIndexOutOfBoundsException
    • countOccurences

      public static int countOccurences(String c, String str)
      Counts how many times a given single character string occurs in a given String object.
      Parameters:
      c - A single character String value whose occurences in another string we wish to count.
      str - The String object that we will search through.
      Returns:
      The number of times c occurs in str
    • getFirstNumberSubstring

      public static String getFirstNumberSubstring(String val) throws StringIndexOutOfBoundsException
      method getFirstNumberSubstring takes a String object and returns the first number string in the String.
      Parameters:
      val - the string to analyze
      Returns:
      the index of the first occurrence of a number character in the sequence.
      Throws:
      StringIndexOutOfBoundsException
    • removeCommas

      public static String removeCommas(String h)
      Allows you to remove commas from a string.
      Parameters:
      h -
      Returns:
      a string in which the contents of the original have been freed from all commas.
    • purifier

      public static String purifier(String h)
      purifier allows you to remove all white spaces in a given string,which it receives as its argument
      Parameters:
      h - The string to free from white space.
      Returns:
      a string devoid of all white space.
    • purifier

      public static String purifier(String h, int fromIndex)
      purifier allows you to remove all white spaces in a given string,which it receives as its argument
      Parameters:
      h - The string to remove white space from.
      Returns:
      a string from which white space has been removed starting from index fromIndex.
    • removeAll

      public static String removeAll(String str, String unwanted) throws IndexOutOfBoundsException
      removeAll allows you to remove all occurrences of an unwanted string from a given string, which it receives as its argument
      Parameters:
      str - The string to remove the unwanted substring from.
      unwanted - The unwanted substring.
      Returns:
      a string from which all instance of unwanted has been removed.
      Throws:
      IndexOutOfBoundsException
    • replaceAll

      public static String replaceAll(String str, String replaced, String replacing)
      The Technology: 1. Split the string into an array on the replaced string. For example, if the string is Shohkhohlhohkhohbanhghohshoh, and the replaced string is hoh and the replacing string is now. Stage 1 generates: [S,k,l,k,banhg,s,] 2. Create a string object and loop through the array, appending to this object in each index, the contents of that index and the replacing string replaceAll allows you to replace all occurrences of an unwanted string in a given string with a new string, which it receives as its argument
      Parameters:
      str - The string on which replacement is to be done.
      replaced - The replaced string.
      replacing - The replacing string.
      Returns:
      a string from which all instance of unwanted has been removed.
    • delete

      public static String delete(String u, int i) throws StringIndexOutOfBoundsException
      method delete takes 2 arguments,the string to be modified and the index of the character to be deleted
      Parameters:
      u -
      i -
      Returns:
      the string after the character at index i has been removed
      Throws:
      StringIndexOutOfBoundsException
    • delete

      public static String delete(String u, String str)
      method delete takes 2 arguments,the string to be modified and the substring to be removed from it.
      Parameters:
      u - the string to be modified
      str - the substring to be removed from u
      Returns:
      the string after the first instance of the specified substring has been removed
      Throws:
      StringIndexOutOfBoundsException
    • delete

      public static String delete(String u, int i, int j) throws StringIndexOutOfBoundsException
      method delete takes 3 arguments,the string to be modified, the index at which deleting is to begin and the index one after the point where deletion is to end. STRING.delete("Corinthian", 2,4)returns "Conthian"
      Parameters:
      u -
      i -
      j -
      Returns:
      Throws:
      StringIndexOutOfBoundsException
    • deleteCharsAfter

      public static String deleteCharsAfter(String str, int i, int num) throws StringIndexOutOfBoundsException
      method delete takes 3 arguments,the string to be modified, the index at which deleting is to begin and the index one after the point where deletion is to end. STRING.delete("Corinthian", 2,4)returns "Conthian"
      Parameters:
      str - ..The original string
      i - ..The index at which we start deleting
      num - The number of characters to delete after the index.
      Returns:
      the resulting string after the chars between i and i+num-1 have been deleted.
      Throws:
      StringIndexOutOfBoundsException
    • isDouble

      public static boolean isDouble(String a) throws NumberFormatException
      boolean Method isDouble(Object a) detects if a string entry is in double number format or not.
      Parameters:
      a -
      Returns:
      Throws:
      NumberFormatException
    • isNumberComponent

      public static boolean isNumberComponent(String comp)
      boolean Method isNumberComponent(args) detects if a string entry is a buiding block for a valid number or not For our purposes,the building blocks are the digits,the "." symbol,the E symbol,the - symbol,but not the addition one.
      Parameters:
      comp - the String object to check
      Returns:
      true if the analyzed object is a valid component of a real number
    • split

      public static ArrayList<String> split(String stringTosplit, String splittingObject) throws ArrayIndexOutOfBoundsException
      This is an optimized specialized substitute for String.split in the Java API. It runs about 10-20 times or more faster than the split method in the Java API and it returns an ArrayList of values, instead of an array. Splits a string on all instances of the splitting object
      Parameters:
      stringTosplit - The string to be split.
      splittingObject - The substring on which the string is to be split.
      Returns:
      an array containing substrings that the string has been split into.
      Throws:
      ArrayIndexOutOfBoundsException
    • splits

      public static String[] splits(String stringTosplit, String splittingObject)
      This is an highly optimized specialized substitute for String.split in the Java API. It runs about 40-100 times faster than the split method in the Java API and it returns an array, too. Splits a string on all instances of the splitting object
      Parameters:
      stringTosplit - The string to be split.
      splittingObject - The substring on which the string is to be split.
      Returns:
      an array containing substrings that the string has been split into.
    • splits

      public static String[] splits(String stringTosplit, String[] splittingObjects) throws NullPointerException
      This is an highly optimized specialized substitute for String.split in the Java API. It runs about 5-10 times faster than the split method in the Java API and it returns an Array object, too. If the array of splitting objects contains nothing or contains elements that are not found in the string, then an Array object containing the original string is returned. But if the array of splitting objects contains an empty string, it chops or slices the string into pieces, and so returns an Array object containing the individual characters of the string. Splits a string on all instances of the splitting object
      Parameters:
      stringTosplit - The string to be split.
      splittingObjects - An array containing substrings on which the string should be split.
      Returns:
      an array containing substrings that the string has been split into.
      Throws:
      NullPointerException - if the array of splitting objects contains a null value or is null.
    • isDigit

      public static boolean isDigit(String a)
      boolean Method isDigit can be used to check for single digits i.e 0-9.
      Parameters:
      a - the String to check.
      Returns:
      true if the string is a valid digit.
    • isDouble1

      public static boolean isDouble1(String a)
      Method isDouble1 is specially built for parsing number strings in my parser.Please do not use it for your own purposes. Its purpose is to detect already scanned number strings in a List object that contains many kinds of string objects
      Parameters:
      a -
      Returns:
      true if the string represents a number string( this in reality is true if the number has already being scanned and proven to be a valid number)
    • isWord

      public static boolean isWord(String a)
    • isLowerCaseWord

      public static boolean isLowerCaseWord(String a)
      method isLowerCaseWord takes one argument and that is the string whose case we wish to know.
      Parameters:
      a - The string to manipulate.
      Returns:
      true if the string is a lowercase letter
    • isUpperCaseWord

      public static boolean isUpperCaseWord(String a)
      method isUpperCaseWord takes one argument and that is the string whose case we wish to know.
      Parameters:
      a - The string to manipulate.
      Returns:
      true if the string is an uppercase letter
    • toUpperCase

      public static String toUpperCase(String m)
      method toUpperCase takes one argument only and that is the input string to be converted to upper case
      Parameters:
      m - the single length string to be converted to upper case
      Returns:
      the upper case version of the input
      Throws:
      StringIndexOutOfBoundsException
    • toLowerCase

      public static String toLowerCase(String m)
      method toLowerCase takes one argument only and that is input string to be converted to lower case
      Parameters:
      m - the single length string to be converted to lower case
      Returns:
      the lower case version of the input
      Throws:
      StringIndexOutOfBoundsException
    • reverse

      public static String reverse(String u1)
      method reverse takes 1 argument and that is the string to be reversed
      Parameters:
      u1 - The string to be reversed.
      Returns:
      The reversed string.
    • replace

      public static String replace(String u, String u1, Integer i, Integer j) throws StringIndexOutOfBoundsException
      method replace takes 4 arguments,the string to be modified, the replacing string, the index at which replacement is to begin and the index where replacement ends plus one i.e replacement ends at index j-1. STRING.replace("Corinthian","The" 3,6)returns "CorThehians"
      Parameters:
      u - The string to manipulate.
      u1 - The replacing string
      i - Index at which to begin replacing
      j - Index at which replacement ends plus one
      Returns:
      A string in which the characters between index i and j-1 have been replaced with the replacing string
      Throws:
      StringIndexOutOfBoundsException
    • isEven

      public static boolean isEven(String a)
    • convertdoubleDigitToString

      private static double convertdoubleDigitToString(String num)
    • convertdoubleDigitToString

      private static String convertdoubleDigitToString(double a)
    • doubleToString

      public static String doubleToString(double num)
    • hasChars

      public static boolean hasChars(String str)
      Parameters:
      str - The String object to check.
      Returns:
      true if it contains at least one non-white space characters.
    • isEven

      public static boolean isEven(double a)
      Checks if a given number is even
      Parameters:
      a - the number
      Returns:
      true if a is even
    • isEven

      public static boolean isEven(float a)
      Checks if a given number is even
      Parameters:
      a - the number
      Returns:
      true if a is even
    • isEven

      public static boolean isEven(int a)
      Checks if a given number is even
      Parameters:
      a - the number
      Returns:
      true if a is even
    • main

      public static void main(String[] args)