home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1CMM8C5 (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.8 KB  |  108 lines

  1. package java.beans;
  2.  
  3. import java.util.Enumeration;
  4. import java.util.Hashtable;
  5.  
  6. public class FeatureDescriptor {
  7.    private boolean expert;
  8.    private boolean hidden;
  9.    private String shortDescription;
  10.    private String name;
  11.    private String displayName;
  12.    private Hashtable table;
  13.  
  14.    public FeatureDescriptor() {
  15.    }
  16.  
  17.    FeatureDescriptor(FeatureDescriptor x, FeatureDescriptor y) {
  18.       this.expert = x.expert | y.expert;
  19.       this.hidden = x.hidden | y.hidden;
  20.       this.name = y.name;
  21.       this.shortDescription = x.shortDescription;
  22.       if (y.shortDescription != null) {
  23.          this.shortDescription = y.shortDescription;
  24.       }
  25.  
  26.       this.displayName = x.displayName;
  27.       if (y.displayName != null) {
  28.          this.displayName = y.displayName;
  29.       }
  30.  
  31.       this.addTable(x.table);
  32.       this.addTable(y.table);
  33.    }
  34.  
  35.    private void addTable(Hashtable t) {
  36.       if (t != null) {
  37.          Enumeration keys = t.keys();
  38.  
  39.          while(keys.hasMoreElements()) {
  40.             String key = (String)keys.nextElement();
  41.             Object value = t.get(key);
  42.             this.setValue(key, value);
  43.          }
  44.  
  45.       }
  46.    }
  47.  
  48.    public Enumeration attributeNames() {
  49.       if (this.table == null) {
  50.          this.table = new Hashtable();
  51.       }
  52.  
  53.       return this.table.keys();
  54.    }
  55.  
  56.    public String getDisplayName() {
  57.       return this.displayName == null ? this.getName() : this.displayName;
  58.    }
  59.  
  60.    public String getName() {
  61.       return this.name;
  62.    }
  63.  
  64.    public String getShortDescription() {
  65.       return this.shortDescription == null ? this.getDisplayName() : this.shortDescription;
  66.    }
  67.  
  68.    public Object getValue(String attributeName) {
  69.       return this.table == null ? null : this.table.get(attributeName);
  70.    }
  71.  
  72.    public boolean isExpert() {
  73.       return this.expert;
  74.    }
  75.  
  76.    public boolean isHidden() {
  77.       return this.hidden;
  78.    }
  79.  
  80.    public void setDisplayName(String displayName) {
  81.       this.displayName = displayName;
  82.    }
  83.  
  84.    public void setExpert(boolean expert) {
  85.       this.expert = expert;
  86.    }
  87.  
  88.    public void setHidden(boolean hidden) {
  89.       this.hidden = hidden;
  90.    }
  91.  
  92.    public void setName(String name) {
  93.       this.name = name;
  94.    }
  95.  
  96.    public void setShortDescription(String text) {
  97.       this.shortDescription = text;
  98.    }
  99.  
  100.    public void setValue(String attributeName, Object value) {
  101.       if (this.table == null) {
  102.          this.table = new Hashtable();
  103.       }
  104.  
  105.       this.table.put(attributeName, value);
  106.    }
  107. }
  108.