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


Java StreamSource.getInputStream方法代码示例

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


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

示例1: processSource

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
protected Source processSource(Source source) {
	if (source instanceof StreamSource) {
		StreamSource streamSource = (StreamSource) source;
		InputSource inputSource = new InputSource(streamSource.getInputStream());
		try {
			XMLReader xmlReader = XMLReaderFactory.createXMLReader();
			String featureName = "http://xml.org/sax/features/external-general-entities";
			xmlReader.setFeature(featureName, isProcessExternalEntities());
			if (!isProcessExternalEntities()) {
				xmlReader.setEntityResolver(NO_OP_ENTITY_RESOLVER);
			}
			return new SAXSource(xmlReader, inputSource);
		}
		catch (SAXException ex) {
			logger.warn("Processing of external entities could not be disabled", ex);
			return source;
		}
	}
	else {
		return source;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:Jaxb2RootElementHttpMessageConverter.java

示例2: jaxpSourcetoXMLInputSource

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
XMLInputSource jaxpSourcetoXMLInputSource(Source source){
     if(source instanceof StreamSource){
         StreamSource stSource = (StreamSource)source;
         String systemId = stSource.getSystemId();
         String publicId = stSource.getPublicId();
         InputStream istream = stSource.getInputStream();
         Reader reader = stSource.getReader();

         if(istream != null){
             return new XMLInputSource(publicId, systemId, null, istream, null);
         }
         else if(reader != null){
             return new XMLInputSource(publicId, systemId,null, reader, null);
         }else{
             return new XMLInputSource(publicId, systemId, null);
         }
     }

     throw new UnsupportedOperationException("Cannot create " +
            "XMLStreamReader or XMLEventReader from a " +
            source.getClass().getName());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:XMLInputFactoryImpl.java

示例3: jaxpSourcetoXMLInputSource

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
XMLInputSource jaxpSourcetoXMLInputSource(Source source){
     if(source instanceof StreamSource){
         StreamSource stSource = (StreamSource)source;
         String systemId = stSource.getSystemId();
         String publicId = stSource.getPublicId();
         InputStream istream = stSource.getInputStream();
         Reader reader = stSource.getReader();

         if(istream != null){
             return new XMLInputSource(publicId, systemId, null, istream, null);
         }
         else if(reader != null){
             return new XMLInputSource(publicId, systemId,null, reader, null);
         }else{
             return new XMLInputSource(publicId, systemId, null, false);
         }
     }

     throw new UnsupportedOperationException("Cannot create " +
            "XMLStreamReader or XMLEventReader from a " +
            source.getClass().getName());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:XMLInputFactoryImpl.java

示例4: getContent

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
public Source getContent() throws SOAPException {
    if (source != null) {
        InputStream bis = null;
        if (source instanceof JAXMStreamSource) {
            StreamSource streamSource = (StreamSource)source;
            bis = streamSource.getInputStream();
        } else if (FastInfosetReflection.isFastInfosetSource(source)) {
            // FastInfosetSource inherits from SAXSource
            SAXSource saxSource = (SAXSource)source;
            bis = saxSource.getInputSource().getByteStream();
        }

        if (bis != null) {
            try {
                bis.reset();
            } catch (IOException e) {
                /* This exception will never be thrown.
                 *
                 * The setContent method will modify the source
                 * if StreamSource to JAXMStreamSource, that uses
                 * a ByteInputStream, and for a FastInfosetSource will
                 * replace the InputStream with a ByteInputStream.
                 */
            }
        }
        return source;
    }

    return ((Envelope) getEnvelope()).getContent();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:31,代码来源:SOAPPartImpl.java

示例5: toXMLInputSource

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
/**
 * Creates a proper {@link XMLInputSource} from a {@link StreamSource}.
 *
 * @return always return non-null valid object.
 */
public static final XMLInputSource toXMLInputSource( StreamSource in ) {
    if( in.getReader()!=null )
        return new XMLInputSource(
        in.getPublicId(), in.getSystemId(), in.getSystemId(),
        in.getReader(), null );
    if( in.getInputStream()!=null )
        return new XMLInputSource(
        in.getPublicId(), in.getSystemId(), in.getSystemId(),
        in.getInputStream(), null );

    return new XMLInputSource(
    in.getPublicId(), in.getSystemId(), in.getSystemId() );
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Util.java

示例6: transformSummaryToHTML

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
/**
 * Transform summary information to HTML.
 *
 * @param htmlWriter the Writer to write the HTML output to
 */
public void transformSummaryToHTML(Writer htmlWriter)
        throws IOException, TransformerException {

	ByteArrayOutputStream summaryOut = new ByteArrayOutputStream(8096);
	reportSummary(summaryOut);
	String summaryXML = summaryOut.toString();


	StreamSource in = new StreamSource(new StringReader(summaryXML));
	StreamResult out = new StreamResult(htmlWriter);
	InputStream xslInputStream = this.getClass().getClassLoader().getResourceAsStream("summary.xsl");
	if (xslInputStream == null)
		throw new IOException("Could not load summary stylesheet");
	StreamSource xsl = new StreamSource(xslInputStream);

	TransformerFactory tf = TransformerFactory.newInstance();
	Transformer transformer = tf.newTransformer(xsl);
	transformer.transform(in, out);

	Reader rdr = in.getReader();
	if (rdr != null)
		rdr.close();
	htmlWriter.close();
	InputStream is = xsl.getInputStream();
	if (is != null)
		is.close();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:ProjectStats.java

示例7: closeHard

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
/**
 * Helper method to close StreamSource
 * @param source
 */
private void closeHard(final StreamSource source) {
  try {
    if (source != null) {
      if (source.getInputStream() != null) IoUtils.closeHard(source.getInputStream());
      if (source.getReader() != null) IoUtils.closeHard(source.getReader());
    }
  } catch (Exception e) {
    IoUtils.ignoreExpectedException(e);
  }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:15,代码来源:AbstractXSLRendererComponent.java

示例8: getContent

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
@Override
public Source getContent() throws SOAPException {
    if (source != null) {
        InputStream bis = null;
        if (source instanceof JAXMStreamSource) {
            StreamSource streamSource = (StreamSource)source;
            bis = streamSource.getInputStream();
        } else if (FastInfosetReflection.isFastInfosetSource(source)) {
            // FastInfosetSource inherits from SAXSource
            SAXSource saxSource = (SAXSource)source;
            bis = saxSource.getInputSource().getByteStream();
        }

        if (bis != null) {
            try {
                bis.reset();
            } catch (IOException e) {
                /* This exception will never be thrown.
                 *
                 * The setContent method will modify the source
                 * if StreamSource to JAXMStreamSource, that uses
                 * a ByteInputStream, and for a FastInfosetSource will
                 * replace the InputStream with a ByteInputStream.
                 */
            }
        }
        return source;
    }

    return ((Envelope) getEnvelope()).getContent();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:SOAPPartImpl.java

示例9: toXMLInputSource

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
/**
 * Creates a proper {@link XMLInputSource} from a {@link StreamSource}.
 *
 * @return always return non-null valid object.
 */
public static final XMLInputSource toXMLInputSource( StreamSource in ) {
    if( in.getReader()!=null )
        return new XMLInputSource(
        in.getPublicId(), in.getSystemId(), in.getSystemId(),
        in.getReader(), null );
    if( in.getInputStream()!=null )
        return new XMLInputSource(
        in.getPublicId(), in.getSystemId(), in.getSystemId(),
        in.getInputStream(), null );

    return new XMLInputSource(
    in.getPublicId(), in.getSystemId(), in.getSystemId(), false );
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:Util.java

示例10: createSourceReader

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
public static XMLStreamReader createSourceReader(Source source, boolean rejectDTDs, String charsetName) {
    try {
        if (source instanceof StreamSource) {
            StreamSource streamSource = (StreamSource) source;
            InputStream is = streamSource.getInputStream();

            if (is != null) {
                // Wrap input stream in Reader if charset is specified
                if (charsetName != null) {
                    return XMLStreamReaderFactory.create(
                        source.getSystemId(), new InputStreamReader(is, charsetName), rejectDTDs);
                }
                else {
                    return XMLStreamReaderFactory.create(
                        source.getSystemId(), is, rejectDTDs);
                }
            }
            else {
                Reader reader = streamSource.getReader();
                if (reader != null) {
                    return XMLStreamReaderFactory.create(
                        source.getSystemId(), reader, rejectDTDs);
                }
                else {
                    return XMLStreamReaderFactory.create(
                        source.getSystemId(), new URL(source.getSystemId()).openStream(), rejectDTDs );
                }
            }
        }
        else if (source.getClass() == fastInfosetSourceClass) {
            return FastInfosetUtil.createFIStreamReader((InputStream)
                fastInfosetSource_getInputStream.invoke(source));
        }
        else if (source instanceof DOMSource) {
            DOMStreamReader dsr =  new DOMStreamReader();
            dsr.setCurrentNode(((DOMSource) source).getNode());
            return dsr;
        }
        else if (source instanceof SAXSource) {
            // TODO: need SAX to StAX adapter here -- Use transformer for now
            Transformer tx =  XmlUtil.newTransformer();
            DOMResult domResult = new DOMResult();
            tx.transform(source, domResult);
            return createSourceReader(
                new DOMSource(domResult.getNode()),
                rejectDTDs);
        }
        else {
            throw new XMLReaderException("sourceReader.invalidSource",
                    source.getClass().getName());
        }
    }
    catch (Exception e) {
        throw new XMLReaderException(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:57,代码来源:SourceReaderFactory.java

示例11: getInputStreamFromSource

import javax.xml.transform.stream.StreamSource; //导入方法依赖的package包/类
private InputStream getInputStreamFromSource(StreamSource s)
    throws TransformerException {

    InputStream stream = s.getInputStream();
    if (stream != null)
        return stream;

    if (s.getReader() != null)
        return null;

    String systemId = s.getSystemId();
    if (systemId != null) {
        try {
            String fileURL = systemId;

            if (systemId.startsWith("file:///"))
            {
                /*
                 systemId is:
                 file:///<drive>:/some/path/file.xml
                 or
                 file:///some/path/file.xml
                */

                String absolutePath = systemId.substring(7);
                /*
                 /<drive>:/some/path/file.xml
                 or
                 /some/path/file.xml
                */

                boolean hasDriveDesignator = absolutePath.indexOf(":") > 0;
                if (hasDriveDesignator) {
                  String driveDesignatedPath = absolutePath.substring(1);
                  /*
                  <drive>:/some/path/file.xml */
                  fileURL = driveDesignatedPath;
                }
                else {
                  /*
                  /some/path/file.xml */
                  fileURL = absolutePath;
                }
            }
            //return new FileInputStream(fileURL);
            try {
                return new FileInputStream(new File(new URI(fileURL)));
            } catch (URISyntaxException ex) {
                throw new TransformerException(ex);
            }
        } catch (IOException e) {
            throw new TransformerException(e.toString());
        }
    }

    throw new TransformerException("Unexpected StreamSource object");
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:58,代码来源:EfficientStreamingTransformer.java


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