Back
package com.futureshocked.debug;
/**
* Simple class that will generate a certain amount of spaces for indentention.
* <br><br>
* Since <tt>scaleFactor</tt> is static this class is probably not useful if you
* wish to have different scale factors being used for indenting at the same
* time, however it's worth it to not have to bother creating a new
* instance.
*/
public class Indenter {
/**
* Just a bunch of spaces...
*/
public static String spaces = " " +
" " +
" " +
" ";
/**
* Scale factor - number of spaces returned is depth * scaleFactor
*/
public static int scaleFactor = 2;
/**
* Returns a <tt>String</tt> full of spaces, based off of depth.
* @param depth How far to indent.
* @return <tt>String</tt> object with the appropriate number of spaces.
*/
public static String indent(int depth) {
int end = depth * scaleFactor;
// if depth is ever too great simply double the length of spaces...
if (end > spaces.length())
spaces = spaces + spaces;
return spaces.substring(0, (depth * scaleFactor));
}
}
Top |