public void addChildElement(int tag, int bufferPos) { childElements.add(new EncoderState(tag, bufferPos)); }
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 endSet(Comparator<EncoderState> comparator) { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() != SET_TYPE)) { throw log.noSetToEnd(); LinkedList<EncoderState> childElements = lastState.getSortedChildElements(comparator); int setBufferPos = lastState.getBufferPos(); ByteStringBuilder dest; if (setBufferPos >= 0) { int childLength = lastState.getChildLength(); int numLengthOctets = writeLength(lastState.getChildLength(), dest); for (EncoderState element : childElements) { contents = buffers.get(element.getBufferPos()); dest.append(contents); contents.setLength(0); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { lastState.addChildLength(1 + numLengthOctets + childLength);
private void endSet(Comparator<EncoderState> comparator) { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() != SET_TYPE)) { throw log.noSetToEnd(); LinkedList<EncoderState> childElements = lastState.getSortedChildElements(comparator); int setBufferPos = lastState.getBufferPos(); ByteStringBuilder dest; if (setBufferPos >= 0) { int childLength = lastState.getChildLength(); int numLengthOctets = writeLength(lastState.getChildLength(), dest); for (EncoderState element : childElements) { contents = buffers.get(element.getBufferPos()); dest.append(contents); contents.setLength(0); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { lastState.addChildLength(1 + numLengthOctets + childLength);
private void endSet(Comparator<EncoderState> comparator) { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() != SET_TYPE)) { throw log.noSetToEnd(); LinkedList<EncoderState> childElements = lastState.getSortedChildElements(comparator); int setBufferPos = lastState.getBufferPos(); ByteStringBuilder dest; if (setBufferPos >= 0) { int childLength = lastState.getChildLength(); int numLengthOctets = writeLength(lastState.getChildLength(), dest); for (EncoderState element : childElements) { contents = buffers.get(element.getBufferPos()); dest.append(contents); contents.setLength(0); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { lastState.addChildLength(1 + numLengthOctets + childLength);
private void endSet(Comparator<EncoderState> comparator) { EncoderState lastState = states.peekLast(); if ((lastState == null) || (lastState.getTag() != SET_TYPE)) { throw log.noSetToEnd(); LinkedList<EncoderState> childElements = lastState.getSortedChildElements(comparator); int setBufferPos = lastState.getBufferPos(); ByteStringBuilder dest; if (setBufferPos >= 0) { int childLength = lastState.getChildLength(); int numLengthOctets = writeLength(lastState.getChildLength(), dest); for (EncoderState element : childElements) { contents = buffers.get(element.getBufferPos()); dest.append(contents); contents.setLength(0); if ((lastState != null) && (lastState.getTag() == SET_TYPE)) { lastState.addChildLength(1 + numLengthOctets + childLength);
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 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 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); } }
@Override public int compare(EncoderState state1, EncoderState state2) { ByteStringBuilder bytes1 = state1.getBuffer(); ByteStringBuilder bytes2 = state2.getBuffer(); ByteIterator bi1 = bytes1.iterate(); ByteIterator bi2 = bytes2.iterate(); // Scan the two encodings from left to right until a difference is found int diff; while (bi1.hasNext() && bi2.hasNext()) { diff = (bi1.next() & 0xff) - (bi2.next() & 0xff); if (diff != 0) { return diff; } } // The longer encoding is considered to be the bigger-valued encoding return bytes1.length() - bytes2.length(); } }
@Override public int compare(EncoderState state1, EncoderState state2) { ByteStringBuilder bytes1 = state1.getBuffer(); ByteStringBuilder bytes2 = state2.getBuffer(); ByteIterator bi1 = bytes1.iterate(); ByteIterator bi2 = bytes2.iterate(); // Scan the two encodings from left to right until a difference is found int diff; while (bi1.hasNext() && bi2.hasNext()) { diff = (bi1.next() & 0xff) - (bi2.next() & 0xff); if (diff != 0) { return diff; } } // The longer encoding is considered to be the bigger-valued encoding return bytes1.length() - bytes2.length(); } }
@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()); } }
@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()); } }
@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()); } }
@Override public int compare(EncoderState state1, EncoderState state2) { ByteStringBuilder bytes1 = state1.getBuffer(); ByteStringBuilder bytes2 = state2.getBuffer(); ByteIterator bi1 = bytes1.iterate(); ByteIterator bi2 = bytes2.iterate(); // Scan the two encodings from left to right until a difference is found int diff; while (bi1.hasNext() && bi2.hasNext()) { diff = (bi1.next() & 0xff) - (bi2.next() & 0xff); if (diff != 0) { return diff; } } // The longer encoding is considered to be the bigger-valued encoding return bytes1.length() - bytes2.length(); } }
public ByteStringBuilder getBuffer() { return buffers.get(getBufferPos()); }
public ByteStringBuilder getBuffer() { return buffers.get(getBufferPos()); }
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()); } }
public void addChildElement(int tag, int bufferPos) { childElements.add(new EncoderState(tag, bufferPos)); }
public void addChildElement(int tag, int bufferPos) { childElements.add(new EncoderState(tag, bufferPos)); }