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-2000 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.netbeans.modules.autoupdate;

import java.util.ArrayList;
import java.util.Collection;

import org.w3c.dom.*;

/** Represents a group of modules.
 *
 * @author  Petr Hrebejk
 */
class ModuleGroup extends Object
    implements org.openide.nodes.Node.Cookie {

    private static final String ATTR_NAME = "name"; // NOI18N

    /** Holds the DOM node for this group */
    private Node node;

    /** Holds value of property name. */
    private String name;

    /** Holds value of property items. */
    private Collection items;

    /** Creates new ModuleGroup */
    public ModuleGroup( ) {
        this( null );
    }

    /** Creates new ModuleGroup */
    public ModuleGroup( Node node ) {
        items = new ArrayList( 11 );
        if ( node != null ) {
            this.node = node;
            setName( getAttribute( ATTR_NAME ) );
        }
    }

    /** Adds a ModuleGroup into group items
     */
    void addItem( ModuleGroup group ) {
        items.add( group );
    }

    /** Adds a ModuleUpdate into group items
     */
    void addItem( ModuleUpdate update ) {
        items.add( update );
    }

    // GETTERS AND SETTERS ------------------------------------------------------

    /** Getter for property name.
     *@return Value of property name.
     */
    public String getName() {
        return name;
    }

    /** Setter for property name.
     *@param name New value of property name.
     */
    public void setName(String name) {
        this.name = name;
    }

    /** Getter for property items.
     *@return Value of property items.
     */
    public Collection getItems() {
        return items;
    }

    // UTILITY METHODS ----------------------------------------------------------

    /** Utility method gets the atribute of node
     *@param attribute Name of the desired attribute
     */
    private String getAttribute( String attribute ) {
        Node attr = node.getAttributes().getNamedItem( attribute );
        return attr == null ? null : attr.getNodeValue();
    }

}
... 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.