= Updated utils and logging subsystem formatting

This commit is contained in:
Matthew Cech
2019-06-19 22:14:13 -07:00
parent 5e531a19b7
commit 06317a4528
58 changed files with 205 additions and 202 deletions
+4 -4
View File
@@ -7,14 +7,14 @@ import java.sql.ResultSet;
public abstract class JDBCDriver
{
// Connects to the database, returns a bool if it succeeded.
public abstract boolean Connect();
public abstract boolean connect();
// Disconnects the driver. Returns if the driver is disconnected now, regardless of connection status.
public abstract boolean Disconnect();
public abstract boolean disconnect();
// Executes a SQL command with the database. Returns if it was executed successfully, or in the
// case of the returning statement, returns the ResultSet. Args are placed into the prepared statement
// in place of each '?' places into it.
public abstract boolean ExecuteStatement(JDBCStatementType type, String command, String[] args);
public abstract ResultSet ExecuteReturningStatement(JDBCStatementType type, String command, String[] args);
public abstract boolean executeStatement(JDBCStatementType type, String command, String[] args);
public abstract ResultSet executeReturningStatement(JDBCStatementType type, String command, String[] args);
}
+4 -4
View File
@@ -5,25 +5,25 @@ import java.sql.ResultSet;
public class JDBCDriverMySQL extends JDBCDriver
{
@Override
public boolean Connect() {
public boolean connect() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean Disconnect() {
public boolean disconnect() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean ExecuteStatement(JDBCStatementType type, String statement, String[] args) {
public boolean executeStatement(JDBCStatementType type, String statement, String[] args) {
// TODO Auto-generated method stub
return false;
}
@Override
public ResultSet ExecuteReturningStatement(JDBCStatementType type, String statement, String[] args) {
public ResultSet executeReturningStatement(JDBCStatementType type, String statement, String[] args) {
// TODO Auto-generated method stub
return null;
}
+4 -4
View File
@@ -5,25 +5,25 @@ import java.sql.ResultSet;
public class JDBCDriverPostgreSQL extends JDBCDriver
{
@Override
public boolean Connect() {
public boolean connect() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean Disconnect() {
public boolean disconnect() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean ExecuteStatement(JDBCStatementType type, String statement, String[] args) {
public boolean executeStatement(JDBCStatementType type, String statement, String[] args) {
// TODO Auto-generated method stub
return false;
}
@Override
public ResultSet ExecuteReturningStatement(JDBCStatementType type, String statement, String[] args) {
public ResultSet executeReturningStatement(JDBCStatementType type, String statement, String[] args) {
// TODO Auto-generated method stub
return null;
}
+10 -10
View File
@@ -18,7 +18,7 @@ public class JDBCDriverSQLite extends JDBCDriver
public static final String databaseName = "catfood";
@Override
public boolean Connect()
public boolean connect()
{
if(connection == null)
{
@@ -38,23 +38,23 @@ public class JDBCDriverSQLite extends JDBCDriver
// create a connection to the database
connection = DriverManager.getConnection(url);
GlobalLog.Log(LogFilter.Database, "Connection to SQLite has been established.");
GlobalLog.log(LogFilter.Database, "Connection to SQLite has been established.");
}
catch (SQLException e)
{
GlobalLog.Error(e.getMessage());
GlobalLog.error(e.getMessage());
}
}
else
{
GlobalLog.Log(LogFilter.Database, "SQLite database asked to connect a second time. This is perfectly fine as this app has all its data tied together.");
GlobalLog.log(LogFilter.Database, "SQLite database asked to connect a second time. This is perfectly fine as this app has all its data tied together.");
}
return connection != null;
}
@Override
public boolean Disconnect()
public boolean disconnect()
{
try
{
@@ -67,13 +67,13 @@ public class JDBCDriverSQLite extends JDBCDriver
}
catch (SQLException ex)
{
GlobalLog.Error(ex.getMessage());
GlobalLog.error(ex.getMessage());
return false;
}
}
@Override
public ResultSet ExecuteReturningStatement(JDBCStatementType type, String command, String[] args)
public ResultSet executeReturningStatement(JDBCStatementType type, String command, String[] args)
{
if(connection == null)
return null;
@@ -114,7 +114,7 @@ public class JDBCDriverSQLite extends JDBCDriver
{
try
{
GlobalLog.Fatal(e.getMessage());
GlobalLog.fatal(e.getMessage());
}
catch (Exception e1)
{
@@ -125,7 +125,7 @@ public class JDBCDriverSQLite extends JDBCDriver
}
}
public boolean ExecuteStatement(JDBCStatementType type, String command, String[] args)
public boolean executeStatement(JDBCStatementType type, String command, String[] args)
{
if(connection == null)
return false;
@@ -178,7 +178,7 @@ public class JDBCDriverSQLite extends JDBCDriver
{
try
{
GlobalLog.Fatal(e.getMessage());
GlobalLog.fatal(e.getMessage());
}
catch (Exception e1)
{
+3 -2
View File
@@ -4,7 +4,7 @@ import utils.HTTPUtils;
public class NetworkColiru
{
public String compileCPlus(String query)
public String compileCPlusPlus(String query)
{
// Escape characters that need escaping.
// Primarily types of whitespace.
@@ -15,7 +15,7 @@ public class NetworkColiru
query = query.replace("\t", "\\t");
// Send the compilation request!
String result = HTTPUtils.SendPOSTRequest("http://coliru.stacked-crooked.com/compile"
String result = HTTPUtils.sendPOSTRequest("http://coliru.stacked-crooked.com/compile"
, "{ \"cmd\": \"g++ main.cpp && ./a.out\", \"src\": \"" + query + "\" }");
// If we got a valid response...
@@ -23,6 +23,7 @@ public class NetworkColiru
{
result = "Here's what happened when I went to compiled that! \n```" + result + "```";
}
return result;
}
+2 -2
View File
@@ -26,7 +26,7 @@ public class NetworkDerpi
GenericImage image = new GenericImage(" ", " ", " ");
query = query.trim();
query = query.replace(" ", ",");
String res = HTTPUtils.SendGETRequest(mainURL + query + "&random_image=1&key=" + Ref.derpiKey);
String res = HTTPUtils.sendGETRequest(mainURL + query + "&random_image=1&key=" + Ref.derpiKey);
if(res != null)
{
// Use class evaluation on an array of the response object to be able to hold multiple.
@@ -34,7 +34,7 @@ public class NetworkDerpi
if(res != null)
{
String res2 = HTTPUtils.SendGETRequest("https://derpibooru.org/" + obj.id + ".json");
String res2 = HTTPUtils.sendGETRequest("https://derpibooru.org/" + obj.id + ".json");
image.editPostURL("<https://derpibooru.org/" + obj.id +">");
DerpiResponseObject imageObj = jsonParser_.fromJson(res2, DerpiResponseObject.class);
+1 -1
View File
@@ -56,7 +56,7 @@ public class NetworkE621
// Configure and send request. Note: Random ordering added as first
// tag by default. User-provided tags, therefore, will override it.
// If order:score is provided, that will be honored over order:random.
String res = HTTPUtils.SendPOSTRequest(API_ROOT
String res = HTTPUtils.sendPOSTRequest(API_ROOT
, "tags=order:random%20" + input + "&limit=" + maxSearchResults_);
+6 -3
View File
@@ -35,7 +35,8 @@ public class NetworkJDoodle
String input = "{\"clientId\": \"" + Ref.jdoodleID + "\",\"clientSecret\":\"" + Ref.jdoodleSecret + "\",\"script\":\"" + query +
"\",\"language\":\"" + lang + "\",\"versionIndex\":\"" + version + "\"} ";
try {
try
{
URL url = new URL("https://api.jdoodle.com/v1/execute");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
@@ -69,10 +70,12 @@ public class NetworkJDoodle
result += "The CPU time was " + doodle.cpuTime + "\n";
connection.disconnect();
return result;
} catch (MalformedURLException e)
}
catch (MalformedURLException e)
{
return "You probably shouldn't be seeing this";
} catch (IOException e)
}
catch (IOException e)
{
return "You probably shouldn't be seeing this";
}
+2 -2
View File
@@ -71,12 +71,12 @@ public class NetworkTheColorAPI
public tca_XYZ XYZ;
}
public ColorData LookupHex(String hex)
public ColorData lookupHex(String hex)
{
try
{
hex = hex.replace("#", "");
String response = HTTPUtils.SendGETRequest("https://www.thecolorapi.com/id?hex=" + hex);
String response = HTTPUtils.sendGETRequest("https://www.thecolorapi.com/id?hex=" + hex);
ColorData data = jsonParser.fromJson(response, ColorData.class);
return data;
-3
View File
@@ -18,8 +18,6 @@ public class NetworkTwitter
.setOAuthConsumerSecret(Ref.twitterAPISecret)
.setOAuthAccessToken(Ref.twitterAccessToken)
.setOAuthAccessTokenSecret(Ref.twitterAccessTokenSecret);
}
public String tweet(String tweetText) throws Exception
@@ -28,6 +26,5 @@ public class NetworkTwitter
Twitter twitter = tf.getInstance();
Status status = twitter.updateStatus(tweetText);
return "Status set to: `" + status.getText() + "`!";
}
}