Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.archive.crawler.settings
Class ComplexType

    java.lang.Object
      javax.management.Attribute
          org.archive.crawler.settings.Type
              org.archive.crawler.settings.ComplexType

All Implemented Interfaces:
  java.io.Serializable, javax.management.DynamicMBean

Direct Known Subclasses:
  MapType, ModuleType

    public abstract class ComplexType

extends Type
implements javax.management.DynamicMBean

Superclass of all configurable modules. This class is in many ways the heart of the settings framework. All modules that should be configurable extends this class or one of its subclasses. All subclasses of this class will automatically conform to the JMX DynamicMBean. You could then use the `getMBeanInfo()` method to investigate which attributes this module supports and then use the `getAttribute(String)` and `setAttribute(Attribute)` methods to alter the attributes values. Because the settings framework supports per domain/host settings there is also available context sensitive versions of the DynamicMBean methods. If you use the non context sensitive methods, it is the global settings that will be altered.

Author:
  John Erik Halse
See Also:
  Serialized Form

Nested Class Summary
`(package private) class` | `ComplexType.Context`
`class` | `ComplexType.MBeanAttributeInfoIterator` Iterator over all MBeanAttributeInfo for this ComplexType

Field Summary
`protected java.util.List<Type>` | `definition`
`protected java.util.Map<java.lang.String,Type>` | `definitionMap`

Constructor Summary
`ComplexType(java.lang.String name, java.lang.String description)` Creates a new instance of ComplexType.

