001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.components.validation.jaxp;
018:
019: import java.io.InputStream;
020: import java.io.Reader;
021:
022: import org.w3c.dom.ls.LSInput;
023: import org.xml.sax.InputSource;
024:
025: /**
026: * <p>An implementation of the {@link LSInput} interface wrapping a nested
027: * {@link InputSource}.</p>
028: *
029: */
030: public class JaxpInput implements LSInput {
031:
032: /** <p>The wrapped {@link InputSource} instance.</p> */
033: private final InputSource input;
034: /** <p>The flag to return by the {@link #getCertifiedText()} method.</p> */
035: private boolean cert = false;
036: /** <p>A string wrapping the data to parse.</p> */
037: private String data = null;
038: /** <p>The optional base URI for relative resolution.</p> */
039: private String base = null;
040:
041: /**
042: * <p>Create a new {@link JaxpInput} instance.</p>
043: *
044: * @param input a <b>non-null</b> {@link InputSource} instance to wrap.
045: * @throws NullPointerException if the {@link InputSource} was <b>null</b>.
046: */
047: public JaxpInput(InputSource input) {
048: if (input == null)
049: throw new NullPointerException("Null InputSource");
050: this .input = input;
051: }
052:
053: public Reader getCharacterStream() {
054: return this .input.getCharacterStream();
055: }
056:
057: public void setCharacterStream(Reader reader) {
058: this .input.setCharacterStream(reader);
059: }
060:
061: public InputStream getByteStream() {
062: return this .input.getByteStream();
063: }
064:
065: public void setByteStream(InputStream stream) {
066: this .input.setByteStream(stream);
067: }
068:
069: public String getStringData() {
070: return this .data;
071: }
072:
073: public void setStringData(String data) {
074: this .data = data;
075: }
076:
077: public String getSystemId() {
078: return this .input.getSystemId();
079: }
080:
081: public void setSystemId(String systemId) {
082: this .input.setSystemId(systemId);
083: }
084:
085: public String getPublicId() {
086: return this .input.getPublicId();
087: }
088:
089: public void setPublicId(String publicId) {
090: this .input.setPublicId(publicId);
091: }
092:
093: public String getBaseURI() {
094: if (this .base != null)
095: return this .base;
096: return this .input.getSystemId();
097: }
098:
099: public void setBaseURI(String base) {
100: this .base = base;
101: }
102:
103: public String getEncoding() {
104: return this .input.getEncoding();
105: }
106:
107: public void setEncoding(String encoding) {
108: this .input.setEncoding(encoding);
109: }
110:
111: public boolean getCertifiedText() {
112: return this .cert;
113: }
114:
115: public void setCertifiedText(boolean cert) {
116: this.cert = cert;
117: }
118: }
|