protected Reader getReader(Source source, ExecutionContext executionContext) { if(source instanceof StreamSource) { StreamSource streamSource = (StreamSource) source; if(streamSource.getReader() != null) { return streamSource.getReader(); } else if(streamSource.getInputStream() != null) { try { if(executionContext instanceof ExecutionContext) { return new InputStreamReader(streamSource.getInputStream(), executionContext.getContentEncoding()); } else { return new InputStreamReader(streamSource.getInputStream(), "UTF-8"); } } catch(UnsupportedEncodingException e) { throw new SmooksException("Unable to decode input stream.", e); } } else { throw new SmooksException("Invalid " + StreamSource.class.getName() + ". No InputStream or Reader instance."); } } return new NullReader(); }
protected Reader getReader(Source source, ExecutionContext executionContext) { if(source instanceof StreamSource) { StreamSource streamSource = (StreamSource) source; if(streamSource.getReader() != null) { return streamSource.getReader(); } else if(streamSource.getInputStream() != null) { try { if(executionContext instanceof ExecutionContext) { return new InputStreamReader(streamSource.getInputStream(), executionContext.getContentEncoding()); } else { return new InputStreamReader(streamSource.getInputStream(), "UTF-8"); } } catch(UnsupportedEncodingException e) { throw new SmooksException("Unable to decode input stream.", e); } } else { throw new SmooksException("Invalid " + StreamSource.class.getName() + ". No InputStream or Reader instance."); } } return new NullReader(); }
protected Reader getReader(Source source, ExecutionContext executionContext) { if(source instanceof StreamSource) { StreamSource streamSource = (StreamSource) source; if(streamSource.getReader() != null) { return streamSource.getReader(); } else if(streamSource.getInputStream() != null) { try { if(executionContext instanceof ExecutionContext) { return new InputStreamReader(streamSource.getInputStream(), executionContext.getContentEncoding()); } else { return new InputStreamReader(streamSource.getInputStream(), "UTF-8"); } } catch(UnsupportedEncodingException e) { throw new SmooksException("Unable to decode input stream.", e); } } else { throw new SmooksException("Invalid " + StreamSource.class.getName() + ". No InputStream or Reader instance."); } } return new NullReader(); }
protected Reader getReader(Source source, ExecutionContext executionContext) { if(source instanceof StreamSource) { StreamSource streamSource = (StreamSource) source; if(streamSource.getReader() != null) { return streamSource.getReader(); } else if(streamSource.getInputStream() != null) { try { if(executionContext instanceof ExecutionContext) { return new InputStreamReader(streamSource.getInputStream(), executionContext.getContentEncoding()); } else { return new InputStreamReader(streamSource.getInputStream(), "UTF-8"); } } catch(UnsupportedEncodingException e) { throw new SmooksException("Unable to decode input stream.", e); } } else { throw new SmooksException("Invalid " + StreamSource.class.getName() + ". No InputStream or Reader instance."); } } return new NullReader(); }
protected Writer getWriter(Result result, ExecutionContext executionContext) { if(!(result instanceof StreamResult)) { return new NullWriter(); } StreamResult streamResult = (StreamResult) result; if(streamResult.getWriter() != null) { return streamResult.getWriter(); } else if(streamResult.getOutputStream() != null) { try { if(executionContext instanceof ExecutionContext) { return new OutputStreamWriter(streamResult.getOutputStream(), executionContext.getContentEncoding()); } else { return new OutputStreamWriter(streamResult.getOutputStream(), "UTF-8"); } } catch(UnsupportedEncodingException e) { throw new SmooksException("Unable to encode output stream.", e); } } else { throw new SmooksException("Invalid " + StreamResult.class.getName() + ". No OutputStream or Writer instance."); } }
protected Writer getWriter(Result result, ExecutionContext executionContext) { if (!(result instanceof StreamResult)) { return new NullWriter(); } StreamResult streamResult = (StreamResult) result; if (streamResult.getWriter() != null) { return streamResult.getWriter(); } else if (streamResult.getOutputStream() != null) { try { if (executionContext != null) { return new OutputStreamWriter(streamResult.getOutputStream(), executionContext.getContentEncoding()); } else { return new OutputStreamWriter(streamResult.getOutputStream(), "UTF-8"); } } catch (UnsupportedEncodingException e) { throw new SmooksException("Unable to encode output stream.", e); } } else { throw new SmooksException("Invalid " + StreamResult.class.getName() + ". No OutputStream or Writer instance."); } }
protected Writer getWriter(Result result, ExecutionContext executionContext) { if (!(result instanceof StreamResult)) { return new NullWriter(); } StreamResult streamResult = (StreamResult) result; if (streamResult.getWriter() != null) { return streamResult.getWriter(); } else if (streamResult.getOutputStream() != null) { try { if (executionContext != null) { return new OutputStreamWriter(streamResult.getOutputStream(), executionContext.getContentEncoding()); } else { return new OutputStreamWriter(streamResult.getOutputStream(), "UTF-8"); } } catch (UnsupportedEncodingException e) { throw new SmooksException("Unable to encode output stream.", e); } } else { throw new SmooksException("Invalid " + StreamResult.class.getName() + ". No OutputStream or Writer instance."); } }
protected Writer getWriter(Result result, ExecutionContext executionContext) { if(!(result instanceof StreamResult)) { return new NullWriter(); } StreamResult streamResult = (StreamResult) result; if(streamResult.getWriter() != null) { return streamResult.getWriter(); } else if(streamResult.getOutputStream() != null) { try { if(executionContext instanceof ExecutionContext) { return new OutputStreamWriter(streamResult.getOutputStream(), executionContext.getContentEncoding()); } else { return new OutputStreamWriter(streamResult.getOutputStream(), "UTF-8"); } } catch(UnsupportedEncodingException e) { throw new SmooksException("Unable to encode output stream.", e); } } else { throw new SmooksException("Invalid " + StreamResult.class.getName() + ". No OutputStream or Writer instance."); } }
protected Writer getWriter(Result result, ExecutionContext executionContext) { if(!(result instanceof StreamResult)) { return new NullWriter(); } StreamResult streamResult = (StreamResult) result; if(streamResult.getWriter() != null) { return streamResult.getWriter(); } else if(streamResult.getOutputStream() != null) { try { if(executionContext instanceof ExecutionContext) { return new OutputStreamWriter(streamResult.getOutputStream(), executionContext.getContentEncoding()); } else { return new OutputStreamWriter(streamResult.getOutputStream(), "UTF-8"); } } catch(UnsupportedEncodingException e) { throw new SmooksException("Unable to encode output stream.", e); } } else { throw new SmooksException("Invalid " + StreamResult.class.getName() + ". No OutputStream or Writer instance."); } }
protected Writer getWriter(Result result, ExecutionContext executionContext) { if (!(result instanceof StreamResult)) { return new NullWriter(); } StreamResult streamResult = (StreamResult) result; if (streamResult.getWriter() != null) { return streamResult.getWriter(); } else if (streamResult.getOutputStream() != null) { try { if (executionContext != null) { return new OutputStreamWriter(streamResult.getOutputStream(), executionContext.getContentEncoding()); } else { return new OutputStreamWriter(streamResult.getOutputStream(), "UTF-8"); } } catch (UnsupportedEncodingException e) { throw new SmooksException("Unable to encode output stream.", e); } } else { throw new SmooksException("Invalid " + StreamResult.class.getName() + ". No OutputStream or Writer instance."); } }
protected Writer getWriter(Result result, ExecutionContext executionContext) { if(!(result instanceof StreamResult)) { return new NullWriter(); } StreamResult streamResult = (StreamResult) result; if(streamResult.getWriter() != null) { return streamResult.getWriter(); } else if(streamResult.getOutputStream() != null) { try { if(executionContext instanceof ExecutionContext) { return new OutputStreamWriter(streamResult.getOutputStream(), executionContext.getContentEncoding()); } else { return new OutputStreamWriter(streamResult.getOutputStream(), "UTF-8"); } } catch(UnsupportedEncodingException e) { throw new SmooksException("Unable to encode output stream.", e); } } else { throw new SmooksException("Invalid " + StreamResult.class.getName() + ". No OutputStream or Writer instance."); } }
protected Writer getWriter(Result result, ExecutionContext executionContext) { if (!(result instanceof StreamResult)) { return new NullWriter(); } StreamResult streamResult = (StreamResult) result; if (streamResult.getWriter() != null) { return streamResult.getWriter(); } else if (streamResult.getOutputStream() != null) { try { if (executionContext != null) { return new OutputStreamWriter(streamResult.getOutputStream(), executionContext.getContentEncoding()); } else { return new OutputStreamWriter(streamResult.getOutputStream(), "UTF-8"); } } catch (UnsupportedEncodingException e) { throw new SmooksException("Unable to encode output stream.", e); } } else { throw new SmooksException("Invalid " + StreamResult.class.getName() + ". No OutputStream or Writer instance."); } }
/** * Marshals the Object 'fromBody' to an OutputStream 'toStream' * </p> * <p/> * The Camel framework will call this method from {@link MarshalProcessor#process(Exchange)} * and it will take care of setting the Out Message's body to the bytes written to the toStream * OutputStream. * * @param exchange The Camel {@link Exchange}. * @param fromBody The object to be marshalled into the output stream. * @param toStream The output stream that will be written to. */ public void marshal(final Exchange exchange, final Object fromBody, final OutputStream toStream) throws Exception { final ExecutionContext execContext = smooks.createExecutionContext(); final TypeConverter typeConverter = exchange.getContext().getTypeConverter(); final JavaSource source = typeConverter.mandatoryConvertTo(JavaSource.class, exchange, fromBody); final StringResult stringResult = new StringResult(); smooks.filterSource(execContext, source, stringResult); toStream.write(stringResult.getResult().getBytes(execContext.getContentEncoding())); }
((HierarchyChangeReader)saxReader).setHierarchyChangeListener(new XMLReaderHierarchyChangeListener(executionContext)); saxReader.parse(createInputSource(source, executionContext.getContentEncoding())); } else { saxReader.parse(createInputSource(source, Charset.defaultCharset().name()));
((HierarchyChangeReader)saxReader).setHierarchyChangeListener(new XMLReaderHierarchyChangeListener(executionContext)); saxReader.parse(createInputSource(source, executionContext.getContentEncoding())); } else { saxReader.parse(createInputSource(source, Charset.defaultCharset().name()));
((HierarchyChangeReader)saxReader).setHierarchyChangeListener(new XMLReaderHierarchyChangeListener(executionContext)); saxReader.parse(createInputSource(source, executionContext.getContentEncoding())); } else { saxReader.parse(createInputSource(source, Charset.defaultCharset().name()));
((HierarchyChangeReader)saxReader).setHierarchyChangeListener(new XMLReaderHierarchyChangeListener(executionContext)); saxReader.parse(createInputSource(source, executionContext.getContentEncoding())); } else { saxReader.parse(createInputSource(source, Charset.defaultCharset().name()));
domReader.parse(createInputSource(source, executionContext.getContentEncoding())); } finally { try {
domReader.parse(createInputSource(source, executionContext.getContentEncoding())); } finally { try {
domReader.parse(createInputSource(source, executionContext.getContentEncoding())); } finally { try {