Skip to content

Method: isCommentToken()

1: package de.fhdw.wtf.common.token;
2:
3: /**
4: * This token contains a whole comment in the original formatting.
5: *
6: */
7: public final class CommentTextToken extends MultiCharToken {
8:         
9:         /**
10:          * generated.
11:          */
12:         private static final long serialVersionUID = 6189611405583012863L;
13:         
14:         /**
15:          * Private Constructor for CommentTextToken. Use create(...)-Factory instead!
16:          *
17:          * @param commentText
18:          * initial comment text
19:          * @param position
20:          * start position of this comment in the original input
21:          */
22:         private CommentTextToken(final String commentText, final Position position) {
23:                 super(commentText, position);
24:         }
25:         
26:         /**
27:          * Factory for a {@link CommentTextToken}.
28:          *
29:          * @param commentText
30:          * initial comment text
31:          * @param position
32:          * start position of this comment in the original input
33:          * @return a new instance of this token
34:          */
35:         public static CommentTextToken create(final String commentText, final Position position) {
36:                 return new CommentTextToken(commentText, position);
37:         }
38:         
39:         @Override
40:         public boolean isCommentToken() {
41:                 return true;
42:         }
43:         
44:         /**
45:          * Getter for the whole comment.
46:          *
47:          * @return comment string
48:          */
49:         public String getCommentText() {
50:                 return this.getTokenString();
51:         }
52:         
53:         @Override
54:         protected boolean equalsTemplate(final Token t) {
55:                 if (t.isCommentToken()) {
56:                         final CommentTextToken ct = (CommentTextToken) t;
57:                         return this.getCommentText().equals(ct.getCommentText());
58:                 }
59:                 return false;
60:         }
61:         
62:         @Override
63:         protected int hashCodeTemplate() {
64:                 return this.getCommentText().hashCode();
65:         }
66:         
67: }