Class PseudoString
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.vilTypes.PseudoString
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT
-
Constructor Summary
Constructors Modifier Constructor Description protectedPseudoString()Prevents external instantiation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringat(java.lang.String string, int index)Returns the character at given position as String.static Sequence<java.lang.String>characters(java.lang.String string)Returns the characters of a string.static java.lang.Stringconcat(java.lang.String s1, java.lang.Object s2)Represents the string concatenation operation.static java.lang.StringconvertAny(java.lang.Object any)The last resort - converts any object to a String usingStringValueHelper.static booleanendsWith(java.lang.String string, java.lang.String postfix)Returns whether the givenstringhas the givenpostfix.static booleanequals(java.lang.String s1, java.lang.String s2)Represents the equality operation for Strings.static booleanequals(java.lang.String string, TypeDescriptor<?> type)Represents the equality operation for types vs.static booleanequalsIgnoreCase(java.lang.String string1, java.lang.String string2)Returns whether two strings are equal ignoring cases for the current locale.static java.lang.StringfirstToLowerCase(java.lang.String string)Turns the first character into a lower case character.static java.lang.StringfirstToUpperCase(java.lang.String string)Turns the first character into an upper case character.static java.lang.Stringformat(java.lang.String format, java.lang.Object value)Fillsformatwith values fromvalue.private static java.lang.StringformatImpl(java.lang.String format, java.lang.Object... values)Implements the generic format operation with exception handling.private static java.lang.StringformatImpl(java.lang.String format, java.util.List<?> values)Implements the format operation for list values.private static java.lang.StringformatImpl(java.lang.String format, java.util.Map<?,?> value)Implements the format operation for map values.static TypeDescriptor<?>getType(java.lang.String value)Returns the type ofvalue.static booleangreaterThan(java.lang.String string1, java.lang.String string2)Returns whetherstring1is greater thanstring2with respect to the current locale.static booleangreaterThanEqual(java.lang.String string1, java.lang.String string2)Returns whetherstring1is greater than or equalstring2with respect to the current locale.static java.lang.IntegerindexOf(java.lang.String string, java.lang.String part)Returns the first position ofpartinstring.static booleanisQuoted(java.lang.String string, java.lang.String quote)Returns whetherstringis quoted byquote, i.e., starts and ends withquote.static java.lang.StringlastToLowerCase(java.lang.String string)Turns the last character into a lower case character.static java.lang.StringlastToUpperCase(java.lang.String string)Turns the last character into an upper case character (QVT).static intlength(java.lang.String string)The length of the string.static booleanlessThan(java.lang.String string1, java.lang.String string2)Returns whetherstring1is less thanstring2with respect to the current locale.static booleanlessThanEqual(java.lang.String string1, java.lang.String string2)Returns whetherstring1is less than or equalstring2with respect to the current locale.static booleanmatchBoolean(java.lang.String string)Returns whetherstringrepresents a Boolean value.static booleanmatches(java.lang.String string, java.lang.String regEx)Returns whetherstringmatches the given regular expression.static booleanmatchIdentifier(java.lang.String string)Returns whetherstringcomplies with the rules for a Java identifier.static booleanmatchInteger(java.lang.String string)Returns whetherstringrepresents an Integer value.static booleanmatchReal(java.lang.String string)Returns whetherstringrepresents a Real value.static java.lang.StringnormalizeSpace(java.lang.String string)Normalizes spaces, i.e., trims and replaces all internal multi-whitespaces by a single one.static booleannotEquals(java.lang.String string, TypeDescriptor<?> type)Represents the un-equality operation for types vs.static java.lang.Stringplus(java.lang.String s1, java.lang.Object s2)Represents the string concatenation operation.static java.lang.Stringquotify(java.lang.String string, java.lang.String quote)Quotifiesstringby addingquotearoundstring.static java.lang.Stringreplace(java.lang.String string, java.lang.String search, java.lang.String replacement)Replaces all occurrences ofsearchinstringbyreplacement.static java.lang.Integerrfind(java.lang.String string, java.lang.String part)Returns the last position ofpartinstring.static Sequence<java.lang.String>split(java.lang.String string, java.lang.String regEx)Splits this string around matches of the given Java regular expression.static booleanstartsWith(java.lang.String string, java.lang.String prefix)Returns whether the givenstringhas the givenprefix.static java.lang.Stringsubstitute(java.lang.String string, java.lang.String regEx, java.lang.String replacement)Replaces all occurrences ofregExinstringbyreplacement.static java.lang.Stringsubstring(java.lang.String in, int start)Returns the specified substring ofinfromstartto end ofin.static java.lang.Stringsubstring(java.lang.String in, int start, int end)Returns the specified substring ofin.static java.lang.StringsubstringAfter(java.lang.String string, java.lang.String match)Returns the substring ofstringafter the (first) occurrence ofmatch.static java.lang.StringsubstringBefore(java.lang.String string, java.lang.String match)Returns the substring ofstringbefore the (first) occurrence ofmatch.static java.lang.BooleantoBoolean(java.lang.String string)Turns the given string into a Boolean.static java.lang.StringtoIdentifier(java.lang.String string)Turns the givenstringinto a typical (Java) programming language identifier by removing all non identifier characters.static java.lang.IntegertoInteger(java.lang.String string)Turns the given string into an integer.static Sequence<java.lang.String>tokenize(java.lang.String string, java.lang.String delimiters)Tokenizes the givenstringalongdelimiters.static java.lang.StringtoLowerCase(java.lang.String string)Transforms all characters to lower case.static java.lang.DoubletoReal(java.lang.String string)Turns the given string into a double.static java.lang.StringtoString(java.lang.String string)Returns the string representation ofstring(OCL).static java.lang.StringtoUpperCase(java.lang.String string)Transforms all characters to upper case.static java.lang.Stringtrim(java.lang.String string)Transforms thestringby removing all leading and trailing spaces.static booleanunequals(java.lang.String s1, java.lang.String s2)Represents the unequality operation for Strings.static java.lang.Stringunquotify(java.lang.String string, java.lang.String quote)
-
-
-
Field Detail
-
DEFAULT
public static final java.lang.String DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
plus
public static java.lang.String plus(java.lang.String s1, java.lang.Object s2)Represents the string concatenation operation.- Parameters:
s1- the first String to be considereds2- the second String (as object)to be considered- Returns:
- s1 + s2
-
concat
public static java.lang.String concat(java.lang.String s1, java.lang.Object s2)Represents the string concatenation operation.- Parameters:
s1- the first String to be considereds2- the second String (as object)to be considered- Returns:
- s1 + s2
-
equals
public static boolean equals(java.lang.String s1, java.lang.String s2)Represents the equality operation for Strings.- Parameters:
s1- the first boolean to be considereds2- the second boolean to be considered- Returns:
- s1 == s2
-
unequals
public static boolean unequals(java.lang.String s1, java.lang.String s2)Represents the unequality operation for Strings.- Parameters:
s1- the first boolean to be considereds2- the second boolean to be considered- Returns:
- s1 != s2
-
length
public static int length(java.lang.String string)
The length of the string.- Parameters:
string- the string to return the length for- Returns:
- the length of the string
-
matches
public static boolean matches(java.lang.String string, java.lang.String regEx)Returns whetherstringmatches the given regular expression.- Parameters:
string- the string to be consideredregEx- the (Java) regular expression- Returns:
trueif it matches,falseelse
-
split
public static Sequence<java.lang.String> split(java.lang.String string, java.lang.String regEx)
Splits this string around matches of the given Java regular expression.- Parameters:
string- the string to be splitregEx- the delimiting regular expression- Returns:
- the splitted string
-
substitute
public static java.lang.String substitute(java.lang.String string, java.lang.String regEx, java.lang.String replacement)Replaces all occurrences ofregExinstringbyreplacement.- Parameters:
string- the string to be considered as basisregEx- the Java regular expression to be replacedreplacement- the replacement string- Returns:
- the modified string
-
replace
public static java.lang.String replace(java.lang.String string, java.lang.String search, java.lang.String replacement)Replaces all occurrences ofsearchinstringbyreplacement.- Parameters:
string- the string to be considered as basissearch- the search string to be replacedreplacement- the replacement string- Returns:
- the modified string
-
toInteger
public static java.lang.Integer toInteger(java.lang.String string)
Turns the given string into an integer.- Parameters:
string- the input string- Returns:
- the converted integer (null if conversion is not possible)
- See Also:
matchInteger(String)
-
matchInteger
public static boolean matchInteger(java.lang.String string)
Returns whetherstringrepresents an Integer value. (QVT)- Parameters:
string- the string to test- Returns:
trueifstringrepresents an Integer value,false- See Also:
toInteger(String)
-
toReal
public static java.lang.Double toReal(java.lang.String string)
Turns the given string into a double.- Parameters:
string- the input string- Returns:
- the converted double (null if conversion is not possible)
- See Also:
matchReal(String)
-
matchReal
public static boolean matchReal(java.lang.String string)
Returns whetherstringrepresents a Real value. (QVT)- Parameters:
string- the string to test- Returns:
trueifstringrepresents a Real- See Also:
toReal(String)
-
toBoolean
public static java.lang.Boolean toBoolean(java.lang.String string)
Turns the given string into a Boolean. False is implicitly assumed for all values that do not represent true.- Parameters:
string- the input string- Returns:
- the converted Boolean (null if conversion is not possible)
- See Also:
matchBoolean(String)
-
matchBoolean
public static boolean matchBoolean(java.lang.String string)
Returns whetherstringrepresents a Boolean value. (QVT)- Parameters:
string- the string to test- Returns:
trueifstringrepresents a Boolean- See Also:
toBoolean(String)
-
substring
public static java.lang.String substring(java.lang.String in, int start, int end)Returns the specified substring ofin.- Parameters:
in- the string to be consideredstart- the inclusive start positionend- the exclusive end position- Returns:
- the substring (or in in case of any parameter problem)
-
substring
public static java.lang.String substring(java.lang.String in, int start)Returns the specified substring ofinfromstartto end ofin.- Parameters:
in- the string to be consideredstart- the inclusive start position- Returns:
- the substring (or in in case of any parameter problem)
-
startsWith
public static boolean startsWith(java.lang.String string, java.lang.String prefix)Returns whether the givenstringhas the givenprefix.- Parameters:
string- the string to be consideredprefix- the prefix- Returns:
trueifstringstarts withprefix,falseelse
-
endsWith
public static boolean endsWith(java.lang.String string, java.lang.String postfix)Returns whether the givenstringhas the givenpostfix.- Parameters:
string- the string to be consideredpostfix- the postfix- Returns:
trueifstringends withpostfix,falseelse
-
trim
public static java.lang.String trim(java.lang.String string)
Transforms thestringby removing all leading and trailing spaces. (QVT)- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
normalizeSpace
public static java.lang.String normalizeSpace(java.lang.String string)
Normalizes spaces, i.e., trims and replaces all internal multi-whitespaces by a single one. (QVT)- Parameters:
string- the string to normalize- Returns:
- the normalized string
-
substringBefore
public static java.lang.String substringBefore(java.lang.String string, java.lang.String match)Returns the substring ofstringbefore the (first) occurrence ofmatch. (QVT)- Parameters:
string- the string to search withinmatch- the string to match for- Returns:
- the substring before the match, an empty string in case of no match
-
substringAfter
public static java.lang.String substringAfter(java.lang.String string, java.lang.String match)Returns the substring ofstringafter the (first) occurrence ofmatch. (QVT)- Parameters:
string- the string to search withinmatch- the string to match for- Returns:
- the substring after the match, an empty string in case of no match
-
toUpperCase
public static java.lang.String toUpperCase(java.lang.String string)
Transforms all characters to upper case.- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
toLowerCase
public static java.lang.String toLowerCase(java.lang.String string)
Transforms all characters to lower case.- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
firstToUpperCase
public static java.lang.String firstToUpperCase(java.lang.String string)
Turns the first character into an upper case character.- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
firstToLowerCase
public static java.lang.String firstToLowerCase(java.lang.String string)
Turns the first character into a lower case character.- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
lastToUpperCase
public static java.lang.String lastToUpperCase(java.lang.String string)
Turns the last character into an upper case character (QVT).- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
lastToLowerCase
public static java.lang.String lastToLowerCase(java.lang.String string)
Turns the last character into a lower case character.- Parameters:
string- the string to be transformed- Returns:
- the transformed string
-
toIdentifier
public static java.lang.String toIdentifier(java.lang.String string)
Turns the givenstringinto a typical (Java) programming language identifier by removing all non identifier characters.- Parameters:
string- the string to be turned into an identifier- Returns:
- the identifier (may be empty in the extreme case)
- See Also:
matchIdentifier(String)
-
matchIdentifier
public static boolean matchIdentifier(java.lang.String string)
Returns whetherstringcomplies with the rules for a Java identifier. (QVT) Iftrue,toIdentifier(String)returnsstring, else a string with all characters removed that are not allowed in a Java identifier.- Parameters:
string- the string to be tested- Returns:
trueifstringrepresents an identifier,falseelse
-
convertAny
public static java.lang.String convertAny(java.lang.Object any)
The last resort - converts any object to a String usingStringValueHelper. This operation is absolutely necessary as the operation resolution inAbstractCallExpressiontries to find a matching operation with operand converted to String using this method.- Parameters:
any- the object to be converted- Returns:
- the resulting value
-
tokenize
public static Sequence<java.lang.String> tokenize(java.lang.String string, java.lang.String delimiters)
Tokenizes the givenstringalongdelimiters.- Parameters:
string- the string to tokenizedelimiters- the delimiters between two tokens. Delimiter characters themselves will not be treated as tokens.- Returns:
- the tokens in sequence of occurrence
-
toString
public static java.lang.String toString(java.lang.String string)
Returns the string representation ofstring(OCL).- Parameters:
string- the string to be turned into a string- Returns:
- the string value
-
indexOf
public static java.lang.Integer indexOf(java.lang.String string, java.lang.String part)Returns the first position ofpartinstring. Find alias is due to QVT.- Parameters:
string- the string to searchpart- the part to search for- Returns:
- the first 0-based position or
-1ifpartis not a substring ofstring
-
rfind
public static java.lang.Integer rfind(java.lang.String string, java.lang.String part)Returns the last position ofpartinstring. (QVT)- Parameters:
string- the string to searchpart- the part to search for- Returns:
- the last 0-based position or
-1ifpartis not a substring ofstring
-
isQuoted
public static boolean isQuoted(java.lang.String string, java.lang.String quote)Returns whetherstringis quoted byquote, i.e., starts and ends withquote. (QVT)- Parameters:
string- the string to testquote- the quote string/character- Returns:
trueifstringis quoted,falseelse
-
quotify
public static java.lang.String quotify(java.lang.String string, java.lang.String quote)Quotifiesstringby addingquotearoundstring. (QVT)- Parameters:
string- the stringquote- the quote string/character- Returns:
- the quoted
string
-
unquotify
public static java.lang.String unquotify(java.lang.String string, java.lang.String quote)- Parameters:
string- the stringquote- the quote string/character- Returns:
- the unquoted
string, if notquotedstring
-
at
public static java.lang.String at(java.lang.String string, int index)Returns the character at given position as String.- Parameters:
string- the string to take the character fromindex- the 0-based index to return the character for- Returns:
- the character at
index
-
equalsIgnoreCase
public static boolean equalsIgnoreCase(java.lang.String string1, java.lang.String string2)Returns whether two strings are equal ignoring cases for the current locale.- Parameters:
string1- the first stringstring2- the second string- Returns:
trueif both strings are considered equal for the current locale,falseelse
-
lessThan
public static boolean lessThan(java.lang.String string1, java.lang.String string2)Returns whetherstring1is less thanstring2with respect to the current locale.- Parameters:
string1- the first stringstring2- the second string- Returns:
- whether
string1is less thanstring2
-
lessThanEqual
public static boolean lessThanEqual(java.lang.String string1, java.lang.String string2)Returns whetherstring1is less than or equalstring2with respect to the current locale.- Parameters:
string1- the first stringstring2- the second string- Returns:
- whether
string1is less than or equalstring2
-
greaterThan
public static boolean greaterThan(java.lang.String string1, java.lang.String string2)Returns whetherstring1is greater thanstring2with respect to the current locale.- Parameters:
string1- the first stringstring2- the second string- Returns:
- whether
string1is greater thanstring2
-
greaterThanEqual
public static boolean greaterThanEqual(java.lang.String string1, java.lang.String string2)Returns whetherstring1is greater than or equalstring2with respect to the current locale.- Parameters:
string1- the first stringstring2- the second string- Returns:
- whether
string1is greater than or equalstring2
-
characters
public static Sequence<java.lang.String> characters(java.lang.String string)
Returns the characters of a string.- Parameters:
string- the string to be turned into characters- Returns:
- the characters of
stringas string sequence
-
getType
public static TypeDescriptor<?> getType(java.lang.String value)
Returns the type ofvalue. "Overrides"PseudoAny.getType(Object).- Parameters:
value- the String to return the type for- Returns:
- the type of object (null if
obis null)
-
equals
public static boolean equals(java.lang.String string, TypeDescriptor<?> type)Represents the equality operation for types vs. Strings (legacy). Use simple or qualified name of type for comparison.- Parameters:
string- the string to comparetype- the type to compare- Returns:
- string == type.getName() || string == type.getQualifiedName()
-
notEquals
public static boolean notEquals(java.lang.String string, TypeDescriptor<?> type)Represents the un-equality operation for types vs. Strings (legacy). Use simple or qualified name of type for comparison.- Parameters:
string- the string to comparetype- the type to compare- Returns:
- string != type.getName() && string != type.getQualifiedName()
-
format
public static java.lang.String format(java.lang.String format, java.lang.Object value)Fillsformatwith values fromvalue. Follows the QVT specification of this operation as far as possible.- Parameters:
format- the format in Java format specification, including %(x) for keys ifvalueis a mapvalue- the value - if sequence, assign the values to the positions of the format specification; if map, replace %(key) by string representation; if value, just apply format.- Returns:
- the formatted string, null in case of any formatting problems
-
formatImpl
private static java.lang.String formatImpl(java.lang.String format, java.util.Map<?,?> value)Implements the format operation for map values.- Parameters:
format- the format operationvalue- the map value- Returns:
- the formatted string
-
formatImpl
private static java.lang.String formatImpl(java.lang.String format, java.util.List<?> values)Implements the format operation for list values.- Parameters:
format- the format operationvalues- the list value(s)- Returns:
- the formatted string
-
formatImpl
private static java.lang.String formatImpl(java.lang.String format, java.lang.Object... values)Implements the generic format operation with exception handling.- Parameters:
format- the format operationvalues- the values- Returns:
- the formatted string
-
-