1 package net.sf.saxon; 2 3 import net.sf.saxon.om.Validation; 4 import net.sf.saxon.event.ProxyReceiver; 5 import org.xml.sax.XMLReader ; 6 7 import javax.xml.transform.Source ; 8 import javax.xml.transform.sax.SAXSource ; 9 import java.util.List ; 10 import java.util.ArrayList ; 11 12 19 20 public class AugmentedSource implements Source { 21 22 private Source source; 23 private int schemaValidation = Validation.DEFAULT; 24 private XMLReader parser = null; 25 private Boolean wrapDocument = null; 26 private List filters = null; 27 28 34 35 private AugmentedSource(Source source) { 36 if (source instanceof AugmentedSource) { 37 throw new IllegalArgumentException ("Contained source must not be an AugmentedSource"); 38 } 39 this.source = source; 40 } 41 42 47 48 public static AugmentedSource makeAugmentedSource(Source source) { 49 if (source instanceof AugmentedSource) { 50 return (AugmentedSource)source; 51 } 52 return new AugmentedSource(source); 53 } 54 55 58 59 public void addFilter(ProxyReceiver filter) { 60 if (filters == null) { 61 filters = new ArrayList (5); 62 } 63 filters.add(filter); 64 } 65 66 69 70 public List getFilters() { 71 return filters; 72 } 73 74 78 79 public Source getContainedSource() { 80 return source; 81 } 82 83 90 91 public void setSchemaValidationMode(int option) { 92 schemaValidation = option; 93 } 94 95 100 101 public int getSchemaValidation() { 102 return schemaValidation; 103 } 104 105 public void setXMLReader(XMLReader parser) { 106 this.parser = parser; 107 if (source instanceof SAXSource ) { 108 ((SAXSource )source).setXMLReader(parser); 109 } 110 } 111 112 public XMLReader getXMLReader() { 113 if (parser != null) { 114 return parser; 115 } else if (source instanceof SAXSource ) { 116 return ((SAXSource )source).getXMLReader(); 117 } else { 118 return null; 119 } 120 } 121 122 128 129 public void setWrapDocument(Boolean wrap) { 130 this.wrapDocument = wrap; 131 } 132 133 139 140 public Boolean getWrapDocument() { 141 return wrapDocument; 142 } 143 144 148 149 public void setSystemId(String id) { 150 source.setSystemId(id); 151 } 152 153 157 158 public String getSystemId() { 159 return source.getSystemId(); 160 } 161 } 162 163 | Popular Tags |