public int decode(InputStream is, BerTag berTag) throws IOException { int codeLength = 0; BerTag passedTag = berTag; if (berTag == null) { berTag = new BerTag(); codeLength += berTag.decode(is); } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { charstring = new BerOctetString(); codeLength += charstring.decode(is, false); return codeLength; } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { bitstring = new BerBitString(); codeLength += bitstring.decode(is, false); return codeLength; } if (passedTag != null) { return 0; } throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item."); }
@Override public int encode(OutputStream reverseOS) throws IOException { return encode(reverseOS, true); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); for (boolean bit : getValueAsBooleans()) { if (bit) { sb.append('1'); } else { sb.append('0'); } } return sb.toString(); } }
@Test public void toString2Test() { BerBitString bitString = new BerBitString(new boolean[] { false, false, false, false, false, false, false, true, false, false, false, false, false, false, true, false, false, false, false, false, false, true, true }); Assert.assertEquals("00000001000000100000011", bitString.toString()); }
public int decode(InputStream is, boolean withTag) throws IOException { int codeLength = 0; if (withTag) { codeLength += tag.decodeAndCheck(is); } codeLength += super.decode(is, false); return codeLength; }
@Override Data getMmsDataObj() { Data data = new Data(); data.setBitString(new BerBitString(value, maxNumBits)); return data; }
public int decode(InputStream is, boolean withTag) throws IOException { int codeLength = 0; if (withTag) { codeLength += tag.decodeAndCheck(is); } codeLength += super.decode(is, false); return codeLength; }
@Override Data getMmsDataObj() { Data data = new Data(); data.setBitString(new BerBitString(value, maxNumBits)); return data; }
@Test public void toStringTest() { BerBitString bitString = new BerBitString(new byte[] { 1, 2, 7 }, 23); Assert.assertEquals("00000001000000100000011", bitString.toString()); }
public int decode(InputStream is, BerTag berTag) throws IOException { int codeLength = 0; BerTag passedTag = berTag; if (berTag == null) { berTag = new BerTag(); codeLength += berTag.decode(is); } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { charstring = new BerGraphicString(); codeLength += charstring.decode(is, false); return codeLength; } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { bitstring = new BerBitString(); codeLength += bitstring.decode(is, false); return codeLength; } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { external = new Myexternal2(); codeLength += external.decode(is, false); return codeLength; } if (passedTag != null) { return 0; } throw new IOException("Error decoding BerChoice: Tag matched to no item."); }
@Override public int encode(OutputStream reverseOS) throws IOException { return encode(reverseOS, true); }
public int decode(InputStream is, boolean withTag) throws IOException { // could be encoded in primitiv and constructed mode // only primitiv mode is implemented int codeLength = 0; if (withTag) { codeLength += tag.decodeAndCheck(is); } BerLength length = new BerLength(); codeLength += length.decode(is); value = new byte[length.val - 1]; int unusedBits = is.read(); if (unusedBits == -1) { throw new EOFException("Unexpected end of input stream."); } if (unusedBits > 7) { throw new IOException( "Number of unused bits in bit string expected to be less than 8 but is: " + unusedBits); } numBits = (value.length * 8) - unusedBits; if (value.length > 0) { Util.readFully(is, value); } codeLength += value.length + 1; return codeLength; }
inclusionStringArray[i / 8] |= 1 << (7 - i % 8); BerBitString inclusionString = new BerBitString(inclusionStringArray, dataSetSize); BerBitString inclusionString = new BerBitString(inclusionStringArray, dataSetSize);
@Override public String toString() { StringBuilder sb = new StringBuilder(); for (boolean bit : getValueAsBooleans()) { if (bit) { sb.append('1'); } else { sb.append('0'); } } return sb.toString(); } }
public int decode(InputStream is, BerTag berTag) throws IOException { int codeLength = 0; BerTag passedTag = berTag; if (berTag == null) { berTag = new BerTag(); codeLength += berTag.decode(is); } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { charstring = new BerGraphicString(); codeLength += charstring.decode(is, false); return codeLength; } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { bitstring = new BerBitString(); codeLength += bitstring.decode(is, false); return codeLength; } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { external = new Myexternal2(); codeLength += external.decode(is, false); return codeLength; } if (passedTag != null) { return 0; } throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item."); }
@Override public int encode(OutputStream reverseOS) throws IOException { return encode(reverseOS, true); }
public int decode(InputStream is, boolean withTag) throws IOException { // could be encoded in primitiv and constructed mode // only primitiv mode is implemented int codeLength = 0; if (withTag) { codeLength += tag.decodeAndCheck(is); } BerLength length = new BerLength(); codeLength += length.decode(is); value = new byte[length.val - 1]; int unusedBits = is.read(); if (unusedBits == -1) { throw new EOFException("Unexpected end of input stream."); } if (unusedBits > 7) { throw new IOException( "Number of unused bits in bit string expected to be less than 8 but is: " + unusedBits); } numBits = (value.length * 8) - unusedBits; if (value.length > 0) { Util.readFully(is, value); } codeLength += value.length + 1; return codeLength; }
inclusionStringArray[i / 8] |= 1 << (7 - i % 8); BerBitString inclusionString = new BerBitString(inclusionStringArray, dataSetSize); BerBitString inclusionString = new BerBitString(inclusionStringArray, dataSetSize);
@Override public String toString() { StringBuilder sb = new StringBuilder(); for (boolean bit : getValueAsBooleans()) { if (bit) { sb.append('1'); } else { sb.append('0'); } } return sb.toString(); } }
public int decode(InputStream is, BerTag berTag) throws IOException { int codeLength = 0; BerTag passedTag = berTag; if (berTag == null) { berTag = new BerTag(); codeLength += berTag.decode(is); } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { charstring = new BerGraphicString(); codeLength += charstring.decode(is, false); return codeLength; } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { bitstring = new BerBitString(); codeLength += bitstring.decode(is, false); return codeLength; } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.CONSTRUCTED, 2)) { external = new Myexternal2(); codeLength += external.decode(is, false); return codeLength; } if (passedTag != null) { return 0; } throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item."); }