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 java.util.ArrayList;
import java.util.List;
import org.netbeans.jmi.javamodel.JavaDoc;
import org.netbeans.lib.java.parser.Token;
import org.netbeans.mdr.storagemodel.StorableObject;
import org.netbeans.modules.javacore.parser.ASTProvider;
import org.openide.text.PositionBounds;

/**
 * Implementation of JavaDoc object instance interface.
 *
 * @author Vladimir Hudec
 */
public abstract class JavaDocImpl extends MetadataElement implements JavaDoc {

    protected String text = null;
    protected List tags = null;

    private boolean isNew = false;
    protected boolean childrenInited = false;


    protected JavaDocImpl(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;
    }

    public List getChildren() {
        return new ArrayList(getTags());
    }
    
    public PositionBounds getPosition() {
        testResourceChange();
        FeatureImpl feature=(FeatureImpl)refImmediateComposite();        
        ASTProvider p=feature.getParser();
        Token javadocToken=p.getComment(feature.getASTree());

        return p.createBounds(javadocToken.getStartOffset(), javadocToken.getEndOffset());
    }
    
    /**
     * Returns the value of attribute text.
     * @return Value of attribute text.
     */
    public String getText() {
        return text;
    }

    /**
     * Sets the value of text attribute. See {@link #getText} for description
     * on the attribute.
     * @param newValue New value to be set.
     */
    public void setText(String newValue) {
        objectChanged(CHANGED_JAVADOC);
        this.text = newValue;
    }

    /**
     * Returns the value of attribute tags.
     * @return Value of tags attribute.
     */
    public List getTags() {
        return tags;
    }

    void setData(String text, List tags) {
        this.text = text;
        this.tags = createChildrenList("tags", tags, CHANGED_JAVADOC); // NOI18N
    }

    protected java.lang.Object getInternalForm() {
        return text;
    }

    /** Part ot the rollback mechanism.
     *
     * In the case of any rollback, all classes should be rebuilt from ASTrees.
     * The layout for method is the next one:
     * protected void reset() {
     *   .. do your own job...
     *   super.reset()
     * }
     */
    protected final void rollback() {
        // TODO: implement me
    }
}
... 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.