1 16 package org.apache.cocoon.woody.formmodel; 17 18 import org.apache.excalibur.xml.sax.XMLizable; 19 import org.apache.oro.text.regex.Pattern; 20 21 import org.outerj.expression.Expression; 22 23 import java.util.ArrayList ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 27 32 public class AggregateFieldDefinition extends FieldDefinition { 33 34 37 private Expression combineExpr; 38 39 43 private String splitRegexp; 44 45 48 private Pattern splitPattern; 49 50 54 protected XMLizable splitFailMessage; 55 56 60 private List splitMappings = new ArrayList (); 61 62 65 private ContainerDefinitionDelegate container = new ContainerDefinitionDelegate(this); 66 67 68 public void addWidgetDefinition(WidgetDefinition widgetDefinition) throws DuplicateIdException { 69 container.addWidgetDefinition(widgetDefinition); 70 } 71 72 public boolean hasWidget(String id) { 73 return container.hasWidget(id); 74 } 75 76 protected void setCombineExpression(Expression expression) { 77 combineExpr = expression; 78 } 79 80 public Expression getCombineExpression() { 81 return combineExpr; 82 } 83 84 protected void setSplitPattern(Pattern pattern, String regexp) { 85 this.splitPattern = pattern; 86 this.splitRegexp = regexp; 87 } 88 89 public Pattern getSplitPattern() { 90 return splitPattern; 91 } 92 93 public String getSplitRegexp() { 94 return splitRegexp; 95 } 96 97 public XMLizable getSplitFailMessage() { 98 return splitFailMessage; 99 } 100 101 protected void setSplitFailMessage(XMLizable splitFailMessage) { 102 this.splitFailMessage = splitFailMessage; 103 } 104 105 protected void addSplitMapping(int group, String fieldId) { 106 splitMappings.add(new SplitMapping(group, fieldId)); 107 } 108 109 public Iterator getSplitMappingsIterator() { 110 return splitMappings.iterator(); 111 } 112 113 public Widget createInstance() { 114 AggregateField aggregateField = new AggregateField(this); 115 116 Iterator fieldDefinitionIt = container.getWidgetDefinitions().iterator(); 117 while (fieldDefinitionIt.hasNext()) { 118 FieldDefinition fieldDefinition = (FieldDefinition)fieldDefinitionIt.next(); 119 aggregateField.addField((Field)fieldDefinition.createInstance()); 120 } 121 122 return aggregateField; 123 } 124 125 public static class SplitMapping { 126 private int group; 127 private String fieldId; 128 129 public SplitMapping(int group, String fieldId) { 130 this.group = group; 131 this.fieldId = fieldId; 132 } 133 134 public int getGroup() { 135 return group; 136 } 137 138 public String getFieldId() { 139 return fieldId; 140 } 141 } 142 } 143 | Popular Tags |