FileDocCategorySizeDatePackage
MailetConfigImpl.javaAPI DocApache James 2.3.15269Fri Jan 12 12:56:22 GMT 2007org.apache.james.core

MailetConfigImpl

public class MailetConfigImpl extends Object implements org.apache.mailet.MailetConfig
Implements the configuration object for a Mailet.
version
CVS $Revision: 494012 $ $Date: 2007-01-08 11:23:58 +0100 (Mo, 08 Jan 2007) $

Fields Summary
private org.apache.mailet.MailetContext
mailetContext
The mailet MailetContext
private String
name
The mailet name
private org.apache.avalon.framework.configuration.Configuration
configuration
The mailet Avalon Configuration
Constructors Summary
public MailetConfigImpl()
No argument constructor for this object.

    
Methods Summary
public java.lang.StringgetInitAttribute(java.lang.String name)
Get the value of an (XML) attribute stored in this MailetConfig.

param
name the name of the attribute whose value is to be retrieved.
return
the attribute value or null if missing

        return configuration.getAttribute(name, null);
    
public java.lang.StringgetInitParameter(java.lang.String name)
Get the value of an parameter stored in this MailetConfig. Multi-valued parameters are returned as a comma-delineated string.

param
name the name of the parameter whose value is to be retrieved.
return
the parameter value

        try {
            String result = null;

            final Configuration[] values = configuration.getChildren( name );
            for ( int i = 0; i < values.length; i++ ) {
                if (result == null) {
                    result = "";
                } else {
                    result += ",";
                }
                Configuration conf = values[i];
                result += conf.getValue();
            }
            return result;
        } catch (ConfigurationException ce) {
            throw new RuntimeException("Embedded configuration exception was: " + ce.getMessage());
        }

    
public java.util.IteratorgetInitParameterNames()
Returns an iterator over the set of configuration parameter names.

return
an iterator over the set of configuration parameter names.

        return new Iterator () {
            Configuration[] children;
            int count = 0;
            {
                children = configuration.getChildren();
            }

            public boolean hasNext() {
                return count < children.length;
            }

            public Object next() {
                return children[count++].getName();
            }

            public void remove() {
                throw new UnsupportedOperationException ("remove not supported");
            }
        };
    
public org.apache.mailet.MailetContextgetMailetContext()
Get the mailet's MailetContext object.

return
the MailetContext for the mailet

        return mailetContext;
    
public java.lang.StringgetMailetName()
Get the name of the mailet.

return
the name of the mailet

        return name;
    
public voidsetConfiguration(org.apache.avalon.framework.configuration.Configuration newConfiguration)
Set the Avalon Configuration object for the mailet.

param
newConfiguration the new Configuration for the mailet

        configuration = newConfiguration;
    
public voidsetMailetContext(org.apache.mailet.MailetContext newContext)
Get the mailet's Avalon Configuration object.

return
the Configuration for the mailet

        mailetContext = newContext;
    
public voidsetMailetName(java.lang.String newName)
Set the name for the mailet.

param
newName the new name for the mailet

        name = newName;