Skip to content

Commit

Permalink
Javadoc: Add missing constructor Javadoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
garydgregory committed Dec 10, 2024
1 parent ec7904b commit ce894b2
Show file tree
Hide file tree
Showing 40 changed files with 316 additions and 41 deletions.
65 changes: 65 additions & 0 deletions src/main/java/org/apache/commons/io/ByteBuffers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.commons.io;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;

/**
* Manufactures {@link ByteBuffer} instances.
*
* @since 2.19.0
*/
public class ByteBuffers {

/**
* Allocates a new byte buffer with little-endian byte order. The bytes of a multibyte value are ordered from least significant to most significant.
* <p>
* The new buffer's position is zero, the limit is its capacity, the mark is undefined, and each of element is initialized to zero. The new buffer has the
* given backing {@code array}, and its {@link ByteBuffer#arrayOffset() array offset} is zero.
* </p>
*
* @param array The array that will back the new byte buffer.
* @return The new byte buffer.
*/
public static ByteBuffer littleEndian(final byte[] array) {
return littleEndian(ByteBuffer.wrap(array));
}

public static ByteBuffer littleEndian(final ByteBuffer allocate) {
return allocate.order(ByteOrder.LITTLE_ENDIAN);
}

/**
* Allocates a new byte buffer with little-endian byte order. The bytes of a multibyte value are ordered from least significant to most significant.
* <p>
* The new buffer's position is zero, the limit is its capacity, the mark is undefined, and each of element is initialized to zero. The new buffer has a
* {@link ByteBuffer#array() backing array}, and its {@link ByteBuffer#arrayOffset() array offset} is zero.
* </p>
*
* @param capacity The new buffer's capacity, in bytes.
* @return The new byte buffer.
* @throws IllegalArgumentException If the <code>capacity</code> is negative.
*/
public static ByteBuffer littleEndian(final int capacity) {
return littleEndian(ByteBuffer.allocate(capacity));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ public static class Builder extends AbstractSupplier<WildcardFileFilter, Builder
/** Whether the comparison is case-sensitive. */
private IOCase ioCase = IOCase.SENSITIVE;

/**
* Constructs a new builder of {@link WildcardFileFilter}.
*/
public Builder() {
// empty
}

@Override
public WildcardFileFilter get() {
return new WildcardFileFilter(ioCase, wildcards);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ public abstract class AbstractInputStream extends InputStream {
*/
private boolean closed;

/**
* Constructs a new instance for subclasses.
*/
public AbstractInputStream() {
// empty
}

/**
* Checks if this instance is closed and throws an IOException if so.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ public class AutoCloseInputStream extends ProxyInputStream {
// @formatter:on
public static class Builder extends AbstractBuilder<AutoCloseInputStream, Builder> {

/**
* Constructs a new builder of {@link AutoCloseInputStream}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link AutoCloseInputStream}.
* <p>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/apache/commons/io/input/BOMInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ static ByteOrderMark getDefaultByteOrderMark() {

private boolean include;

/**
* Constructs a new builder of {@link BOMInputStream}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link BOMInputStream}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ public T setPropagateClose(final boolean propagateClose) {
//@formatter:on
public static class Builder extends AbstractBuilder<Builder> {

/**
* Constructs a new builder of {@link BoundedInputStream}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link BoundedInputStream}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public static class Builder extends AbstractStreamBuilder<BufferedFileChannelInp

private FileChannel fileChannel;

/**
* Constructs a new builder of {@link BufferedFileChannelInputStream}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link BufferedFileChannelInputStream}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ public static class Builder extends AbstractStreamBuilder<CharSequenceInputStrea

private CharsetEncoder charsetEncoder = newEncoder(getCharset());

/**
* Constructs a new builder of {@link CharSequenceInputStream}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link CharSequenceInputStream}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ public static class Builder extends AbstractBuilder<ChecksumInputStream, Builder
*/
private long expectedChecksumValue;

/**
* Constructs a new builder of {@link ChecksumInputStream}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link ChecksumInputStream}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public final class MemoryMappedFileInputStream extends AbstractInputStream {
public static class Builder extends AbstractStreamBuilder<MemoryMappedFileInputStream, Builder> {

/**
* Constructs a new {@link Builder}.
* Constructs a new builder of {@link MemoryMappedFileInputStream}.
*/
public Builder() {
setBufferSizeDefault(DEFAULT_BUFFER_SIZE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static class Builder extends AbstractBuilder<Builder> {
private MessageDigest messageDigest;

/**
* Constructs a new {@link Builder}.
* Constructs a new builder of {@link MessageDigestCalculatingInputStream}.
* <p>
* The default for compatibility is the MD5 cryptographic algorithm which is weak and should not be used.
* </p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static class Builder extends AbstractBuilder<Builder> {
private MessageDigest messageDigest;

/**
* Constructs a new {@link Builder}.
* Constructs a new builder of {@link MessageDigestInputStream}.
*/
public Builder() {
// empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ public void setObservers(final List<Observer> observers) {
*/
public static class Builder extends AbstractBuilder<Builder> {

/**
* Constructs a new builder of {@link ObservableInputStream}.
*/
public Builder() {
// empty
}

@Override
public ObservableInputStream get() throws IOException {
return new ObservableInputStream(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ protected static abstract class AbstractBuilder<T, B extends AbstractStreamBuild

private IOIntConsumer afterRead;

/**
* Constructs a builder of {@code T}.
*/
protected AbstractBuilder() {
// empty
}

/**
* Gets the {@link ProxyInputStream#afterRead(int)} consumer.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public static class Builder extends AbstractStreamBuilder<QueueInputStream, Buil
private BlockingQueue<Integer> blockingQueue = new LinkedBlockingQueue<>();
private Duration timeout = Duration.ZERO;

/**
* Constructs a new builder of {@link QueueInputStream}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link QueueInputStream}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public static class Builder extends AbstractStreamBuilder<RandomAccessFileInputS
// private RandomAccessFile randomAccessFile;
private boolean propagateClose;

/**
* Constructs a new builder of {@link RandomAccessFileInputStream}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link RandomAccessFileInputStream}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ public static class Builder extends AbstractStreamBuilder<ReadAheadInputStream,

private ExecutorService executorService;

/**
* Constructs a new builder of {@link ReadAheadInputStream}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link ReadAheadInputStream}.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ public static class Builder extends AbstractStreamBuilder<ReaderInputStream, Bui

private CharsetEncoder charsetEncoder = newEncoder(getCharset());

/**
* Constructs a new builder of {@link ReaderInputStream}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link ReaderInputStream}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class ReversedLinesFileReader implements Closeable, IOIterable<String> {
public static class Builder extends AbstractStreamBuilder<ReversedLinesFileReader, Builder> {

/**
* Constructs a new {@link Builder}.
* Constructs a new builder of {@link ReversedLinesFileReader}.
*/
public Builder() {
setBufferSizeDefault(DEFAULT_BLOCK_SIZE);
Expand Down Expand Up @@ -480,6 +480,38 @@ public void close() throws IOException {
channel.close();
}

@Override
public IOIterator<String> iterator() {
return new IOIterator<String>() {

private String next;

@Override
public boolean hasNext() throws IOException {
if (next == null) {
next = readLine();
}
return next != null;
}

@Override
public String next() throws IOException {
if (next == null) {
next = readLine();
}
final String tmp = next;
next = null;
return tmp;
}

@Override
public Iterator<String> unwrap() {
return null;
}

};
}

/**
* Returns the lines of the file from bottom to top.
*
Expand Down Expand Up @@ -552,36 +584,4 @@ public String toString(final int lineCount) throws IOException {
return lines.isEmpty() ? EMPTY_STRING : String.join(System.lineSeparator(), lines) + System.lineSeparator();
}

@Override
public IOIterator<String> iterator() {
return new IOIterator<String>() {

private String next;

@Override
public boolean hasNext() throws IOException {
if (next == null) {
next = readLine();
}
return next != null;
}

@Override
public String next() throws IOException {
if (next == null) {
next = readLine();
}
final String tmp = next;
next = null;
return tmp;
}

@Override
public Iterator<String> unwrap() {
return null;
}

};
}

}
7 changes: 7 additions & 0 deletions src/main/java/org/apache/commons/io/input/Tailer.java
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ private static Thread newDaemonThread(final Runnable runnable) {
private boolean startThread = true;
private ExecutorService executorService = Executors.newSingleThreadExecutor(Builder::newDaemonThread);

/**
* Constructs a new builder of {@link Tailer}.
*/
public Builder() {
// empty
}

/**
* Builds a new {@link Tailer}.
*
Expand Down
Loading

0 comments on commit ce894b2

Please sign in to comment.