Class Token
- java.lang.Object
-
- com.gurock.smartinspect.Token
-
public abstract class Token extends Object
Represents a token in the pattern string of the TextProtocol protocol.This is the abstract base class for all available tokens. Derived classes are not documented for clarity reasons. To create a suitable token object for a given token string, you can use the TokenFactory class.
Note: This class is not guaranteed to be threadsafe.
-
-
Constructor Summary
Constructors Constructor Description Token()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Stringexpand(LogEntry logEntry)Creates a string representation of a variable or literal token.booleangetIndent()Indicates if this token supports indenting.StringgetOptions()Returns the optional options string for this token.StringgetValue()Returns the raw string value of the parsed pattern string for this token.intgetWidth()Returns the minimum width of this token.voidsetOptions(String options)Sets the optional options string for this token.voidsetValue(String value)Sets the raw string value of the parsed pattern string for this token.voidsetWidth(int width)Sets the minimum width of this token.
-
-
-
Method Detail
-
expand
public abstract String expand(LogEntry logEntry)
Creates a string representation of a variable or literal token. With the help of the supplied LogEntry, this token is expanded into a string. For example, if this token represents the %session% variable of a pattern string, this method simply returns the session name of the supplied LogEntry.For a literal token, the supplied LogEntry argument is ignored and the value property is returned.
- Parameters:
logEntry- The LogEntry to use to create the string representation- Returns:
- The text representation of this token for the supplied LogEntry object
-
getValue
public String getValue()
Returns the raw string value of the parsed pattern string for this token.This method returns the raw string of this token as found in the parsed pattern string. For a variable, this property is set to the variable name surrounded with '%' characters and an optional options string like this: %name{options}%. For a literal, this property can have any value.
- Returns:
- The raw string value of the parsed pattern string for this token
-
setValue
public void setValue(String value)
Sets the raw string value of the parsed pattern string for this token.This method sets the raw string of this token as found in the parsed pattern string. For a variable, this property is set to the variable name surrounded with '%' characters and an optional options string like this: %name{options}%. For a literal, this property can have any value.
- Parameters:
value- The new value of this token
-
getOptions
public String getOptions()
Returns the optional options string for this token.A variable token can have an optional options string. In the raw string representation of a token, an options string can be specified in curly brackets after the variable name like this: %name{options}%. For a literal, this property is always set to an empty string.
- Returns:
- The optional options string for this token
-
setOptions
public void setOptions(String options)
Sets the optional options string for this token.A variable token can have an optional options string. In the raw string representation of a token, an options string can be specified in curly braces after the variable name like this: %name{options}%. For a literal, this property is always set to an empty string.
- Parameters:
options- The new options for this token
-
getIndent
public boolean getIndent()
Indicates if this token supports indenting.This method always returns false unless this token represents the title token of a pattern string. This method is used in the PatternParser.expand() method to determine if a token allows indenting.
- Returns:
- True if this token supports indenting and false otherwise
-
setWidth
public void setWidth(int width)
Sets the minimum width of this token. A variable token can have an optional width modifier. In the raw string representation of a token, a width modifier can be specified after the variable name like this: %name,width%. Width must be a valid positive or negative integer.If the width is greater than 0, formatted values will be right-aligned. If the width is less than 0, they will be left-aligned.
For a literal, this property is always set to 0.
- Parameters:
width- The new minimum width of this token
-
getWidth
public int getWidth()
Returns the minimum width of this token.A variable token can have an optional width modifier. In the raw string representation of a token, a width modifier can be specified after the variable name like this: %name,width%. Width must be a valid positive or negative integer.
If the width is greater than 0, formatted values will be right-aligned. If the width is less than 0, they will be left-aligned.
For a literal, this property is always set to 0.
- Returns:
- The minimum width of this token
-
-