Package parser
Class STRING
java.lang.Object
parser.STRING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
contains allows you to verify if an input string contains a given substring.private static String
convertdoubleDigitToString
(double a) private static double
static int
countOccurences
(String c, String str) Counts how many times a given single character string occurs in a given String object.static String
method delete takes 2 arguments,the string to be modified and the index of the character to be deletedstatic String
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
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
getFirstOccurenceOfDigit
(String value) method getFirstOccurenceOfDigit takes a String object and returns the first occurence of a number character in the String.static boolean
static boolean
isDecimalPoint
(String val) 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 evenstatic boolean
isEven
(float a) Checks if a given number is evenstatic boolean
isEven
(int a) Checks if a given number is evenstatic boolean
static boolean
isExponentOf10
(String val) static boolean
isfullyDouble
(String num) 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
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.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
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 forwardsstatic 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 backwardsstatic String
purifier allows you to remove all white spaces in a given string,which it receives as its argumentstatic String
purifier allows you to remove all white spaces in a given string,which it receives as its argumentstatic String
removeAll allows you to remove all occurrences of an unwanted string from a given string, which it receives as its argumentstatic String
Allows you to remove commas from a string.static String
removeNewLineChar
(String input) 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 reversedThis is an optimized specialized substitute for String.split in the Java API.static String[]
This is an highly optimized specialized substitute for String.split in the Java API.static String[]
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 casestatic String
method toUpperCase takes one argument only and that is the input string to be converted to upper case
-
Constructor Details
-
STRING
public STRING()
-
-
Method Details
-
contains
contains allows you to verify if an input string contains a given substring.- Parameters:
str
- : the string to checksubstr
- : the substring to check for- Returns:
- true or false depending on if or not the input consists of digits alone or otherwise.
-
isOnlyDigits
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
- 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
- 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
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
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
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
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
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
- Parameters:
val
- the entry being analyzed.- Returns:
- true if the entry is a + sign or a minus sign
-
isDecimalPoint
- Parameters:
val
- the entry being analyzed.- Returns:
- true if the entry is a floating point
-
isExponentOf10
- Parameters:
val
- the entry being analyzed.- Returns:
- true if the entry is the power of 10 symbol i.e E
-
getFirstOccurenceOfDigit
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
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
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
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
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
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
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
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
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
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
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
method delete takes 2 arguments,the string to be modified and the substring to be removed from it.- Parameters:
u
- the string to be modifiedstr
- the substring to be removed from u- Returns:
- the string after the first instance of the specified substring has been removed
- Throws:
StringIndexOutOfBoundsException
-
delete
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 stringi
- ..The index at which we start deletingnum
- 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
boolean Method isDouble(Object a) detects if a string entry is in double number format or not.- Parameters:
a
-- Returns:
- Throws:
NumberFormatException
-
isNumberComponent
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
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
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
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
-
isLowerCaseWord
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
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
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
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
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 stringi
- Index at which to begin replacingj
- 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
-
convertdoubleDigitToString
-
convertdoubleDigitToString
-
doubleToString
-
hasChars
- 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
-