1 19 package org.enhydra.zeus.transform; 20 21 import java.util.HashMap ; 22 import java.io.IOException ; 23 import java.util.List ; 24 import java.util.Map ; 25 26 import org.enhydra.zeus.Source; 28 import org.enhydra.zeus.Transformer; 29 import org.enhydra.zeus.ZeusException; 30 import org.enhydra.zeus.transform.ValueEnumeration; 31 32 54 public abstract class BaseTransformer implements Transformer { 55 56 57 protected Source source; 58 59 60 private TransformerOptions transformerOptions; 61 62 63 private Map valueEnumerations; 64 65 74 public BaseTransformer(Source source) { 75 if ((source == null) && !(this instanceof DefaultsTransformer)) { 77 throw new IllegalArgumentException ("A Transformer cannot have " + 78 "a null Source."); 79 } 80 this.source = source; 81 82 transformerOptions = new TransformerOptions(); 84 valueEnumerations = new HashMap (); 85 } 86 87 95 public void setTransformerOptions(TransformerOptions transformerOptions) { 96 if (transformerOptions == null) { 97 throw new IllegalArgumentException ("A Transformer cannot " + 98 "have a null set of TransformerOptions."); 99 } 100 this.transformerOptions = transformerOptions; 101 } 102 103 112 public TransformerOptions getTransformerOptions() { 113 return transformerOptions; 114 } 115 116 124 public void addValueEnumeration(ValueEnumeration valueEnumeration) { 125 if (valueEnumeration == null) { 126 throw new IllegalArgumentException ("A Transformer cannot have " + 127 "a null ValueEnumeration."); 128 } 129 valueEnumerations.put(valueEnumeration.getName(), valueEnumeration); 130 } 131 132 151 public ValueEnumeration getValueEnumeration(String name) 152 throws NoSuchValueEnumerationException { 153 154 ValueEnumeration valueEnumeration = 155 (ValueEnumeration)valueEnumerations.get(name); 156 157 if (valueEnumeration == null) { 159 throw new NoSuchValueEnumerationException(name); 160 } 161 162 return valueEnumeration; 164 } 165 166 192 public List transform(List bindings) throws IOException , ZeusException { 193 return transform(bindings, false); 195 } 196 197 224 public abstract List transform(List bindings, boolean recursing) 225 throws IOException , ZeusException; 226 227 } 228 | Popular Tags |