mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
18.03.2007 d318e2f7f6f8ba84a77e864ea9e0aeff8f711ccd
Display size upper limits whose value is some power of two minus 1 using a more compact notation.
1 files modified
24 ■■■■ changed files
opends/src/server/org/opends/server/admin/PropertyDefinitionUsageBuilder.java 24 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/admin/PropertyDefinitionUsageBuilder.java
@@ -254,10 +254,26 @@
      if (isDetailed) {
        if (d.getUpperLimit() != null) {
          builder.append(" <= ");
          SizeUnit unit = SizeUnit.getBestFitUnitExact(d.getUpperLimit());
          builder
              .append(numberFormat.format(unit.fromBytes(d.getUpperLimit())));
          long upperLimit = d.getUpperLimit();
          SizeUnit unit = SizeUnit.getBestFitUnitExact(upperLimit);
          // Quite often an upper limit is some power of 2 minus 1. In those
          // cases lets use a "less than" relation rather than a "less than
          // or equal to" relation. This will result in a much more readable
          // quantity.
          if (unit == SizeUnit.BYTES && upperLimit < Long.MAX_VALUE) {
            unit = SizeUnit.getBestFitUnitExact(upperLimit + 1);
            if (unit != SizeUnit.BYTES) {
              upperLimit += 1;
              builder.append(" < ");
            } else {
              builder.append(" <= ");
            }
          } else {
            builder.append(" <= ");
          }
          builder.append(numberFormat.format(unit.fromBytes(upperLimit)));
          builder.append(unit.getShortName());
        }