Method Summary
`Type` | `addElement(CrawlerSettings settings, Type type)`
`Type` | `addElementToDefinition(Type type)` Add a new attribute to the definition of this ComplexType.
`Constraint.FailedCheck` | `checkValue(CrawlerSettings settings, java.lang.String attributeName, java.lang.Object value)` Check an attribute to see if it fulfills all the constraints set on the definition of this attribute.
`(package private) Constraint.FailedCheck` | `checkValue(CrawlerSettings settings, java.lang.String attributeName, Type definition, java.lang.Object value)`
`void` | `earlyInitialize(CrawlerSettings settings)` This method can be overridden in subclasses to do local initialisation.
`java.lang.String` | `getAbsoluteName()` Get the absolute name of this ComplexType.
`java.lang.Object` | `getAttribute(java.lang.Object context, java.lang.String name)` Obtain the value of a specific attribute that is valid for a specific CrawlerSettings object.
`java.lang.Object` | `getAttribute(java.lang.String name)` Obtain the value of a specific attribute from the crawl order.
`java.lang.Object` | `getAttribute(java.lang.String name, CrawlURI uri)` Obtain the value of a specific attribute that is valid for a specific CrawlURI.
`javax.management.MBeanAttributeInfo` | `getAttributeInfo(CrawlerSettings settings, java.lang.String name)` Get the effective Attribute info for an element of this type from a settings object.
`javax.management.MBeanAttributeInfo` | `getAttributeInfo(java.lang.String name)` Get the Attribute info for an element of this type from the global settings.
`ComplexType.MBeanAttributeInfoIterator` | `getAttributeInfoIterator(java.lang.Object context)` Get an Iterator over all the MBeanAttributeInfo in this ComplexType.
`javax.management.AttributeList` | `getAttributes(java.lang.String[] name)`
`protected DataContainer` | `getDataContainerRecursive(ComplexType.Context context)` Get the active data container for this ComplexType for a specific settings object.
`protected DataContainer` | `getDataContainerRecursive(ComplexType.Context context, java.lang.String key)` Get the active data container for this ComplexType for a specific settings object.
`java.lang.Object` | `getDefaultValue()` The default value for this type
`(package private) Type` | `getDefinition(java.lang.String attributeName)` Get the content type definition for an attribute.
`java.lang.String` | `getDescription()` Get the description of this type The description should be suitable for showing in a user interface.
`Type` | `getElementFromDefinition(java.lang.String name)` Get an element definition from this complex type.
`java.lang.Object[]` | `getLegalValues()` Get the legal values for this type.
`java.lang.Object` | `getLocalAttribute(CrawlerSettings settings, java.lang.String name)` Obtain the value of a specific attribute that is valid for a specific CrawlerSettings object.
`javax.management.MBeanInfo` | `getMBeanInfo()`
`javax.management.MBeanInfo` | `getMBeanInfo(java.lang.Object context)`
`ComplexType` | `getParent()` Get the parent of this ComplexType.
`protected java.lang.String[]` | `getPreservedFields()` Get a list of attribute names that the complex type should attempt to preserve if the module is exchanged with an other one.
`(package private) ComplexType.Context` | `getSettingsFromObject(java.lang.Object o)` Get settings object valid for a URI.
`(package private) ComplexType.Context` | `getSettingsFromObject(java.lang.Object o, java.lang.String attributeName)` Get settings object valid for a URI.
`SettingsHandler` | `getSettingsHandler()`
`java.lang.Object` | `getUncheckedAttribute(java.lang.Object context, java.lang.String name)` Obtain the value of a specific attribute that is valid for a specific CrawlerSettings object.
`java.lang.Object` | `getValue()` Returns this object.
`CrawlerSettings` | `globalSettings()` Get the global settings object (aka order).
`java.lang.Object` | `invoke(java.lang.String arg0, java.lang.Object[] arg1, java.lang.String[] arg2)`
`boolean` | `isInitialized()` Returns true if this ComplexType is initialized.
`boolean` | `isOverridden(CrawlerSettings settings, java.lang.String name)` Returns true if an element is overridden for this settings object.
`java.util.Iterator` | `iterator(java.lang.Object context)` Get an Iterator over all the attributes in this ComplexType.
`protected Type` | `removeElementFromDefinition(java.lang.String name)` This method can only be called before the ComplexType has been initialized.
`protected void` | `setAsOrder(SettingsHandler settingsHandler)`
`void` | `setAttribute(javax.management.Attribute attribute)` Set the value of a specific attribute of the ComplexType.
`void` | `setAttribute(CrawlerSettings settings, javax.management.Attribute attribute)` Set the value of a specific attribute of the ComplexType.
`javax.management.AttributeList` | `setAttributes(javax.management.AttributeList attributes)`
`void` | `setDescription(java.lang.String string)` Set the description of this ComplexType The description should be suitable for showing in a user interface.
`protected void` | `setPreservedFields(java.lang.String[] preservedFields)` Set a list of attribute names that the complex type should attempt to preserve if the module is exchanged with an other one.
`java.lang.String` | `toString()`
`java.lang.Object` | `unsetAttribute(CrawlerSettings settings, java.lang.String name)` Unset an attribute on a per host level.

Methods inherited from class org.archive.crawler.settings.Type
`addConstraint, equals, getConstraints, getLegalValueType, isExpertSetting, isOverrideable, isTransient, setExpertSetting, setLegalValueType, setOverrideable, setTransient`

Methods inherited from class javax.management.Attribute
`getName`

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### definition

    protected final java.util.List<Type> definition

### definitionMap

    protected final java.util.Map<java.lang.String,Type> definitionMap

Constructor Detail

### ComplexType

    public ComplexType(java.lang.String name,
                       java.lang.String description)

  Creates a new instance of ComplexType.

  Parameters:
    `name` - the name of the element.
    `description` - the description of the element.

Method Detail

### setAsOrder

    protected void setAsOrder(SettingsHandler settingsHandler)
                       throws javax.management.InvalidAttributeValueException

  Throws:
    `javax.management.InvalidAttributeValueException`

### globalSettings

    public CrawlerSettings globalSettings()

  Get the global settings object (aka order).

  Returns:
    the global settings object.

