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.FloatLiteral; 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 FloatLiteralImpl extends LiteralImpl implements FloatLiteral { 34 private float value; 35 36 37 public FloatLiteralImpl(StorableObject o) { 38 super(o); 39 type = ((JavaModelPackage) refImmediatePackage()).getType().resolve(PrimitiveTypeKindEnum.FLOAT.toString()); 40 } 41 42 public void setValue(float value) { 43 objectChanged(CHANGED_VALUE); 44 this.value = value; 45 } 46 47 public float getValue() { 48 if (isChanged(CHANGED_VALUE)) { 49 return value; 50 } else { 51 return ((Float ) ((Token) getASTree()).getValue()).floatValue(); 52 } 53 } 54 55 public String getSourceText() { 56 String origElem; 57 if ((origElem = checkChange()) != null) 58 return origElem; 59 return String.valueOf(getValue())+'f'; 60 } 61 62 public void getDiff(List diff) { 63 if (isChanged(CHANGED_VALUE)) { 64 replaceNode(diff, getParser(), getASTree(), String.valueOf(getValue())+'f', 0, null); 65 } 66 } 67 68 void setData(float value) { 69 this.value = value; 70 } 71 72 public Element duplicate(JavaModelPackage targetExtent) { 73 return targetExtent.getFloatLiteral().createFloatLiteral(getValue()); 74 } 75 } 76 | Popular Tags |