当前位置: 首页>>代码示例>>Java>>正文


Java InvalidMarkException类代码示例

本文整理汇总了Java中java.nio.InvalidMarkException的典型用法代码示例。如果您正苦于以下问题:Java InvalidMarkException类的具体用法?Java InvalidMarkException怎么用?Java InvalidMarkException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InvalidMarkException类属于java.nio包,在下文中一共展示了InvalidMarkException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testClear

import java.nio.InvalidMarkException; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "clear",
    args = {}
)
public void testClear() {
    // save state
    int oldPosition = baseBuf.position();
    int oldLimit = baseBuf.limit();

    Buffer ret = baseBuf.clear();
    assertSame(ret, baseBuf);
    assertEquals(0, baseBuf.position());
    assertEquals(baseBuf.limit(), baseBuf.capacity());
    try {
        baseBuf.reset();
        fail("Should throw Exception");
    } catch (InvalidMarkException e) {
        // expected
    }

    // restore state
    baseBuf.limit(oldLimit);
    baseBuf.position(oldPosition);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:27,代码来源:AbstractBufferTest.java

示例2: testRewind

import java.nio.InvalidMarkException; //导入依赖的package包/类
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "",
    method = "rewind",
    args = {}
)
public void testRewind() {
    // save state
    int oldPosition = baseBuf.position();
    int oldLimit = baseBuf.limit();

    Buffer ret = baseBuf.rewind();
    assertEquals(0, baseBuf.position());
    assertSame(ret, baseBuf);
    try {
        baseBuf.reset();
        fail("Should throw Exception");
    } catch (InvalidMarkException e) {
        // expected
    }

    // restore state
    baseBuf.limit(oldLimit);
    baseBuf.position(oldPosition);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:26,代码来源:AbstractBufferTest.java

示例3: reset

import java.nio.InvalidMarkException; //导入依赖的package包/类
/**
 * Similar to {@link ByteBuffer}.reset(), ensures that this MBB
 * is reset back to last marked position.
 * @return This MBB
 */
@Override
public MultiByteBuff reset() {
  // when the buffer is moved to the next one.. the reset should happen on the previous marked
  // item and the new one should be taken as the base
  if (this.markedItemIndex < 0) throw new InvalidMarkException();
  ByteBuffer markedItem = this.items[this.markedItemIndex];
  markedItem.reset();
  this.curItem = markedItem;
  // All items after the marked position upto the current item should be reset to 0
  for (int i = this.curItemIndex; i > this.markedItemIndex; i--) {
    this.items[i].position(0);
  }
  this.curItemIndex = this.markedItemIndex;
  return this;
}
 
开发者ID:apache,项目名称:hbase,代码行数:21,代码来源:MultiByteBuff.java

示例4: testClear

import java.nio.InvalidMarkException; //导入依赖的package包/类
public void testClear() {
    // save state
    int oldPosition = baseBuf.position();
    int oldLimit = baseBuf.limit();

    Buffer ret = baseBuf.clear();
    assertSame(ret, baseBuf);
    assertEquals(baseBuf.position(), 0);
    assertEquals(baseBuf.limit(), baseBuf.capacity());
    try {
        baseBuf.reset();
        fail("Should throw Exception"); //$NON-NLS-1$S
    } catch (InvalidMarkException e) {
        // expected
    }

    // restore state
    baseBuf.limit(oldLimit);
    baseBuf.position(oldPosition);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:AbstractBufferTest.java

示例5: testFlip

import java.nio.InvalidMarkException; //导入依赖的package包/类
public void testFlip() {
    // save state
    int oldPosition = baseBuf.position();
    int oldLimit = baseBuf.limit();

    Buffer ret = baseBuf.flip();
    assertSame(ret, baseBuf);
    assertEquals(baseBuf.position(), 0);
    assertEquals(baseBuf.limit(), oldPosition);
    try {
        baseBuf.reset();
        fail("Should throw Exception"); //$NON-NLS-1$
    } catch (InvalidMarkException e) {
        // expected
    }

    // restore state
    baseBuf.limit(oldLimit);
    baseBuf.position(oldPosition);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:AbstractBufferTest.java

示例6: testRewind

import java.nio.InvalidMarkException; //导入依赖的package包/类
public void testRewind() {
    // save state
    int oldPosition = baseBuf.position();
    int oldLimit = baseBuf.limit();

    Buffer ret = baseBuf.rewind();
    assertEquals(baseBuf.position(), 0);
    assertSame(ret, baseBuf);
    try {
        baseBuf.reset();
        fail("Should throw Exception"); //$NON-NLS-1$
    } catch (InvalidMarkException e) {
        // expected
    }

    // restore state
    baseBuf.limit(oldLimit);
    baseBuf.position(oldPosition);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:AbstractBufferTest.java

示例7: testClear

import java.nio.InvalidMarkException; //导入依赖的package包/类
public static void testClear(Buffer buf) {
    // save state
    int oldPosition = buf.position();
    int oldLimit = buf.limit();

    Buffer ret = buf.clear();
    assertSame(ret, buf);
    assertEquals(buf.position(), 0);
    assertEquals(buf.limit(), buf.capacity());
    try {
        buf.reset();
        fail("Should throw Exception"); //$NON-NLS-1$
    } catch (InvalidMarkException e) {
        // expected
    }

    // restore state
    buf.limit(oldLimit);
    buf.position(oldPosition);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:BufferTest.java

示例8: testFlip

import java.nio.InvalidMarkException; //导入依赖的package包/类
public static void testFlip(Buffer buf) {
    // save state
    int oldPosition = buf.position();
    int oldLimit = buf.limit();

    Buffer ret = buf.flip();
    assertSame(ret, buf);
    assertEquals(buf.position(), 0);
    assertEquals(buf.limit(), oldPosition);
    try {
        buf.reset();
        fail("Should throw Exception"); //$NON-NLS-1$
    } catch (InvalidMarkException e) {
        // expected
    }

    // restore state
    buf.limit(oldLimit);
    buf.position(oldPosition);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:BufferTest.java

示例9: testRewind

import java.nio.InvalidMarkException; //导入依赖的package包/类
public static void testRewind(Buffer buf) {
    // save state
    int oldPosition = buf.position();
    int oldLimit = buf.limit();
    
    Buffer ret = buf.rewind();
    assertEquals(buf.position(), 0);
    assertSame(ret, buf);
    try {
        buf.reset();
        fail("Should throw Exception"); //$NON-NLS-1$
    } catch (InvalidMarkException e) {
        // expected
    }

    // restore state
    buf.limit(oldLimit);
    buf.position(oldPosition);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:BufferTest.java

示例10: allocatesSimple

import java.nio.InvalidMarkException; //导入依赖的package包/类
@Test
public void allocatesSimple() {
    LongBuffer buffer = LongBuffer.allocate(100);
    assertThat(buffer.isDirect(), is(false));
    assertThat(buffer.isReadOnly(), is(false));
    assertThat(buffer.hasArray(), is(true));
    assertThat(buffer.capacity(), is(100));
    assertThat(buffer.position(), is(0));
    assertThat(buffer.limit(), is(100));
    try {
        buffer.reset();
        fail("Mark is expected to be undefined");
    } catch (InvalidMarkException e) {
        // ok
    }
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:17,代码来源:LongBufferTest.java

示例11: wrapsArray

import java.nio.InvalidMarkException; //导入依赖的package包/类
@Test
public void wrapsArray() {
    long[] array = new long[100];
    LongBuffer buffer = LongBuffer.wrap(array, 10, 70);
    assertThat(buffer.isDirect(), is(false));
    assertThat(buffer.isReadOnly(), is(false));
    assertThat(buffer.hasArray(), is(true));
    assertThat(buffer.array(), is(array));
    assertThat(buffer.arrayOffset(), is(0));
    assertThat(buffer.capacity(), is(100));
    assertThat(buffer.position(), is(10));
    assertThat(buffer.limit(), is(80));
    try {
        buffer.reset();
        fail("Mark is expected to be undefined");
    } catch (InvalidMarkException e) {
        // ok
    }
    array[0] = 23;
    assertThat(buffer.get(0), is((long) 23));
    buffer.put(1, 24);
    assertThat(array[1], is((long) 24));
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:24,代码来源:LongBufferTest.java

示例12: compacts

import java.nio.InvalidMarkException; //导入依赖的package包/类
@Test
public void compacts() {
    long[] array = { 2, 3, 5, 7 };
    LongBuffer buffer = LongBuffer.wrap(array);
    buffer.get();
    buffer.mark();
    buffer.compact();
    assertThat(array, is(new long[] { 3, 5, 7, 7 }));
    assertThat(buffer.position(), is(3));
    assertThat(buffer.limit(), is(4));
    assertThat(buffer.capacity(), is(4));
    try {
        buffer.reset();
        fail("Exception expected");
    } catch (InvalidMarkException e) {
        // ok
    }
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:19,代码来源:LongBufferTest.java

示例13: allocatesSimple

import java.nio.InvalidMarkException; //导入依赖的package包/类
@Test
public void allocatesSimple() {
    ShortBuffer buffer = ShortBuffer.allocate(100);
    assertThat(buffer.isDirect(), is(false));
    assertThat(buffer.isReadOnly(), is(false));
    assertThat(buffer.hasArray(), is(true));
    assertThat(buffer.capacity(), is(100));
    assertThat(buffer.position(), is(0));
    assertThat(buffer.limit(), is(100));
    try {
        buffer.reset();
        fail("Mark is expected to be undefined");
    } catch (InvalidMarkException e) {
        // ok
    }
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:17,代码来源:ShortBufferTest.java

示例14: wrapsArray

import java.nio.InvalidMarkException; //导入依赖的package包/类
@Test
public void wrapsArray() {
    short[] array = new short[100];
    ShortBuffer buffer = ShortBuffer.wrap(array, 10, 70);
    assertThat(buffer.isDirect(), is(false));
    assertThat(buffer.isReadOnly(), is(false));
    assertThat(buffer.hasArray(), is(true));
    assertThat(buffer.array(), is(array));
    assertThat(buffer.arrayOffset(), is(0));
    assertThat(buffer.capacity(), is(100));
    assertThat(buffer.position(), is(10));
    assertThat(buffer.limit(), is(80));
    try {
        buffer.reset();
        fail("Mark is expected to be undefined");
    } catch (InvalidMarkException e) {
        // ok
    }
    array[0] = 23;
    assertThat(buffer.get(0), is((short) 23));
    buffer.put(1, (short) 24);
    assertThat(array[1], is((short) 24));
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:24,代码来源:ShortBufferTest.java

示例15: compacts

import java.nio.InvalidMarkException; //导入依赖的package包/类
@Test
public void compacts() {
    short[] array = { 2, 3, 5, 7 };
    ShortBuffer buffer = ShortBuffer.wrap(array);
    buffer.get();
    buffer.mark();
    buffer.compact();
    assertThat(array, is(new short[] { 3, 5, 7, 7 }));
    assertThat(buffer.position(), is(3));
    assertThat(buffer.limit(), is(4));
    assertThat(buffer.capacity(), is(4));
    try {
        buffer.reset();
        fail("Exception expected");
    } catch (InvalidMarkException e) {
        // ok
    }
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:19,代码来源:ShortBufferTest.java


注:本文中的java.nio.InvalidMarkException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。