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

📄 modepropertyconfiguration.java

📁 AStar算法
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      file.move(newPath, false, monitor);  }    /**   * @return true if there are properties that need to be saved to a file.   */  public boolean isDirty(){    return isDirty;  }    private void setDirty(boolean isDirty){    this.isDirty = isDirty;    if (isDirty())      fireListeners();  }    /**   * Retrieves a value for the property of this name.   * This method first looks to userDefined values, then to VJP defined values   * (unless useVJP has been set to false), then finally to JPF defined.   * If none of these levels define the property, then a null value is returned.   *    * @return the value of the property   */  public String getPropertyValue(String name) {    if (userDefined.containsKey(name)) {      return userDefined.get(name);    } else if (vjpDefined.containsKey(name)){      return vjpDefined.get(name);    } else {      return jpfDefined.get(name);    }  }    /**   * @return true if the property specified is defined.   */  public boolean isDefined(String propertyName){    return userDefined.containsKey(propertyName) ||             vjpDefined.containsKey(propertyName) ||            jpfDefined.containsKey(propertyName);  }    /**   * @return true if the property specified is defined.   */  public boolean isDefined(Property prop){    return isDefined(prop.getName());  }    /**   * @return true if the property is user defined.   */  public boolean isUserDefined(String prop){    return userDefined.containsKey(prop);  }    /**   * Retrieves a {@link Property} object for the property of this name.   * This method first looks to userDefined values, then to VJP defined values   * (unless useVJP has been set to false), then finally to JPF defined.   * If none of these levels define the property, then a null value is returned.   *    * @return a property object that represents the key/value of the property   */  public Property getProperty(String propertyName) {    return new Property(propertyName, getPropertyValue(propertyName));  }    /**   * Sets the given property as a User defined property.   * @param name the name for the property being defined   * @param value the value for the property being defined   */  public void setProperty(String name, String value) {    setDirty(true);    userDefined.put(name, value);  }  /**   * Sets the given property as a User defined property.   * @param prop the property to set in this configuration   */  public void setProperty(Property prop) {    setProperty(prop.getName(), prop.getValue());  }  /**   * Sets the given property as a User defined property.   * @param prop the name of the property to be defined   * @param value the value of the propert being defined   */  public void setProperty(Property prop, String value) {    prop.setValue(value);    setProperty(prop);  }    /**   * Remove the user defined value of a setting and set it back to its    * default value   * @param prop the property to set back to its default value   */  public void setToDefaultValue(Property prop) {    setDirty(true);    removeProperty(prop.getName());    prop.setValue(getPropertyValue(prop.getName()));  }    /**   * Returns whether the property is using the default value or a user defined   * value. If the property is not defined in either JPF or VJP then a false   * value will be returned.   *    * @param propertyName the name of the property to be checked   * @return true if the property is using the default value   *         false if the property is using a custom user defined value.   */  public boolean isUsingDefaultValue(String propertyName) {    return !userDefined.containsKey(propertyName)            && isDefaultProperty(propertyName);  }    /**   * Returns whether the property is defined by either jpfDefaults or if in use   * VJP defaults.   * @return true if the property is defined as a default property   */  public boolean isDefaultProperty(String propertyName){    return vjpDefined.containsKey(propertyName) ||           jpfDefined.containsKey(propertyName);  }  /**   * Set the VJP default value for a property   *    * @param name the name of the property to be defined.   * @param value the value of the property to be defined.   */  public void setVJPDefault(String name, String value){    setDirty(true);    vjpDefined.put(name, value);  }    /**   * Removes this property from this configuration.   */  public void removeProperty(String propertyName){    setDirty(true);    userDefined.remove(propertyName);  }    /**   * Removes the property from the userdefined status.    * Note: only user defined properties can be removed.   * This is the same as settings it back to its default value.   *    * @param the property to be removed from this configuration   */  public void removeProperty(Property property) {   removeProperty(property.getName());  }  /**   * Returns an object array containing all of the properties listed by the JPF   * defaults and the VJP defaults. While only properties defined in either JPF   * or VJP are in this collection, values may come from the UserDefined level.   *    *  @returns all of the properties defined by this configuration, including   *           the defaults.   */  public Object[] getDefaultPropertiesAsArray() {    int size = userDefined.size() + vjpDefined.size() + jpfDefined.size();    ArrayList<Property> properties = new ArrayList<Property>(size);    //First add in the jpfDefaults    for (String propertyName : jpfDefined.keySet()) {      if (!vjpDefined.containsKey(propertyName)) //Make sure this property isn't being handled by VJP        properties.add(getProperty(propertyName));    }        //The reason why I don't just add all of the properties from JPF defined    //is to avoid duplicate entries on the arraylist.        //Now add in the VJP defaults    for (String propertyName : vjpDefined.keySet()) {      properties.add(getProperty(propertyName));    }    return properties.toArray();  }  /**   * Returns all Properties that are only defined by the user and not found   * in jpf.properties or defined by VJP   *    * @return an array of Properties defined by the user. These properties are   *         not overriding any entry eithey by JPF or VJP. These properties   *         exist soley on their own.   */  public Object[] getUserDefinedPropertiesAsArray() {     ArrayList<Property> properties = new ArrayList<Property>(userDefined.size());    for (String propertyName : userDefined.keySet()) {      if (!jpfDefined.containsKey(propertyName) && !vjpDefined.containsKey(propertyName))        properties.add(getProperty(propertyName));    }    return properties.toArray();  }    /**   * The IFile associated to this configuration.   * @return The IFile associated to this configuration.   */  public IFile getIFile() {    return file;  }    /**   * Adds a change listener to this configuration.   * Change listeners are fired once this configuration becomes dirty.   *    * @param listener adds the listener to this configuration.   */  public void addChangeListener(PropertyChangeListener listener) {    listeners.add(listener);  }    /**   * Removes this change listener from this configuration.   *    * @param listener the listener to be removed from this configuration.   */  public void removeChangeListener(PropertyChangeListener listener){    listeners.remove(listener);  }    private void fireListeners(){    for(PropertyChangeListener listener : listeners)      listener.changeOccurred();  }    /**   * Renames a property stored in this configuration   * @param oldValue the name of the old value   * @param newValue the value    */  public void renameProperty(String oldName, String newName) {    if (userDefined.containsKey(oldName))      userDefined.put(newName, userDefined.remove(oldName));            }    private class ConfigLine{     private String line;    public ConfigLine(){}    public ConfigLine(String line){this.line = line;}    public String getLine(){return line;}  }  private class PropertyLine extends ConfigLine{    private String property;        public PropertyLine(String property){      super();      this.property = property;    }        public String getPropertyName(){return property;}    public String getLine(){return isDefined(property) ? property+"="+getPropertyValue(property) : "";}  }  }

⌨️ 快捷键说明

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