Package org.tmatesoft.hg.internal

Examples of org.tmatesoft.hg.internal.NewlineFilter.filter()


    FileOutputStream fos = new FileOutputStream(new File("/temp/design.newline.out"));
    ByteBuffer b = ByteBuffer.allocate(12);
    NewlineFilter nlFilter = NewlineFilter.createNix2Win(true);
    while (fis.getChannel().read(b) != -1) {
      b.flip(); // get ready to be read
      ByteBuffer f = nlFilter.filter(b);
      fos.getChannel().write(f); // XXX in fact, f may not be fully consumed
      if (b.hasRemaining()) {
        b.compact();
      } else {
        b.clear();
View Full Code Here


    ByteBuffer res = ByteBuffer.allocate(i1.length + i2.length); // at most of the original size
    nlFilter.preview(ByteBuffer.wrap(i1));
    nlFilter.preview(ByteBuffer.wrap(i2));
    //
    input.put(i1).flip();
    res.put(nlFilter.filter(input));
    Assert.assertTrue("Unpocessed chars shall be left in input buffer", input.remaining() > 0);
    input.compact();
    input.put(i2);
    input.flip();
    res.put(nlFilter.filter(input));
View Full Code Here

    res.put(nlFilter.filter(input));
    Assert.assertTrue("Unpocessed chars shall be left in input buffer", input.remaining() > 0);
    input.compact();
    input.put(i2);
    input.flip();
    res.put(nlFilter.filter(input));
    Assert.assertTrue("Input shall be consumed completely", input.remaining() == 0);
    //
    res.flip();
    byte[] result = new byte[res.remaining()];
    res.get(result);
View Full Code Here

    // preview requred
    nlFilter.preview(input);
    nlFilter.preview(ByteBuffer.wrap(i2));
    // input.position(0); correctly written preview shall not affect buffer position
    //
    res.put(nlFilter.filter(input));
    Assert.assertTrue("Unpocessed chars shall be left in input buffer", input.remaining() > 0);
    input.compact();
    input.put(i2);
    input.flip();
    res.put(nlFilter.filter(input));
View Full Code Here

    res.put(nlFilter.filter(input));
    Assert.assertTrue("Unpocessed chars shall be left in input buffer", input.remaining() > 0);
    input.compact();
    input.put(i2);
    input.flip();
    res.put(nlFilter.filter(input));
    Assert.assertTrue("Input shall be consumed completely", input.remaining() == 0);
    res.flip();
    result = new byte[res.remaining()];
    res.get(result);
    Assert.assertArrayEquals(lf_1.getBytes(), result);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.