Added Javadoc comments to the classes

This commit is contained in:
2024-08-11 23:48:02 -04:00
parent b16956b184
commit c10df8e5df
29 changed files with 3270 additions and 431 deletions

View File

@@ -1,7 +1,23 @@
//CipherStreamJava/src/main/java/com/mattrixwv/cipherstream/polysubstitution/LargePolybiusSquare.java
//Mattrixwv
// Created: 04-21-23
// Modified: 05-04-23
// 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;
@@ -15,11 +31,18 @@ import com.mattrixwv.cipherstream.exceptions.InvalidInputException;
import com.mattrixwv.cipherstream.exceptions.InvalidKeywordException;
/**
* Represents the Polybius square cipher encryption and decryption.
* The Polybius square cipher is a classical encryption method that uses a 6x6 grid
* to encode and decode messages based on the positions of letters and numbers in the grid.
*/
public class LargePolybiusSquare extends PolybiusSquare{
private static final Logger logger = LoggerFactory.getLogger(LargePolybiusSquare.class);
//Create the grid from the keyword
/**
* Creates the grid from the keyword.
*/
@Override
protected void createGrid(){
logger.debug("Creating grid");
@@ -31,7 +54,13 @@ public class LargePolybiusSquare extends PolybiusSquare{
}
}
}
//Strips invalid characters from the string that needs encoded/decoded
/**
* Strips invalid characters from the string that needs encoding/decoding.
*
* @param inputString the input string to be cleaned
* @throws InvalidCharacterException if an invalid character is found
* @throws InvalidInputException if the input string is invalid
*/
@Override
protected void setInputStringEncode(String inputString) throws InvalidCharacterException, InvalidInputException{
if(inputString == null){
@@ -75,7 +104,11 @@ public class LargePolybiusSquare extends PolybiusSquare{
throw new InvalidInputException("Input must contain at least 1 letter");
}
}
//Returns the input string ready for encoding
/**
* Returns the input string ready for encoding.
*
* @return the prepared input string
*/
@Override
protected String getPreparedInputStringEncode(){
logger.debug("Preparing input string for encoding");
@@ -87,7 +120,11 @@ public class LargePolybiusSquare extends PolybiusSquare{
return cleanString;
}
//Strips invalid characters from the keyword and creates the grid
/**
* Strips invalid characters from the keyword and creates the grid.
*
* @param keyword the keyword to be processed
*/
@Override
protected void setKeyword(String keyword) throws InvalidKeywordException{
if(keyword == null){
@@ -116,7 +153,11 @@ public class LargePolybiusSquare extends PolybiusSquare{
//Create the grid from the sanitized keyword
createGrid();
}
//Adds characters that aren't letters to the output
/**
* Adds characters that aren't letters to the output during encoding.
*
* @param cleanString the cleaned string to be formatted
*/
@Override
protected void addCharactersToCleanStringEncode(String cleanString){
logger.debug("Formatting output string");
@@ -144,6 +185,11 @@ public class LargePolybiusSquare extends PolybiusSquare{
outputString = fullOutput.toString();
logger.debug("Saving output string {}", outputString);
}
/**
* Adds characters that aren't letters to the output during decoding.
*
* @param cleanString the cleaned string to be formatted
*/
@Override
protected void addCharactersToCleanStringDecode(String cleanString){
logger.debug("Formatting output string");
@@ -172,7 +218,9 @@ public class LargePolybiusSquare extends PolybiusSquare{
logger.debug("Saving output string {}", outputString);
}
//Makes sure all variables are empty
/**
* Resets all variables to their default values.
*/
@Override
public void reset(){
logger.debug("Resetting");
@@ -183,10 +231,22 @@ public class LargePolybiusSquare extends PolybiusSquare{
keyword = "";
}
//Constructors
//?Constructors
/**
* Constructs a PolybiusSquare cipher instance with default settings.
*
* @throws InvalidCharacterException if default characters are invalid
*/
public LargePolybiusSquare() throws InvalidCharacterException{
super();
}
/**
* Constructs a PolybiusSquare cipher instance with specified settings.
*
* @param preserveWhitespace whether to preserve whitespace
* @param preserveSymbols whether to preserve symbols
* @throws InvalidCharacterException if default characters are invalid
*/
public LargePolybiusSquare(boolean preserveWhitespace, boolean preserveSymbols) throws InvalidCharacterException{
super(preserveWhitespace, preserveSymbols);
}