1 19 20 package org.netbeans.api.retouche.source; 21 22 24 33 public final class Comment { 34 private Style style; 35 private int pos; 36 private int endPos; 37 private int indent; 38 private String text; 39 40 43 public enum Style { 44 47 LINE, 48 49 52 BLOCK, 53 54 57 JAVADOC, 58 } 59 60 64 68 public static Comment create(Style style, int pos, int endPos, int indent, String text) { 69 return new Comment(style, pos, endPos, indent, text); 70 } 71 72 75 private Comment(Style style, int pos, int endPos, int indent, String text) { 76 this.style = style; 77 this.pos = pos; 78 this.endPos = endPos; 79 this.indent = indent; 80 this.text = text; 81 } 82 83 public Style style() { 84 return style; 85 } 86 87 91 public int pos() { 92 return pos; 93 } 94 95 99 public int endPos() { 100 return endPos; 101 } 102 103 107 public int indent() { 108 return indent; 109 } 110 111 112 public boolean isDocComment() { 113 return style == Style.JAVADOC; 114 } 115 116 119 public String getText() { 120 return text; 121 } 122 123 public String toString() { 128 StringBuilder sb = new StringBuilder (style.toString()); 129 sb.append(" pos="); 130 sb.append(pos); 131 sb.append(" endPos="); 132 sb.append(endPos); 133 sb.append(" indent="); 134 sb.append(indent); 135 sb.append(' '); 136 sb.append(text); 137 return sb.toString(); 138 } 139 140 public boolean equals(Object obj) { 141 if (!(obj instanceof Comment)) 142 return false; 143 Comment c = (Comment)obj; 144 return c.style == style && c.pos == pos && c.endPos == endPos && 145 c.indent == indent && c.text.equals(text); 146 } 147 148 public int hashCode() { 149 return style.hashCode() + pos + endPos + indent + text.hashCode(); 150 } 151 } 152 | Popular Tags |