|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ClassDescriptor.java | 100% | 100% | 100% | 100% |
|
1 |
/*
|
|
2 |
* Copyright (C) The MetaClass Group. All rights reserved.
|
|
3 |
*
|
|
4 |
* This software is published under the terms of the Spice
|
|
5 |
* Software License version 1.1, a copy of which has been included
|
|
6 |
* with this distribution in the LICENSE.txt file.
|
|
7 |
*/
|
|
8 |
package org.codehaus.metaclass.model;
|
|
9 |
|
|
10 |
import java.io.Serializable;
|
|
11 |
|
|
12 |
/**
|
|
13 |
* This class contains the meta information about a Class. It contains
|
|
14 |
* the name of the class, access modifiers, attributes, the classes fields and
|
|
15 |
* the classes methods.
|
|
16 |
*
|
|
17 |
* @author Peter Donald
|
|
18 |
* @version $Revision: 1.11 $ $Date: 2003/11/27 08:09:53 $
|
|
19 |
*/
|
|
20 |
public final class ClassDescriptor |
|
21 |
extends FeatureDescriptor
|
|
22 |
implements Serializable
|
|
23 |
{ |
|
24 |
/**
|
|
25 |
* The name of class.
|
|
26 |
*/
|
|
27 |
private final String m_name;
|
|
28 |
|
|
29 |
/**
|
|
30 |
* The fields of the class.
|
|
31 |
*/
|
|
32 |
private final FieldDescriptor[] m_fields;
|
|
33 |
|
|
34 |
/**
|
|
35 |
* The methods in the class.
|
|
36 |
*/
|
|
37 |
private final MethodDescriptor[] m_methods;
|
|
38 |
|
|
39 |
/**
|
|
40 |
* Create a ClassDescriptor with metadata about a class.
|
|
41 |
* The descriptor usually represents a corrresponding
|
|
42 |
* java class but this is not always the case.
|
|
43 |
*
|
|
44 |
* @param name the name of class
|
|
45 |
* @param declaredAttributes the declared attributes
|
|
46 |
* @param attributes the top level attribute metadata
|
|
47 |
* @param fields the field descriptors for class
|
|
48 |
* @param methods the method descriptors for class
|
|
49 |
*/
|
|
50 | 194 |
public ClassDescriptor( final String name,
|
51 |
final Attribute[] declaredAttributes, |
|
52 |
final Attribute[] attributes, |
|
53 |
final FieldDescriptor[] fields, |
|
54 |
final MethodDescriptor[] methods ) |
|
55 |
{ |
|
56 | 194 |
super( declaredAttributes, attributes );
|
57 | 194 |
if( null == name ) |
58 |
{ |
|
59 | 2 |
throw new NullPointerException( "name" ); |
60 |
} |
|
61 | 192 |
if( null == fields ) |
62 |
{ |
|
63 | 2 |
throw new NullPointerException( "fields" ); |
64 |
} |
|
65 | 190 |
for( int i = 0; i < fields.length; i++ ) |
66 |
{ |
|
67 | 14 |
if( null == fields[ i ] ) |
68 |
{ |
|
69 | 2 |
throw new NullPointerException( "fields[" + i + "]" ); |
70 |
} |
|
71 |
} |
|
72 | 188 |
if( null == methods ) |
73 |
{ |
|
74 | 2 |
throw new NullPointerException( "methods" ); |
75 |
} |
|
76 | 186 |
for( int i = 0; i < methods.length; i++ ) |
77 |
{ |
|
78 | 28 |
if( null == methods[ i ] ) |
79 |
{ |
|
80 | 2 |
throw new NullPointerException( "methods[" + i + "]" ); |
81 |
} |
|
82 |
} |
|
83 | 184 |
m_name = name; |
84 | 184 |
m_fields = fields; |
85 | 184 |
m_methods = methods; |
86 |
} |
|
87 |
|
|
88 |
/**
|
|
89 |
* Return the name of the class.
|
|
90 |
*
|
|
91 |
* @return the name of the class.
|
|
92 |
*/
|
|
93 | 196 |
public String getName()
|
94 |
{ |
|
95 | 196 |
return m_name;
|
96 |
} |
|
97 |
|
|
98 |
/**
|
|
99 |
* Return the FieldDescriptors for class.
|
|
100 |
* Note that it is not necessary that all fields in the
|
|
101 |
* class have corresponding FieldDescriptors.
|
|
102 |
*
|
|
103 |
* @return the FieldDescriptors for class.
|
|
104 |
*/
|
|
105 | 116 |
public FieldDescriptor[] getFields()
|
106 |
{ |
|
107 | 116 |
return m_fields;
|
108 |
} |
|
109 |
|
|
110 |
/**
|
|
111 |
* Return the MethodDescriptors for class.
|
|
112 |
* Note that it is not necessary that all methods in the
|
|
113 |
* class have corresponding MethodDescriptors.
|
|
114 |
*
|
|
115 |
* @return the MethodDescriptors for class.
|
|
116 |
*/
|
|
117 | 128 |
public MethodDescriptor[] getMethods()
|
118 |
{ |
|
119 | 128 |
return m_methods;
|
120 |
} |
|
121 |
} |
|
122 |
|
|