public class BracketParser
extends java.lang.Object
Constructor and Description |
---|
BracketParser() |
Modifier and Type | Method and Description |
---|---|
static java.util.HashMap<java.lang.String,java.lang.String> |
createHashMapFromEscaped(java.lang.String s)
Creates a HashMap for a String in the general format Name1(value1)Name2(value2)...
|
static java.util.HashMap<java.lang.String,java.lang.String> |
createHashMapFromNonEscaped(java.lang.String s)
Creates a HashMap for a String in the general format Name1(value1)Name2(value2)...
|
static java.util.HashMap<java.lang.String,java.lang.String> |
createHashMapWithMandatoryValuesFromEscaped(java.lang.String s)
Creates a HashMap for a String in the general format Name1(value1)Name2(value2)...
|
static java.util.HashMap<java.lang.String,java.lang.String> |
createHashMapWithMandatoryValuesFromNonEscaped(java.lang.String s)
Creates a HashMap for a String in the general format Name1(value1)Name2(value2)...
|
static java.util.LinkedList<java.lang.String> |
createListFromEscaped(java.lang.String s)
Creates a List of values contained in a String in the general format Name1(value1)Name2(value2)...
|
static java.util.LinkedList<java.lang.String> |
createListFromNonEscaped(java.lang.String s)
Creates a List of values contained in a String in the general format Name1(value1)Name2(value2)...
|
static java.util.Map<java.lang.String,java.lang.String> |
createMapFromEscapedString(java.lang.String s,
boolean emptyMapAllowed)
Parses a bracketed String and builds a hashmap with the information contained within the (map) value is the (attribute) value, also in string format.
|
static java.util.TreeMap<java.lang.String,java.lang.String> |
createTreeMapFromEscaped(java.lang.String s)
Creates a TreeMap for a String in the general format Name1(value1)Name2(value2)...
|
static java.util.TreeMap<java.lang.String,java.lang.String> |
createTreeMapFromNonEscaped(java.lang.String s)
Creates a TreeMap for a String in the general format Name1(value1)Name2(value2)...
|
static java.util.TreeMap<java.lang.String,java.lang.String> |
createTreeMapWithMandatoryValuesFromEscaped(java.lang.String s)
Creates a TreeMap for a String in the general format Name1(value1)Name2(value2)...
|
static java.util.TreeMap<java.lang.String,java.lang.String> |
createTreeMapWithMandatoryValuesFromNonEscaped(java.lang.String s)
Creates a TreeMap for a String in the general format Name1(value1)Name2(value2)...
|
static void |
fillMapFromEscaped(java.lang.String s,
java.util.Map<java.lang.String,java.lang.String> attributeValueMap)
Filles the given Map with the entries held in a String in the general format Name1(value1)Name2(value2)...
|
static void |
fillMapFromNonEscaped(java.lang.String s,
java.util.Map<java.lang.String,java.lang.String> attributeValueMap)
Filles the given Map with the entries held in a String in the general format Name1(value1)Name2(value2)...
|
static void |
fillMapWithMandatoryValuesFromEscaped(java.lang.String s,
java.util.Map<java.lang.String,java.lang.String> attributeValueMap)
Filles the given Map with the entries held in a String in the general format Name1(value1)Name2(value2)...
|
static void |
fillMapWithMandatoryValuesFromNonEscaped(java.lang.String s,
java.util.Map<java.lang.String,java.lang.String> attributeValueMap)
Filles the given Map with the entries held in a String in the general format Name1(value1)Name2(value2)...
|
static void |
fillNonEmptyMapWithMandatoryValuesFromEscaped(java.lang.String s,
java.util.Map<java.lang.String,java.lang.String> attributeValueMap) |
static void |
fillNonEmptyMapWithMandatoryValuesFromNonEscaped(java.lang.String s,
java.util.Map<java.lang.String,java.lang.String> attributeValueMap) |
static int |
findCorrespondingClosingBracket(java.lang.String s)
Find the position of the closing bracket that matches the opening bracket in position 0.
|
static NameValueResult |
getNameAndMandatoryValueFromEscaped(java.lang.String s,
int startPos)
Returns the 'name' part of an expression of the form "name(content)"
|
static NameValueResult |
getNameAndMandatoryValueFromNonEscaped(java.lang.String s,
int startPos)
Returns the 'name' part of an expression of the form "name(content)"
|
static NameValueResult |
getNameAndMandatoryValueUntrimmedFromEscaped(java.lang.String s,
int startPos)
Returns the 'name' part of an expression of the form "name(content)"
|
static NameValueResult |
getNameValueFromEscaped(java.lang.String s,
int startPos)
Returns the 'name' part of an expression of the form "name(content)"
|
static NameValueResult |
getNameValueFromNonEscaped(java.lang.String s,
int startPos)
Returns the 'name' part of an expression of the form "name(content)"
|
static NameValueResult |
getNameValueUntrimmedFromEscaped(java.lang.String s,
int startPos)
Returns the 'name' part of an expression of the form "name(content)"
|
static java.lang.String |
meta(java.lang.String s)
Adapts a given string for representation of the siraprise metalanguage characters ()\
|
static java.lang.String |
removeSuperfluousOuterBrackets(java.lang.String arg)
Removes superfluous outer brackets from arg.
|
static java.util.LinkedList<java.lang.String> |
splitIntoExpressions(java.lang.String arg2,
int remainingFreeArguments)
Gets the multiple expressions that are in the comma-separated list arg2
|
static java.lang.String |
unMeta(java.lang.String s)
Translates strings in SIRA_PRISE meta language to their actual value.
|
static java.lang.String |
unMetaWithoutException(java.lang.String s)
Translates strings in SIRA_PRISE meta language to their actual value.
|
public static java.util.HashMap<java.lang.String,java.lang.String> createHashMapFromEscaped(java.lang.String s) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, DuplicateNameException
s
- A string in the general format name1(value1)name2(value2)... The 'value' parts are in escaped format, i.e. ()\ tokens that are part of the value, should be contained as \(, \), \\.InvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingNoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketDuplicateNameException
- If the String argument contains a duplicate name.public static java.util.HashMap<java.lang.String,java.lang.String> createHashMapFromNonEscaped(java.lang.String s) throws NoClosingBracketException, DuplicateNameException
s
- A string in the general format name1(value1)name2(value2)... Values cannot hold any tokens of the meta language, i.e. one of ()\ .NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketDuplicateNameException
- If the String argument contains a duplicate name.public static java.util.HashMap<java.lang.String,java.lang.String> createHashMapWithMandatoryValuesFromEscaped(java.lang.String s) throws DuplicateNameException, NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, NoValueCorrespondingToNameException
s
- A string in the general format name1(value1)name2(value2)... The 'value' parts are in escaped format, i.e. ()\ tokens that are part of the value, should be contained as \(, \), \\.DuplicateNameException
- If the String argument contains a duplicate name.NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingNoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.public static java.util.HashMap<java.lang.String,java.lang.String> createHashMapWithMandatoryValuesFromNonEscaped(java.lang.String s) throws DuplicateNameException, NoClosingBracketException, NoValueCorrespondingToNameException
s
- A string in the general format name1(value1)name2(value2)... Values cannot hold any tokens of the meta language, i.e. one of ()\ .DuplicateNameException
- If the String argument contains a duplicate name.NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketNoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.public static java.util.LinkedList<java.lang.String> createListFromEscaped(java.lang.String s) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, NoValueCorrespondingToNameException
s
- A string in the general format name1(value1)name2(value2)...MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missing If the string argument ends with the escape token (backslash), with the subsequent escaped character missingNoValueCorrespondingToNameException
- If a name with no corresponding value is contained.InvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\ If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketpublic static java.util.LinkedList<java.lang.String> createListFromNonEscaped(java.lang.String s) throws NoClosingBracketException, NoValueCorrespondingToNameException
s
- A string in the general format name1(value1)name2(value2)...NoValueCorrespondingToNameException
- If a name with no corresponding value is contained.NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketpublic static java.util.Map<java.lang.String,java.lang.String> createMapFromEscapedString(java.lang.String s, boolean emptyMapAllowed) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, NoValueCorrespondingToNameException, DuplicateNameException
s
- The textual representation of a bracketed expressionemptyMapAllowed
- true if the result is not expected to contain at least one entryDuplicateNameException
- If the String argument contains a duplicate name.NoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketpublic static java.util.TreeMap<java.lang.String,java.lang.String> createTreeMapFromEscaped(java.lang.String s) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, DuplicateNameException
s
- A string in the general format name1(value1)name2(value2)... The 'value' parts are in escaped format, i.e. ()\ tokens that are part of the value, should be contained as \(, \), \\.InvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingNoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketDuplicateNameException
- If the String argument contains a duplicate name.public static java.util.TreeMap<java.lang.String,java.lang.String> createTreeMapFromNonEscaped(java.lang.String s) throws NoClosingBracketException, DuplicateNameException
s
- A string in the general format name1(value1)name2(value2)... Values cannot hold any tokens of the meta language, i.e. one of ()\ .NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketDuplicateNameException
- If the String argument contains a duplicate name.public static java.util.TreeMap<java.lang.String,java.lang.String> createTreeMapWithMandatoryValuesFromEscaped(java.lang.String s) throws DuplicateNameException, NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, NoValueCorrespondingToNameException
s
- A string in the general format name1(value1)name2(value2)... The 'value' parts are in escaped format, i.e. ()\ tokens that are part of the value, should be contained as \(, \), \\.DuplicateNameException
- If the String argument contains a duplicate name.NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingNoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.public static java.util.TreeMap<java.lang.String,java.lang.String> createTreeMapWithMandatoryValuesFromNonEscaped(java.lang.String s) throws DuplicateNameException, NoClosingBracketException, NoValueCorrespondingToNameException
s
- A string in the general format name1(value1)name2(value2)... Values cannot hold any tokens of the meta language, i.e. one of ()\ .DuplicateNameException
- If the String argument contains a duplicate name.NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketNoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.public static void fillMapFromEscaped(java.lang.String s, java.util.Map<java.lang.String,java.lang.String> attributeValueMap) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, DuplicateNameException
s
- A string in the general format name1(value1)name2(value2)... The 'value' parts are in escaped format, i.e. ()\ tokens that are part of the value, should be contained as \(, \), \\.attributeValueMap
- The map to be filled. May or may not be empty. If non-empty at the moment of invocation, entries from the String argument will be added to the Map, in addition to those that were already present.NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingDuplicateNameException
- If the String argument contains a duplicate name, or contains a name for which the given map already holds an entry.public static void fillMapFromNonEscaped(java.lang.String s, java.util.Map<java.lang.String,java.lang.String> attributeValueMap) throws NoClosingBracketException, DuplicateNameException
s
- A string in the general format name1(value1)name2(value2)... Values cannot hold any tokens of the meta language, i.e. one of ()\ .attributeValueMap
- The map to be filled. May or may not be empty. If non-empty at the moment of invocation, entries from the String argument will be added to the Map, in addition to those that were already present.NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketDuplicateNameException
- If the String argument contains a duplicate name, or contains a name for which the given map already holds an entry.public static void fillMapWithMandatoryValuesFromEscaped(java.lang.String s, java.util.Map<java.lang.String,java.lang.String> attributeValueMap) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, NoValueCorrespondingToNameException, DuplicateNameException
s
- A string in the general format name1(value1)name2(value2)... Values cannot hold any tokens of the meta language, i.e. one of ()\ .attributeValueMap
- The map to be filled. May or may not be empty. If non-empty at the moment of invocation, entries from the String argument will be added to the Map, in addition to those that were already present.NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingNoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.DuplicateNameException
- If the String argument contains a duplicate name, or contains a name for which the given map already holds an entry.public static void fillMapWithMandatoryValuesFromNonEscaped(java.lang.String s, java.util.Map<java.lang.String,java.lang.String> attributeValueMap) throws NoClosingBracketException, NoValueCorrespondingToNameException, DuplicateNameException
s
- A string in the general format name1(value1)name2(value2)... Values cannot hold any tokens of the meta language, i.e. one of ()\ .attributeValueMap
- The map to be filled. May or may not be empty. If non-empty at the moment of invocation, entries from the String argument will be added to the Map, in addition to those that were already present.NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketNoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.DuplicateNameException
- If the String argument contains a duplicate name, or contains a name for which the given map already holds an entry.public static void fillNonEmptyMapWithMandatoryValuesFromEscaped(java.lang.String s, java.util.Map<java.lang.String,java.lang.String> attributeValueMap) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, NoValueCorrespondingToNameException, DuplicateNameException
s
- The string to parseattributeValueMap
- The map to fillDuplicateNameException
- If the String argument contains a duplicate name, or contains a name for which the given map already holds an entry.NoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketpublic static void fillNonEmptyMapWithMandatoryValuesFromNonEscaped(java.lang.String s, java.util.Map<java.lang.String,java.lang.String> attributeValueMap) throws NoClosingBracketException, NoValueCorrespondingToNameException, DuplicateNameException
s
- The string to parseattributeValueMap
- The map to fillDuplicateNameException
- If the String argument contains a duplicate name, or contains a name for which the given map already holds an entry.NoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketpublic static int findCorrespondingClosingBracket(java.lang.String s) throws NoClosingBracketException
s
- A String holding a bracketed expression that begins with an opening bracketNoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketpublic static NameValueResult getNameAndMandatoryValueFromEscaped(java.lang.String s, int startPos) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, NoValueCorrespondingToNameException
s
- a string of the general form name(content)startPos
- The first position in s to inspect for the name, in the range [0...length-1]NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\ If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingNoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.public static NameValueResult getNameAndMandatoryValueFromNonEscaped(java.lang.String s, int startPos) throws NoClosingBracketException, NoValueCorrespondingToNameException
s
- a string of the general form name(content)startPos
- The first position in s to inspect for the name, in the range [0...length-1]NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketNoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.public static NameValueResult getNameAndMandatoryValueUntrimmedFromEscaped(java.lang.String s, int startPos) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, NoValueCorrespondingToNameException
s
- a string of the general form name(content)startPos
- The first position in s to inspect for the name, in the range [0...length-1]NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\ If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingNoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.public static NameValueResult getNameValueFromEscaped(java.lang.String s, int startPos) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException
s
- a string of the general form name(content)startPos
- The first position in s to inspect for the name, in the range [0...length-1]NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\ If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingpublic static NameValueResult getNameValueFromNonEscaped(java.lang.String s, int startPos) throws NoClosingBracketException
s
- a string of the general form name(content)startPos
- The first position in s to inspect for the name, in the range [0...length-1]NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketpublic static NameValueResult getNameValueUntrimmedFromEscaped(java.lang.String s, int startPos) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException
s
- a string of the general form name(content)startPos
- The first position in s to inspect for the name, in the range [0...length-1]NoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\ If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingpublic static java.lang.String meta(java.lang.String s)
s
- The string to be adapted for representation of the siraprise metalanguage characters ()\public static java.lang.String removeSuperfluousOuterBrackets(java.lang.String arg)
arg
- The argument from which superfluous outer brackets are to be removedpublic static java.lang.String unMeta(java.lang.String s) throws InvalidEscapedCharacterException, MissingEscapedCharacterException
s
- The string to be un-meta-ifiedInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\ If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingpublic static java.lang.String unMetaWithoutException(java.lang.String s)
s
- The string to be un-meta-ifiedpublic static java.util.LinkedList<java.lang.String> splitIntoExpressions(java.lang.String arg2, int remainingFreeArguments) throws NoClosingBracketException, InvalidEscapedCharacterException, MissingEscapedCharacterException, NoValueCorrespondingToNameException, SeparatorCommaMissingException
arg2
- The argument to be further split into several expressionsremainingFreeArguments
- The maximum number of arguments to be returnedNoClosingBracketException
- If an opening bracket was found with an unmatched closing bracketInvalidEscapedCharacterException
- If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\ If the string argument contains an invalid escape sequence, i.e. a backslash followed by a character other than ()\MissingEscapedCharacterException
- If the string argument ends with the escape token (backslash), with the subsequent escaped character missingNoValueCorrespondingToNameException
- If the string does not hold any opening bracket, meaning a name with no corresponding value is contained.SeparatorCommaMissingException
- If a separator comma was expected but missing