KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > jpivot > olap > model > impl > PropertyHolderImpl


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.jpivot.olap.model.impl;
14
15 import java.util.List JavaDoc;
16
17 import com.tonbeller.jpivot.olap.model.Property;
18 import com.tonbeller.jpivot.olap.model.PropertyHolder;
19
20 /**
21  * Created on 11.10.2002
22  *
23  * @author av
24  */

25 public class PropertyHolderImpl implements PropertyHolder {
26   private static final Property[] EMPTY = new Property[0];
27   Property[] properties;
28   
29   public PropertyHolderImpl() {
30     this.properties = EMPTY;
31   }
32   
33   public PropertyHolderImpl(Property[] properties) {
34     this.properties = properties;
35   }
36
37   public PropertyHolderImpl(List JavaDoc propertyList) {
38     this.properties = (Property[]) propertyList.toArray(new Property[propertyList.size()]);
39   }
40   
41   /**
42    * Returns the properties.
43    * @return Property[]
44    */

45   public Property[] getProperties() {
46     return properties;
47   }
48
49
50   /**
51    * Sets the properties.
52    * @param properties The properties to set
53    */

54   public void setProperties(Property[] properties) {
55     this.properties = properties;
56   }
57
58
59   /**
60    * @see com.tonbeller.jpivot.olap.model.Member#getProperty(String)
61    */

62   public Property getProperty(String JavaDoc name) {
63     for (int i = 0; i < properties.length; i++)
64       if (name.equals(properties[i].getName()))
65         return properties[i];
66     return null;
67   }
68
69   /**
70    * very slow!
71    */

72   public void addProperty(PropertyImpl property) {
73     int N = properties.length;
74     Property[] old = properties;
75     properties = new Property[N + 1];
76     System.arraycopy(old, 0, properties, 0, N);
77     properties[N] = property;
78   }
79
80 }
81
Popular Tags