KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > loom > components > util > profile > PartitionProfile


1 /*
2  * Copyright (C) The Loom Group. All rights reserved.
3  *
4  * This software is published under the terms of the Loom
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.loom.components.util.profile;
9
10 import org.codehaus.loom.components.util.metadata.PartitionTemplate;
11
12 /**
13  * The PartitionProfile contains the set of data required to construct a
14  * specific instance of a Profile. It contains a set of child PartitionProfile
15  * and {@link org.codehaus.loom.components.util.profile.ComponentProfile}
16  * objects.
17  *
18  * @author Peter Donald
19  * @version $Revision: 1.2 $ $Date: 2004/05/01 12:48:35 $
20  */

21 public class PartitionProfile
22 {
23     /** Constant for an empty set of partitions. */
24     public static final PartitionProfile[] EMPTY_SET = new PartitionProfile[ 0 ];
25
26     /** The PartitionTemplate for this partition. */
27     private final PartitionTemplate m_metaData;
28
29     /** An array of partitions that are contained by this object. */
30     private final PartitionProfile[] m_partitions;
31
32     /** An array of partitions that are contained by this object. */
33     private final ComponentProfile[] m_components;
34
35     /**
36      * Create a PartitionProfile.
37      *
38      * @param metaData the meta data about this profile
39      * @param partitions the partitions contained by this partition
40      * @param components the components contained by this partition
41      */

42     public PartitionProfile( final PartitionTemplate metaData,
43                              final PartitionProfile[] partitions,
44                              final ComponentProfile[] components )
45     {
46         if( null == metaData )
47         {
48             throw new NullPointerException JavaDoc( "metaData" );
49         }
50         if( null == partitions )
51         {
52             throw new NullPointerException JavaDoc( "partitions" );
53         }
54         if( null == components )
55         {
56             throw new NullPointerException JavaDoc( "components" );
57         }
58
59         m_metaData = metaData;
60         m_partitions = partitions;
61         m_components = components;
62     }
63
64     /**
65      * Return the metaData about this profile.
66      *
67      * @return the metaData about this profile.
68      */

69     public PartitionTemplate getMetaData()
70     {
71         return m_metaData;
72     }
73
74     /**
75      * Return the set of partitions contained in this partition.
76      *
77      * @return the set of partitions contained in this partition.
78      */

79     public PartitionProfile[] getPartitions()
80     {
81         return m_partitions;
82     }
83
84     /**
85      * Return the set of components contained in this partition.
86      *
87      * @return the set of components contained in this partition.
88      */

89     public ComponentProfile[] getComponents()
90     {
91         return m_components;
92     }
93
94     /**
95      * Return the partition with specified name.
96      *
97      * @return the partition with specified name.
98      */

99     public PartitionProfile getPartition( final String JavaDoc name )
100     {
101         for( int i = 0; i < m_partitions.length; i++ )
102         {
103             final PartitionProfile partition = m_partitions[ i ];
104             if( partition.getMetaData().getName().equals( name ) )
105             {
106                 return partition;
107             }
108         }
109         return null;
110     }
111
112     /**
113      * Return the component with specified name.
114      *
115      * @return the component with specified name.
116      */

117     public ComponentProfile getComponent( final String JavaDoc name )
118     {
119         for( int i = 0; i < m_components.length; i++ )
120         {
121             final ComponentProfile component = m_components[ i ];
122             if( component.getTemplate().getName().equals( name ) )
123             {
124                 return component;
125             }
126         }
127         return null;
128     }
129 }
130
Popular Tags