Package freenet.support.io

Examples of freenet.support.io.NullBucket


    final Bucket descriptionBucket;
    try {
      if(description != null)
        descriptionBucket = new ArrayBucket(description.getBytes("UTF-8"));
      else
        descriptionBucket = new NullBucket();
    } catch (UnsupportedEncodingException e) {
      throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e);
    }
    buckets.put("Description", descriptionBucket);
  }
View Full Code Here


    final Bucket descriptionBucket;
    try {
      if(description != null)
        descriptionBucket = new ArrayBucket(description.getBytes("UTF-8"));
      else
        descriptionBucket = new NullBucket();
    } catch (UnsupportedEncodingException e) {
      throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e);
    }
    buckets.put("Description", descriptionBucket);
View Full Code Here

            extensionCheck = name.substring(idx);
        }
      }
    } else if(returnType == ReturnType.NONE) {
      targetFile = null;
      ret = new NullBucket();
    } else {
        targetFile = null;
        ret = null; // Let the ClientGetter allocate the Bucket later on.
    }
    this.extensionCheck = extensionCheck;
View Full Code Here

            extensionCheck = name.substring(idx);
        }
      }
    } else if(returnType == ReturnType.NONE) {
      targetFile = null;
      ret = new NullBucket();
        } else {
            targetFile = null;
            ret = null; // Let the ClientGetter allocate the Bucket later on.
    }
    this.extensionCheck = extensionCheck;
View Full Code Here

  }
 
  private ClientGetter makeGetter(Bucket ret) {
      return new ClientGetter(this,
                uri, fctx, priorityClass,
                binaryBlob ? new NullBucket() : ret, binaryBlob ? new BinaryBlobWriter(ret) : null, false, initialMetadata, extensionCheck);
  }
View Full Code Here

    } catch (NumberFormatException e) {
      throw new MessageInvalidException(ProtocolErrorMessage.ERROR_PARSING_NUMBER, "Could not parse DataLength: "+e.toString(), identifier, global);
    }
    try {
      if(length == 0)
        data = new NullBucket();
      else
        data = bf.makeBucket(length);
    } catch (IOException e) {
      throw new MessageInvalidException(ProtocolErrorMessage.INTERNAL_ERROR, "Internal error: could not allocate temp bucket: "+e.toString(), identifier, global);
    }
View Full Code Here

    final Bucket messageTextBucket;
    try {
      if(messageText != null)
        messageTextBucket = new ArrayBucket(messageText.getBytes("UTF-8"));
      else
        messageTextBucket = new NullBucket();
    } catch (UnsupportedEncodingException e) {
      throw new Error("Impossible: JVM doesn't support UTF-8: " + e, e);
    }
    buckets.put("MessageText", messageTextBucket);
  }
View Full Code Here

  @Override
  public void readFrom(InputStream is, BucketFactory bf, FCPServer server) throws IOException, MessageInvalidException {
    long len = dataLength();
    if(len < 0) return;
    if(len == 0) {
      bucket = new NullBucket();
      return;
    }
    RandomAccessBucket tempBucket;
    try {
      tempBucket = createBucket(bf, len, server);
View Full Code Here

        System.out.println(filename + " not found, test skipped");
        continue;
      }

      try {
        filter.readFilter(ib.getInputStream(), new NullBucket().getOutputStream(), "", null, null);

        assertTrue(filename + " should " + (valid ? "" : "not ") + "be valid", valid);
      } catch (DataFilterException dfe) {
        assertFalse(filename + " should " + (valid ? "" : "not ") + "be valid", valid);
      }
View Full Code Here

    }

    byte[] compressedData = doCompress(uncompressedData);

    Bucket inBucket = new ArrayBucket(compressedData);
    NullBucket outBucket = new NullBucket();
    InputStream decompressorInput = null;
    OutputStream decompressorOutput = null;

    try {
      decompressorInput = inBucket.getInputStream();
      decompressorOutput = outBucket.getOutputStream();
      Compressor.COMPRESSOR_TYPE.BZIP2.decompress(decompressorInput, decompressorOutput, 4096 + 10, 4096 + 20);
      decompressorInput.close();
      decompressorOutput.close();
    } catch (CompressionOutputSizeException e) {
      // expect this
      return;
    } finally {
      Closer.close(decompressorInput);
      Closer.close(decompressorOutput);
      inBucket.free();
      outBucket.free();
    }
    fail("did not throw expected CompressionOutputSizeException");

  }
View Full Code Here

TOP

Related Classes of freenet.support.io.NullBucket

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.