Skip to content

Method: stringRepresentation()

1: package de.fhdw.wtf.common.token;
2:
3: /**
4: * This token signalizes the end of a stream.
5: */
6: public class EndToken extends Token {
7:         
8:         /**
9:          * generated.
10:          */
11:         private static final long serialVersionUID = 3907661300211152274L;
12:         /**
13:          * Defines constant for hashCodeTemplate().
14:          */
15:         private static final int HASHCODE_TEMPLATE_CONSTANT = 36298324;
16:         
17:         /**
18:          * To-String of this class.
19:          */
20:         private static final String TOSTRING = "";
21:         
22:         /**
23:          * Private Constructor for EndToken. Use create(...)-Factory instead!
24:          *
25:          * @param position
26:          * start position of this token in the original input.
27:          */
28:         protected EndToken(final Position position) {
29:                 super(position);
30:         }
31:         
32:         /**
33:          * Factory for a {@link EndToken}.
34:          *
35:          * @param position
36:          * start position of this token in the original input.
37:          * @return a new instance of this token
38:          */
39:         public static EndToken create(final Position position) {
40:                 return new EndToken(position);
41:         }
42:         
43:         @Override
44:         public boolean isEndToken() {
45:                 return true;
46:         }
47:         
48:         @Override
49:         protected boolean equalsTemplate(final Token t) {
50:                 return t.isEndToken();
51:         }
52:         
53:         @Override
54:         protected int hashCodeTemplate() {
55:                 return HASHCODE_TEMPLATE_CONSTANT;
56:         }
57:         
58:         @Override
59:         public boolean equals(final Object o) {
60:                 if (o instanceof EndToken) {
61:                         return super.equals(o);
62:                 }
63:                 return false;
64:         }
65:         
66:         @Override
67:         public int hashCode() {
68:                 return super.hashCode();
69:         }
70:         
71:         @Override
72:         public String stringRepresentation() {
73:                 return TOSTRING;
74:         }
75:         
76:         @Override
77:         public int getLength() {
78:                 return 0;
79:         }
80:         
81: }