donaldp 2002/10/20 20:44:30 Added: metaclass/src/java/org/apache/excalibur/metaclass/model Attribute.java ClassDescriptor.java ClassInfo.java FeatureDescriptor.java FieldDescriptor.java MethodDescriptor.java ParameterDescriptor.java package.html Log: Runtime metadata discovery V5 Revision Changes Path 1.1 jakarta-avalon-excalibur/metaclass/src/java/org/apache/excalibur/metaclass/model/Attribute.java Index: Attribute.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.excalibur.metaclass.model; import java.io.Serializable; import java.util.Properties; /** * Attributes are the mechanism via which the Component model * is extended. Each Attribute is made up of * <ul> * <li>name: the name of the Attribute</li> * <li>parameters: a set of key-value pairs specifying parameters for Attribute</li> * </ul> * * @author <a href="mailto:peter at apache.org">Peter Donald</a> * @version $Revision: 1.1 $ $Date: 2002/10/21 03:44:29 $ */ public final class Attribute implements Serializable { private static final String[] EMPTY_SET = new String[ 0 ]; /** * The name of the Attribute. */ private final String m_name; /** * The arbitrary set of parameters associated with the Attribute. */ private final Properties m_parameters; /** * Create a Attribute with specified name and parameters. * * @param name the Attribute name * @param parameters the Attribute parameters */ public Attribute( 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 Attribute. * * @return the name of the Attribute. */ 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 Attribute. * * @return an array of parameter names available under this Attribute. */ public String[] getParameterNames() { if( null == m_parameters ) { return EMPTY_SET; } else { return (String[])m_parameters.keySet().toArray( EMPTY_SET ); } } public String toString() { return getName() + m_parameters; } } 1.1 jakarta-avalon-excalibur/metaclass/src/java/org/apache/excalibur/metaclass/model/ClassDescriptor.java Index: ClassDescriptor.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.excalibur.metaclass.model; import org.apache.avalon.framework.info.FeatureDescriptor; import org.apache.avalon.framework.info.Attribute; /** * This descriptor contains the information relevent to a * particular class. It essentially contains a list of attributes * defined by the class and the name of the class that it is applied to. * * @author <a href="mailto:peter at apache.org">Peter Donald</a> * @version $Revision: 1.1 $ $Date: 2002/10/21 03:44:29 $ */ public final class ClassDescriptor extends FeatureDescriptor { /** * The name of class. */ private final String m_classname; public ClassDescriptor( final String classname, final Attribute[] attribute ) { super( attribute ); if( null == classname ) { throw new NullPointerException( "classname" ); } m_classname = classname; } /** * Return the name of the class. * * @return the name of the class. */ public String getClassname() { return m_classname; } } 1.1 jakarta-avalon-excalibur/metaclass/src/java/org/apache/excalibur/metaclass/model/ClassInfo.java Index: ClassInfo.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.excalibur.metaclass.model; import java.io.Serializable; /** * This class contains the meta information about a Class. It contains * references to descriptors about the class, the classes fields and * the classes methods. * * @author <a href="mailto:peter at apache.org">Peter Donald</a> * @version $Revision: 1.1 $ $Date: 2002/10/21 03:44:29 $ */ public class ClassInfo implements Serializable { private final ClassDescriptor m_classDescriptor; private final FieldDescriptor[] m_fields; private final MethodDescriptor[] m_methods; public ClassInfo( final ClassDescriptor classDescriptor, final FieldDescriptor[] fields, final MethodDescriptor[] methods ) { m_classDescriptor = classDescriptor; m_fields = fields; m_methods = methods; } public ClassDescriptor getClassDescriptor() { return m_classDescriptor; } public FieldDescriptor[] getFields() { return m_fields; } public MethodDescriptor[] getMethods() { return m_methods; } } 1.1 jakarta-avalon-excalibur/metaclass/src/java/org/apache/excalibur/metaclass/model/FeatureDescriptor.java Index: FeatureDescriptor.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.excalibur.metaclass.model; import java.io.Serializable; import java.util.Arrays; import java.util.ArrayList; /** * This is the Abstract class for all feature descriptors. * Every descriptor has the capability of adding Attributes * of some kind. These Attributes can then be interpreted by * the container. The meaning of the specific Attributes will * be defined by future specification documents. * * @author <a href="mailto:peter at apache.org">Peter Donald</a> * @version $Revision: 1.1 $ $Date: 2002/10/21 03:44:29 $ */ public abstract class FeatureDescriptor implements Serializable { /** * The arbitrary set of Attributes associated with Component. */ private final Attribute[] m_attributes; /** * The modifiers for this particular feature as defined * in {@link java.lang.reflect.Modifier}. */ private final int m_modifiers; /** * Create a FeatureDescriptor with specific set of attributes. * * @param attributes the attributes */ protected FeatureDescriptor( final Attribute[] attributes, final int modifiers ) { if( null == attributes ) { throw new NullPointerException( "attributes" ); } m_attributes = attributes; m_modifiers = modifiers; } /** * Return the attributes associated with descriptor. * * @return the attributes associated with descriptor. */ public Attribute[] getAttributes() { return m_attributes; } /** * Return the attribute with specified name. * * @return the attribute with specified name. */ public Attribute getAttributeByName( final String name ) { for( int i = 0; i < m_attributes.length; i++ ) { final Attribute attribute = m_attributes[ i ]; if( attribute.getName().equals( name ) ) { return attribute; } } return null; } /** * Return the attributes with specified name. * * @return the attributes with specified name. */ public Attribute[] getAttributesByName( final String name ) { final ArrayList results = new ArrayList(); for( int i = 0; i < m_attributes.length; i++ ) { final Attribute attribute = m_attributes[ i ]; if( attribute.getName().equals( name ) ) { results.add( attribute ); } } return (Attribute[])results.toArray( new Attribute[ results.size() ] ); } /** * Return the modifiers for feature decoded by * {@link java.lang.reflect.Modifier}. * * @return the modifiers for feature decoded by * {@link java.lang.reflect.Modifier}. */ public int getModifiers() { return m_modifiers; } /** * Helper method to convert attributes into a * string representation. * * @return attributes converted into a string representation */ protected final String attributesToString() { if( 0 == m_attributes.length ) { return ""; } else { return String.valueOf( Arrays.asList( m_attributes ) ); } } } 1.1 jakarta-avalon-excalibur/metaclass/src/java/org/apache/excalibur/metaclass/model/FieldDescriptor.java Index: FieldDescriptor.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.excalibur.metaclass.model; import java.io.Serializable; /** * A descriptor that describes a Field. It contains * information about; * <ul> * <li>name: the name of the field</li> * <li>type: the type of the field</li> * <li>modifiers: the access modifiers for the field</li> * </ul> * * <p>Also associated with each field is a set of arbitrary * Attributes that can be used to store extra information * about method.</p> * * @author <a href="mailto:peter at apache.org">Peter Donald</a> * @version $Revision: 1.1 $ $Date: 2002/10/21 03:44:29 $ */ public final class FieldDescriptor extends FeatureDescriptor implements Serializable { /** * The name of the field. */ private final String m_name; /** * The type of the field. */ private final String m_type; /** * Create a descriptor for a field. * * @param name the name of the field * @param type the return type of the field * @param modifiers the access modifiers for field * @param attributes any attributes associated with method */ public FieldDescriptor( final String name, final String type, final int modifiers, final Attribute[] attributes ) { super( attributes, modifiers ); if( null == name ) { throw new NullPointerException( "name" ); } if( null == type ) { throw new NullPointerException( "type" ); } m_name = name; m_type = type; } /** * Return the name of the field. * * @return the name of the field. */ public String getName() { return m_name; } /** * Return the type of the field. * * @return the type of the field. */ public String getType() { return m_type; } } 1.1 jakarta-avalon-excalibur/metaclass/src/java/org/apache/excalibur/metaclass/model/MethodDescriptor.java Index: MethodDescriptor.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.excalibur.metaclass.model; import java.io.Serializable; /** * A descriptor that describes a Method. It contains * information about; * <ul> * <li>name: the name of the method</li> * <li>return type: the return type of the method</li> * <li>modifiers: the access modifiers for the method</li> * <li>parameters: the parameters a method takes</li> * </ul> * * <p>Also associated with each method is a set of arbitrary * Attributes that can be used to store extra information * about method.</p> * * @author <a href="mailto:peter at apache.org">Peter Donald</a> * @version $Revision: 1.1 $ $Date: 2002/10/21 03:44:29 $ */ public final class MethodDescriptor extends FeatureDescriptor implements Serializable { /** * The name of the Method. */ private final String m_name; /** * The return type of the method. */ private final String m_returnType; /** * The parameters associated with the method. */ private final ParameterDescriptor[] m_parameters; /** * Create a descriptor for a method. * * @param name the name of the method * @param returnType the return type of the method * @param modifiers the access modifiers for method * @param parameters the parameters of the method * @param attributes any attributes associated with method */ public MethodDescriptor( final String name, final String returnType, final int modifiers, final ParameterDescriptor[] parameters, final Attribute[] attributes ) { super( attributes, modifiers ); if( null == name ) { throw new NullPointerException( "name" ); } if( null == returnType ) { throw new NullPointerException( "returnType" ); } if( null == parameters ) { throw new NullPointerException( "parameters" ); } m_name = name; m_returnType = returnType; m_parameters = parameters; } /** * Return the name of the method. * * @return the name of the method. */ public String getName() { return m_name; } /** * Return the return type of the method. * * @return the return type of the method. */ public String getReturnType() { return m_returnType; } /** * Return the parameters associated with method. * * @return the parameters associated with method. */ public ParameterDescriptor[] getParameters() { return m_parameters; } } 1.1 jakarta-avalon-excalibur/metaclass/src/java/org/apache/excalibur/metaclass/model/ParameterDescriptor.java Index: ParameterDescriptor.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.excalibur.metaclass.model; import java.io.Serializable; /** * A descriptor that describes a parameter of a Method. * It contains information about; * <ul> * <li>name: the name of the parameter. * This name may be automatically constructed if descriptor is * created via reflection.</li> * <li>type: the type of the parameter</li> * </ul> * * <p>Also associated with each parameter is a set of arbitrary * Attributes that can be used to store extra information * about parameter. Usually these attributes are used to store * information such as display name for a Parameter.</p> * * @author <a href="mailto:peter at apache.org">Peter Donald</a> * @version $Revision: 1.1 $ $Date: 2002/10/21 03:44:29 $ */ public final class ParameterDescriptor implements Serializable { /** * The name of the Parameter in source file. */ private final String m_name; /** * The class/interface of the Parameter. */ private final String m_type; /** * Construct a descriptor for a parameter. * * @param name the name of the parameter * @param type the type of the parameter */ public ParameterDescriptor( final String name, final String type ) { if( null == name ) { throw new NullPointerException( "name" ); } if( null == type ) { throw new NullPointerException( "type" ); } m_name = name; m_type = type; } /** * Return the name of the parameter. * * @return the name of the parameter. */ public String getName() { return m_name; } /** * Return the type of the parameter. * * @return the type of the parameter. */ public String getType() { return m_type; } } 1.1 jakarta-avalon-excalibur/metaclass/src/java/org/apache/excalibur/metaclass/model/package.html Index: package.html =================================================================== <html> <body> A set of classes supporting the representation of metadata about a particular class. <h3>Overview</h3> <p>This package includes a set of classes supporting the representation of metadata about a class. The metadata primarily consists of "attributes" that can be attached to classes, fields and methods.<p> <h3>Package Structure (UML)</h3> <p><img src="doc-files/uml.gif" border="0" /></p> </body> </html>
-- To unsubscribe, e-mail: <mailto:avalon-cvs-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:avalon-cvs-help@;jakarta.apache.org>