|
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 org.netbeans.jmi.javamodel.ArrayReference; import org.netbeans.jmi.javamodel.MultipartId; import org.netbeans.jmi.javamodel.NamedElement; import org.netbeans.lib.java.parser.ASTree; import org.netbeans.mdr.storagemodel.StorableObject; import java.util.List; import org.netbeans.jmi.javamodel.ArrayReferenceClass; import org.netbeans.jmi.javamodel.Element; /** * * @author Martin Matula */ public abstract class ArrayReferenceImpl extends TypeReferenceImpl implements ArrayReference { private int dimCount; /** Creates a new instance of MultipartIdImpl */ public ArrayReferenceImpl(StorableObject o) { super(o); } protected ASTree getNameAST() { return getASTree(); } void setData(String name, MultipartId parent, int dimCount) { super.setData(name, parent); this.dimCount = dimCount; } public String getSourceText() { String origElem; if ((origElem = checkChange()) != null) return origElem; StringBuffer buf = new StringBuffer(); buf.append(((MetadataElement) getParent()).getSourceText()); appendDims(buf); return buf.toString(); } public void setDimCount(int dimCount) { objectChanged(CHANGED_DIM_COUNT); this.dimCount = dimCount; } public int getDimCount() { if (isChanged(CHANGED_DIM_COUNT)) { return dimCount; } else { ASTree dimsTree = getASTree().getSubTrees()[1]; return (dimsTree.getLastToken() - dimsTree.getFirstToken() + 1) / 2; } } private StringBuffer appendDims(StringBuffer buf) { for (int i = 0; i < getDimCount(); i++) { formatElementPart(ARRAY_OPEN_BRACKET, buf); formatElementPart(ARRAY_CLOSE_BRACKET, buf); } return buf; } public void getDiff(List diff) { ASTree tree = getASTree(); getChildDiff(diff, getParser(), tree.getSubTrees()[0], (MetadataElement) getParent(), CHANGED_PARENT); if (isChanged(CHANGED_DIM_COUNT)) { replaceNode(diff, getParser(), tree.getSubTrees()[1], appendDims(new StringBuffer()).toString(), 0, null); } } public NamedElement getElement() { return (NamedElement) getParser().getSemanticInfo(getASTree(), this); } /** * Creates copy of the ArrayReference instance */ public Element duplicate() { return ((ArrayReferenceClass) this.refClass()).createArrayReference( getName(), duplicateParent(), getDimCount() ); } } |
... 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.