alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

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 org.netbeans.jmi.javamodel.JavaModelPackage;
import org.netbeans.jmi.javamodel.TagDefinition;
import org.netbeans.jmi.javamodel.TagValue;
import org.netbeans.mdr.storagemodel.StorableObject;

/**
 * Implementation of TagValue object instance interface.
 *
 * @author Vladimir Hudec
 */
public abstract class TagValueImpl extends MetadataElement implements TagValue {
    
    protected String value = null;
    protected TagDefinition tagDefinition = null;
    
    private boolean isNew = false;
    protected boolean childrenInited = false;
    
    
    protected TagValueImpl(StorableObject s) {
        super(s);
    }
    
    protected final boolean isInitialized() {
        return isNew;
    }
    
    /** Overriding methods must call super.setNew() */
    protected void setNew() {
        setChanged();
        isNew = true;
        childrenInited = true;
    }
    
    protected final boolean isNew() {
        return isNew;
    }
 
    /**
     * Returns the value of attribute value.
     * @return Value of attribute value.
     */
    public String getValue() {
        return value;
    }
    
    /**
     * Sets the value of value attribute. See {@link #getValue} for description 
     * on the attribute.
     * @param newValue New value to be set.
     */
    public void setValue(String newValue) {
        objectChanged(CHANGED_JAVADOC);
        this.value = newValue;
    }
    
    /**
     * Returns the value of reference definition.
     * @return Value of reference definition.
     */
    public TagDefinition getDefinition() {
        return tagDefinition;
    }
    
    /**
     * Sets the value of reference definition. See {@link #getDefinition} for 
     * description on the reference.
     * @param newValue New value to be set.
     */
    public void setDefinition(TagDefinition newValue) {
        if (tagDefinition != null && newValue != null && tagDefinition.equals(newValue))
            return;

        IsValueForImpl isValueForImpl = (IsValueForImpl)(((JavaModelPackage) refImmediatePackage()).getIsValueFor());

        if (tagDefinition != null)
            isValueForImpl.remove(this, tagDefinition);
        if (newValue != null)
            isValueForImpl.add(this, newValue);
    }
    
    void setData(String name, String value) {
        if (name != null) {
            JavaModelPackage pkg = (JavaModelPackage) refImmediatePackage();
            TagDefinitionClassImpl tagDefinitionClass = (TagDefinitionClassImpl) pkg.getTagDefinition();
            setData(value, tagDefinitionClass.createTagDefinition(name));
        }
        else {
            setData(value, (TagDefinition)null);
        }
    }

    void setData(String value, TagDefinition tagDefinition) {
        this.value = value;
        this.tagDefinition = tagDefinition;
    }
    
    protected java.lang.Object getInternalForm() {
        return value;
    }
}
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.