|
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.ArrayList; import java.util.List; import org.netbeans.jmi.javamodel.*; import org.netbeans.lib.java.parser.ASTree; import org.netbeans.lib.java.parser.ParserTokens; import org.netbeans.mdr.storagemodel.StorableObject; import org.netbeans.modules.javacore.parser.ASTProvider; /** * @author Martin Matula */ public abstract class WildCardImpl extends TransientElement implements WildCard { private boolean isLower; private MultipartId boundName; private JavaClass bound; public WildCardImpl(StorableObject o) { super(o); } public boolean isLower() { if (isChanged(CHANGED_IS_LOWER)) { return isLower; } else { ASTree lower = getASTree().getSubTrees()[0]; return lower == null || lower.getType() == ParserTokens.EXTENDS; } } public void setLower(boolean newValue) { objectChanged(CHANGED_IS_LOWER); isLower = newValue; } public MultipartId getBoundName() { if (!childrenInited) { initChildren(); } return boundName; } public void setBoundName(MultipartId newValue) { objectChanged(CHANGED_BOUND); changeChild(getBoundName(), newValue); this.boundName = newValue; this.bound = null; } public JavaClass getBound() { if (bound == null || !isChanged(CHANGED_BOUND)) { return (JavaClass) getBoundName().getElement(); } else { return bound; } } public void setBound(JavaClass newValue) { bound = newValue; MultipartIdClass proxy = ((JavaModelPackage) refImmediatePackage()).getMultipartId(); setBoundName(proxy.createMultipartId(newValue.getName(), null, null)); } public List getChildren() { List list = new ArrayList(1); addIfNotNull(list, getBoundName()); return list; } protected void initChildren() { childrenInited = false; ASTree tree = getASTree(); ASTree[] children = getASTree().getSubTrees(); if (tree != null) { boundName = (MultipartId) initOrCreate(boundName, children[1]); } childrenInited = true; } public String getSourceText() { String origElem; if ((origElem = checkChange()) != null) return origElem; StringBuffer buf = new StringBuffer(); buf.append('?'); MultipartIdImpl boundName = (MultipartIdImpl) getBoundName(); if (boundName != null) { buf.append(isLower() ? " extends " : " super "); // NOI18N buf.append(boundName.getSourceText()); } return buf.toString(); } public void getDiff(List diff) { ASTProvider parser = getParser(); ASTree tree = getASTree(); if (isChanged(CHANGED_IS_LOWER) || isChanged(CHANGED_BOUND)) { replaceNode(diff, parser, tree, getSourceText(), 0, null); } else if (isChanged(CHANGED_CHILDREN)) { ((MetadataElement) getBoundName()).getDiff(diff); } } void setData(boolean isLower, MultipartId boundName) { this.isLower = isLower; changeChild(null, boundName); this.boundName = boundName; } protected void _delete() { // --- delete components ------------------------------------------- if (childrenInited) { deleteChild(boundName); } // --- delete links ----------------------------------------------- // no links to delete // --- call super --------------------------------------- super._delete(); } public void replaceChild(Element oldElement,Element newElement){ if (childrenInited) { if (oldElement.equals(boundName)) { setBoundName((MultipartId) 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.