本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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
}
}
示例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));
}
示例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
}
}
示例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
}
}
示例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));
}
示例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
}
}