1 11 12 package org.eclipse.jdt.core.dom; 13 14 import java.util.ArrayList ; 15 import java.util.List ; 16 17 import org.eclipse.jdt.internal.compiler.util.Util; 18 19 29 public final class TextElement extends ASTNode implements IDocElement { 30 31 36 public static final SimplePropertyDescriptor TEXT_PROPERTY = 37 new SimplePropertyDescriptor(TextElement.class, "text", String .class, MANDATORY); 39 45 private static final List PROPERTY_DESCRIPTORS; 46 47 static { 48 List propertyList = new ArrayList (2); 49 createPropertyList(TextElement.class, propertyList); 50 addProperty(TEXT_PROPERTY, propertyList); 51 PROPERTY_DESCRIPTORS = reapPropertyList(propertyList); 52 } 53 54 64 public static List propertyDescriptors(int apiLevel) { 65 return PROPERTY_DESCRIPTORS; 66 } 67 68 71 private String text = Util.EMPTY_STRING; 72 73 84 TextElement(AST ast) { 85 super(ast); 86 } 87 88 91 final List internalStructuralPropertiesForType(int apiLevel) { 92 return propertyDescriptors(apiLevel); 93 } 94 95 98 final Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) { 99 if (property == TEXT_PROPERTY) { 100 if (get) { 101 return getText(); 102 } else { 103 setText((String ) value); 104 return null; 105 } 106 } 107 return super.internalGetSetObjectProperty(property, get, value); 109 } 110 111 114 final int getNodeType0() { 115 return TEXT_ELEMENT; 116 } 117 118 121 ASTNode clone0(AST target) { 122 TextElement result = new TextElement(target); 123 result.setSourceRange(this.getStartPosition(), this.getLength()); 124 result.setText(getText()); 125 return result; 126 } 127 128 131 final boolean subtreeMatch0(ASTMatcher matcher, Object other) { 132 return matcher.match(this, other); 134 } 135 136 139 void accept0(ASTVisitor visitor) { 140 visitor.visit(this); 141 visitor.endVisit(this); 142 } 143 144 149 public String getText() { 150 return this.text; 151 } 152 153 166 public void setText(String text) { 167 if (text == null) { 168 throw new IllegalArgumentException (); 169 } 170 if (text.indexOf("*/") > 0) { throw new IllegalArgumentException (); 172 } 173 preValueChange(TEXT_PROPERTY); 174 this.text = text; 175 postValueChange(TEXT_PROPERTY); 176 } 177 178 181 int memSize() { 182 int size = BASE_NODE_SIZE + 1 * 4; 183 if (this.text != Util.EMPTY_STRING) { 184 size += stringSize(this.text); 186 } 187 return size; 188 } 189 190 193 int treeSize() { 194 return memSize(); 195 } 196 } 197 198 | Popular Tags |