⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 metadata.java

📁 java实现浏览器等本地桌面的功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }    /**     * Sets the meta-data's &quot;displayWidth&quot; property which provides     * a hint as to the number of characters typically required to display the value.     * The default is 24.     * @see #getDisplayWidth     * @param displayWidth integer containing the number of characters required to     *        display the value     * @throws IllegalArgumentException if displayWidth < 0     */    public void setDisplayWidth(int displayWidth) {        if (displayWidth < 0) {            throw new IllegalArgumentException("displayWidth must be >= 0");        }        int oldDisplayWidth = this.displayWidth;        this.displayWidth = displayWidth;        firePropertyChange("displayWidth", oldDisplayWidth, displayWidth);    }    /**     * Gets the meta-data's &quot;readOnly&quot; property which indicates     * whether or not the associated data field's value cannot be modified.     * The default is <code>false</code>.     * @see #setReadOnly     * @return boolean indicating whether the data field is read-only     */    public boolean isReadOnly() {        return readOnly;    }    /**     * Sets the meta-data's &quot;readOnly&quot; property.     * @see #isReadOnly     * @param readOnly boolean indicating whether the data field is read-only     */    public void setReadOnly(boolean readOnly) {        boolean oldReadOnly = this.readOnly;        this.readOnly = readOnly;        firePropertyChange("readOnly", oldReadOnly, readOnly);    }    /**     * Gets the meta-data's &quot;minValueCount&quot; property, which indicates     * the minimum number of values required for the data field.  The default     * is 0, which means a null value is permitted.  This property should be set     * to 1 if the field requires a non-null value.     * @see #setMinValueCount     * @return integer indicating the minimum number of values required for     *         the data field     */    public int getMinValueCount() {        return minValueCount;    }   /**    * Sets the meta-data's &quot;minValueCount&quot; property.    * @param minValueCount integer indicating the minimum number of values required for    *         the data field    */   public void setMinValueCount(int minValueCount) {       int oldMinValueCount = this.minValueCount;       this.minValueCount = minValueCount;       firePropertyChange("minValueCount", oldMinValueCount, minValueCount);   }   /**    * Convenience method for calculating whether the &quot;minValueCount&quot;    * property is greater than 0.    * @return boolean indicating whether at least one non-null value must    *         be set for the data field    */   public boolean isRequired() {       return getMinValueCount() > 0;   }   public void setRequired(boolean required) {       if (required) {           if (getMinValueCount() <= 0) {               setMinValueCount(1);           }       }       else { /* not required */           if (getMinValueCount() > 0) {               setMinValueCount(0);           }       }   }   /**    * Gets the meta-data's &quot;maxValueCount&quot; property, which indicates    * the maximum number of values permitted for the data field.  The default    * is 1, which means a single value is permitted.  If this property is set    * to a value greater than 1, then the values will be contained in a    * <code>List</code> collection.    * @see java.util.List    * @see #setMaxValueCount    * @return integer indicating the maximum number of values permitted for    *         the data field    */   public int getMaxValueCount() {       return maxValueCount;   }   /**    * Sets the meta-data's &quot;maxValueCount&quot; property.    * @param maxValueCount integer indicating the maximum number of values permitted for    *         the data field    */   public void setMaxValueCount(int maxValueCount) {       int oldMaxValueCount = this.maxValueCount;       this.maxValueCount = maxValueCount;       firePropertyChange("maxValueCount", oldMaxValueCount, maxValueCount);   }   /**    * Places a custom property into this meta-data's custom properties map.    *    * @param propertyName   A non-null string of the form    *                       com.mydomain.packagename.PropertyName    * @param value The value for the named property    */   public void setCustomProperty(String propertyName, Object value) {       if (propertyName == null) {           throw new NullPointerException("The propertyName for a custom property " +                                              "on MetaData cannot be null");       }       Object oldValue = customProps.get(propertyName);       customProps.put(propertyName, value);       firePropertyChange(propertyName, oldValue, value);   }   /**    * @param propertyName A non-null string of the form    *            com.mydomain.packagename.PropertyName    * @return The value for the given propertyName in the custom properties map.    */   public Object getCustomProperty(String propertyName) {       if (propertyName == null) {           throw new NullPointerException("The propertyName for a custom property " +                                              "on MetaData cannot be null");       }       return customProps.get(propertyName);   }   /**    * @param propertyName A non-null string of the form com.mydomain.packagename.PropertyName    * @param defaultValue The default value to return if the custom properties map    *            does not contain they specified propertyName    * @return The value at the given propertyName in the customProps map.    */   public Object getCustomProperty(String propertyName, Object defaultValue) {       if (propertyName == null) {           throw new NullPointerException("The propertyName for a custom property " +                                              "on MetaData cannot be null");       }       return customProps.containsKey(propertyName) ?           customProps.get(propertyName) : defaultValue;   }   /**    * Removes the custom property from the custom properties map.    * @param propertyName A non-null string of the form com.mydomain.packagename.PropertyName    */   public void removeCustomProperty(String propertyName) {       if (propertyName == null) {           throw new NullPointerException("The propertyName for a custom property " +                                              "on MetaData cannot be null");       }       Object oldValue = customProps.get(propertyName);       customProps.remove(propertyName);       firePropertyChange(propertyName, oldValue, null);   }   /**    *    * @return array containing the existing propertyNames in the custom properties map.    */   public String[] getCustomPropertyKeys() {       Object keys[] = customProps.keySet().toArray();       String propertyNames[] = new String[keys.length];       System.arraycopy(keys, 0, propertyNames, 0, keys.length);       return propertyNames;   }    /**     * Adds the specified validator for this meta-data.  A validator object is     * used to determine whether a particular object is a valid value for     * the associated data field.  A data field may have 0 or more validators.     * @see #removeValidator     * @see #getValidators     * @param validator Validator object which performs validation checks on     *        values being set on the associated data field     */    public void addValidator(Validator validator) {        if (validators == null) {            validators = new ArrayList();        }        validators.add(validator);    }    /**     * Removes the specified validator for this meta-data.     * @see #addValidator     * @param validator Validator object which performs validation checks on     *        values being set on the associated data field     */    public void removeValidator(Validator validator) {        if (validators != null) {            validators.remove(validator);            if (validators.size() == 0) {                validators = null;            }        }    }    /**     * @see #addValidator     * @return array containing 0 or more validators set on this meta-data     */    public Validator[] getValidators() {        if (validators != null) {            return (Validator[])validators.toArray(new Validator[1]);        }        return new Validator[0];    }    /**     * Adds the specified property change listener to this meta-data object.     * @param pcl PropertyChangeListener object to receive events when meta-data     *        properties change     */    public void addPropertyChangeListener(PropertyChangeListener pcl) {        if (pcs == null) {            pcs = new PropertyChangeSupport(this);        }        pcs.addPropertyChangeListener(pcl);    }    /**     * Removes the specified property change listener from this meta-data object.     * @param pcl PropertyChangeListener object to receive events when meta-data     *        properties change     */    public void removePropertyChangeListener(PropertyChangeListener pcl) {        if (pcs != null) {            pcs.removePropertyChangeListener(pcl);        }    }    /**     *     * @return array containing the PropertyChangeListener objects registered     *         on this meta-data object     */    public PropertyChangeListener[] getPropertyChangeListeners() {        if (pcs != null) {            return pcs.getPropertyChangeListeners();        }        return new PropertyChangeListener[0];    }    protected void firePropertyChange(String propertyName,                                      int oldValue, int newValue) {        if (newValue != oldValue) {            firePropertyChange(propertyName,                               new Integer(oldValue), new Integer(newValue));        }    }    protected void firePropertyChange(String propertyName,                                      boolean oldValue, boolean newValue) {        if (newValue != oldValue) {            firePropertyChange(propertyName,                               Boolean.valueOf(oldValue),                               Boolean.valueOf(newValue));        }    }    protected void firePropertyChange(String propertyName, Object oldValue,                                      Object newValue) {        if (pcs != null) {            pcs.firePropertyChange(propertyName, oldValue, newValue);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -