1 19 package org.netbeans.modules.javacore.jmiimpl.javamodel; 20 21 import java.util.List ; 22 import org.netbeans.jmi.javamodel.Element; 23 import org.netbeans.jmi.javamodel.JavaModelPackage; 24 import org.netbeans.jmi.javamodel.StringLiteral; 25 import org.netbeans.lib.java.parser.Token; 26 import org.netbeans.mdr.storagemodel.StorableObject; 27 28 32 public abstract class StringLiteralImpl extends LiteralImpl implements StringLiteral { 33 private String value; 34 35 36 public StringLiteralImpl(StorableObject o) { 37 super(o); 38 type = ((JavaModelPackage) refImmediatePackage()).getType().resolve("java.lang.String"); } 40 41 public void setValue(String value) { 42 objectChanged(CHANGED_VALUE); 43 this.value = value; 44 } 45 46 public String getValue() { 47 if (isChanged(CHANGED_VALUE)) { 48 return value; 49 } else { 50 return (String ) ((Token) getASTree()).getValue(); 51 } 52 } 53 54 public String getSourceText() { 55 String origElem; 56 if ((origElem = checkChange()) != null) 57 return origElem; 58 return getText(); 59 } 60 61 private String getText() { 62 return '"' + getValue() + '"'; } 64 65 public void getDiff(List diff) { 66 replaceNode(diff, getParser(), getASTree(), getText(), 0, null); 67 } 68 69 void setData(String value) { 70 this.value = value; 71 } 72 73 public Element duplicate(JavaModelPackage targetExtent) { 74 return targetExtent.getStringLiteral().createStringLiteral(getValue()); 75 } 76 } 77 | Popular Tags |