Class DataHelper


  • public final class DataHelper
    extends java.lang.Object
    A help for dealing with BLOB and CLOB data
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] extractBytes​(java.io.InputStream inputStream)
      Extract by bytes from the given stream.
      static byte[] extractBytes​(java.io.InputStream inputStream, long start, int length)
      Extract a portion of the bytes from the given stream.
      static java.lang.String extractString​(java.io.Reader reader)
      Extract the contents of the given reader/stream as a string.
      static java.lang.String extractString​(java.io.Reader reader, int lengthHint)
      Extract the contents of the given reader/stream as a string.
      static java.lang.String extractString​(java.sql.Clob value)
      Extract the contents of the given Clob as a string.
      static boolean isNClob​(java.lang.Class type)  
      static java.io.InputStream subStream​(java.io.InputStream inputStream, long start, int length)
      Extract a portion of the bytes from the given stream, wrapping them in a new stream.
      static java.lang.Object subStream​(java.io.Reader characterStream, long start, int length)
      Extract a portion of a reader, wrapping the portion in a new reader.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • isNClob

        public static boolean isNClob​(java.lang.Class type)
      • extractString

        public static java.lang.String extractString​(java.io.Reader reader)
        Extract the contents of the given reader/stream as a string. The reader will be closed.
        Parameters:
        reader - The reader for the content
        Returns:
        The content as string
      • extractString

        public static java.lang.String extractString​(java.io.Reader reader,
                                                     int lengthHint)
        Extract the contents of the given reader/stream as a string. The reader will be closed.
        Parameters:
        reader - The reader for the content
        lengthHint - if the length is known in advance the implementation can be slightly more efficient
        Returns:
        The content as string
      • subStream

        public static java.lang.Object subStream​(java.io.Reader characterStream,
                                                 long start,
                                                 int length)
        Extract a portion of a reader, wrapping the portion in a new reader.
        Parameters:
        characterStream - The reader for the content
        start - The start position/offset (0-based, per general stream/reader contracts).
        length - The amount to extract
        Returns:
        The content portion as a reader
      • extractBytes

        public static byte[] extractBytes​(java.io.InputStream inputStream)
        Extract by bytes from the given stream.
        Parameters:
        inputStream - The stream of bytes.
        Returns:
        The contents as a byte[]
      • extractBytes

        public static byte[] extractBytes​(java.io.InputStream inputStream,
                                          long start,
                                          int length)
        Extract a portion of the bytes from the given stream.
        Parameters:
        inputStream - The stream of bytes.
        start - The start position/offset (0-based, per general stream/reader contracts).
        length - The amount to extract
        Returns:
        The extracted bytes
      • subStream

        public static java.io.InputStream subStream​(java.io.InputStream inputStream,
                                                    long start,
                                                    int length)
        Extract a portion of the bytes from the given stream, wrapping them in a new stream.
        Parameters:
        inputStream - The stream of bytes.
        start - The start position/offset (0-based, per general stream/reader contracts).
        length - The amount to extract
        Returns:
        The extracted bytes as a stream
      • extractString

        public static java.lang.String extractString​(java.sql.Clob value)
        Extract the contents of the given Clob as a string.
        Parameters:
        value - The clob to to be extracted from
        Returns:
        The content as string