donaldp 2002/09/13 05:23:42
Added: info/src/java/org/apache/avalon/framework/info
TagDescriptor.java
Log:
Add in descriptor for tag
Revision Changes Path
1.1
jakarta-avalon-excalibur/info/src/java/org/apache/avalon/framework/info/TagDescriptor.java
Index: TagDescriptor.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.avalon.framework.info;
import java.io.Serializable;
import java.util.Properties;
/**
* Tags are the mechanism via which the Avalon Component model
* is extended. Each tag is made up of
* <ul>
* <li>name: the name of the tag</li>
* <li>parameters: a set of key-value pairs specifying parameters for tag</li>
* </ul>
*
* @author <a href="mailto:peter at apache.org">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/09/13 12:23:41 $
*/
public final class TagDescriptor
implements Serializable
{
private static final String[] EMPTY_SET = new String[ 0 ];
/**
* The name of the tag.
*/
private final String m_name;
/**
* The arbitrary set of attributes associated with Component.
*/
private final Properties m_parameters;
/**
* Create a tag with specified name and parameters.
*
* @param name the tag name
* @param parameters the tag parameters
*/
public TagDescriptor( final String name,
final Properties parameters )
{
if( null == name )
{
throw new NullPointerException( "name" );
}
if( null == parameters )
{
throw new NullPointerException( "parameters" );
}
m_name = name;
m_parameters = parameters;
}
/**
* Return the name of the tag.
*
* @return the name of the tag.
*/
public String getName()
{
return m_name;
}
/**
* Return the parameter for specified key.
*
* @return the parameter for specified key.
*/
public String getParameter( final String key )
{
if( null == m_parameters )
{
return null;
}
else
{
return m_parameters.getProperty( key );
}
}
/**
* Return the parameter for specified key, or defaultValue if unspecified.
*
* @return the parameter for specified key, or defaultValue if unspecified.
*/
public String getParameter( final String key,
final String defaultValue )
{
if( null == m_parameters )
{
return defaultValue;
}
else
{
return m_parameters.getProperty( key, defaultValue );
}
}
/**
* Returns an array of parameter names available under this tag.
*
* @return an array of parameter names available under this tag.
*/
public String[] getParameterNames()
{
if( null == m_parameters )
{
return EMPTY_SET;
}
else
{
return (String[])m_parameters.keySet().toArray( EMPTY_SET );
}
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>