### addElement

    public Type addElement(CrawlerSettings settings,
                           Type type)
                    throws javax.management.InvalidAttributeValueException

  Throws:
    `javax.management.InvalidAttributeValueException`

### setPreservedFields

    protected void setPreservedFields(java.lang.String[] preservedFields)

  Set a list of attribute names that the complex type should attempt to preserve if the module is exchanged with an other one.

  Parameters:
    `preservedFields` - array of attributenames to preserve.

### getPreservedFields

    protected java.lang.String[] getPreservedFields()

  Get a list of attribute names that the complex type should attempt to preserve if the module is exchanged with an other one.

  Returns:
    an array of attributenames to preserve.

### getDataContainerRecursive

    protected DataContainer getDataContainerRecursive(ComplexType.Context context)

  Get the active data container for this ComplexType for a specific settings object. If no value has been overridden on the settings object for this ComplexType, then it traverses up until it find a DataContainer with values for this ComplexType. This method should probably not be called from user code. It is a helper method for the settings framework.

  Parameters:
    `context` - Context from which we get settings.
  Returns:
    the active DataContainer.

### getDataContainerRecursive

    protected DataContainer getDataContainerRecursive(ComplexType.Context context,
                                                      java.lang.String key)
                                               throws javax.management.AttributeNotFoundException

  Get the active data container for this ComplexType for a specific settings object. If the key has not been overridden on the settings object for this ComplexType, then it traverses up until it find a DataContainer with the key for this ComplexType. This method should probably not be called from user code. It is a helper method for the settings framework.

  Parameters:
    `context` - the settings object for which the `DataContainer` is active.
    `key` - the key to look for.
  Returns:
    the active DataContainer.
  Throws:
    `javax.management.AttributeNotFoundException`

### getSettingsHandler

    public SettingsHandler getSettingsHandler()

### getAbsoluteName

    public java.lang.String getAbsoluteName()

  Get the absolute name of this ComplexType. The absolute name is like a file path with the name of the element prepended by all the parents names separated by slashes.

  Returns:
    Absolute name.

### getSettingsFromObject

    ComplexType.Context getSettingsFromObject(java.lang.Object o,
                                              java.lang.String attributeName)

  Get settings object valid for a URI.

  This method takes an object, try to convert it into a `CrawlURI` and then tries to get the settings object from it. If this fails, then the global settings object is returned.

  If the requested attribute is not set on this settings object it tries its parent until it gets a settings object where this attribute is set is found. If nothing is found, global settings is returned.

  Parameters:
    `o` - possible `CrawlURI`.
    `attributeName` - the attribute that should have a value set on the returned settings object.
  Returns:
    the settings object valid for the URI.

### getSettingsFromObject

    ComplexType.Context getSettingsFromObject(java.lang.Object o)

  Get settings object valid for a URI. This method takes an object, try to convert it into a `CrawlURI` and then tries to get the settings object from it. If this fails, then the global settings object is returned.

  Parameters:
    `o` - possible `CrawlURI`.
  Returns:
    the settings object valid for the URI.

### isOverridden

    public boolean isOverridden(CrawlerSettings settings,
                                java.lang.String name)
                         throws javax.management.AttributeNotFoundException

  Returns true if an element is overridden for this settings object.

  Parameters:
    `settings` - the settings object to investigate.
    `name` - the name of the element to check.
  Returns:
    true if element is overridden for this settings object, false if not set here or is first defined here.
  Throws:
    `javax.management.AttributeNotFoundException` - if element doesn't exist.

### getAttribute

    public java.lang.Object getAttribute(java.lang.String name)
                                  throws javax.management.AttributeNotFoundException,
                                         javax.management.MBeanException,
                                         javax.management.ReflectionException

  Obtain the value of a specific attribute from the crawl order. If the attribute doesn't exist in the crawl order, the default value will be returned.

  Specified by:
    `getAttribute` in interface `javax.management.DynamicMBean`
  Parameters:
    `name` - the name of the attribute to be retrieved.
  Returns:
    The value of the attribute retrieved.
  Throws:
    `javax.management.AttributeNotFoundException`
    `javax.management.MBeanException`
    `javax.management.ReflectionException`

