com.sun.xml.rpc.sp.StreamingParserFactory Maven / Gradle / Ivy
/*
* Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package com.sun.xml.rpc.sp;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/**
* Factory class for creating demand-driven parsers.
*
* In typical use an instance of this class is created and configured, and then
* it is used to create parser instances as required, like so:
*
*
* StreamingParserFactory spf
* = StreamingParserFactory.newInstance();
* pf.setValidating(true);
* pf.setCoalescing(false);
* StreamingParser sp = spf.newParser(in);
*
* @author Mark Reinhold
* @author JAX-RPC RI Development Team
*/
public abstract class StreamingParserFactory {
protected StreamingParserFactory() {
}
/**
* Creates a new factory of demand-driven parsers.
*/
public static StreamingParserFactory newInstance() {
return new com.sun.xml.rpc.sp.StreamingParserFactoryImpl();
}
/**
* Sets the validating property of this factory.
*
* @param validating
* Parsers henceforth created by this factory will perform
* validation if, and only if, this parameter is true
*
* @throws UnsupportedOperationException
* If the parser implementation does not support the requested
* value
*/
public abstract void setValidating(boolean validating);
/**
* Returns the validating property of this factory.
*
* @return true if, and only if, all parsers henceforth created
* by this factory will perform validation
*/
public abstract boolean isValidating();
/**
* Sets the coalescing property of this factory. If coalescing is
* enabled then the parser will always coalesce adjacent runs of character
* data, i.e., the {@link StreamingParser#CHARS} state will never occur
* more than once in sequence.
*
* @param coalescing
* Parsers henceforth created by this factory will coalesce
* character data if, and only if, this parameter is true
*
* @throws UnsupportedOperationException
* If the parser implementation does not support the requested
* value
*/
public abstract void setCoalescing(boolean coalescing);
/**
* Returns the coalescing property of this factory.
*
* @return true if, and only if, all parsers henceforth created
* by this factory will coalesce adjacent runs of character data
*/
public abstract boolean isCoalescing();
/**
* Sets the namespaceAware property of this factory.
*
* @param namespaceAware
* Parsers henceforth created by this factory will support
* namespace if, and only if, this parameter is true
*
* @throws UnsupportedOperationException
* If the parser implementation does not support the requested
* value
*/
public abstract void setNamespaceAware(boolean namespaceAware);
/**
* Returns the namespaceAware property of this factory.
*
* @return true if, and only if, all parsers henceforth created
* by this factory will support namespace
*/
public abstract boolean isNamespaceAware();
/**
* Creates a new parser instance that reads from the given input stream.
* No parsing is done by this method; the {@link StreamingParser#parse
* parse} method of the resulting parser must be invoked to parse the
* initial component of the input document.
*
* @param in
* The input stream from which the XML document will be read
*/
public abstract StreamingParser newParser(InputStream in);
/**
* Creates a new demand-driven parser that reads from the given file. No
* parsing is done by this constructor; the {@link StreamingParser#parse
* parse} method must be invoked to parse the initial component of the
* given document.
*
* @param file
* The file from which the XML document will be read
*
* @throws IOException
* If an I/O error occurs
*/
public abstract StreamingParser newParser(File file) throws IOException;
}