KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openide > filesystems > FileAttributeEvent


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 package org.openide.filesystems;
20
21
22 /** Event used to listen on filesystem attribute changes.
23 *
24 * @author Petr Hamernik
25 */

26 public class FileAttributeEvent extends FileEvent {
27     /** generated Serialized Version UID */
28     static final long serialVersionUID = -8601944809928093922L;
29
30     /** Name of attribute. */
31     private String JavaDoc name;
32
33     /** Old value of attribute */
34     private Object JavaDoc oldValue;
35
36     /** New value of attribute */
37     private Object JavaDoc newValue;
38
39     /** Creates new <code>FileAttributeEvent</code>. The <code>FileObject</code> where the action occurred
40     * is assumed to be the same as the source object.
41     * @param src source file which sent this event
42     * @param name name of attribute, or <code>null</code> (since 1.33 only) if any attributes may have changed
43     * @param oldValue old value of attribute, or <code>null</code> if the name is
44     * @param newValue new value of attribute, or <code>null</code> if the name is
45     */

46     public FileAttributeEvent(FileObject src, String JavaDoc name, Object JavaDoc oldValue, Object JavaDoc newValue) {
47         this(src, src, name, oldValue, newValue);
48     }
49
50     /** Creates new <code>FileAttributeEvent</code>.
51     * @param src source file which sent this event
52     * @param file file object where the action occurred
53     * @param name name of attribute, or <code>null</code> (since 1.33 only) if any attributes may have changed
54     * @param oldValue old value of attribute, or <code>null</code> if the name is
55     * @param newValue new value of attribute, or <code>null</code> if the name is
56     */

57     public FileAttributeEvent(FileObject src, FileObject file, String JavaDoc name, Object JavaDoc oldValue, Object JavaDoc newValue) {
58         this(src, file, name, oldValue, newValue, false);
59     }
60
61     /** Creates new <code>FileAttributeEvent</code>.
62     * @param src source file which sent this event
63     * @param file file object where the action occurred
64     * @param name name of attribute, or <code>null</code> (since 1.33 only) if any attributes may have changed
65     * @param oldValue old value of attribute, or <code>null</code> if the name is
66     * @param newValue new value of attribute, or <code>null</code> if the name is
67     * @param expected sets flag whether the value was expected
68     */

69     public FileAttributeEvent(
70         FileObject src, FileObject file, String JavaDoc name, Object JavaDoc oldValue, Object JavaDoc newValue, boolean expected
71     ) {
72         super(src, file, expected);
73         this.name = name;
74         this.oldValue = oldValue;
75         this.newValue = newValue;
76     }
77
78     /** Gets the name of the attribute.
79     * @return Name of the attribute, or <code>null</code> (since 1.33 only) if an unknown attribute changed
80     */

81     public String JavaDoc getName() {
82         return name;
83     }
84
85     /** Gets the old value of the attribute.
86     * @return Old value of the attribute, or <code>null</code> if the name is
87     */

88     public Object JavaDoc getOldValue() {
89         return oldValue;
90     }
91
92     /** Gets the new value of the attribute.
93     * @return New value of the attribute, or <code>null</code> if the name is
94     */

95     public Object JavaDoc getNewValue() {
96         return newValue;
97     }
98
99     @Override JavaDoc
100     void insertIntoToString(StringBuilder JavaDoc b) {
101         b.append(",name=");
102         b.append(name);
103         b.append(",oldValue=");
104         b.append(oldValue);
105         b.append(",newValue=");
106         b.append(newValue);
107     }
108
109 }
110
Popular Tags