Fix build warnings
This commit is contained in:
@@ -1,23 +1,3 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/polysubstitution/PolybiusSquare.java
|
||||
//Mattrixwv
|
||||
// Created: 01-04-22
|
||||
//Modified: 08-11-24
|
||||
/*
|
||||
Copyright (C) 2024 Mattrixwv
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.mattrixwv.cipherstream.polysubstitution;
|
||||
|
||||
|
||||
@@ -94,14 +74,14 @@ public class PolybiusSquare{
|
||||
|
||||
|
||||
/**
|
||||
* Sets the replaced character.
|
||||
* Validates the Replaced character.
|
||||
*
|
||||
* @param replaced the character to be replaced
|
||||
* @param replaced the character to be validated
|
||||
* @throws InvalidCharacterException if the character is not a letter or is invalid
|
||||
* @return the validated character
|
||||
*/
|
||||
protected void setReplaced(char replaced) throws InvalidCharacterException{
|
||||
logger.debug("Setting replaced");
|
||||
logger.debug("Original character {}", replaced);
|
||||
private char validateReplaced(char replaced) throws InvalidCharacterException{
|
||||
logger.debug("Validating replaced character {}", replaced);
|
||||
|
||||
if(!Character.isAlphabetic(replaced)){
|
||||
throw new InvalidCharacterException("The replaced character must be a letter");
|
||||
@@ -112,18 +92,30 @@ public class PolybiusSquare{
|
||||
throw new InvalidCharacterException("The replaced letter cannot be the same as the replacing letter");
|
||||
}
|
||||
|
||||
this.replaced = Character.toUpperCase(replaced);
|
||||
logger.debug("Cleaned character {}", this.replaced);
|
||||
replaced = Character.toUpperCase(replaced);
|
||||
logger.debug("Cleaned character {}", replaced);
|
||||
return replaced;
|
||||
}
|
||||
/**
|
||||
* Sets the replacer character.
|
||||
* Sets the replaced character.
|
||||
*
|
||||
* @param replacer the character the replaces replaced
|
||||
* @param replaced the character to be replaced
|
||||
* @throws InvalidCharacterException if the character is not a letter or is invalid
|
||||
*/
|
||||
protected void setReplacer(char replacer) throws InvalidCharacterException{
|
||||
logger.debug("Setting replacer");
|
||||
logger.debug("Original character {}", replacer);
|
||||
protected void setReplaced(char replaced) throws InvalidCharacterException{
|
||||
logger.debug("Setting replaced");
|
||||
|
||||
this.replaced = validateReplaced(replaced);
|
||||
}
|
||||
/**
|
||||
* Validates the Replacer character.
|
||||
*
|
||||
* @param replacer the character to be validated
|
||||
* @throws InvalidCharacterException if the character is not a letter or is invalid
|
||||
* @return the validated character
|
||||
*/
|
||||
private char validateReplacer(char replacer) throws InvalidCharacterException{
|
||||
logger.debug("Validating replacer character {}", replacer);
|
||||
|
||||
if(!Character.isAlphabetic(replacer)){
|
||||
throw new InvalidCharacterException("The replacer character must be a letter");
|
||||
@@ -134,8 +126,20 @@ public class PolybiusSquare{
|
||||
throw new InvalidCharacterException("The replacer letter cannot be the same as the replaced letter");
|
||||
}
|
||||
|
||||
this.replacer = Character.toUpperCase(replacer);
|
||||
logger.debug("Cleaned character {}", this.replacer);
|
||||
replacer = Character.toUpperCase(replacer);
|
||||
logger.debug("Cleaned character {}", replacer);
|
||||
return replacer;
|
||||
}
|
||||
/**
|
||||
* Sets the replacer character.
|
||||
*
|
||||
* @param replacer the character the replaces replaced
|
||||
* @throws InvalidCharacterException if the character is not a letter or is invalid
|
||||
*/
|
||||
protected void setReplacer(char replacer) throws InvalidCharacterException{
|
||||
logger.debug("Setting replacer");
|
||||
|
||||
this.replacer = validateReplacer(replacer);
|
||||
}
|
||||
/**
|
||||
* Creates the grid from the keyword.
|
||||
@@ -478,9 +482,12 @@ public class PolybiusSquare{
|
||||
* @throws InvalidCharacterException if default characters are invalid
|
||||
*/
|
||||
public PolybiusSquare() throws InvalidCharacterException{
|
||||
reset();
|
||||
setReplaced('J');
|
||||
setReplacer('I');
|
||||
grid = new char[5][5];
|
||||
inputString = "";
|
||||
outputString = "";
|
||||
keyword = "";
|
||||
this.replaced = validateReplaced('J');
|
||||
this.replacer = validateReplacer('I');
|
||||
preserveWhitespace = false;
|
||||
preserveSymbols = false;
|
||||
}
|
||||
@@ -492,9 +499,12 @@ public class PolybiusSquare{
|
||||
* @throws InvalidCharacterException if default characters are invalid
|
||||
*/
|
||||
public PolybiusSquare(boolean preserveWhitespace, boolean preserveSymbols) throws InvalidCharacterException{
|
||||
reset();
|
||||
setReplaced('J');
|
||||
setReplacer('I');
|
||||
grid = new char[5][5];
|
||||
inputString = "";
|
||||
outputString = "";
|
||||
keyword = "";
|
||||
this.replaced = validateReplaced('J');
|
||||
this.replacer = validateReplacer('I');
|
||||
this.preserveWhitespace = preserveWhitespace;
|
||||
this.preserveSymbols = preserveSymbols;
|
||||
}
|
||||
@@ -508,9 +518,12 @@ public class PolybiusSquare{
|
||||
* @throws InvalidCharacterException if any character is invalid
|
||||
*/
|
||||
public PolybiusSquare(boolean preserveWhitespace, boolean preserveSymbols, char replaced, char replacer) throws InvalidCharacterException{
|
||||
reset();
|
||||
setReplaced(replaced);
|
||||
setReplacer(replacer);
|
||||
grid = new char[5][5];
|
||||
inputString = "";
|
||||
outputString = "";
|
||||
keyword = "";
|
||||
this.replaced = validateReplaced(replaced);
|
||||
this.replacer = validateReplacer(replacer);
|
||||
this.preserveWhitespace = preserveWhitespace;
|
||||
this.preserveSymbols = preserveSymbols;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user