Class VariableString
java.lang.Object
io.github.syst3ms.skriptparser.lang.base.TaggedExpression
io.github.syst3ms.skriptparser.lang.VariableString
- All Implemented Interfaces:
Expression<String>, SyntaxElement
A string that possibly contains expressions inside it, meaning that its value may be unknown at parse time
-
Method Summary
Modifier and TypeMethodDescriptionbooleaninit(Expression<?>[] expressions, int matchedPattern, ParseContext parseContext) Initializes this SyntaxElement before being used.booleanisSimple()booleanisSingle()static Optional<VariableString> newInstance(String s, ParserState parserState, SkriptLogger logger) Creates a new instance of a VariableString from the text inside a string literal.static Optional<VariableString> newInstanceWithQuotes(String s, ParserState parserState, SkriptLogger logger) Creates a new instance of a VariableString.toString(TriggerContext ctx) toString(TriggerContext ctx, boolean debug) toString(TriggerContext ctx, String tagCtx) Returns the value of this string after applying the tags according to the given tag context.Methods inherited from class TaggedExpression
apply, getValuesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Expression
acceptsChange, acceptsChange, acceptsChange, change, check, check, convertExpression, getArray, getSingle, getSource, isAndList, isLoopOf, iterator, setAndList, stream
-
Method Details
-
newInstanceWithQuotes
public static Optional<VariableString> newInstanceWithQuotes(String s, ParserState parserState, SkriptLogger logger) Creates a new instance of a VariableString.- Parameters:
s- the text to create a new instance from, with its surrounding quoteslogger- the logger- Returns:
nullif either:- The argument isn't quoted correctly
newInstance(String, ParserState, SkriptLogger)returned null, which can happen when the string literal is of the form"..."- Something went very wrong when parsing a raw literal
R"possible delimiter(...)possible delimiter'
-
newInstance
public static Optional<VariableString> newInstance(String s, ParserState parserState, SkriptLogger logger) Creates a new instance of a VariableString from the text inside a string literal.- Parameters:
s- the content of the string literal, without quotesparserState- the current parser statelogger- the logger- Returns:
- a new instance of a VariableString, or
nullif there are unbalanced % symbols
-
init
@Contract("_, _, _ -> fail") public boolean init(Expression<?>[] expressions, int matchedPattern, ParseContext parseContext) Description copied from interface:SyntaxElementInitializes this SyntaxElement before being used. This method is always called before all the others in an extending class, the only exception beingCodeSection.loadSection(FileSection, ParserState, SkriptLogger).- Parameters:
expressions- an array of expressions representing all the expressions that are being passed to this syntax element. As opposed to Skript, elements of this array can't benull.matchedPattern- the index of the pattern that was successfully matched. It corresponds to the order of the syntaxes in registrationparseContext- an object containing additional information about the parsing of this syntax element, like regex matches and parse marks- Returns:
trueif the syntax element was initialized successfully,falseotherwise.- See Also:
-
isSingle
public boolean isSingle()- Returns:
- whether this expression returns a single value. By default, this is defined on registration, but it can be overridden.
-
getReturnType
- Returns:
- the return type of this expression. By default, this is defined on registration, but, like Expression.isSingle(), can be overriden.
-
toString
-
toString
Description copied from class:TaggedExpressionReturns the value of this string after applying the tags according to the given tag context.- Specified by:
toStringin classTaggedExpression- Parameters:
ctx- the eventtagCtx- the tag context- Returns:
- the applied string
-
toString
- Parameters:
ctx- the eventdebug- whether to show additional information or not- Returns:
- a
Stringthat should aim to resemble what is written in the script as closely as possible
-
isSimple
public boolean isSimple()- Returns:
- whether this VariableString is actually constant and whose value can be known at parse time
-
defaultVariableName
-