1 19 20 package org.netbeans.modules.settings.convertors; 21 22 import java.util.Properties ; 23 24 28 public class FooSetting { 29 private final static String PROP_PROPERTY1 = "property1"; 30 private final static String PROP_NAME = "name"; 31 32 33 private String property1; 34 35 36 private String name = "defaultName"; 37 38 39 private java.beans.PropertyChangeSupport propertyChangeSupport = new java.beans.PropertyChangeSupport (this); 40 41 private int listenerCount = 0; 42 43 44 public FooSetting() { 45 } 46 public FooSetting(String txt) { 47 this.property1 = txt; 48 } 49 50 53 public void addPropertyChangeListener(java.beans.PropertyChangeListener l) { 54 propertyChangeSupport.addPropertyChangeListener(l); 55 listenerCount++; 56 } 57 58 61 public void removePropertyChangeListener(java.beans.PropertyChangeListener l) { 62 propertyChangeSupport.removePropertyChangeListener(l); 63 listenerCount--; 64 } 65 66 int getListenerCount() { 67 return listenerCount; 68 } 69 70 73 public String getProperty1() { 74 return this.property1; 75 } 76 77 80 public void setProperty1(String property1) { 81 String oldProperty1 = this.property1; 82 this.property1 = property1; 83 propertyChangeSupport.firePropertyChange(PROP_PROPERTY1, oldProperty1, property1); 84 } 85 86 89 public String getName() { 90 return this.name; 91 } 92 93 96 public void setName(String name) { 97 String oldName = this.name; 98 this.name = name; 99 propertyChangeSupport.firePropertyChange(PROP_NAME, oldName, name); 100 } 101 102 private void readProperties(Properties p) { 103 property1 = p.getProperty(PROP_PROPERTY1); 104 String _name = p.getProperty(PROP_NAME); 105 if (_name != null) name = _name; 106 } 107 108 private void writeProperties(Properties p) { 109 if (property1 != null) { 110 p.setProperty(PROP_PROPERTY1, property1); 111 } 112 if (name != null) { 113 p.setProperty(PROP_NAME, name); 114 } 115 } 116 117 public String toString() { 118 return this.getClass().getName() + '@' + 119 Integer.toHexString(System.identityHashCode(this)) + 120 '[' + property1 + ", " + name + ']'; 121 } 122 123 public boolean equals(Object obj) { 124 if (obj == null || !(obj instanceof FooSetting)) return false; 125 FooSetting foo = (FooSetting) obj; 126 if (property1 == null || foo.property1 == null) { 127 return property1 == foo.property1; 128 } 129 return property1.equals(foo.property1); 130 } 131 132 } 133 | Popular Tags |