CPD Results

The following document contains the results of PMD's CPD 6.29.0.

Duplications

File Line
com/foxinmy/weixin4j/http/support/okhttp/OkHttpResponse2.java 35
com/foxinmy/weixin4j/http/support/okhttp/OkHttpResponse3.java 33
Headers headers = this.response.headers();
			for (int i = 0; i < headers.size(); i++) {
				this.headers.add(headers.name(i), headers.value(i));
			}
		}
		return this.headers;
	}

	@Override
	public HttpVersion getProtocol() {
		if (protocol == null) {
			String protocol = this.response.protocol().toString().split("/")[0];
			boolean keepAlive = KEEP_ALIVE.equalsIgnoreCase(this.response
					.header("Connection"));
			if (this.response.protocol() == Protocol.HTTP_1_0) {
				return new HttpVersion(protocol, 1, 0, keepAlive);
			} else if (this.response.protocol() == Protocol.HTTP_1_1) {
				return new HttpVersion(protocol, 1, 1, keepAlive);
			} else if (this.response.protocol() == Protocol.HTTP_2) {
				return new HttpVersion(protocol, 2, 0, keepAlive);
			} else if (this.response.protocol() == Protocol.SPDY_3) {
				return new HttpVersion(protocol, 3, 0, keepAlive);
			} else {
				this.protocol = new HttpVersion(protocol, keepAlive);
			}
		}
		return protocol;
	}

	@Override
	public HttpStatus getStatus() {
		if (status == null) {
			status = new HttpStatus(this.response.code(),
					this.response.message());
		}
		return status;
	}

	@Override
	public void close() {
File Line
com/foxinmy/weixin4j/http/support/apache4/HttpComponent4_1Response.java 31
com/foxinmy/weixin4j/http/support/apache4/HttpComponent4_2Response.java 34
byte[] content) throws IOException {
		super(content);
		this.httpResponse = httpResponse;
	}

	@Override
	public HttpHeaders getHeaders() {
		if (headers == null) {
			headers = new HttpHeaders();
			Header[] headers = httpResponse.getAllHeaders();
			for (Header header : headers) {
				this.headers.add(header.getName(), header.getValue());
			}
		}
		return headers;
	}

	@Override
	public HttpVersion getProtocol() {
		if (protocol == null) {
			ProtocolVersion version = httpResponse.getProtocolVersion();
			Header connection = httpResponse.getFirstHeader("Connection");
			protocol = new HttpVersion(version.getProtocol(),
					version.getMajor(), version.getMinor(), connection != null
							&& KEEP_ALIVE.equalsIgnoreCase(connection
									.getValue()));
		}
		return protocol;
	}

	@Override
	public HttpStatus getStatus() {
		if (status == null) {
			StatusLine statusLine = httpResponse.getStatusLine();
			status = new HttpStatus(statusLine.getStatusCode(),
					statusLine.getReasonPhrase());
		}
		return status;
	}

	@Override
	public void close() {
		try {
File Line
com/foxinmy/weixin4j/util/ByteArrayBuffer.java 121
com/foxinmy/weixin4j/util/CharArrayBuffer.java 176
public void append(final char[] b, final int off, final int len) {
        if (b == null) {
            return;
        }
        if ((off < 0) || (off > b.length) || (len < 0) ||
                ((off + len) < 0) || ((off + len) > b.length)) {
            throw new IndexOutOfBoundsException("off: "+off+" len: "+len+" b.length: "+b.length);
        }
        if (len == 0) {
            return;
        }
        final int oldlen = this.len;
        final int newlen = oldlen + len;
        if (newlen > this.buffer.length) {
            expand(newlen);
        }
        for (int i1 = off, i2 = oldlen; i2 < newlen; i1++, i2++) {
            this.buffer[i2] = (byte) b[i1];
File Line
com/foxinmy/weixin4j/util/ByteArrayBuffer.java 73
com/foxinmy/weixin4j/util/CharArrayBuffer.java 77
public void append(final byte[] b, final int off, final int len) {
        if (b == null) {
            return;
        }
        if ((off < 0) || (off > b.length) || (len < 0) ||
                ((off + len) < 0) || ((off + len) > b.length)) {
            throw new IndexOutOfBoundsException("off: "+off+" len: "+len+" b.length: "+b.length);
        }
        if (len == 0) {
            return;
        }
        final int newlen = this.len + len;
        if (newlen > this.buffer.length) {
            expand(newlen);
        }
        System.arraycopy(b, off, this.buffer, this.len, len);
        this.len = newlen;
    }

    /**
     * Appends {@code b} byte to this buffer. The capacity of the buffer
     * is increased, if necessary, to accommodate the additional byte.
     *
     * @param   b        the byte to be appended.
     */
    public void append(final int b) {
File Line
com/foxinmy/weixin4j/util/ByteArrayBuffer.java 59
com/foxinmy/weixin4j/util/CharArrayBuffer.java 160
}

    /**
     * Appends {@code len} bytes to this buffer from the given source
     * array starting at index {@code off}. The capacity of the buffer
     * is increased, if necessary, to accommodate all {@code len} bytes.
     *
     * @param   b        the bytes to be appended.
     * @param   off      the index of the first byte to append.
     * @param   len      the number of bytes to append.
     * @throws IndexOutOfBoundsException if {@code off} if out of
     * range, {@code len} is negative, or
     * {@code off} + {@code len} is out of range.
     */
    public void append(final byte[] b, final int off, final int len) {
        if (b == null) {
            return;
        }
        if ((off < 0) || (off > b.length) || (len < 0) ||
                ((off + len) < 0) || ((off + len) > b.length)) {
            throw new IndexOutOfBoundsException("off: "+off+" len: "+len+" b.length: "+b.length);
        }
        if (len == 0) {
            return;
        }
        final int newlen = this.len + len;
File Line
com/foxinmy/weixin4j/util/ByteArrayBuffer.java 105
com/foxinmy/weixin4j/util/CharArrayBuffer.java 63
}

    /**
     * Appends {@code len} chars to this buffer from the given source
     * array starting at index {@code off}. The capacity of the buffer
     * is increased if necessary to accommodate all {@code len} chars.
     * <p>
     * The chars are converted to bytes using simple cast.
     *
     * @param   b        the chars to be appended.
     * @param   off      the index of the first char to append.
     * @param   len      the number of bytes to append.
     * @throws IndexOutOfBoundsException if {@code off} if out of
     * range, {@code len} is negative, or
     * {@code off} + {@code len} is out of range.
     */
    public void append(final char[] b, final int off, final int len) {
        if (b == null) {
            return;
        }
        if ((off < 0) || (off > b.length) || (len < 0) ||
                ((off + len) < 0) || ((off + len) > b.length)) {
            throw new IndexOutOfBoundsException("off: "+off+" len: "+len+" b.length: "+b.length);
        }
        if (len == 0) {
            return;
        }
        final int oldlen = this.len;