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