You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/06 13:06:11 UTC

[commons-net] 02/04: Javadoc and format tweaks

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git

commit d7698b92cddc341f64df6f07fb3b13ae7e91711f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Nov 6 07:52:49 2022 -0500

    Javadoc and format tweaks
---
 .../org/apache/commons/net/util/SubnetUtils.java   | 40 ++++++++++++----------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/src/main/java/org/apache/commons/net/util/SubnetUtils.java b/src/main/java/org/apache/commons/net/util/SubnetUtils.java
index 5f84bf44..96bcc19a 100644
--- a/src/main/java/org/apache/commons/net/util/SubnetUtils.java
+++ b/src/main/java/org/apache/commons/net/util/SubnetUtils.java
@@ -20,7 +20,7 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 /**
- * A class that performs some subnet calculations given a network address and a subnet mask.
+ * Performs some subnet calculations given a network address and a subnet mask.
  * @see "http://www.faqs.org/rfcs/rfc1519.html"
  * @since 2.0
  */
@@ -31,6 +31,7 @@ public class SubnetUtils {
      *
      */
     public final class SubnetInfo {
+
         /* Mask to convert unsigned int to a long (i.e. keep 32 bits) */
         private static final long UNSIGNED_INT_MASK = 0x0FFFFFFFFL;
 
@@ -42,7 +43,7 @@ public class SubnetUtils {
         private long broadcastLong(){ return broadcast &  UNSIGNED_INT_MASK; }
 
         /*
-        * Convert a 4-element array into dotted decimal format
+        * Converts a 4-element array into dotted decimal format
         */
         private String format(final int[] octets) {
             final int last = octets.length - 1;
@@ -61,7 +62,7 @@ public class SubnetUtils {
         }
 
         /**
-         * Get the count of available addresses.
+         * Gets the count of available addresses.
          * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false.
          * @return the count of addresses, may be zero.
          * @throws RuntimeException if the correct count is greater than {@code Integer.MAX_VALUE}
@@ -78,7 +79,7 @@ public class SubnetUtils {
         }
 
         /**
-         * Get the count of available addresses.
+         * Gets the count of available addresses.
          * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false.
          * @return the count of addresses, may be zero.
          * @since 3.4
@@ -111,7 +112,7 @@ public class SubnetUtils {
         }
 
         /**
-         * Return the high address as a dotted IP address.
+         * Gets the high address as a dotted IP address.
          * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false.
          *
          * @return the IP address in dotted format, may be "0.0.0.0" if there is no valid address
@@ -121,7 +122,7 @@ public class SubnetUtils {
         }
 
         /**
-         * Return the low address as a dotted IP address.
+         * Gets the low address as a dotted IP address.
          * Will be zero for CIDR/31 and CIDR/32 if the inclusive flag is false.
          *
          * @return the IP address in dotted format, may be "0.0.0.0" if there is no valid address
@@ -152,7 +153,7 @@ public class SubnetUtils {
         }
 
         /**
-         * Returns true if the parameter <code>address</code> is in the
+         * Tests if the parameter <code>address</code> is in the
          * range of usable endpoint addresses for this subnet. This excludes the
          * network and broadcast addresses by default. Use {@link SubnetUtils#setInclusiveHostCount(boolean)}
          * to change this.
@@ -171,7 +172,7 @@ public class SubnetUtils {
         }
 
         /**
-         * Returns true if the parameter <code>address</code> is in the
+         * Tests if the parameter <code>address</code> is in the
          * range of usable endpoint addresses for this subnet. This excludes the
          * network and broadcast addresses. Use {@link SubnetUtils#setInclusiveHostCount(boolean)}
          * to change this.
@@ -190,8 +191,8 @@ public class SubnetUtils {
         // long versions of the values (as unsigned int) which are more suitable for range checking
         private long networkLong()  { return network &  UNSIGNED_INT_MASK; }
 
-        /*
-        * Convert a packed integer address into a 4-element array
+       /**
+        * Converts a packed integer address into a 4-element array
         */
         private int[] toArray(final int val) {
             final int ret[] = new int[4];
@@ -228,8 +229,9 @@ public class SubnetUtils {
     private static final int NBITS = 32;
 
     private static final String PARSE_FAIL = "Could not parse [%s]";
+
     /*
-     * Convenience method to extract the components of a dotted decimal address and
+     * Extracts the components of a dotted decimal address and
      * pack into an integer using a regex match
      */
     private static int matchAddress(final Matcher matcher) {
@@ -241,7 +243,7 @@ public class SubnetUtils {
         return addr;
     }
     /*
-     * Convenience function to check integer boundaries.
+     * Checks integer boundaries.
      * Checks if a value x is in the range [begin,end].
      * Returns x if it is in range, throws an exception otherwise.
      */
@@ -254,7 +256,7 @@ public class SubnetUtils {
     }
 
     /*
-     * Convert a dotted decimal format address to a packed integer format
+     * Converts a dotted decimal format address to a packed integer format
      */
     private static int toInteger(final String address) {
         final Matcher matcher = addressPattern.matcher(address);
@@ -276,7 +278,7 @@ public class SubnetUtils {
     private boolean inclusiveHostCount;
 
     /**
-     * Constructor that takes a CIDR-notation string, e.g. "192.168.0.1/16"
+     * Constructs an instance from a CIDR-notation string, e.g. "192.168.0.1/16"
      * @param cidrNotation A CIDR-notation string, e.g. "192.168.0.1/16"
      * @throws IllegalArgumentException if the parameter is invalid,
      * i.e. does not match n.n.n.n/m where n=1-3 decimal digits, m = 1-2 decimal digits in range 0-32
@@ -311,7 +313,7 @@ public class SubnetUtils {
     }
 
     /**
-     * Constructor that takes a dotted decimal address and a dotted decimal mask.
+     * Constructs an instance from a dotted decimal address and a dotted decimal mask.
      * @param address An IP address, e.g. "192.168.0.1"
      * @param mask A dotted decimal netmask e.g. "255.255.0.0"
      * @throws IllegalArgumentException if the address or mask is invalid,
@@ -333,7 +335,7 @@ public class SubnetUtils {
     }
 
     /**
-     * Return a {@link SubnetInfo} instance that contains subnet-specific statistics
+     * Gets a {@link SubnetInfo} instance that contains subnet-specific statistics
      * @return new instance
      */
     public final SubnetInfo getInfo() { return new SubnetInfo(); }
@@ -347,7 +349,7 @@ public class SubnetUtils {
     }
 
     /**
-     * Returns <code>true</code> if the return value of {@link SubnetInfo#getAddressCount()}
+     * Tests if the return value of {@link SubnetInfo#getAddressCount()}
      * includes the network and broadcast addresses.
      * @since 2.2
      * @return true if the host count includes the network and broadcast addresses
@@ -357,7 +359,7 @@ public class SubnetUtils {
     }
 
     /*
-     * Count the number of 1-bits in a 32-bit integer using a divide-and-conquer strategy
+     * Counts the number of 1-bits in a 32-bit integer using a divide-and-conquer strategy
      * see Hacker's Delight section 5.1
      */
     int pop(int x) {
@@ -370,7 +372,7 @@ public class SubnetUtils {
     }
 
     /**
-     * Set to <code>true</code> if you want the return value of {@link SubnetInfo#getAddressCount()}
+     * Sets to <code>true</code> if you want the return value of {@link SubnetInfo#getAddressCount()}
      * to include the network and broadcast addresses.
      * This also applies to {@link SubnetInfo#isInRange(int)}
      * @param inclusiveHostCount true if network and broadcast addresses are to be included