KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > metadata > spi > retrieval > simple > SimpleMetaDatasItem


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.metadata.spi.retrieval.simple;
23
24 import org.jboss.metadata.spi.MetaData;
25 import org.jboss.metadata.spi.retrieval.MetaDataItem;
26 import org.jboss.metadata.spi.retrieval.MetaDatasItem;
27
28 /**
29  * SimpleMetaDatasItem.
30  *
31  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
32  * @version $Revision: 45742 $
33  */

34 public class SimpleMetaDatasItem extends SimpleItem<Object JavaDoc[]> implements MetaDatasItem
35 {
36    /** No meta data */
37    public static final SimpleMetaDatasItem NO_META_DATA = new SimpleMetaDatasItem();
38    
39    /** The meta data items */
40    private MetaDataItem[] metaDataItems;
41    
42    /** The meta data */
43    private Object JavaDoc[] metaDatas;
44
45    /**
46     * Create a new SimpleMetaDatasItem.
47     */

48    protected SimpleMetaDatasItem()
49    {
50       this(NO_META_DATA_ITEMS);
51    }
52
53    /**
54     * Create a new SimpleMetaDatasItem.
55     *
56     * @param metaDataItems the meta data items
57     */

58    public SimpleMetaDatasItem(MetaDataItem[] metaDataItems)
59    {
60       setMetaDataItems(metaDataItems);
61    }
62
63    public Object JavaDoc[] getValue()
64    {
65       if (metaDatas == null)
66       {
67          Object JavaDoc[] temp = new Object JavaDoc[metaDataItems.length];
68          for (int i = 0; i < temp.length; ++i)
69             temp[i] = metaDataItems[i].getValue();
70          metaDatas = temp;
71       }
72       return metaDatas;
73    }
74
75    public MetaDataItem[] getMetaDatas()
76    {
77       return metaDataItems;
78    }
79    
80    /**
81     * Set the meta data items
82     *
83     * @param metaDataItems the meta data items
84     */

85    protected void setMetaDataItems(MetaDataItem[] metaDataItems)
86    {
87       if (metaDataItems == null)
88          throw new IllegalArgumentException JavaDoc("Null metaDataItems");
89       
90       this.metaDataItems = metaDataItems;
91       if (metaDataItems.length == 0)
92          metaDatas = MetaData.NO_METADATA;
93       else
94          metaDatas = null;
95    }
96 }
97
Popular Tags