/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>If this constructor is used to process a stylesheet, normally * setSystemId should also be called, so that relative URI references * can be resolved.</p> * * @param inputStream A valid InputStream reference to an XML stream. */ public StreamSource(InputStream inputStream) { setInputStream(inputStream); }
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so that * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>This constructor allows the systemID to be set in addition * to the input stream, which allows relative URIs * to be processed.</p> * * @param inputStream A valid InputStream reference to an XML stream. * @param systemId Must be a String that conforms to the URI syntax. */ public StreamSource(InputStream inputStream, String systemId) { setInputStream(inputStream); setSystemId(systemId); }
is.setEncoding(StandardCharsets.UTF_8.name()); StreamSource source = new StreamSource(new InputStreamReader(entityStream, StandardCharsets.UTF_8)); source.setInputStream(entityStream); return (T) unmarshaller.unmarshal(source);
is.setEncoding(StandardCharsets.UTF_8.name()); StreamSource source = new StreamSource(new InputStreamReader(entityStream, StandardCharsets.UTF_8)); source.setInputStream(entityStream); obj = unmarshaller.unmarshal(source);
is.setEncoding(StandardCharsets.UTF_8.name()); StreamSource source = new StreamSource(new InputStreamReader(entityStream, StandardCharsets.UTF_8)); source.setInputStream(entityStream); result = unmarshaller.unmarshal(source, (Class<?>) typeArg);
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>If this constructor is used to process a stylesheet, normally * setSystemId should also be called, so that relative URI references * can be resolved.</p> * * @param inputStream A valid InputStream reference to an XML stream. */ public StreamSource(InputStream inputStream) { setInputStream(inputStream); }
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>If this constructor is used to process a stylesheet, normally * setSystemId should also be called, so that relative URI references * can be resolved.</p> * * @param inputStream A valid InputStream reference to an XML stream. */ public StreamSource(InputStream inputStream) { setInputStream(inputStream); }
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>If this constructor is used to process a stylesheet, normally * setSystemId should also be called, so that relative URI references * can be resolved.</p> * * @param inputStream A valid InputStream reference to an XML stream. */ public StreamSource(InputStream inputStream) { setInputStream(inputStream); }
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>If this constructor is used to process a stylesheet, normally * setSystemId should also be called, so that relative URI references * can be resolved.</p> * * @param inputStream A valid InputStream reference to an XML stream. */ public StreamSource(InputStream inputStream) { setInputStream(inputStream); }
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>If this constructor is used to process a stylesheet, normally * setSystemId should also be called, so that relative URI references * can be resolved.</p> * * @param inputStream A valid InputStream reference to an XML stream. */ public StreamSource(InputStream inputStream) { setInputStream(inputStream); }
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>If this constructor is used to process a stylesheet, normally * setSystemId should also be called, so that relative URI references * can be resolved.</p> * * @param inputStream A valid InputStream reference to an XML stream. */ public StreamSource(InputStream inputStream) { setInputStream(inputStream); }
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>If this constructor is used to process a stylesheet, normally * setSystemId should also be called, so that relative URI references * can be resolved.</p> * * @param inputStream A valid InputStream reference to an XML stream. */ public StreamSource(InputStream inputStream) { setInputStream(inputStream); }
/** * Create a Source from the String. The string must be in UTF-8 format, * otherwise, the Source is not created. * * @param msg * an UTF-8 String * @return the Source built from the String, null if not an UTF-8 */ private Source createSource(final String msg) throws IOException { StreamSource source = new StreamSource(); byte[] msgByte = msg.getBytes("UTF-8"); ByteArrayInputStream in = new ByteArrayInputStream(msgByte); source.setInputStream(in); return source; }
/** * Create a Source from the String. The string must be in UTF-8 format, * otherwise, the Source is not created. * * @param msg * an UTF-8 String * @return the Source built from the String, null if not an UTF-8 */ private Source createSource(final String msg) throws IOException { StreamSource source = new StreamSource(); byte[] msgByte = msg.getBytes("UTF-8"); ByteArrayInputStream in = new ByteArrayInputStream(msgByte); source.setInputStream(in); return source; }
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so that * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>This constructor allows the systemID to be set in addition * to the input stream, which allows relative URIs * to be processed.</p> * * @param inputStream A valid InputStream reference to an XML stream. * @param systemId Must be a String that conforms to the URI syntax. */ public StreamSource(InputStream inputStream, String systemId) { setInputStream(inputStream); setSystemId(systemId); }
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so that * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>This constructor allows the systemID to be set in addition * to the input stream, which allows relative URIs * to be processed.</p> * * @param inputStream A valid InputStream reference to an XML stream. * @param systemId Must be a String that conforms to the URI syntax. */ public StreamSource(InputStream inputStream, String systemId) { setInputStream(inputStream); setSystemId(systemId); }
/** * Construct a StreamSource from a byte stream. Normally, * a stream should be used rather than a reader, so that * the XML parser can resolve character encoding specified * by the XML declaration. * * <p>This constructor allows the systemID to be set in addition * to the input stream, which allows relative URIs * to be processed.</p> * * @param inputStream A valid InputStream reference to an XML stream. * @param systemId Must be a String that conforms to the URI syntax. */ public StreamSource(InputStream inputStream, String systemId) { setInputStream(inputStream); setSystemId(systemId); }
private XMLStreamReader createXMLStreamReader(InputSource source) throws UnmarshalException { StreamSource streamSource = new StreamSource(); streamSource.setSystemId(source.getSystemId()); streamSource.setPublicId(source.getPublicId()); streamSource.setInputStream(source.getByteStream()); streamSource.setReader(source.getCharacterStream()); XMLStreamReader streamReader = createXMLStreamReader(streamSource); return streamReader; }
private XMLStreamReader createXMLStreamReader(InputSource source) throws UnmarshalException { StreamSource streamSource = new StreamSource(); streamSource.setSystemId(source.getSystemId()); streamSource.setPublicId(source.getPublicId()); streamSource.setInputStream(source.getByteStream()); streamSource.setReader(source.getCharacterStream()); XMLStreamReader streamReader = createXMLStreamReader(streamSource); return streamReader; }
private static final Source forkStreamSource(final StreamSource source) throws IOException { InputStreamForker streamForker; if (source.getInputStream() != null) { streamForker = new InputStreamForker(source.getInputStream()); } else { streamForker = new InputStreamForker(new ReaderInputStream(source.getReader())); } source.setInputStream(streamForker.fork()); return new StreamSource(streamForker.fork()); }