com.vladsch.flexmark.util.format.FormattedCounter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flexmark-util-format Show documentation
Show all versions of flexmark-util-format Show documentation
flexmark-java format utility classes
The newest version!
package com.vladsch.flexmark.util.format;
import com.vladsch.flexmark.util.misc.Utils;
public class FormattedCounter {
private final NumberFormat numberFormat;
private final Boolean isLowercase;
private final String delimiter;
private int count;
public FormattedCounter(NumberFormat format, Boolean lowercase, String delimiter) {
numberFormat = format;
isLowercase = lowercase;
this.delimiter = delimiter;
reset();
}
public void reset() {
count = 0;
}
public int getCount() {
return count;
}
public int nextCount() {
return ++count;
}
public String getFormatted(boolean withDelimiter) {
String s = NumberFormat.getFormat(numberFormat, Utils.minLimit(count, 1));
String o = isLowercase == null ? s : isLowercase ? s.toLowerCase() : s.toUpperCase();
return withDelimiter && delimiter != null && !delimiter.isEmpty() ? o + delimiter : o;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy