1 19 20 package org.netbeans.modules.settings.examples; 21 22 import java.util.Properties ; 23 24 28 public final class ProxySettings { 29 private final static String PROP_PROXYHOST = "proxyHost"; private final static String PROP_PROXYPORT = "proxyPort"; 32 33 private String proxyHost; 34 35 36 private java.beans.PropertyChangeSupport propertyChangeSupport = new java.beans.PropertyChangeSupport (this); 37 38 39 private int proxyPort; 40 41 42 public ProxySettings() { 43 } 44 45 48 public void addPropertyChangeListener(java.beans.PropertyChangeListener l) { 49 propertyChangeSupport.addPropertyChangeListener(l); 50 } 51 52 55 public void removePropertyChangeListener(java.beans.PropertyChangeListener l) { 56 propertyChangeSupport.removePropertyChangeListener(l); 57 } 58 59 62 public String getProxyHost() { 63 return (proxyHost == null)? "default": proxyHost; 64 } 65 66 69 public void setProxyHost(String proxyHost) { 70 String oldProxyHost = this.proxyHost; 71 this.proxyHost = proxyHost; 72 propertyChangeSupport.firePropertyChange(PROP_PROXYHOST, oldProxyHost, proxyHost); } 74 75 78 public int getProxyPort() { 79 return this.proxyPort; 80 } 81 82 85 public void setProxyPort(int proxyPort) { 86 int oldProxyPort = this.proxyPort; 87 this.proxyPort = proxyPort; 88 propertyChangeSupport.firePropertyChange(PROP_PROXYPORT, new Integer (oldProxyPort), new Integer (proxyPort)); 89 } 90 91 private void readProperties(Properties p) { 92 this.proxyHost = p.getProperty(PROP_PROXYHOST); try { 94 this.proxyPort = Integer.parseInt(p.getProperty(PROP_PROXYPORT)); 95 } catch (NumberFormatException ex) { 96 this.proxyPort = 0; 97 } 98 } 99 100 private void writeProperties(Properties p) { 101 p.setProperty(PROP_PROXYHOST, proxyHost); 102 p.setProperty(PROP_PROXYPORT, String.valueOf(proxyPort)); 103 } 104 } 105 | Popular Tags |