类 FactoryConfiguration

所有已实现的接口:
Comparable<Configuration>
直接已知子类:
EasyFactoryConfiguration, FileFactoryConfiguration

public class FactoryConfiguration extends CompoundConfiguration<ToolboxConfiguration>

This class serves to define configuration info for a ToolboxFactory. It contains the ToolboxConfigurations for the factory as well as any Data which is to be made available in the application scope by the factory and any Propertys which you intend to be available to all tools managed by the factory, regardless of toolbox or scope.

Most users will not find themselves directly using the API of this class, as its subclasses generally provide much simpler means of inputting the actual configuration info whether from XML, Java or a Properties files.

When combining any Configurations via the various addConfiguration(org.apache.velocity.tools.config.FactoryConfiguration) methods in each class, it is essential to remember that subsequent configurations always override previous ones. This is a "last entry wins" approach to configuration!

For debugging, this class tracks its "sources", keeping a chronological list of all sources for configuration data. When you add configuration info to this class via addConfiguration(org.apache.velocity.tools.config.FactoryConfiguration), the source lists from those FactoryConfigurations is appended to this instance's list. The initial item in this list will typically be the name of the FactoryConfiguration class (or subclass) along with a caller-provided string identifying where this instance was created. This aids greatly in debugging combined, complex configurations. You may add further sources at any time via addSource(java.lang.String).

The toString() method of this class provides a complete and well-formatted listing of the configuration info contained within this instance and is also very useful for debugging.

版本:
$Id: FactoryConfiguration.java 511959 2007-02-26 19:24:39Z nbubna $
作者:
Nathan Bubna
  • 构造器详细资料

    • FactoryConfiguration

      public FactoryConfiguration()
    • FactoryConfiguration

      public FactoryConfiguration(String source)
      Creates a new instance with the specified source name combined with this class's name as the initial source.
      参数:
      source - configuration source name
    • FactoryConfiguration

      protected FactoryConfiguration(Class clazz, String source)
      Allows subclasses to construct an instance that uses their classname.
      参数:
      clazz - FactoryConfiguration class name
      source - configuration source name
  • 方法详细资料

    • getSource

      public String getSource()
      Returns the original source of this particular instance.
      返回:
      configuration source
    • setSource

      public void setSource(String source)
      Sets the name of the original source of this particular instance. This does not affect subsequently added sources.
      参数:
      source - configuration source name
    • getSources

      public List<String> getSources()
      Returns the list of sources for this configuration info in order starting from the source name given to this instance (if any) and going to the most recently added source.
      返回:
      list of all configuration sources
    • addSource

      public void addSource(String source)
      参数:
      source - source to add
    • addData

      public void addData(Data newDatum)
      参数:
      newDatum - data to add
    • removeData

      public boolean removeData(Data datum)
      参数:
      datum - data to remove
      返回:
      true if removed
    • getData

      public Data getData(String key)
      Search for Data by key
      参数:
      key - key of data to get
      返回:
      found Data or null
    • getData

      public Data getData(Data findme)
      Search for Data by value
      参数:
      findme - value to find
      返回:
      found Data or null
    • hasData

      public boolean hasData()
    • getData

      public SortedSet<Data> getData()
    • setData

      public void setData(Collection<Data> data)
    • addToolbox

      public void addToolbox(ToolboxConfiguration toolbox)
    • removeToolbox

      public void removeToolbox(ToolboxConfiguration toolbox)
    • getToolbox

      public ToolboxConfiguration getToolbox(String scope)
    • getToolboxes

      public Collection<ToolboxConfiguration> getToolboxes()
    • setToolboxes

      public void setToolboxes(Collection<ToolboxConfiguration> toolboxes)
    • addConfiguration

      public void addConfiguration(FactoryConfiguration config)
    • validate

      public void validate()
      覆盖:
      validate 在类中 CompoundConfiguration<ToolboxConfiguration>
    • equals

      public boolean equals(Object o)
      This will consider the object equal if it is a FactoryConfiguration and whose toString(boolean) method, when passed false, returns a String equal to that returned by a call to toString(false) on this instance. toString(boolean) is used since that returns a String encompassing all relevant info about the configuration except for the source information. In other words, two FactoryConfigurations are considered equal if they have the same data, properties and toolboxes in String form.
      覆盖:
      equals 在类中 CompoundConfiguration<ToolboxConfiguration>
      参数:
      o - object to compare to
      返回:
      equality
    • hashCode

      public int hashCode()
      覆盖:
      hashCode 在类中 CompoundConfiguration<ToolboxConfiguration>
    • toString

      public String toString()
      覆盖:
      toString 在类中 Object
    • toString

      public String toString(boolean includeSources)
    • createFactory

      public ToolboxFactory createFactory()