Package org.ajax4jsf.io

Examples of org.ajax4jsf.io.FastBufferInputStream


            flushBuffers();

            if (stream != null) {
                ByteBuffer firstBuffer = stream.getFirstBuffer();
                firstBuffer.compact();
                return new FastBufferInputStream(firstBuffer);
            } else {
                return EMPTY_STREAM;
            }
        }
View Full Code Here


            }
        }
        ByteBuffer buffer = fbos.getFirstBuffer();
        buffer.compact();

        return new FastBufferInputStream(buffer);
    }
View Full Code Here

        this.content = readContent(resource.getInputStream());
    }

    @Override
    public InputStream getInputStream() throws IOException {
        return new FastBufferInputStream(content);
    }
View Full Code Here

    @Override
    public InputStream getInputStream() throws IOException {
        checkNotDeleted();

        return new FastBufferInputStream(buffer);
    }
View Full Code Here

     * Convert saved context to stream for parsing
     * @return stream from saved content
     */
    public InputStream getContentAsStream() {
      int length = 0;
      FastBufferInputStream result = null;     
        String encoding = this.getCharacterEncoding() ;
///        byte[] content;
        if (isUseStream()) {
          try {
        servletOutputStream.flush();
      } catch (IOException ex) {
        log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
      }
///      content = byteStream.toByteArray();     
      result = new FastBufferInputStream(byteStream);     
        } else if (isUseWriter()) {
      printWriter.flush();
      printWriter.close();
      length = stringWriter.getLength();
///      String stringContent = stringWriter.toString();
      try {
        FastBufferOutputStream stream = stringWriter.convertToOutputStream(encoding);
        result = new FastBufferInputStream(stream);
///        content = stringContent.getBytes(encoding);
      } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        log.warn(Messages.getMessage(Messages.UNSUPPORTED_ENCODING_WARNING));
        FastBufferOutputStream stream = stringWriter.convertToOutputStream();
        result = new FastBufferInputStream(stream);
///        content = stringContent.getBytes();
      }
    } else  {
            if (log.isDebugEnabled()) {
            log.debug(Messages.getMessage(Messages.NO_WRITER_CALLED_INFO));
View Full Code Here

     * Convert saved context to stream for parsing
     * @return stream from saved content
     */
    public InputStream getContentAsStream() {
      int length = 0;
      FastBufferInputStream result = null;     
        String encoding = this.getCharacterEncoding() ;
///        byte[] content;
        if (isUseStream()) {
          try {
        servletOutputStream.flush();
      } catch (IOException ex) {
        log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
      }
///      content = byteStream.toByteArray();     
      result = new FastBufferInputStream(byteStream);     
        } else if (isUseWriter()) {
      printWriter.flush();
      printWriter.close();
      length = stringWriter.getLength();
///      String stringContent = stringWriter.toString();
      try {
        FastBufferOutputStream stream = stringWriter.convertToOutputStream(encoding);
        result = new FastBufferInputStream(stream);
///        content = stringContent.getBytes(encoding);
      } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        log.warn(Messages.getMessage(Messages.UNSUPPORTED_ENCODING_WARNING));
        FastBufferOutputStream stream = stringWriter.convertToOutputStream();
        result = new FastBufferInputStream(stream);
///        content = stringContent.getBytes();
      }
    } else  {
            if (log.isDebugEnabled()) {
            log.debug(Messages.getMessage(Messages.NO_WRITER_CALLED_INFO));
View Full Code Here

        // write it one more time by one byte
        for (int i = 0; i < bytes.length; i++) {
            output.write(bytes[i]);
        }

        FastBufferInputStream input = new FastBufferInputStream(output);
        StringBuffer sb = new StringBuffer();

        // use for reading unconvenient array length.
        byte[] bs = new byte[ARRAY_LENGTH];
        int l = 0;

        while ((l = input.read(bs, READ_OFF, READ_LENGTH)) >= 0) {
            if (BUILD_STRING) {
                sb.append(new String(bs, READ_OFF, l));
            }
        }
View Full Code Here

        for (int i = 0; i < bytes.length; i++) {
            output.write(bytes[i]);
        }

        FastBufferOutputStream output2 = output.convertToOutputStream("UTF-8");
        FastBufferInputStream input = new FastBufferInputStream(output2);
        StringBuffer sb = new StringBuffer();

        // use for reading unconvenient array length.
        byte[] bs = new byte[ARRAY_LENGTH];
        int l = 0;

        while ((l = input.read(bs, READ_OFF, READ_LENGTH)) >= 0) {
            if (BUILD_STRING) {
                sb.append(new String(bs, READ_OFF, l));
            }
        }
View Full Code Here

     * Convert saved context to stream for parsing
     * @return stream from saved content
     */
    public InputStream getContentAsStream() {
      int length = 0;
      FastBufferInputStream result = null;     
        String encoding = this.getCharacterEncoding() ;
///        byte[] content;
        if (isUseStream()) {
          try {
        servletOutputStream.flush();
      } catch (IOException ex) {
        log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
      }
///      content = byteStream.toByteArray();     
      result = new FastBufferInputStream(byteStream);     
        } else if (isUseWriter()) {
      printWriter.flush();
      printWriter.close();
      length = stringWriter.getLength();
///      String stringContent = stringWriter.toString();
      try {
        FastBufferOutputStream stream = stringWriter.convertToOutputStream(encoding);
        result = new FastBufferInputStream(stream);
///        content = stringContent.getBytes(encoding);
      } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        log.warn(Messages.getMessage(Messages.UNSUPPORTED_ENCODING_WARNING));
        FastBufferOutputStream stream = stringWriter.convertToOutputStream();
        result = new FastBufferInputStream(stream);
///        content = stringContent.getBytes();
      }
    } else  {
            if (log.isDebugEnabled()) {
            log.debug(Messages.getMessage(Messages.NO_WRITER_CALLED_INFO));
View Full Code Here

     * Convert saved context to stream for parsing
     * @return stream from saved content
     */
    public InputStream getContentAsStream() {
      int length = 0;
      FastBufferInputStream result = null;     
        String encoding = this.getCharacterEncoding() ;
///        byte[] content;
        if (isUseStream()) {
          try {
        servletOutputStream.flush();
      } catch (IOException ex) {
        log.warn(Messages.getMessage(Messages.FLUSH_BUFFERED_STREAM_ERROR), ex);
      }
///      content = byteStream.toByteArray();     
      result = new FastBufferInputStream(byteStream);     
        } else if (isUseWriter()) {
      printWriter.flush();
      printWriter.close();
      length = stringWriter.getLength();
///      String stringContent = stringWriter.toString();
      try {
        FastBufferOutputStream stream = stringWriter.convertToOutputStream(encoding);
        result = new FastBufferInputStream(stream);
///        content = stringContent.getBytes(encoding);
      } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        log.warn(Messages.getMessage(Messages.UNSUPPORTED_ENCODING_WARNING));
        FastBufferOutputStream stream = stringWriter.convertToOutputStream();
        result = new FastBufferInputStream(stream);
///        content = stringContent.getBytes();
      }
    } else  {
            if (log.isDebugEnabled()) {
            log.debug(Messages.getMessage(Messages.NO_WRITER_CALLED_INFO));
View Full Code Here

TOP

Related Classes of org.ajax4jsf.io.FastBufferInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.