Skip to content

Method: getTokenString()

1: package de.fhdw.wtf.common.token;
2:
3: /**
4: * A multi char token represents a scanned part of the input grammar. Each token-type defines a regular sequence of
5: * characters belonging to its type.
6: *
7: * This type is the interface describing variable tokens.
8: */
9: public abstract class MultiCharToken extends Token {
10:         
11:         /**
12:          * generated.
13:          */
14:         private static final long serialVersionUID = -7790580991639162261L;
15:         
16:         /**
17:          * String-Represantation of the Token.
18:          *
19:          */
20:         private final String tokenString;
21:         
22:         /**
23:          * Constructor initializing the position of this token.
24:          *
25:          * @param tokenString
26:          * initial token String
27:          * @param position
28:          * begin position of this token
29:          */
30:         protected MultiCharToken(final String tokenString, final Position position) {
31:                 super(position);
32:                 this.tokenString = tokenString;
33:         }
34:         
35:         @Override
36:         public int getLength() {
37:                 return this.getTokenString().length();
38:         }
39:         
40:         /**
41:          * Getter for the token string.
42:          *
43:          * @return token string
44:          */
45:         public String getTokenString() {
46:                 return this.tokenString;
47:         }
48:         
49:         @Override
50:         public String stringRepresentation() {
51:                 return this.getTokenString();
52:         }
53: }