KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > events > PathVariableChangeEvent


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.core.internal.events;
13
14 import java.util.EventObject JavaDoc;
15 import org.eclipse.core.resources.IPathVariableChangeEvent;
16 import org.eclipse.core.resources.IPathVariableManager;
17 import org.eclipse.core.runtime.IPath;
18
19 /**
20  * Describes a change in path variable. Core's default implementation for the
21  * <code>IPathVariableChangeEvent</code> interface.
22  */

23 public class PathVariableChangeEvent extends EventObject JavaDoc implements IPathVariableChangeEvent {
24     private static final long serialVersionUID = 1L;
25
26     /**
27      * The name of the changed variable.
28      */

29     private String JavaDoc variableName;
30
31     /**
32      * The value of the changed variable (may be null).
33      */

34     private IPath value;
35
36     /** The event type. */
37     private int type;
38
39     /**
40      * Constructor for this class.
41      */

42     public PathVariableChangeEvent(IPathVariableManager source, String JavaDoc variableName, IPath value, int type) {
43         super(source);
44         if (type < VARIABLE_CHANGED || type > VARIABLE_DELETED)
45             throw new IllegalArgumentException JavaDoc("Invalid event type: " + type); //$NON-NLS-1$
46
this.variableName = variableName;
47         this.value = value;
48         this.type = type;
49     }
50
51     /**
52      * @see org.eclipse.core.resources.IPathVariableChangeEvent#getValue()
53      */

54     public IPath getValue() {
55         return value;
56     }
57
58     /**
59      * @see org.eclipse.core.resources.IPathVariableChangeEvent#getVariableName()
60      */

61     public String JavaDoc getVariableName() {
62         return variableName;
63     }
64
65     /**
66      * @see org.eclipse.core.resources.IPathVariableChangeEvent#getType()
67      */

68     public int getType() {
69         return type;
70     }
71
72     /**
73      * Return a string representation of this object.
74      */

75     public String JavaDoc toString() {
76         String JavaDoc[] typeStrings = {"VARIABLE_CHANGED", "VARIABLE_CREATED", "VARIABLE_DELETED"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
77
StringBuffer JavaDoc sb = new StringBuffer JavaDoc(getClass().getName());
78         sb.append("[variable = "); //$NON-NLS-1$
79
sb.append(variableName);
80         sb.append(", type = "); //$NON-NLS-1$
81
sb.append(typeStrings[type - 1]);
82         if (type != VARIABLE_DELETED) {
83             sb.append(", value = "); //$NON-NLS-1$
84
sb.append(value);
85         }
86         sb.append("]"); //$NON-NLS-1$
87
return sb.toString();
88     }
89
90 }
91
Popular Tags