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