### getAttribute

    public java.lang.Object getAttribute(java.lang.String name,
                                         CrawlURI uri)
                                  throws javax.management.AttributeNotFoundException

  Obtain the value of a specific attribute that is valid for a specific CrawlURI. This method will try to get the attribute from the host settings valid for the CrawlURI. If it is not found it will traverse the settings up to the order and as a last resort deliver the default value. This is also the case if the CrawlURI is null or if the CrawlURI hasn't been assigned a CrawlServer.

  Parameters:
    `name` - the name of the attribute to be retrieved.
    `uri` - the CrawlURI that this attribute should be valid for.
  Returns:
    The value of the attribute retrieved.
  Throws:
    `javax.management.AttributeNotFoundException`
  See Also:
    `getAttribute(Object settings, String name)`

### getAttribute

    public java.lang.Object getAttribute(java.lang.Object context,
                                         java.lang.String name)
                                  throws javax.management.AttributeNotFoundException

  Obtain the value of a specific attribute that is valid for a specific CrawlerSettings object.

  This method will first try to get a settings object from the supplied context, then try to look up the attribute from this settings object. If it is not found it will traverse the settings up to the order and as a last resort deliver the default value.

  Parameters:
    `context` - the object to get the settings from.
    `name` - the name of the attribute to be retrieved.
  Returns:
    The value of the attribute retrieved.
  Throws:
    `javax.management.AttributeNotFoundException`
  See Also:
    `CrawlerSettings`

### getUncheckedAttribute

    public java.lang.Object getUncheckedAttribute(java.lang.Object context,
                                                  java.lang.String name)

  Obtain the value of a specific attribute that is valid for a specific CrawlerSettings object.

  This method will first try to get a settings object from the supplied context, then try to look up the attribute from this settings object. If it is not found it will traverse the settings up to the order and as a last resort deliver the default value.

  The only difference from the `getAttribute(Object, String)`is that this method doesn't throw any checked exceptions. If an undefined attribute is requested from a ComplexType, it is concidered a bug and a runtime exception is thrown instead.

  Parameters:
    `context` - the object to get the settings from.
    `name` - the name of the attribute to be retrieved.
  Returns:
    The value of the attribute retrieved.
  Throws:
    `java.lang.IllegalArgumentException`
  See Also:
    `getAttribute(Object, String)`, `CrawlerSettings`

### getLocalAttribute

    public java.lang.Object getLocalAttribute(CrawlerSettings settings,
                                              java.lang.String name)
                                       throws javax.management.AttributeNotFoundException

  Obtain the value of a specific attribute that is valid for a specific CrawlerSettings object. This method will try to get the attribute from the supplied host settings object. If it is not found it will return `null` and not try to investigate the hierarchy of settings.

  Parameters:
    `settings` - the CrawlerSettings object to search for this attribute.
    `name` - the name of the attribute to be retrieved.
  Returns:
    The value of the attribute retrieved or null if its not set.
  Throws:
    `javax.management.AttributeNotFoundException` - is thrown if the attribute doesn't exist.
  See Also:
    `CrawlerSettings`

### setAttribute

    public final void setAttribute(javax.management.Attribute attribute)
                            throws javax.management.AttributeNotFoundException,
                                   javax.management.InvalidAttributeValueException,
                                   javax.management.MBeanException,
                                   javax.management.ReflectionException

  Set the value of a specific attribute of the ComplexType. This method sets the specific attribute for the order file.

  Specified by:
    `setAttribute` in interface `javax.management.DynamicMBean`
  Parameters:
    `attribute` - The identification of the attribute to be set and the value it is to be set to.
  Throws:
    `javax.management.AttributeNotFoundException` - is thrown if there is no attribute with this name.
    `javax.management.InvalidAttributeValueException` - is thrown if the attribute is of wrong type and cannot be converted to the right type.
    `javax.management.MBeanException` - this is to conform to the MBean specification, but this exception is never thrown, though this might change in the future.
    `javax.management.ReflectionException` - this is to conform to the MBean specification, but this exception is never thrown, though this might change in the future.
  See Also:
    `DynamicMBean.setAttribute(javax.management.Attribute)`

