aboutsummaryrefslogtreecommitdiff
path: root/src/com/wilko/jaim/Utils.java
diff options
context:
space:
mode:
authorFrankie B <git@diskfloppy.me>2024-05-10 00:32:34 +0100
committerFrankie B <git@diskfloppy.me>2024-05-10 00:32:34 +0100
commit3faced7068a8401b57be8949e80ce4f4da4a0fb5 (patch)
tree32e76b06780fe6c14ddb4917d3ad0b222fa9c596 /src/com/wilko/jaim/Utils.java
parenta1dff2cb8d33b17bc5981f1638cd50266713e98f (diff)
Format all code, add editorconfig
Diffstat (limited to 'src/com/wilko/jaim/Utils.java')
-rw-r--r--src/com/wilko/jaim/Utils.java128
1 files changed, 60 insertions, 68 deletions
diff --git a/src/com/wilko/jaim/Utils.java b/src/com/wilko/jaim/Utils.java
index a226966..8ddac39 100644
--- a/src/com/wilko/jaim/Utils.java
+++ b/src/com/wilko/jaim/Utils.java
@@ -1,4 +1,4 @@
-/*
+/*
* (C) 2002 Paul Wilkinson wilko@users.sourceforge.net
*
* This program is free software; you can redistribute it and/or modify
@@ -26,100 +26,92 @@
package com.wilko.jaim;
/**
- *
* @author paulw
* @version $Revision: 1.4 $
*/
public class Utils {
- private static final String roastKey="Tic/Toc";
- private static final int roastLen=7;
+ private static final String roastKey = "Tic/Toc";
+ private static final int roastLen = 7;
- /** convert a buddy name to normalised format - remove spaces and convert to lower case
+ /**
+ * convert a buddy name to normalised format - remove spaces and convert to lower case
+ *
* @param input The un-normalised buddy name
* @return the normalised buddy name
- */
+ */
public static String normalise(java.lang.String input) {
- StringBuffer output=new StringBuffer();
- String temp=input.toLowerCase();
- for (int i=0;i<input.length();i++)
- {
- char c=temp.charAt(i);
- if ((c>= '0' && c<='9')||(c>='a' && c<='z'))
- {
+ StringBuffer output = new StringBuffer();
+ String temp = input.toLowerCase();
+ for (int i = 0; i < input.length(); i++) {
+ char c = temp.charAt(i);
+ if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z')) {
output.append(c);
}
}
-
- return(output.toString());
+
+ return (output.toString());
}
-
- /** Roast a password using the AOL roasting protocol
+
+ /**
+ * Roast a password using the AOL roasting protocol
+ *
* @param password The password to be roasted
* @return The roasted password
- */
+ */
public static String roast(java.lang.String password) {
- char[] hexChars={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
-
- StringBuffer temppw=new StringBuffer();
+ char[] hexChars = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+
+ StringBuffer temppw = new StringBuffer();
temppw.append("0x");
- for (int i=0;i<password.length();i++)
- {
- int roastedByte=password.charAt(i)^roastKey.charAt(i%roastLen);
-
- temppw.append(hexChars[(roastedByte>>4)&0x0f]);
- temppw.append(hexChars[roastedByte&0x0f]);
+ for (int i = 0; i < password.length(); i++) {
+ int roastedByte = password.charAt(i) ^ roastKey.charAt(i % roastLen);
+
+ temppw.append(hexChars[(roastedByte >> 4) & 0x0f]);
+ temppw.append(hexChars[roastedByte & 0x0f]);
}
- return(temppw.toString());
+ return (temppw.toString());
}
-
- /** This method performs a simple HTML strip on text. It looks for < characters and then skips input until a matching > is found.
+
+ /**
+ * This method performs a simple HTML strip on text. It looks for < characters and then skips input until a matching > is found.
* This may fail if the HTML tag contains an embedded '>'
+ *
* @param input The text to have HTML stripped
* @return The text stripped of html
- */
- public static String stripHTML(java.lang.String input)
- {
- StringBuffer output=new StringBuffer();
- boolean inHTML=false;
- for (int i=0;i<input.length();i++)
- {
- char c=input.charAt(i);
- if (c=='<')
- {
- inHTML=true;
- }
- else
- {
- if (c=='>') {
- inHTML=false;
- }
- else
- {
- if (!inHTML)
- {
+ */
+ public static String stripHTML(java.lang.String input) {
+ StringBuffer output = new StringBuffer();
+ boolean inHTML = false;
+ for (int i = 0; i < input.length(); i++) {
+ char c = input.charAt(i);
+ if (c == '<') {
+ inHTML = true;
+ } else {
+ if (c == '>') {
+ inHTML = false;
+ } else {
+ if (!inHTML) {
output.append(c);
}
}
}
}
- return(output.toString());
+ return (output.toString());
}
-
-
- /** Encode a text message so that it is suitable for transmission using toc_send_im
+
+
+ /**
+ * Encode a text message so that it is suitable for transmission using toc_send_im
*
* @param input The text to be encoded
* @return The encoded text
- */
- public static String encodeText(String input)
- {
- StringBuffer output=new StringBuffer("\"");
- for (int i=0;i<input.length();i++)
- {
- char c=input.charAt(i);
- switch (c)
- {
+ */
+ public static String encodeText(String input) {
+ StringBuffer output = new StringBuffer("\"");
+ for (int i = 0; i < input.length(); i++) {
+ char c = input.charAt(i);
+ switch (c) {
case '\"':
case '(':
case ')':
@@ -134,10 +126,10 @@ public class Utils {
}
output.append(c);
}
-
+
output.append('\"');
- return(output.toString());
+ return (output.toString());
}
-
-
+
+
}