Change static variable names

This commit is contained in:
Paul Schaub 2021-08-15 15:35:22 +02:00
parent 20b3080e94
commit 485666c72a
1 changed files with 16 additions and 16 deletions

View File

@ -26,8 +26,8 @@ import org.bouncycastle.bcpg.ArmoredOutputStream;
public final class ArmoredOutputStreamFactory { public final class ArmoredOutputStreamFactory {
public static final String PGPAINLESS = "PGPainless"; public static final String PGPAINLESS = "PGPainless";
private static String VERSION = PGPAINLESS; private static String version = PGPAINLESS;
public static String[] COMMENT = new String[0]; private static String[] comment = new String[0];
private ArmoredOutputStreamFactory() { private ArmoredOutputStreamFactory() {
@ -41,8 +41,8 @@ public final class ArmoredOutputStreamFactory {
*/ */
public static ArmoredOutputStream get(OutputStream outputStream) { public static ArmoredOutputStream get(OutputStream outputStream) {
ArmoredOutputStream armoredOutputStream = new ArmoredOutputStream(outputStream); ArmoredOutputStream armoredOutputStream = new ArmoredOutputStream(outputStream);
armoredOutputStream.setHeader(ArmorUtils.HEADER_VERSION, VERSION); armoredOutputStream.setHeader(ArmorUtils.HEADER_VERSION, version);
for (String comment : COMMENT) { for (String comment : comment) {
ArmorUtils.addCommentHeader(armoredOutputStream, comment); ArmorUtils.addCommentHeader(armoredOutputStream, comment);
} }
return armoredOutputStream; return armoredOutputStream;
@ -52,45 +52,45 @@ public final class ArmoredOutputStreamFactory {
* Overwrite the version header of ASCII armors with a custom value. * Overwrite the version header of ASCII armors with a custom value.
* Newlines in the version info string result in multiple version header entries. * Newlines in the version info string result in multiple version header entries.
* *
* @param version version string * @param versionString version string
*/ */
public static void setVersionInfo(String version) { public static void setVersionInfo(String versionString) {
if (version == null || version.trim().isEmpty()) { if (versionString == null || versionString.trim().isEmpty()) {
throw new IllegalArgumentException("Version Info MUST NOT be null NOR empty."); throw new IllegalArgumentException("Version Info MUST NOT be null NOR empty.");
} }
VERSION = version; version = versionString;
} }
/** /**
* Reset the version header to its default value of {@link #PGPAINLESS}. * Reset the version header to its default value of {@link #PGPAINLESS}.
*/ */
public static void resetVersionInfo() { public static void resetVersionInfo() {
VERSION = PGPAINLESS; version = PGPAINLESS;
} }
/** /**
* Set a comment header value in the ASCII armor header. * Set a comment header value in the ASCII armor header.
* If the comment contains newlines, it will be split into multiple header entries. * If the comment contains newlines, it will be split into multiple header entries.
* *
* @param comment comment * @param commentString comment
*/ */
public static void setComment(String comment) { public static void setComment(String commentString) {
if (comment == null) { if (commentString == null) {
throw new IllegalArgumentException("Comment cannot be null."); throw new IllegalArgumentException("Comment cannot be null.");
} }
String trimmed = comment.trim(); String trimmed = commentString.trim();
if (trimmed.isEmpty()) { if (trimmed.isEmpty()) {
throw new IllegalArgumentException("Comment cannot be empty."); throw new IllegalArgumentException("Comment cannot be empty.");
} }
String[] lines = comment.split("\n"); String[] lines = commentString.split("\n");
COMMENT = lines; comment = lines;
} }
/** /**
* Reset to the default of no comment headers. * Reset to the default of no comment headers.
*/ */
public static void resetComment() { public static void resetComment() {
COMMENT = new String[0]; comment = new String[0];
} }
} }