KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > vfs > metadata > value > PropertyValue


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.vfs.metadata.value;
20
21 import java.util.*;
22
23 import org.openharmonise.vfs.metadata.*;
24
25
26 /**
27  * This is the value for compund type properties.
28  *
29  * @author Matthew Large
30  * @version $Revision: 1.1 $
31  *
32  */

33 public class PropertyValue implements ValueInstance {
34
35     /**
36      * List of {@link PropertyInstance} objects that are part of this value.
37      */

38     ArrayList m_aPropertyInstances = new ArrayList();
39
40     public PropertyValue() {
41         super();
42     }
43
44     /**
45      * Construcs a new compound value.
46      *
47      * @param aPropertyInstances List of {@link PropertyInstance} objects
48      */

49     public PropertyValue(ArrayList aPropertyInstances) {
50         super();
51         this.m_aPropertyInstances = aPropertyInstances;
52     }
53     
54     /**
55      * Sets the property instances that are part of this value.
56      *
57      * @param aPropertyInstances List of {@link PropertyInstance} objects
58      */

59     public void setValue(ArrayList aPropertyInstances) {
60         this.m_aPropertyInstances = aPropertyInstances;
61     }
62     
63     /**
64      * Returns a list of {@link PropertyInstance} objects that are part of
65      * this value.
66      *
67      * @return List of {@link PropertyInstance} objects
68      */

69     public ArrayList getValue() {
70         return this.m_aPropertyInstances;
71     }
72     
73     /* (non-Javadoc)
74      * @see java.lang.Object#equals(java.lang.Object)
75      */

76     public boolean equals(Object JavaDoc arg0) {
77         if(super.equals(arg0)) {
78             return true;
79         } else if(arg0 instanceof PropertyValue) {
80             if( this.compareAllValues( ((PropertyValue)arg0).getValue()) ) {
81                 return true;
82             } else {
83                 return false;
84             }
85         } else {
86             return false;
87         }
88     }
89     
90     /**
91      * Compares a given list of {@link PropertyInstance} objects against
92      * the list that is part of this value.
93      *
94      * @param aPropertyInstances List of {@link PropertyInstance} objects
95      * @return true if there is a complete match
96      */

97     private boolean compareAllValues(ArrayList aPropertyInstances) {
98         boolean bSame = true;
99         
100         Iterator itor = aPropertyInstances.iterator();
101         while (itor.hasNext()) {
102             boolean bFound = false;
103             PropertyInstance propInst = (PropertyInstance) itor.next();
104             Iterator itor2 = this.m_aPropertyInstances.iterator();
105             while (itor2.hasNext()) {
106                 PropertyInstance myPropInst = (PropertyInstance) itor2.next();
107                 if(myPropInst.equals(propInst)) {
108                     bFound = true;
109                     break;
110                 }
111             }
112             if(!bFound) {
113                 bSame=false;
114                 break;
115             }
116         }
117         
118         return bSame;
119     }
120
121 }
122
Popular Tags