AutoRefactor'ed code cleanups
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean elementAvailable() throws IOException { |
| | | if ((state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) && !needTypeState(false)) { |
| | | return false; |
| | | } |
| | | if ((state == ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE) |
| | | && !needFirstLengthByteState(false)) { |
| | | return false; |
| | | } |
| | | return peekLength <= reader.remaining(); |
| | | return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE || needTypeState(false)) |
| | | && (state != ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE || needFirstLengthByteState(false)) |
| | | && peekLength <= reader.remaining(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean hasNextElement() throws IOException { |
| | | return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(false); |
| | | return state != ASN1.ELEMENT_READ_STATE_NEED_TYPE || needTypeState(false); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | |
| | | /** {@inheritDoc} */ |
| | | public boolean elementAvailable() throws IOException { |
| | | if ((state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) && !needTypeState(false, false)) { |
| | | return false; |
| | | } |
| | | if ((state == ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE) |
| | | && !needFirstLengthByteState(false, false)) { |
| | | return false; |
| | | } |
| | | if ((state == ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES) |
| | | && !needAdditionalLengthBytesState(false, false)) { |
| | | return false; |
| | | } |
| | | return peekLength <= in.available(); |
| | | return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE || needTypeState(false, false)) |
| | | && (state != ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE || needFirstLengthByteState(false, false)) |
| | | && (state != ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES |
| | | || needAdditionalLengthBytesState(false, false)) |
| | | && peekLength <= in.available(); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | // haven't exhausted the size limit for the sub sequence sub input |
| | | // stream. |
| | | final SizeLimitInputStream subSq = (SizeLimitInputStream) in; |
| | | return (subSq.getSizeLimit() - subSq.getBytesRead() > 0); |
| | | return subSq.getSizeLimit() - subSq.getBytesRead() > 0; |
| | | } |
| | | |
| | | return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(true, false); |
| | | return state != ASN1.ELEMENT_READ_STATE_NEED_TYPE || needTypeState(true, false); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | boolean schemaValidationFailure = false; |
| | | final List<LocalizableMessage> schemaErrors = new LinkedList<LocalizableMessage>(); |
| | | |
| | | if (lastLDIFLine != null) { |
| | | if (lastLDIFLine != null |
| | | // This line was read when looking for the change type. |
| | | if (!readLDIFRecordAttributeValue(record, lastLDIFLine, entry, schemaErrors)) { |
| | | && !readLDIFRecordAttributeValue(record, lastLDIFLine, entry, schemaErrors)) { |
| | | schemaValidationFailure = true; |
| | | } |
| | | } |
| | | |
| | | while (record.iterator.hasNext()) { |
| | | final String ldifLine = record.iterator.next(); |
| | |
| | | assertThat(Integer.signum(cmp)).isEqualTo(expectedCompareResult); |
| | | } |
| | | |
| | | /** Additional tests with testDNs data provider. */ |
| | | @Test(dataProvider = "testDNs") |
| | | /** Additional tests with testDNs data provider */ |
| | | public void testToIrreversibleNormalizedByteString2(String one, String two, String three) { |
| | | DN dn1 = DN.valueOf(one); |
| | | DN dn2 = DN.valueOf(two); |
| | |
| | | assertEquals(actual.toIrreversibleReadableString(), expectedReadableString); |
| | | } |
| | | |
| | | /** Additional tests with testDNs data provider. */ |
| | | @Test(dataProvider = "testDNs") |
| | | /** Additional tests with testDNs data provider */ |
| | | public void testToIrreversibleReadableString2(String one, String two, String three) { |
| | | DN dn1 = DN.valueOf(one); |
| | | DN dn2 = DN.valueOf(two); |
| | |
| | | private int bytesRead; |
| | | |
| | | public void checkLimit(final int readSize) throws IOException { |
| | | if ((readLimit > 0) && (bytesRead + readSize > readLimit)) { |
| | | if (0 < readLimit && readLimit < bytesRead + readSize) { |
| | | final LocalizableMessage message = ERR_ASN1_TRUNCATED_LENGTH_BYTE.get(); |
| | | throw DecodeException.fatalError(message); |
| | | } |
| | |
| | | * If an error occurs while trying to decode an ASN1 element. |
| | | */ |
| | | public boolean elementAvailable() throws IOException { |
| | | return !((state == ASN1.ELEMENT_READ_STATE_NEED_TYPE) |
| | | && !needTypeState(true)) |
| | | && !((state == ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE) |
| | | && !needFirstLengthByteState(true)) |
| | | && !((state == ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES) |
| | | && !needAdditionalLengthBytesState(true)) |
| | | return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE || needTypeState(true)) |
| | | && (state != ASN1.ELEMENT_READ_STATE_NEED_FIRST_LENGTH_BYTE || needFirstLengthByteState(true)) |
| | | && (state != ASN1.ELEMENT_READ_STATE_NEED_ADDITIONAL_LENGTH_BYTES |
| | | || needAdditionalLengthBytesState(true)) |
| | | && peekLength <= readLimiter.remaining(); |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | * If an error occurs while trying to decode an ASN1 element. |
| | | */ |
| | | public boolean hasNextElement() throws IOException { |
| | | return (state != ASN1.ELEMENT_READ_STATE_NEED_TYPE) || needTypeState(true); |
| | | return state != ASN1.ELEMENT_READ_STATE_NEED_TYPE || needTypeState(true); |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | private void startPurgeIfMaxNumberAddReached() { |
| | | AtomicBoolean purgeLatch = new AtomicBoolean(); |
| | | if (!isPurgeBranchRunning.get() |
| | | && 0 < maxNbAddIterations && maxNbAddIterations < totalAdds.get()) { |
| | | if (purgeLatch.compareAndSet(false, true)) { |
| | | && 0 < maxNbAddIterations && maxNbAddIterations < totalAdds.get() |
| | | && purgeLatch.compareAndSet(false, true)) { |
| | | newPurgerThread().start(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // FIXME Followings @Checkstyle:ignore tags are related to the maven-checkstyle-plugin |
| | | // issue related here: https://github.com/checkstyle/checkstyle/issues/5 |
| | |
| | | } |
| | | } |
| | | |
| | | //To allow tests |
| | | /** To allow tests. */ |
| | | static ResponseTimeBuckets getResponseTimeBuckets() { |
| | | return new ResponseTimeBuckets(); |
| | | } |