Package lombok

Examples of lombok.val


      throws IOException
  {
    if (maxChunkSize <= 0)
      throw new IllegalArgumentException("maxChunkSize=" + maxChunkSize);

    val length = data.length;

    if (length < maxChunkSize)
      stream.write(data, 0, length);
    else
    {
View Full Code Here


   */
  @Validate
  public static String readAllCharacters(@NotNull final InputStream stream, @NotNull final Charset streamEncoding)
      throws IOException
  {
    val data = readFully(stream, stream.available());
    return new String(data, streamEncoding);
  }
View Full Code Here

    if (length < 0)
      throw new IllegalArgumentException("length=" + length);
    if (length > Integer.MAX_VALUE)
      throw new IllegalArgumentException("length=" + length);

    val buffer = new byte[(int) length];
    readFully(stream, buffer, length);
    return buffer;
  }
View Full Code Here

      throws IOException
  {
    if (length < 0 || length > Integer.MAX_VALUE)
      throw new IllegalArgumentException("length=" + length);

    val buffer = new byte[(int) length];
    readFully(stream, buffer, length, maxChunkSize);
    return buffer;
  }
View Full Code Here

  @Validate
  public static void skipUntil(@NotNull final InputStream stream, @NotNull final String terminator, @NotNull final Charset streamEncoding)
      throws IOException
  {
    // this is the terminator string
    val terminatorCharBuffer = ByteBuffer.wrap(terminator.getBytes(streamEncoding)).asCharBuffer();

    // buffer holding the latest characters
    CharBuffer tempCharBuffer = CharBuffer.allocate(terminatorCharBuffer.length());

    // read the first batch
    for (int i = 0; i < terminatorCharBuffer.length(); i++)
      tempCharBuffer.put(readCharacter(stream, streamEncoding));

    // compare and read next until arrays hold equal values
    while (!(StringUtils.sequenceEqual(terminatorCharBuffer.array(), tempCharBuffer.array())))
    {
      // read next char
      val ch = readCharacter(stream, streamEncoding);

      // left shift elements in array, throw away the first read
      tempCharBuffer = CharBuffer.wrap(tempCharBuffer.subSequence(1, tempCharBuffer.length())).append(ch);
    }
  }
View Full Code Here

    };
  }

  static Method getSingleMethodIfExists(final Object obj, final String methodName)
  {
    val methods = ReflectionUtils.getMethods(obj.getClass(), methodName, false);
    if (methods.length > 1)
      throw new IllegalArgumentException("Found multiple method overloads for " + obj.getClass() + "." + methodName);
    if (methods.length <= 0)
      throw new IllegalArgumentException("Could not find method " + obj.getClass() + "." + methodName);
View Full Code Here

      throws IOException
  {
    while (true)
    {
      // read next byte
      val read = stream.read();

      // check status
      if (read >= 0)
      {
        if ((byte) read == terminator)
View Full Code Here

  @Validate
  public static void skipUntil(@NotNull final InputStream stream, @NotNull final byte[] terminator)
      throws IOException
  {
    // buffer holding the latest bytes
    val tempBuffer = new byte[terminator.length];

    // read the first batch
    for (int i = 0; i < tempBuffer.length; i++)
    {
      val read = stream.read();

      // check status
      if (read >= 0)
        tempBuffer[i] = (byte) read;
      else
        throw new IOException(String.format(EOF_EXCEPTION_MESSAGE_BYTES, tempBuffer.length - i));
    }

    // compare and read next until arrays hold equal values
    while (!(ByteArrayUtils.sequenceEqual(tempBuffer, terminator)))
    {
      // read next byte
      val read = stream.read();

      // check status
      if (read >= 0)
      {
        // left shift elements in array, throw away the first read
View Full Code Here

  @Validate
  public static String readUntil(final InputStream stream, final char terminator, @NotNull final Charset streamEncoding)
      throws IOException
  {
    char ch;
    val sb = new StringBuilder(256);

    while ((ch = readCharacter(stream, streamEncoding)) != terminator)
      sb.append(ch);

    return sb.toString();
  }
View Full Code Here

  @Validate
  public static String
      readUntil(@NotNull final InputStream stream, @NotNull final String terminator, @NotNull final Charset streamEncoding)
          throws IOException
  {
    val result = new StringBuilder(256);

    // this is the terminator string
    val terminatorCharBuffer = CharBuffer.wrap(terminator.toCharArray());

    // buffer holding the latest characters read
    CharBuffer tempCharBuffer = CharBuffer.allocate(terminatorCharBuffer.length());

    // read the first batch to fill the buffer
    for (int i = 0; i < terminatorCharBuffer.length(); i++)
      tempCharBuffer.put(readCharacter(stream, streamEncoding));

    // compare and read next until arrays hold equal values
    while (!(StringUtils.sequenceEqual(terminatorCharBuffer.array(), tempCharBuffer.array())))
    {
      // read next char
      val ch = readCharacter(stream, streamEncoding);

      // left shift elements in array, throw away the first read
      tempCharBuffer = CharBuffer.wrap(tempCharBuffer.subSequence(1, tempCharBuffer.length())).append(ch);

      // add to result string
View Full Code Here

TOP

Related Classes of lombok.val

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.