new CharacterStreamDescriptor.Builder().bufferable(true).
byteLength(byteLength).charLength(charLength).
curBytePos(curBytePos).curCharPos(curCharPos).
dataOffset(dataOffset).maxCharLength(maxCharLen).
stream(emptyStream);
CharacterStreamDescriptor csd1 = b1.build();
CharacterStreamDescriptor.Builder b2 =
new CharacterStreamDescriptor.Builder().copyState(csd1);
CharacterStreamDescriptor csd2 = b2.build();
// Test the values.
assertEquals(csd2.isBufferable(), csd1.isBufferable());
assertEquals(csd2.isPositionAware(), csd1.isPositionAware());
assertEquals(csd2.getDataOffset(), csd1.getDataOffset());
assertEquals(csd2.getCurBytePos(), csd1.getCurBytePos());
assertEquals(csd2.getCurCharPos(), csd1.getCurCharPos());
assertEquals(csd2.getByteLength(), csd1.getByteLength());
assertEquals(csd2.getCharLength(), csd1.getCharLength());
assertEquals(csd2.getMaxCharLength(), csd1.getMaxCharLength());
assertTrue(csd2.getStream() == csd1.getStream());
// Override one value.
CharacterStreamDescriptor.Builder b3 =
new CharacterStreamDescriptor.Builder().copyState(csd1).
maxCharLength(8765);
CharacterStreamDescriptor csd3 = b3.build();
assertEquals(8765, csd3.getMaxCharLength());
// Demonstrate that copying the state after setting a value explicitly
// overwrites the the set value.
CharacterStreamDescriptor.Builder b4 =
new CharacterStreamDescriptor.Builder().
maxCharLength(8765).
copyState(csd1);
CharacterStreamDescriptor csd4 = b4.build();
assertEquals(csd1.getMaxCharLength(), csd4.getMaxCharLength());
}