### setAttribute

    public final void setAttribute(CrawlerSettings settings,
                                   javax.management.Attribute attribute)
                            throws javax.management.InvalidAttributeValueException,
                                   javax.management.AttributeNotFoundException

  Set the value of a specific attribute of the ComplexType. This method is an extension to the Dynamic MBean specification so that it is possible to set the value for a CrawlerSettings object other than the settings object representing the order.

  Parameters:
    `settings` - the settings object for which this attributes value is valid
    `attribute` - The identification of the attribute to be set and the value it is to be set to.
  Throws:
    `javax.management.AttributeNotFoundException` - is thrown if there is no attribute with this name.
    `javax.management.InvalidAttributeValueException` - is thrown if the attribute is of wrong type and cannot be converted to the right type.
  See Also:
    `DynamicMBean.setAttribute(javax.management.Attribute)`

### getDefinition

    Type getDefinition(java.lang.String attributeName)

  Get the content type definition for an attribute.

  Parameters:
    `attributeName` - the name of the attribute to get definition for.
  Returns:
    the content type definition for the attribute.

### checkValue

    public Constraint.FailedCheck checkValue(CrawlerSettings settings,
                                             java.lang.String attributeName,
                                             java.lang.Object value)

  Check an attribute to see if it fulfills all the constraints set on the definition of this attribute.

  Parameters:
    `settings` - the CrawlerSettings object for which this check was executed.
    `attributeName` - the name of the attribute to check.
    `value` - the value to check.
  Returns:
    null if everything is ok, otherwise it returns a FailedCheck object with detailed information of what went wrong.

### checkValue

    Constraint.FailedCheck checkValue(CrawlerSettings settings,
                                      java.lang.String attributeName,
                                      Type definition,
                                      java.lang.Object value)

### unsetAttribute

    public java.lang.Object unsetAttribute(CrawlerSettings settings,
                                           java.lang.String name)
                                    throws javax.management.AttributeNotFoundException

  Unset an attribute on a per host level. This methods removes an override on a per host or per domain level.

  Parameters:
    `settings` - the settings object for which the attribute should be unset.
    `name` - the name of the attribute.
  Returns:
    The removed attribute or null if nothing was removed.
  Throws:
    `javax.management.AttributeNotFoundException` - is thrown if the attribute name doesn't exist.

### getAttributes

    public javax.management.AttributeList getAttributes(java.lang.String[] name)

  Specified by:
    `getAttributes` in interface `javax.management.DynamicMBean`

### setAttributes

    public javax.management.AttributeList setAttributes(javax.management.AttributeList attributes)

  Specified by:
    `setAttributes` in interface `javax.management.DynamicMBean`

### invoke

    public java.lang.Object invoke(java.lang.String arg0,
                                   java.lang.Object[] arg1,
                                   java.lang.String[] arg2)
                            throws javax.management.MBeanException,
                                   javax.management.ReflectionException

  Specified by:
    `invoke` in interface `javax.management.DynamicMBean`
  Throws:
    `javax.management.MBeanException`
    `javax.management.ReflectionException`

### getMBeanInfo

    public javax.management.MBeanInfo getMBeanInfo()

  Specified by:
    `getMBeanInfo` in interface `javax.management.DynamicMBean`

### getMBeanInfo

    public javax.management.MBeanInfo getMBeanInfo(java.lang.Object context)

