Format all code, add editorconfig
This commit is contained in:
parent
a1dff2cb8d
commit
3faced7068
52 changed files with 1985 additions and 1892 deletions
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue