|
@@ -58,6 +58,14 @@ public class Tools
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Method to pad the left of a Sting with given character
|
|
|
+ * @param count Destination amount of data
|
|
|
+ * @param base String to pad up
|
|
|
+ * @param filler Padding data
|
|
|
+ * @return Padded String
|
|
|
+ */
|
|
|
public static String padLeft(final int count, final String base, final char filler)
|
|
|
{
|
|
|
if (base == null)
|
|
@@ -72,7 +80,12 @@ public class Tools
|
|
|
Arrays.fill(prefix, filler);
|
|
|
return new StringBuilder(count).append(prefix).append(base).toString();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Method rename and shorthand for Thread.sleep()
|
|
|
+ * @param time Time to wait in ms
|
|
|
+ */
|
|
|
public static void wait(int time)
|
|
|
{
|
|
|
|
|
@@ -85,7 +98,12 @@ public class Tools
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * SHA-Hashes a String
|
|
|
+ * @param s String to hash
|
|
|
+ * @return Hashed String
|
|
|
+ */
|
|
|
public static String getSHAString(String s)
|
|
|
{
|
|
|
try
|
|
@@ -112,7 +130,13 @@ public class Tools
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Integerizes a String
|
|
|
+ * @param ip String to integerize
|
|
|
+ * @return Array of Integers where each int is a Character of the string
|
|
|
+ */
|
|
|
public static int[] lettersToInt(String ip)
|
|
|
{
|
|
|
ip = ip.toLowerCase();
|
|
@@ -125,6 +149,11 @@ public class Tools
|
|
|
return ri;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Sum of the Elements of the Array
|
|
|
+ * @param i Integer-array to sumup
|
|
|
+ * @return Sum of the elements
|
|
|
+ */
|
|
|
public static int addIntsTogether(int[] i)
|
|
|
{
|
|
|
int t = 1;
|
|
@@ -135,6 +164,14 @@ public class Tools
|
|
|
return t;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Deprecated
|
|
|
+ /**
|
|
|
+ * HACK!!!
|
|
|
+ * @param m unknown
|
|
|
+ * @param ints unknown
|
|
|
+ * @return unknown
|
|
|
+ */
|
|
|
public static int addIntsTogether(HashMap<String, String> m, boolean ints)
|
|
|
{
|
|
|
//boolean ints = !noints;
|
|
@@ -168,6 +205,13 @@ public class Tools
|
|
|
return t;
|
|
|
}
|
|
|
|
|
|
+ @Deprecated
|
|
|
+ /**
|
|
|
+ * Adds the Strings together while respecting Alphabet and wraps . Dont use for new Code
|
|
|
+ * @param s1 String 1
|
|
|
+ * @param s2 String 2
|
|
|
+ * @return the merged Strings
|
|
|
+ */
|
|
|
public static String stringAdd(String s1, String s2)
|
|
|
{
|
|
|
char[] ca1 = s1.toLowerCase().toCharArray();
|
|
@@ -235,7 +279,7 @@ public class Tools
|
|
|
|
|
|
return backString(op);
|
|
|
}
|
|
|
-
|
|
|
+ @Deprecated
|
|
|
public static String backString(int[] ia)
|
|
|
{
|
|
|
int l = ia.length, i1;
|
|
@@ -259,7 +303,7 @@ public class Tools
|
|
|
|
|
|
return rl;
|
|
|
}
|
|
|
-
|
|
|
+ @Deprecated
|
|
|
public static String stringFold(String s, int l, int rec)//halbiert Strings und addiert die Hälften
|
|
|
{
|
|
|
int l1 = s.length() / 2;//,l2;
|
|
@@ -281,16 +325,34 @@ public class Tools
|
|
|
return so1;
|
|
|
}
|
|
|
|
|
|
+ @Deprecated
|
|
|
public static String stringFold(String s, int l)
|
|
|
{
|
|
|
return stringFold(s, l, 30);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 2-Elemente-Meckermeldung
|
|
|
+ * @param mode ignored
|
|
|
+ * @param MSGLine1 Zeile 1 der Meldung
|
|
|
+ * @param MSGLine2 ZEile 2 der Meldung
|
|
|
+ * @return true if left button got pressed, false on right one
|
|
|
+ */
|
|
|
public static boolean dlg(boolean mode, String MSGLine1, String MSGLine2)
|
|
|
{
|
|
|
return dlg(mode, MSGLine1, MSGLine2, "Fortfahren", "Abbrechen");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2-Elemente-Meckermeldung
|
|
|
+ * @param mode ignored
|
|
|
+ * @param MSGLine1 Zeile 1 der Meldung
|
|
|
+ * @param MSGLine2 ZEile 2 der Meldung
|
|
|
+ * @param btnLeft MEssage of left button
|
|
|
+ * @param btnRight MEssage of Right button
|
|
|
+ * @return true if left button got pressed, false on right one
|
|
|
+ */
|
|
|
public static boolean dlg(boolean mode, String MSGLine1, String MSGLine2, String btnLeft, String btnRight)
|
|
|
{
|
|
|
if(hl)
|
|
@@ -411,6 +473,10 @@ public class Tools
|
|
|
return ContState;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Wrapper to debugmessage code
|
|
|
+ * @param logLine Line to logg
|
|
|
+ */
|
|
|
public static void log(final String logLine)
|
|
|
{
|
|
|
/*Thread t = new Thread(new Runnable() {
|
|
@@ -540,6 +606,10 @@ public class Tools
|
|
|
|
|
|
*/
|
|
|
//</editor-fold>
|
|
|
+ /**
|
|
|
+ * COmmand run wrapper
|
|
|
+ * @param runnable Command elements
|
|
|
+ */
|
|
|
public static void runSingleCmd(String... runnable)
|
|
|
{
|
|
|
runSingleCmd(true, runnable);
|
|
@@ -884,7 +954,13 @@ public class Tools
|
|
|
return FileTK.getRelativePath(absolutePath, basePath);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /**
|
|
|
+ * Array shortening method
|
|
|
+ * @param toTrunc SArray to remove
|
|
|
+ * @param number Amount to remove
|
|
|
+ * @param fromBack True means remove from end, false means remove from start
|
|
|
+ * @return Shortened array
|
|
|
+ */
|
|
|
@SuppressWarnings("ManualArrayToCollectionCopy")//Quick and Dirty Hack
|
|
|
public static Object[] truncateArray(Object[] toTrunc, int number, boolean fromBack)
|
|
|
{
|
|
@@ -912,11 +988,23 @@ public class Tools
|
|
|
return out;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * OPens a Input window for a line of text
|
|
|
+ * @param title Title of the window
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public static String getInputString(String title)
|
|
|
{
|
|
|
return getInputString(title, false);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * OPens a Input window for a line of text
|
|
|
+ * @param title Title of the window
|
|
|
+ * @param txArea WHether to use a MUltiline input or a singleline inout
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public static String getInputString(String title, boolean txArea)
|
|
|
{
|
|
|
Object txfIP;//Hack!!!!
|
|
@@ -933,7 +1021,7 @@ public class Tools
|
|
|
null,
|
|
|
txfIP,
|
|
|
title,
|
|
|
- JOptionPane.OK_OPTION);
|
|
|
+ JOptionPane.PLAIN_MESSAGE);
|
|
|
String ret = "";
|
|
|
if (txArea == true)
|
|
|
{
|
|
@@ -946,6 +1034,11 @@ public class Tools
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Shorthand to write serialized data to a file
|
|
|
+ * @param o Object to dump
|
|
|
+ * @param p Destination file
|
|
|
+ */
|
|
|
public static void saveSerializedObject(Object[] o, String p)
|
|
|
{
|
|
|
try
|
|
@@ -959,7 +1052,12 @@ public class Tools
|
|
|
//NOP
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Shorthand to load serialized data
|
|
|
+ * @param p Path to load from
|
|
|
+ * @return Array with the objects dumped
|
|
|
+ */
|
|
|
public static Object[] loadSerializedObject(String p)
|
|
|
{
|
|
|
try
|