|
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-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javacore.jmiimpl.javamodel; import java.util.List; import org.netbeans.jmi.javamodel.Attribute; import org.netbeans.jmi.javamodel.AttributeValue; import org.netbeans.jmi.javamodel.InitialValue; import org.netbeans.lib.java.parser.ASTree; import org.netbeans.mdr.storagemodel.StorableObject; /** * * @author Pavel Flaska */ public abstract class AttributeValueImpl extends TransientElement implements AttributeValue { String name; String attributeValueText; protected InitialValue attributeValue; /** Creates a new instance of AnnotationValueImpl */ public AttributeValueImpl(StorableObject o) { super(o); } public InitialValue getValue() { if (!childrenInited) { initChildren(); } return attributeValue; } public void setValue(InitialValue newValue) { throw new UnsupportedOperationException("setValue()"); // NOI18N } public void setName(String name) { if (name == null) throw new NullPointerException(); objectChanged(CHANGED_NAME); this.name = name; } public String getName() { return name; } public Attribute getDefinition() { throw new UnsupportedOperationException("getDefinition()"); // NOI18N } public void setDefinition(Attribute newValue) { throw new UnsupportedOperationException("setDefinition()"); // NOI18N } //////////////////////////////////////////////////////////////////////////// public String getSourceText() { String origElem; if ((origElem = checkChange()) != null) return origElem; StringBuffer buf = new StringBuffer(); String name = getName(); if (name != null && name.length() > 0) { buf.append(name); buf.append(formatElementPart(FIELD_EQUALS)); } buf.append(((MetadataElement) getValue()).getSourceText()); return buf.toString(); } public void getDiff(List diff) { throw new UnsupportedOperationException("getDiff()"); // NOI18N } void setData(String name, InitialValue attributeValue, String attributeValueText) { this.name = name; changeChild(null, attributeValue); this.attributeValue = attributeValue; this.attributeValueText = attributeValueText; } protected void initChildren() { childrenInited = false; ASTree tree = getASTree(); if (tree != null) { attributeValue = (InitialValue) initOrCreate(attributeValue, extractAttributeValue()); } childrenInited = true; } private ASTree extractAttributeValue() { return getASTree().getSubTrees()[1]; } } |
... 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.