01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: PropertyValueList.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.ioc;
09:
10: import com.uwyn.rife.ioc.PropertyValue;
11: import com.uwyn.rife.ioc.PropertyValueObject;
12: import com.uwyn.rife.ioc.exceptions.PropertyValueException;
13: import java.util.ArrayList;
14:
15: /**
16: * An ordered list of property values.
17: *
18: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
19: * @version $Revision: 3634 $
20: * @since 1.0
21: */
22: public class PropertyValueList extends ArrayList<PropertyValue> {
23: private static final long serialVersionUID = -7791482346118685259L;
24:
25: /**
26: * Interpretes the list of property values and make one new property value
27: * out of it.
28: *
29: * @return the new <code>PropertyValue</code> instance
30: * @since 1.0
31: */
32: public PropertyValue makePropertyValue()
33: throws PropertyValueException {
34: // evaluate the current property values series and check if this should be
35: // interpreted as a text result or as a participant value
36: PropertyValue result = null;
37:
38: PropertyValue non_neglectablepropval = null;
39: for (PropertyValue propval : this ) {
40: if (!propval.isNeglectable()) {
41: if (non_neglectablepropval != null) {
42: non_neglectablepropval = null;
43: break;
44: }
45:
46: non_neglectablepropval = propval;
47: }
48: }
49:
50: if (non_neglectablepropval != null) {
51: if (non_neglectablepropval.isStatic()) {
52: result = new PropertyValueObject(non_neglectablepropval
53: .getValueString().trim());
54: } else {
55: result = non_neglectablepropval;
56: }
57: }
58:
59: if (null == result) {
60: StringBuilder key_text = new StringBuilder();
61: for (PropertyValue propval : this ) {
62: key_text.append(propval.getValueString());
63: }
64: result = new PropertyValueObject(key_text.toString().trim());
65: }
66:
67: return result;
68: }
69: }
|