1 /*
2 * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
68 * MutableTreeNodes implementations. Especially with some of the enumerations
69 * that are provided, using some of these methods assumes the
70 * DefaultMutableTreeNode contains only DefaultMutableNode instances. All
71 * of the TreeNode/MutableTreeNode methods will behave as defined no
72 * matter what implementations are added.
73 *
74 * <p>
75 * <strong>Warning:</strong>
76 * Serialized objects of this class will not be compatible with
77 * future Swing releases. The current serialization support is
78 * appropriate for short term storage or RMI between applications running
79 * the same version of Swing. As of 1.4, support for long term storage
80 * of all JavaBeans™
81 * has been added to the <code>java.beans</code> package.
82 * Please see {@link java.beans.XMLEncoder}.
83 *
84 * @see MutableTreeNode
85 *
86 * @author Rob Davis
87 */
88 public class DefaultMutableTreeNode implements Cloneable,
89 MutableTreeNode, Serializable
90 {
91 private static final long serialVersionUID = -4298474751201349152L;
92
93 /**
94 * An enumeration that is always empty. This is used when an enumeration
95 * of a leaf node's children is requested.
96 */
97 static public final Enumeration<TreeNode> EMPTY_ENUMERATION
98 = Collections.emptyEnumeration();
99
100 /** this node's parent, or null if this node has no parent */
101 protected MutableTreeNode parent;
102
103 /** array of children, may be null if this node has no children */
104 protected Vector children;
105
106 /** optional user object */
107 transient protected Object userObject;
|
1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
68 * MutableTreeNodes implementations. Especially with some of the enumerations
69 * that are provided, using some of these methods assumes the
70 * DefaultMutableTreeNode contains only DefaultMutableNode instances. All
71 * of the TreeNode/MutableTreeNode methods will behave as defined no
72 * matter what implementations are added.
73 *
74 * <p>
75 * <strong>Warning:</strong>
76 * Serialized objects of this class will not be compatible with
77 * future Swing releases. The current serialization support is
78 * appropriate for short term storage or RMI between applications running
79 * the same version of Swing. As of 1.4, support for long term storage
80 * of all JavaBeans™
81 * has been added to the <code>java.beans</code> package.
82 * Please see {@link java.beans.XMLEncoder}.
83 *
84 * @see MutableTreeNode
85 *
86 * @author Rob Davis
87 */
88 @SuppressWarnings("serial") // Same-version serialization only
89 public class DefaultMutableTreeNode implements Cloneable,
90 MutableTreeNode, Serializable
91 {
92 private static final long serialVersionUID = -4298474751201349152L;
93
94 /**
95 * An enumeration that is always empty. This is used when an enumeration
96 * of a leaf node's children is requested.
97 */
98 static public final Enumeration<TreeNode> EMPTY_ENUMERATION
99 = Collections.emptyEnumeration();
100
101 /** this node's parent, or null if this node has no parent */
102 protected MutableTreeNode parent;
103
104 /** array of children, may be null if this node has no children */
105 protected Vector children;
106
107 /** optional user object */
108 transient protected Object userObject;
|