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