|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javacore.jmiimpl.javamodel; import java.util.List; import javax.jmi.reflect.ConstraintViolationException; import org.netbeans.jmi.javamodel.CharLiteral; import org.netbeans.jmi.javamodel.JavaModelPackage; import org.netbeans.jmi.javamodel.PrimitiveTypeKindEnum; import org.netbeans.lib.java.parser.Token; import org.netbeans.mdr.storagemodel.StorableObject; /** * * @author mm109185 */ public abstract class CharLiteralImpl extends LiteralImpl implements CharLiteral { private String value; public CharLiteralImpl(StorableObject o) { super(o); type = ((JavaModelPackage) refImmediatePackage()).getType().resolve(PrimitiveTypeKindEnum.CHAR.toString()); } public void setValue(String value) { objectChanged(CHANGED_VALUE); doValueChange(value); } public String getValue() { if (isChanged(CHANGED_VALUE)) { return value; } else { return "" + ((Token) getASTree()).getValue(); } } public String getSourceText() { String origElem; if ((origElem = checkChange()) != null) return origElem; return getText(); } public void getDiff(List diff) { replaceNode(diff, getParser(), getASTree(), getText(), 0, null); } private String getText() { return "'" + String.valueOf(getValue()) + '\''; // NOI18N } void setData(String value) { doValueChange(value); } private void doValueChange(String value) { if (value == null) { this.value = "\000"; // NOI18N } else { if (value.length() != 1) throw new ConstraintViolationException(null, null, "Must pass exactly one character."); // NOI18N this.value = value; } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.