diff --git a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/LabelBuilder.java b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/LabelBuilder.java index c1a186d69..f8572fdca 100644 --- a/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/LabelBuilder.java +++ b/metafacture-biblio/src/main/java/org/metafacture/biblio/iso2709/LabelBuilder.java @@ -124,7 +124,7 @@ void setSystemChars(final char[] systemChars) { void setSystemChar(final int index, final char value) { assert 0 <= index && index < SYSTEM_CHARS_LENGTH; - buffer.setWritePosition(SYSTEM_CHARS_LENGTH + index); + buffer.setWritePosition(SYSTEM_CHARS_START + index); buffer.writeChar(value); } diff --git a/metafacture-biblio/src/test/java/org/metafacture/biblio/iso2709/RecordBuilderTest.java b/metafacture-biblio/src/test/java/org/metafacture/biblio/iso2709/RecordBuilderTest.java index ca604b710..7117a691c 100644 --- a/metafacture-biblio/src/test/java/org/metafacture/biblio/iso2709/RecordBuilderTest.java +++ b/metafacture-biblio/src/test/java/org/metafacture/biblio/iso2709/RecordBuilderTest.java @@ -183,6 +183,18 @@ public void shouldThrowExceptionIfSystemCharsIsNull() { builder.setSystemChars(null); // Exception expected } + @Test + public void shouldWriteSystemCharToRecordLabel() { + builder.setSystemChar(0, 'U'); + builder.setSystemChar(1, 'S'); + builder.setSystemChar(2, 'C'); + + final byte[] record = builder.build(); + + assertEquals(0x55, record[17]); + assertEquals(0x53, record[18]); + assertEquals(0x43, record[19]); + } @Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionIfSystemCharIndexGreaterThan2() { builder.setSystemChar(3, '1');