001: /*
002: * Created on 25 Jul 2006
003: */
004: package uk.org.ponder.springutil;
005:
006: /**
007: * A static, that is to say, concrete, implementation of the
008: * {@link TargetListAggregatingBean} marker definition.
009: *
010: * @author Antranig Basman (antranig@caret.cam.ac.uk)
011: *
012: */
013:
014: public class StaticTLAB implements TargetListAggregatingBean {
015: private String targetBean;
016: private String targetProperty;
017: private Object value;
018: private boolean unwraplists = true;
019: private Object bindAfter;
020: private Object bindBefore;
021: private String valueref;
022: private String[] valuerefs;
023:
024: /**
025: * The name of the target bean to receive the held bean as part of its list
026: * dependency
027: */
028: public void setTargetBean(String targetBean) {
029: this .targetBean = targetBean;
030: }
031:
032: public String getTargetBean() {
033: return targetBean;
034: }
035:
036: /** The name of the list-valued property of the target bean * */
037: public void setTargetProperty(String targetProperty) {
038: this .targetProperty = targetProperty;
039: }
040:
041: public String getTargetProperty() {
042: return targetProperty;
043: }
044:
045: /**
046: * A compact alternative to specifying <code>targetBean</code> and
047: * <code>targetProperty</code> - use <code>targetPath</code> instead to
048: * specify a single dot-separated "EL" as
049: * <code>targetBean.targetProperty</code>
050: */
051: public void setTargetPath(String targetPath) {
052: int dotpos = targetPath.indexOf('.');
053: if (dotpos == -1) {
054: throw new IllegalArgumentException("target path "
055: + targetPath + " must contain a dot");
056: }
057: targetBean = targetPath.substring(0, dotpos);
058: targetProperty = targetPath.substring(dotpos + 1);
059: }
060:
061: /**
062: * The "held" object to be aggregated into the list-valued property of the
063: * target bean. Exactly one out of this property and {@link #setValueRef(String)}
064: * must be set.
065: */
066: public void setValue(Object value) {
067: this .value = value;
068: }
069:
070: public Object getValue() {
071: return value;
072: }
073:
074: /** The EL or bean name at which the "held" object can be found. Exactly
075: * one out of this property and {@link #setValue(Object)} must be set.
076: */
077:
078: public void setValueRef(String valueref) {
079: this .valueref = valueref;
080: }
081:
082: public String getValueRef() {
083: return valueref;
084: }
085:
086: /**
087: * If set to <code>false</code> (the default is <code>true</code>, any
088: * list-valued object will be delivered "in the raw" into the target property
089: * list, rather than being unpacked into it.
090: */
091:
092: public void setUnwrapLists(boolean unwraplists) {
093: this .unwraplists = unwraplists;
094: }
095:
096: public boolean getUnwrapLists() {
097: return unwraplists;
098: }
099:
100: /** If set to "*" will cause the contributed bean to be placed in the first
101: * list position. Other values will be supported in future versions.
102: */
103: public void setBindBefore(Object bindBefore) {
104: this .bindBefore = bindBefore;
105: }
106:
107: /** If set to "*" will cause the contributed bean to be placed in the last
108: * list position. Other values will be supported in future versions.
109: */
110: public void setBindAfter(Object bindAfter) {
111: this .bindAfter = bindAfter;
112: }
113:
114: public Object getBindAfter() {
115: return bindAfter;
116: }
117:
118: public Object getBindBefore() {
119: return bindBefore;
120: }
121:
122: public void setValueRefs(String[] valuerefs) {
123: this .valuerefs = valuerefs;
124: }
125:
126: public String[] getValueRefs() {
127: return valuerefs;
128: }
129: }
|