当前位置: 首页>>代码示例>>Java>>正文


Java InputSource.getByteStream方法代码示例

本文整理汇总了Java中org.xml.sax.InputSource.getByteStream方法的典型用法代码示例。如果您正苦于以下问题:Java InputSource.getByteStream方法的具体用法?Java InputSource.getByteStream怎么用?Java InputSource.getByteStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xml.sax.InputSource的用法示例。


在下文中一共展示了InputSource.getByteStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getByteStream

import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Override
public InputStream getByteStream() {
	final InputStream originalInputStream = inputSource.getByteStream();
	if (originalInputStream == null) {
		return null;
	} else {
		try {
			InputSource resolvedEntity = this.entityResolver.resolveEntity(
					getPublicId(), getSystemId());
			if (resolvedEntity != null) {
				return resolvedEntity.getByteStream();
			} else {
				return originalInputStream;
			}
		} catch (IOException ioex) {
			return originalInputStream;
		} catch (SAXException saxex) {
			return originalInputStream;
		}
	}
}
 
开发者ID:CodeFX-org,项目名称:java-9-wtf,代码行数:22,代码来源:ReResolvingInputSourceWrapper.java

示例2: close

import org.xml.sax.InputSource; //导入方法依赖的package包/类
public static void close(InputSource inputSource) {
    if (inputSource == null) {
        // Nothing to do
        return;
    }

    InputStream is = inputSource.getByteStream();
    if (is != null) {
        try {
            is.close();
        } catch (Throwable t) {
            ExceptionUtils.handleThrowable(t);
        }
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:InputSourceUtil.java

示例3: parse

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * parse the given inputSource with a new Parser
 * @param inputSource
 * @return the document parsed from the input Source
 */
public static Document parse(InputSource inputSource) throws SAXException,IOException {
	DocumentBuilder db=newParser();
	try {
		Document doc=db.parse(inputSource);
	return doc;  			
	} catch (java.net.MalformedURLException mue) {
		if (EXCEPTION_DEBUG) {
			String msg=mue.getMessage();
			if (msg!=null) {
				System.err.println(msg);
			}	
			InputStream is=inputSource.getByteStream();
			is.reset();
			String content=parseISToString(is);
			System.err.println(content);
		}	
		throw mue;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:HttpUnitUtils.java

示例4: init

import org.xml.sax.InputSource; //导入方法依赖的package包/类
public void init(InputSource in, String name, InputEntity stack,
                 boolean isPE)
        throws IOException, SAXException {

    input = in;
    this.isPE = isPE;
    reader = in.getCharacterStream();

    if (reader == null) {
        InputStream bytes = in.getByteStream();

        if (bytes == null)
            reader = XmlReader.createReader(new URL(in.getSystemId())
                    .openStream());
        else if (in.getEncoding() != null)
            reader = XmlReader.createReader(in.getByteStream(),
                    in.getEncoding());
        else
            reader = XmlReader.createReader(in.getByteStream());
    }
    next = stack;
    buf = new char[BUFSIZ];
    this.name = name;
    checkRecursion(stack);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:InputEntity.java

示例5: parse

import org.xml.sax.InputSource; //导入方法依赖的package包/类
public void parse(InputSource input) throws IOException, SAXException {
    try {
        InputStream s = input.getByteStream();
        if (s == null) {
            String systemId = input.getSystemId();
            if (systemId == null) {
                throw new SAXException(CommonResourceBundle.getInstance().getString("message.inputSource"));
            }
            parse(systemId);
        } else {
            parse(s);
        }
    } catch (FastInfosetException e) {
        logger.log(Level.FINE, "parsing error", e);
        throw new SAXException(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:SAXDocumentParser.java

示例6: close

import org.xml.sax.InputSource; //导入方法依赖的package包/类
public static void close(InputSource inputSource) {
	if (inputSource == null) {
		// Nothing to do
		return;
	}

	InputStream is = inputSource.getByteStream();
	if (is != null) {
		try {
			is.close();
		} catch (Throwable t) {
			ExceptionUtils.handleThrowable(t);
		}
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:17,代码来源:InputSourceUtil.java

示例7: resolveEntity

import org.xml.sax.InputSource; //导入方法依赖的package包/类
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    InputSource source = core.resolveEntity(publicId,systemId);
    if(source==null)
        return null;    // default

    // ideally entity resolvers should be giving us the system ID for the resource
    // (or otherwise we won't be able to resolve references within this imported WSDL correctly),
    // but if none is given, the system ID before the entity resolution is better than nothing.
    if(source.getSystemId()!=null)
        systemId = source.getSystemId();

    URL url = new URL(systemId);
    InputStream stream;
    if (useStreamFromEntityResolver) {
            stream = source.getByteStream();
    } else {
            stream = url.openStream();
    }
    return new Parser(url,
            new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:22,代码来源:EntityResolverWrapper.java

示例8: createXMLInputSource

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * Creates an XMLInputSource from a SAX InputSource.
 */
private XMLInputSource createXMLInputSource(InputSource source, String baseURI) {

    String publicId = source.getPublicId();
    String systemId = source.getSystemId();
    String baseSystemId = baseURI;
    InputStream byteStream = source.getByteStream();
    Reader charStream = source.getCharacterStream();
    String encoding = source.getEncoding();
    XMLInputSource xmlInputSource =
        new XMLInputSource(publicId, systemId, baseSystemId);
    xmlInputSource.setByteStream(byteStream);
    xmlInputSource.setCharacterStream(charStream);
    xmlInputSource.setEncoding(encoding);
    return xmlInputSource;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:EntityResolver2Wrapper.java

示例9: saxToXMLInputSource

import org.xml.sax.InputSource; //导入方法依赖的package包/类
private static XMLInputSource saxToXMLInputSource(InputSource sis) {
    String publicId = sis.getPublicId();
    String systemId = sis.getSystemId();

    Reader charStream = sis.getCharacterStream();
    if (charStream != null) {
        return new XMLInputSource(publicId, systemId, null, charStream,
                null);
    }

    InputStream byteStream = sis.getByteStream();
    if (byteStream != null) {
        return new XMLInputSource(publicId, systemId, null, byteStream,
                sis.getEncoding());
    }

    return new XMLInputSource(publicId, systemId, null);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:XMLSchemaLoader.java

示例10: init

import org.xml.sax.InputSource; //导入方法依赖的package包/类
public void init(InputSource in, String name, InputEntity stack,
                 boolean isPE)
        throws IOException, SAXException {

    input = in;
    this.isPE = isPE;
    reader = in.getCharacterStream();

    if (reader == null) {
        InputStream bytes = in.getByteStream();

        if (bytes == null)
            if (Boolean.valueOf(System.getProperty("enableExternalEntityProcessing")))
                reader = XmlReader.createReader(new URL(in.getSystemId()).openStream());
            else
                fatal("P-082", new Object[] {in.getSystemId()});
        else if (in.getEncoding() != null)
            reader = XmlReader.createReader(in.getByteStream(), in.getEncoding());
        else
            reader = XmlReader.createReader(in.getByteStream());
    }
    next = stack;
    buf = new char[BUFSIZ];
    this.name = name;
    checkRecursion(stack);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:InputEntity.java

示例11: create

import org.xml.sax.InputSource; //导入方法依赖的package包/类
public static XMLStreamReader create(InputSource source, boolean rejectDTDs) {
    try {
        // Char stream available?
        if (source.getCharacterStream() != null) {
            return get().doCreate(source.getSystemId(), source.getCharacterStream(), rejectDTDs);
        }

        // Byte stream available?
        if (source.getByteStream() != null) {
            return get().doCreate(source.getSystemId(), source.getByteStream(), rejectDTDs);
        }

        // Otherwise, open URI
        return get().doCreate(source.getSystemId(), new URL(source.getSystemId()).openStream(),rejectDTDs);
    } catch (IOException e) {
        throw new XMLReaderException("stax.cantCreate",e);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:XMLStreamReaderFactory.java

示例12: createXMLInputSource

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * Creates an XMLInputSource from a SAX InputSource.
 */
private XMLInputSource createXMLInputSource(InputSource source, String baseURI) {

    String publicId = source.getPublicId();
    String systemId = source.getSystemId();
    String baseSystemId = baseURI;
    InputStream byteStream = source.getByteStream();
    Reader charStream = source.getCharacterStream();
    String encoding = source.getEncoding();
    XMLInputSource xmlInputSource =
        new XMLInputSource(publicId, systemId, baseSystemId, false);
    xmlInputSource.setByteStream(byteStream);
    xmlInputSource.setCharacterStream(charStream);
    xmlInputSource.setEncoding(encoding);
    return xmlInputSource;

}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:EntityResolver2Wrapper.java

示例13: saxToXMLInputSource

import org.xml.sax.InputSource; //导入方法依赖的package包/类
private static XMLInputSource saxToXMLInputSource(InputSource sis) {
    String publicId = sis.getPublicId();
    String systemId = sis.getSystemId();

    Reader charStream = sis.getCharacterStream();
    if (charStream != null) {
        return new XMLInputSource(publicId, systemId, null, charStream,
                null);
    }

    InputStream byteStream = sis.getByteStream();
    if (byteStream != null) {
        return new XMLInputSource(publicId, systemId, null, byteStream,
                sis.getEncoding());
    }

    return new XMLInputSource(publicId, systemId, null, false);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:XMLSchemaLoader.java

示例14: resolveEntity

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * Resolves an external parsed entity. If the entity cannot be
 * resolved, this method should return null.
 *
 * @param resourceIdentifier        contains the physical co-ordinates of the resource to be resolved
 *
 * @throws XNIException Thrown on general error.
 * @throws IOException  Thrown if resolved entity stream cannot be
 *                      opened or some other i/o error occurs.
 */
public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier)
    throws XNIException, IOException {

    // When both pubId and sysId are null, the user's entity resolver
    // can do nothing about it. We'd better not bother calling it.
    // This happens when the resourceIdentifier is a GrammarDescription,
    // which describes a schema grammar of some namespace, but without
    // any schema location hint. -Sg
    String pubId = resourceIdentifier.getPublicId();
    String sysId = resourceIdentifier.getExpandedSystemId();
    if (pubId == null && sysId == null)
        return null;

    // resolve entity using SAX entity resolver
    if (fEntityResolver != null && resourceIdentifier != null) {
        try {
            InputSource inputSource = fEntityResolver.resolveEntity(pubId, sysId);
            if (inputSource != null) {
                String publicId = inputSource.getPublicId();
                String systemId = inputSource.getSystemId();
                String baseSystemId = resourceIdentifier.getBaseSystemId();
                InputStream byteStream = inputSource.getByteStream();
                Reader charStream = inputSource.getCharacterStream();
                String encoding = inputSource.getEncoding();
                XMLInputSource xmlInputSource =
                    new XMLInputSource(publicId, systemId, baseSystemId);
                xmlInputSource.setByteStream(byteStream);
                xmlInputSource.setCharacterStream(charStream);
                xmlInputSource.setEncoding(encoding);
                return xmlInputSource;
            }
        }

        // error resolving entity
        catch (SAXException e) {
            Exception ex = e.getException();
            if (ex == null) {
                ex = e;
            }
            throw new XNIException(ex);
        }
    }

    // unable to resolve entity
    return null;

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:58,代码来源:EntityResolverWrapper.java

示例15: parseSomeSetup

import org.xml.sax.InputSource; //导入方法依赖的package包/类
private boolean parseSomeSetup(InputSource source)
        throws SAXException, IOException, IllegalAccessException,
                                 java.lang.reflect.InvocationTargetException,
                                 java.lang.InstantiationException
{
        if(fConfigSetInput!=null)
        {
                // Obtain input from SAX inputSource object, construct XNI version of
                // that object. Logic adapted from Xerces2.
                Object[] parms1={source.getPublicId(),source.getSystemId(),null};
                Object xmlsource=fConfigInputSourceCtor.newInstance(parms1);
                Object[] parmsa={source.getByteStream()};
                fConfigSetByteStream.invoke(xmlsource,parmsa);
                parmsa[0]=source.getCharacterStream();
                fConfigSetCharStream.invoke(xmlsource,parmsa);
                parmsa[0]=source.getEncoding();
                fConfigSetEncoding.invoke(xmlsource,parmsa);

                // Bugzilla5272 patch suggested by Sandy Gao.
                // Has to be reflection to run with Xerces2
                // after compilation against Xerces1. or vice
                // versa, due to return type mismatches.
                Object[] noparms=new Object[0];
                fReset.invoke(fIncrementalParser,noparms);

                parmsa[0]=xmlsource;
                fConfigSetInput.invoke(fPullParserConfig,parmsa);

                // %REVIEW% Do first pull. Should we instead just return true?
                return parseSome();
        }
        else
        {
                Object[] parm={source};
                Object ret=fParseSomeSetup.invoke(fIncrementalParser,parm);
                return ((Boolean)ret).booleanValue();
        }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:IncrementalSAXSource_Xerces.java


注:本文中的org.xml.sax.InputSource.getByteStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。