29.07.2013 Views

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

}<br />

}<br />

}<br />

if(print)<br />

print(out);<br />

private static int getLevel(String className)<br />

{<br />

String[] temp;<br />

String nextName = "";<br />

}<br />

//Extract classnames and packagenames<br />

StringTokenizer st = new StringTokenizer(className, ". ");<br />

while(st.hasMoreTokens())<br />

{<br />

temp = new String[st.countTokens()];<br />

for(int j = 0; j < temp.length; j++)<br />

temp[j] = st.nextToken();<br />

for(int j = temp.length - 1; j >= 0; j--)<br />

{<br />

nextName = temp[j];<br />

for(int i = 0; i < debugDefinitions.length; i++)<br />

{<br />

if(debugDefinitions[i].className.equals(nextName))<br />

{<br />

//Name found.<br />

return debugDefinitions[i].debuglevel;<br />

}<br />

}<br />

}<br />

}<br />

// Neither packages nor classname found in the DefinitionsList<br />

return -1;<br />

// Searches for the name in String <strong>of</strong> the form:<br />

// <strong>Spam</strong>Cash.Utilities.Debugger.<br />

private static String getClassName(String name)<br />

{<br />

//System.out.println("NAME: "+name);<br />

StringTokenizer st = new StringTokenizer(name, ". ");<br />

String[] temp = new String[st.countTokens()];<br />

for(int j = 0; j < temp.length; j++)<br />

temp[j] = st.nextToken();<br />

}<br />

//System.out.println("Result: "+temp[temp.length - 1]);<br />

return temp[temp.length - 1];<br />

private static String trim(String s)<br />

{<br />

if(!trim)<br />

return s;<br />

int maxLength = 90;<br />

String newline = System.getProperty("line.separator");<br />

String s2 = "";<br />

}<br />

StringTokenizer st = new StringTokenizer(s, newline);<br />

s2 = st.nextToken();<br />

if(s2.length() < maxLength)<br />

return s2;<br />

else<br />

return s2.substring(0, maxLength - 3) + "...";<br />

private static void print(String s)<br />

402

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!