private void startConstructedElement(int tag) { EncoderState lastState = states.peekLast(); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { updateCurrentBuffer(); lastState.addChildElement(tag, currentBufferPos); } writeTag(tag, currentBuffer); if (tag != SET_TYPE) { updateCurrentBuffer(); } states.add(new EncoderState(tag, currentBufferPos)); }
private void endConstructedElement() { ByteStringBuilder dest; if (currentBufferPos > 0) { // Output the element to its parent buffer dest = buffers.get(currentBufferPos - 1); } else { // Output the element directly to the target destination dest = target; } int length = currentBuffer.length(); int numLengthOctets = writeLength(length, dest); dest.append(currentBuffer); currentBuffer.setLength(0); currentBuffer = dest; currentBufferPos -= 1; states.removeLast(); // If this element's parent element is a set element, update the parent's accumulated length EncoderState lastState = states.peekLast(); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { lastState.addChildLength(1 + numLengthOctets + length); } }
private void startConstructedElement(int tag) { EncoderState lastState = states.peekLast(); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { updateCurrentBuffer(); lastState.addChildElement(tag, currentBufferPos); } writeTag(tag, currentBuffer); if (tag != SET_TYPE) { updateCurrentBuffer(); } states.add(new EncoderState(tag, currentBufferPos)); }
@Override public void endSequence() throws IllegalStateException { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() != SEQUENCE_TYPE)) { throw log.noSequenceToEnd(); } endConstructedElement(); }
@Override public void endExplicit() throws IllegalStateException { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() == SEQUENCE_TYPE) || (lastState.getTag() == SET_TYPE) || ((lastState.getTag() & CONSTRUCTED_MASK) == 0)) { throw log.noExplicitlyTaggedElementToEnd(); } endConstructedElement(); }
private void startConstructedElement(int tag) { EncoderState lastState = states.peekLast(); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { updateCurrentBuffer(); lastState.addChildElement(tag, currentBufferPos); } writeTag(tag, currentBuffer); if (tag != SET_TYPE) { updateCurrentBuffer(); } states.add(new EncoderState(tag, currentBufferPos)); }
@Override public void endExplicit() throws IllegalStateException { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() == SEQUENCE_TYPE) || (lastState.getTag() == SET_TYPE) || ((lastState.getTag() & CONSTRUCTED_MASK) == 0)) { throw log.noExplicitlyTaggedElementToEnd(); } endConstructedElement(); }
private void startConstructedElement(int tag) { EncoderState lastState = states.peekLast(); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { updateCurrentBuffer(); lastState.addChildElement(tag, currentBufferPos); } writeTag(tag, currentBuffer); if (tag != SET_TYPE) { updateCurrentBuffer(); } states.add(new EncoderState(tag, currentBufferPos)); }
@Override public void endSequence() throws IllegalStateException { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() != SEQUENCE_TYPE)) { throw log.noSequenceToEnd(); } endConstructedElement(); }
private void endSet(Comparator<EncoderState> comparator) { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() != SET_TYPE)) { throw log.noSetToEnd(); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { lastState.addChildLength(1 + numLengthOctets + childLength);
@Override public void writeEncoded(byte[] encoded) { EncoderState lastState = states.peekLast(); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { updateCurrentBuffer(); lastState.addChildElement(encoded[0], currentBufferPos); } if (implicitTag != -1) { writeTag(encoded[0], currentBuffer); currentBuffer.append(encoded, 1, encoded.length - 1); } else { currentBuffer.append(encoded); } // If this element's parent element is a set element, update the parent's accumulated length if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { lastState.addChildLength(currentBuffer.length()); } }
private void writeElement(int tag, byte[] contents) { EncoderState lastState = states.peekLast(); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { updateCurrentBuffer(); lastState.addChildElement(tag, currentBufferPos); } writeTag(tag, currentBuffer); writeLength(contents.length, currentBuffer); currentBuffer.append(contents); // If this element's parent element is a set element, update the parent's accumulated length if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { lastState.addChildLength(currentBuffer.length()); } }
private void writeElement(int tag, ByteStringBuilder contents) { EncoderState lastState = states.peekLast(); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { updateCurrentBuffer(); lastState.addChildElement(tag, currentBufferPos); } writeTag(tag, currentBuffer); writeLength(contents.length(), currentBuffer); currentBuffer.append(contents); // If this element's parent element is a set element, update the parent's accumulated length if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { lastState.addChildLength(currentBuffer.length()); } }
@Override public void endExplicit() throws IllegalStateException { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() == SEQUENCE_TYPE) || (lastState.getTag() == SET_TYPE) || ((lastState.getTag() & CONSTRUCTED_MASK) == 0)) { throw log.noExplicitlyTaggedElementToEnd(); } endConstructedElement(); }
@Override public void endSequence() throws IllegalStateException { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() != SEQUENCE_TYPE)) { throw log.noSequenceToEnd(); } endConstructedElement(); }