Package net.oijon.osca
Class Rule
- java.lang.Object
-
- net.oijon.osca.Rule
-
public class Rule extends java.lang.ObjectCreates an object that can be used to change text based on a target, replacement, environment, and exception.
-
-
Field Summary
Fields Modifier and Type Field Description protected static char[]whitespaces
-
Constructor Summary
Constructors Constructor Description Rule(java.lang.String ruleStr)Creates a rule based on an input stringRule(java.lang.String target, java.lang.String replacement, java.lang.String environment)Creates a rule with a given target, replacement, and environmentRule(java.lang.String target, java.lang.String replacement, java.lang.String environment, java.lang.String exception)Creates a rule with a given target, replacement, environment, and exceptionRule(java.lang.String target, java.lang.String replacement, java.lang.String environment, java.lang.String exception, java.util.ArrayList<Category> categories)Creates a rule with a given target, replacement, environment, and exception, along with a list of categoriesRule(java.lang.String target, java.lang.String replacement, java.lang.String environment, java.util.ArrayList<Category> categories)Creates a rule with a given target, replacement, and environment, along with a category listRule(java.lang.String ruleStr, java.util.ArrayList<Category> categories)Creates a rule based on an input string and a list of categories
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringparse(java.lang.String input)Takes a string, runs it through the rule, and gives an output.static java.util.ArrayList<Rule>parseFromList(java.lang.String ruleList)Parses a list of rules, and makes it an ArrayListstatic java.lang.StringparseList(java.util.ArrayList<Rule> list, java.lang.String input)Parses a list of rules on one stringjava.lang.StringtoString()
-
-
-
Constructor Detail
-
Rule
public Rule(java.lang.String ruleStr) throws InvalidRuleSyntaxExceptionCreates a rule based on an input string- Parameters:
ruleStr- The string to make the rule from- Throws:
InvalidRuleSyntaxException- Thrown when ruleStr does not follow the expected X/Y/Z/A format
-
Rule
public Rule(java.lang.String ruleStr, java.util.ArrayList<Category> categories) throws InvalidRuleSyntaxExceptionCreates a rule based on an input string and a list of categories- Parameters:
ruleStr- The string to make the rule fromcategories- The list of categories to use- Throws:
InvalidRuleSyntaxException- Thrown when ruleStr does not follow the expected X/Y/Z/A format
-
Rule
public Rule(java.lang.String target, java.lang.String replacement, java.lang.String environment, java.util.ArrayList<Category> categories)Creates a rule with a given target, replacement, and environment, along with a category list- Parameters:
target- The target for the rulereplacement- The replacement for the ruleenvironment- The environment for the rulecategories- The list of categories to use
-
Rule
public Rule(java.lang.String target, java.lang.String replacement, java.lang.String environment)Creates a rule with a given target, replacement, and environment- Parameters:
target- The target for the rulereplacement- The replacement for the ruleenvironment- The environment for the rule
-
Rule
public Rule(java.lang.String target, java.lang.String replacement, java.lang.String environment, java.lang.String exception)Creates a rule with a given target, replacement, environment, and exception- Parameters:
target- The target for the rulereplacement- The replacement for the ruleenvironment- The environment for the ruleexception- The exception for the rule; when the rule should not apply
-
Rule
public Rule(java.lang.String target, java.lang.String replacement, java.lang.String environment, java.lang.String exception, java.util.ArrayList<Category> categories)Creates a rule with a given target, replacement, environment, and exception, along with a list of categories- Parameters:
target- The target for the rulereplacement- The replacement for the ruleenvironment- The environment for the ruleexception- The exception for the rule; when the rule should not applycategories- The list of categories to use
-
-
Method Detail
-
parse
public java.lang.String parse(java.lang.String input)
Takes a string, runs it through the rule, and gives an output.- Parameters:
input- The string to run through the rule- Returns:
- The output of the rule on the given string
-
parseList
public static java.lang.String parseList(java.util.ArrayList<Rule> list, java.lang.String input)
Parses a list of rules on one string- Parameters:
list- The list of rules to useinput- The input to be processed- Returns:
- The output of every rule on the input
-
parseFromList
public static java.util.ArrayList<Rule> parseFromList(java.lang.String ruleList)
Parses a list of rules, and makes it an ArrayList- Parameters:
ruleList- A list of rules, separated by newlines- Returns:
- an ArrayList of each rule specified
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-