Skip to content

Method: stringRepresentation()

1: package de.fhdw.wtf.common.token.symbols;
2:
3: import de.fhdw.wtf.common.token.Position;
4: import de.fhdw.wtf.common.token.Token;
5:
6: /**
7: * Represents the exclamation symbol '!' as a token.
8: */
9: public final class ExclamationToken extends SymbolToken {
10:         
11:         /**
12:          * Defines constant for hashCodeTemplate().
13:          */
14:         private static final int HASHCODE_TEMPLATE_CONSTANT = 9836623;
15:         
16:         /**
17:          * Creates a new ExclamationToken at the given position.
18:          *
19:          * @param position
20:          * represents the start position of the symbol '!' in the original input
21:          */
22:         private ExclamationToken(final Position position) {
23:                 super(position, SymbolConstants.EXCLAMATION);
24:         }
25:         
26:         /**
27:          * Creates a new ExclamationToken at the given position.
28:          *
29:          * @param position
30:          * represents the start position of the symbol '!' in the original input
31:          * @return a new instance of this {@link SymbolToken}
32:          */
33:         public static ExclamationToken create(final Position position) {
34:                 return new ExclamationToken(position);
35:         }
36:         
37:         @Override
38:         public boolean isExclamationToken() {
39:                 return true;
40:         }
41:         
42:         @Override
43:         protected boolean equalsTemplate(final Token t) {
44:                 return t.isExclamationToken();
45:         }
46:         
47:         @Override
48:         public String stringRepresentation() {
49:                 return SymbolConstants.EXCLAMATION;
50:         }
51:         
52:         @Override
53:         protected int hashCodeTemplate() {
54:                 return HASHCODE_TEMPLATE_CONSTANT;
55:         }
56: }