1 5 6 package org.infohazard.maverick.transform; 7 8 import org.infohazard.maverick.flow.*; 9 import org.infohazard.maverick.util.XML; 10 import javax.servlet.*; 11 import org.jdom.Element; 12 13 14 44 public class DocumentTransformFactory implements TransformFactory 45 { 46 49 protected static final String DEFAULT_DEFAULT_WRAPPED_NAME = "wrapped"; 50 51 54 protected static final String ATTR_DEFAULT_WRAPPED_NAME = "default-bean-name"; 55 56 57 60 protected static final String ATTR_PATH = "path"; 61 protected static final String ATTR_BEAN = "bean"; 62 63 64 68 protected String defaultWrappedName = DEFAULT_DEFAULT_WRAPPED_NAME; 69 70 72 public void init(Element factoryNode, ServletConfig servletCfg) throws ConfigException 73 { 74 if (factoryNode != null) 75 { 76 String wrappedNameStr = XML.getValue(factoryNode, ATTR_DEFAULT_WRAPPED_NAME); 78 if (wrappedNameStr != null) 79 this.defaultWrappedName = wrappedNameStr; 80 } 81 } 82 83 85 public Transform createTransform(Element transformNode) throws ConfigException 86 { 87 String path = XML.getValue(transformNode, ATTR_PATH); 88 if (path == null) 89 throw new ConfigException("Document transform node must have a \"" 90 + ATTR_PATH + "\" attribute: " 91 + XML.toString(transformNode)); 92 93 String wrappedName = XML.getValue(transformNode, ATTR_BEAN); 94 if (wrappedName == null) 95 wrappedName = this.defaultWrappedName; 96 97 return new DocumentTransform(path, wrappedName); 98 } 99 } | Popular Tags |