Skip to content

Method: getDescription()

1: package de.fhdw.wtf.common.exception.walker;
2:
3: import de.fhdw.wtf.common.ast.Attribute;
4: import de.fhdw.wtf.common.exception.editor.EditorMarkable;
5: import de.fhdw.wtf.common.exception.editor.EditorMarker;
6: import de.fhdw.wtf.common.token.Position;
7:
8: /**
9: * Will be thrown if the {@link de.fhdw.wtf.walker.tasks.DoubleAttributenameCheck} found twice attributes with the same
10: * name in a class and his inheritance-structur.
11: *
12: */
13: public final class DoubleAttributenameException extends TaskException implements EditorMarkable {
14:         
15:         /**
16:          * generated.
17:          */
18:         private static final long serialVersionUID = -6608366879366425685L;
19:         
20:         /**
21:          * One Attribute with the same name as another attribute.
22:          */
23:         private final Attribute attribute;
24:         
25:         /**
26:          * Constructor of {@link DoubleAttributenameException}.
27:          *
28:          * @param attribute
29:          * attribute
30:          */
31:         private DoubleAttributenameException(final Attribute attribute) {
32:                 super(de.fhdw.wtf.common.constants.walker.ExceptionConstants.DOUBLE_ATTRIBUTENAME_MESSAGE + attribute.getName());
33:                 this.attribute = attribute;
34:         }
35:         
36:         /**
37:          * Creates a {@link DoubleAttributenameException}-Object.
38:          *
39:          * @param a
40:          * attribute
41:          * @return The {@link DoubleAttributenameException}-Object.
42:          */
43:         public static DoubleAttributenameException create(final Attribute a) {
44:                 return new DoubleAttributenameException(a);
45:         }
46:         
47:         @Override
48:         public Position getStartPosition() {
49:                 return this.attribute.getFirstToken().getPosition();
50:         }
51:         
52:         @Override
53:         public String getDescription() {
54:                 return this.getMessage();
55:         }
56:         
57:         @Override
58:         public Position getEndPos() {
59:                 return this.attribute.getLastToken().getPosition();
60:         }
61:         
62:         @Override
63:         public EditorMarker getMarker() {
64:                 return EditorMarker.DOUBLE_ATTRIBUTENAME_MARKER;
65:         }
66:         
67: }