Updating tests
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//CipherStreamJava/src/main/java/com/mattrixwv/CipherStreamJava/monoSubstitution/BaseX.java
|
||||
//Mattrixwv
|
||||
// Created: 01-08-22
|
||||
//Modified: 04-16-23
|
||||
//Modified: 05-04-23
|
||||
package com.mattrixwv.cipherstream.monosubstitution;
|
||||
|
||||
|
||||
@@ -16,12 +16,14 @@ import com.mattrixwv.cipherstream.exceptions.InvalidBaseException;
|
||||
|
||||
|
||||
public class BaseX{
|
||||
protected static Logger logger = LoggerFactory.getLogger(BaseX.class);
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(BaseX.class);
|
||||
//Fields
|
||||
protected String inputString; //The string that needs encoded/decoded
|
||||
protected String outputString; //The encoded/decoded string
|
||||
//Settings
|
||||
protected int base; //The base that the number will be encoded at
|
||||
|
||||
|
||||
//Sets the input string
|
||||
protected void setInputStringEncode(String inputString) throws InvalidInputException{
|
||||
if(inputString == null){
|
||||
@@ -80,7 +82,7 @@ public class BaseX{
|
||||
this.base = base;
|
||||
}
|
||||
//Encode inputString, store it in outputString, and return it
|
||||
protected String encode(){
|
||||
protected void encode(){
|
||||
logger.debug("Encoding");
|
||||
|
||||
//Encode every character in inputString
|
||||
@@ -99,12 +101,9 @@ public class BaseX{
|
||||
//Save the output
|
||||
outputString = output.toString().toUpperCase();
|
||||
logger.debug("Saving output string '{}'", outputString);
|
||||
|
||||
//Return the output
|
||||
return outputString;
|
||||
}
|
||||
//Decode inputString, store it in outputString, and return it
|
||||
protected String decode() throws InvalidCharacterException{
|
||||
protected void decode() throws InvalidCharacterException{
|
||||
logger.debug("Decoding");
|
||||
|
||||
//Decode every binary number in the string
|
||||
@@ -128,9 +127,6 @@ public class BaseX{
|
||||
//Save the output
|
||||
outputString = output.toString();
|
||||
logger.debug("Saving output string '{}'", outputString);
|
||||
|
||||
//Return the output
|
||||
return outputString;
|
||||
}
|
||||
|
||||
//Constructor
|
||||
@@ -142,43 +138,47 @@ public class BaseX{
|
||||
reset();
|
||||
setBase(base);
|
||||
}
|
||||
//Returns the inputString
|
||||
public String getInputString(){
|
||||
return inputString;
|
||||
}
|
||||
//Returns the outputString
|
||||
public String getOutputString(){
|
||||
return outputString;
|
||||
}
|
||||
//Returns the base
|
||||
public int getBase(){
|
||||
return base;
|
||||
}
|
||||
|
||||
//Sets the inputString and encodes the message
|
||||
public String encode(String inputString) throws InvalidInputException{
|
||||
reset();
|
||||
setInputStringEncode(inputString);
|
||||
return encode();
|
||||
encode();
|
||||
return outputString;
|
||||
}
|
||||
public String encode(int base, String inputString) throws InvalidBaseException, InvalidInputException{
|
||||
reset();
|
||||
setBase(base);
|
||||
setInputStringEncode(inputString);
|
||||
return encode();
|
||||
encode();
|
||||
return outputString;
|
||||
}
|
||||
//Sets the inputString and decodes the message
|
||||
public String decode(String inputString) throws InvalidCharacterException, InvalidInputException{
|
||||
reset();
|
||||
setInputStringDecode(inputString);
|
||||
return decode();
|
||||
decode();
|
||||
return outputString;
|
||||
}
|
||||
public String decode(int base, String inputString) throws InvalidBaseException, InvalidCharacterException, InvalidInputException{
|
||||
reset();
|
||||
setBase(base);
|
||||
setInputStringDecode(inputString);
|
||||
return decode();
|
||||
decode();
|
||||
return outputString;
|
||||
}
|
||||
//Makes sure all of the variables are empty
|
||||
|
||||
//Getters
|
||||
public String getInputString(){
|
||||
return inputString;
|
||||
}
|
||||
public String getOutputString(){
|
||||
return outputString;
|
||||
}
|
||||
public int getBase(){
|
||||
return base;
|
||||
}
|
||||
//Makes sure all variables are empty
|
||||
public void reset(){
|
||||
logger.debug("Resetting fields");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user