KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > autoupdate > ModuleGroup


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.autoupdate;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collection JavaDoc;
24
25 import org.w3c.dom.*;
26
27 /** Represents a group of modules.
28  *
29  * @author Petr Hrebejk
30  */

31 class ModuleGroup extends Object JavaDoc
32     implements org.openide.nodes.Node.Cookie {
33
34     private static final String JavaDoc ATTR_NAME = "name"; // NOI18N
35

36     /** Holds the DOM node for this group */
37     private Node node;
38
39     /** Holds value of property name. */
40     private String JavaDoc name;
41
42     /** Holds value of property items. */
43     private Collection JavaDoc items;
44
45     /** Creates new ModuleGroup */
46     public ModuleGroup( ) {
47         this( null );
48     }
49
50     /** Creates new ModuleGroup */
51     public ModuleGroup( Node node ) {
52         items = new ArrayList JavaDoc( 11 );
53         if ( node != null ) {
54             this.node = node;
55             setName( getAttribute( ATTR_NAME ) );
56         }
57     }
58
59     /** Adds a ModuleGroup into group items
60      */

61     void addItem( ModuleGroup group ) {
62         items.add( group );
63     }
64
65     /** Adds a ModuleUpdate into group items
66      */

67     void addItem( ModuleUpdate update ) {
68         items.add( update );
69     }
70
71     // GETTERS AND SETTERS ------------------------------------------------------
72

73     /** Getter for property name.
74      *@return Value of property name.
75      */

76     public String JavaDoc getName() {
77         return name;
78     }
79
80     /** Setter for property name.
81      *@param name New value of property name.
82      */

83     public void setName(String JavaDoc name) {
84         this.name = name;
85     }
86
87     /** Getter for property items.
88      *@return Value of property items.
89      */

90     public Collection JavaDoc getItems() {
91         return items;
92     }
93
94     // UTILITY METHODS ----------------------------------------------------------
95

96     /** Utility method gets the atribute of node
97      *@param attribute Name of the desired attribute
98      */

99     private String JavaDoc getAttribute( String JavaDoc attribute ) {
100         Node attr = node.getAttributes().getNamedItem( attribute );
101         return attr == null ? null : attr.getNodeValue();
102     }
103
104 }
105
Popular Tags