KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > settings > examples > JavaCompilerSetting


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.settings.examples;
21
22 import java.util.Properties JavaDoc;
23
24 /**
25  *
26  * @author Jan Pokorsky
27  */

28 public final class JavaCompilerSetting {
29     private final static String JavaDoc PROP_DEBUG = "debug"; //NOI18N
30
private final static String JavaDoc PROP_DEPRECATION = "deprecation"; //NOI18N
31
private final static String JavaDoc PROP_CLASS_PATH = "classPath"; //NOI18N
32
private final static String JavaDoc PROP_EXEC_PATH = "path"; //NOI18N
33

34
35     private java.beans.PropertyChangeSupport JavaDoc propertyChangeSupport = new java.beans.PropertyChangeSupport JavaDoc(this);
36     
37     private boolean debug;
38     private boolean deprecation;
39     private String JavaDoc classpath = ""; //NOI18N
40
private String JavaDoc path = ""; //NOI18N
41

42     public JavaCompilerSetting() {
43     }
44     
45     /** Adds a PropertyChangeListener to the listener list.
46      * @param l The listener to add.
47      */

48     public void addPropertyChangeListener(java.beans.PropertyChangeListener JavaDoc l) {
49         propertyChangeSupport.addPropertyChangeListener(l);
50     }
51     
52     /** Removes a PropertyChangeListener from the listener list.
53      * @param l The listener to remove.
54      */

55     public void removePropertyChangeListener(java.beans.PropertyChangeListener JavaDoc l) {
56         propertyChangeSupport.removePropertyChangeListener(l);
57     }
58     
59     private void readProperties(Properties JavaDoc p) {
60         this.classpath = p.getProperty(PROP_CLASS_PATH);
61         this.path = p.getProperty(PROP_EXEC_PATH);
62         String JavaDoc bool = p.getProperty(PROP_DEBUG);
63         if (bool != null)
64             this.debug = Boolean.valueOf(bool).booleanValue();
65         else
66             this.debug = false;
67                 
68         bool = p.getProperty(PROP_DEPRECATION);
69         if (bool != null)
70             this.deprecation = Boolean.valueOf(bool).booleanValue();
71         else
72             this.deprecation = false;
73     }
74     
75     private void writeProperties(Properties JavaDoc p) {
76         p.setProperty(PROP_CLASS_PATH, getClasspath());
77         p.setProperty(PROP_EXEC_PATH, getPath());
78         p.setProperty(PROP_DEPRECATION, String.valueOf(isDeprecation()));
79         p.setProperty(PROP_DEBUG, String.valueOf(isDebug()));
80     }
81     
82     public boolean isDebug() {
83         return this.debug;
84     }
85     public void setDebug(boolean debug) {
86         boolean oldDebug = this.debug;
87         this.debug = debug;
88         propertyChangeSupport.firePropertyChange(PROP_DEBUG, oldDebug, debug);
89     }
90     public boolean isDeprecation() {
91         return this.deprecation;
92     }
93     public void setDeprecation(boolean deprecation) {
94         boolean oldDeprecation = this.deprecation;
95         this.deprecation = deprecation;
96         propertyChangeSupport.firePropertyChange(PROP_DEPRECATION, oldDeprecation, deprecation);
97     }
98     public String JavaDoc getClasspath() {
99         return this.classpath;
100     }
101     public void setClasspath(String JavaDoc classpath) {
102         String JavaDoc oldClasspath = this.classpath;
103         this.classpath = classpath;
104         propertyChangeSupport.firePropertyChange(PROP_CLASS_PATH, oldClasspath, classpath);
105     }
106     public String JavaDoc getPath() {
107         return this.path;
108     }
109     public void setPath(String JavaDoc path) {
110         String JavaDoc oldPath = this.path;
111         this.path = path;
112         propertyChangeSupport.firePropertyChange(PROP_EXEC_PATH, oldPath, path);
113     }
114     
115 }
116
Popular Tags