|
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.*; import org.netbeans.jmi.javamodel.ArrayInitialization; import org.netbeans.jmi.javamodel.Element; import org.netbeans.lib.java.parser.ASTree; import org.netbeans.lib.java.parser.ASTreeTypes; import org.netbeans.lib.java.parser.Token; import org.netbeans.mdr.storagemodel.StorableObject; import org.netbeans.modules.javacore.parser.ASTProvider; /** * * @author Martin Matula */ public abstract class ArrayInitializationImpl extends TransientElement implements ArrayInitialization { private LightAttrList elementValues = null; /** Creates a new instance of ArrayInitializationImpl */ public ArrayInitializationImpl(StorableObject o) { super(o); } public List getElementValues() { if (!childrenInited) { initChildren(); } return elementValues; } public List getChildren() { return new ArrayList(getElementValues()); } protected void initChildren() { childrenInited = false; ASTree tree = getASTree(); if (tree != null) { ASTree[] parts = tree.getSubTrees(); elementValues = createChildrenList(elementValues, "elementValues", parts[0], ASTreeTypes.VARIABLE_INITIALIZERS, CHANGED_ELEMENT_VALUES, false); // NOI18N } childrenInited = true; } public String getSourceText() { String origElem; if ((origElem = checkChange()) != null) return origElem; StringBuffer buf = new StringBuffer(); List values = getElementValues(); formatElementPart(ARRAY_OPEN_CURLY, buf); Iterator iter = values.iterator(); while (iter.hasNext()) { TransientElement val = (TransientElement) iter.next(); buf.append(val.getSourceText()); if (iter.hasNext()) { formatElementPart(COMMA, buf); } } formatElementPart(ARRAY_CLOSE_CURLY, buf); return buf.toString(); } public void getDiff(List diff) { ASTProvider parser = getParser(); ASTree tree = getASTree(); ASTree[] children = tree.getSubTrees(); getCollectionDiff(diff, parser, CHANGED_ELEMENT_VALUES, children[0], ASTreeTypes.VARIABLE_INITIALIZERS, getElementValues(), parser.getToken(tree.getLastToken()).getStartOffset(), formatElementPart(COMMA)); } void setData(List elementValues) { this.elementValues = createChildrenList("elementValues", elementValues, CHANGED_ELEMENT_VALUES); // NOI18N } protected void _delete() { // --- delete components ------------------------------------------- if (childrenInited) { deleteChildren(elementValues); } // --- delete links ----------------------------------------------- // no links to delete // --- call super --------------------------------------- super._delete(); } public void replaceChild(Element oldElement,Element newElement) { if (childrenInited) { replaceObject(getElementValues(),oldElement,newElement); } } } |
... 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.