### getAttributeInfo

    public javax.management.MBeanAttributeInfo getAttributeInfo(CrawlerSettings settings,
                                                                java.lang.String name)

  Get the effective Attribute info for an element of this type from a settings object.

  Parameters:
    `settings` - the settings object for which the Attribute info is effective.
    `name` - the name of the element to get the attribute for.
  Returns:
    the attribute info

### getAttributeInfo

    public javax.management.MBeanAttributeInfo getAttributeInfo(java.lang.String name)

  Get the Attribute info for an element of this type from the global settings.

  Parameters:
    `name` - the name of the element to get the attribute for.
  Returns:
    the attribute info

### getDescription

    public java.lang.String getDescription()

  Get the description of this type The description should be suitable for showing in a user interface.

  Specified by:
    `getDescription` in class `Type`
  Returns:
    this type's description

### getParent

    public ComplexType getParent()

  Get the parent of this ComplexType.

  Returns:
    the parent of this ComplexType.

### setDescription

    public void setDescription(java.lang.String string)

  Set the description of this ComplexType The description should be suitable for showing in a user interface.

  Parameters:
    `string` - the description to set for this type.

### getDefaultValue

    public java.lang.Object getDefaultValue()

  Description copied from class: `Type`
  The default value for this type

  Specified by:
    `getDefaultValue` in class `Type`
  Returns:
    this type's default value

### addElementToDefinition

    public Type addElementToDefinition(Type type)

  Add a new attribute to the definition of this ComplexType. This method can only be called before the ComplexType has been initialized. This usally means that this method is available for constructors of subclasses of this class.

  Parameters:
    `type` - the type to add.
  Returns:
    the newly added type.

### getElementFromDefinition

    public Type getElementFromDefinition(java.lang.String name)

  Get an element definition from this complex type. This method can only be called before the ComplexType has been initialized. This usally means that this method is available for constructors of subclasses of this class.

  Parameters:
    `name` - name of element to get.
  Returns:
    the requested element or null if non existent.

### removeElementFromDefinition

    protected Type removeElementFromDefinition(java.lang.String name)

  This method can only be called before the ComplexType has been initialized. This usually means that this method is available for constructors of subclasses of this class.

  Parameters:
    `name` - Name of element to remove.
  Returns:
    Element removed.

### earlyInitialize

    public void earlyInitialize(CrawlerSettings settings)

  This method can be overridden in subclasses to do local initialisation. This method is run before the class has been updated with information from settings files. That implies that if you call getAttribute inside this method you will only get the default values.

  Parameters:
    `settings` - the CrawlerSettings object for which this complex type is defined.

### isInitialized

    public boolean isInitialized()

  Returns true if this ComplexType is initialized.

  Returns:
    true if this ComplexType is initialized.

### getLegalValues

    public java.lang.Object[] getLegalValues()

  Description copied from class: `Type`
  Get the legal values for this type.

  Specified by:
    `getLegalValues` in class `Type`
  Returns:
    the legal values for this type or null if there are no restrictions.

### getValue

    public java.lang.Object getValue()

  Returns this object. This method is implemented to be able to treat the ComplexType as an subclass of `Attribute`.

  Overrides:
    `getValue` in class `javax.management.Attribute`
  Returns:
    this object.
  See Also:
    `Attribute.getValue()`

### iterator

    public java.util.Iterator iterator(java.lang.Object context)

  Get an Iterator over all the attributes in this ComplexType.

  Parameters:
    `context` - the context for which this set of attributes are valid.
  Returns:
    an iterator over all the attributes in this map.

### getAttributeInfoIterator

    public ComplexType.MBeanAttributeInfoIterator getAttributeInfoIterator(java.lang.Object context)

  Get an Iterator over all the MBeanAttributeInfo in this ComplexType.

  Parameters:
    `context` - the context for which this set of MBeanAttributeInfo are valid.
  Returns:
    an iterator over all the MBeanAttributeInfo in this map.

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2008 Internet Archive. All Rights Reserved.