|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.string.StringIndenter
Indentation management.
Details: StringIndenter contains a variety of utility functions that will make dealing with indented strings and tabs in strings easier.
Field Summary | |
static int |
STANDARD_TAB_SIZE
Standard tab size. |
Constructor Summary | |
StringIndenter()
|
Method Summary | |
static java.lang.String |
convertTabs(java.lang.String s)
Converts tabs to spaces. |
static java.lang.String |
convertTabs(java.lang.String s,
int ts)
Converts tabs to spaces. |
static int |
getIndent(java.lang.String s)
Determines indent amount. |
static int |
getIndent(java.lang.String s,
int ts)
Determines indent amount. |
static java.lang.String |
makeIndentPrefix(int indent)
Creates prefix for indenting. |
static java.lang.String |
makeIndentPrefix(int indent,
int tab_size)
Creates prefix for indenting. |
static java.lang.String |
setIndent(java.lang.String s,
int i)
Sets indent of string. |
static java.lang.String |
setIndent(java.lang.String s,
int i,
int ts)
Sets indent of string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int STANDARD_TAB_SIZE
Details: STANDARD_TAB_SIZE represents the traditional tab size of 8 spaces. It is defined here for convenience.
Constructor Detail |
public StringIndenter()
Method Detail |
public static final java.lang.String makeIndentPrefix(int indent, int tab_size)
Details: makeIndentPrefix creates a string of tabs and spaces suitable for prepending to a string you want to indent indent space. Calling this method is similar to a call to calling StringToolbox.repeat (' ', indent)
, except that consecutive blocks of tab_size spaces are replaced with tab ('\t
') characters.
indent
- the indent amounttab_size
- the tab sizepublic static final java.lang.String makeIndentPrefix(int indent)
Details: makeIndentPrefix calls makeIndentPrefix (indent, STANDARD_TAB_SIZE) and returns the result. See makeIndentPrefix(int,int) for more details.
indent
- the indent amountpublic static int getIndent(java.lang.String s, int ts)
Details: getIndent
interprets the given string's leading spaces and tabs to determine the amount of indent. Tabs count as 1-tab_size spaces, depending on where the tabs occur in the string. This method recognizes only spaces and tabs. Scanning stops at all other characters, and the indent measured up to that point is returned.
s
- the stringts
- the tab sizepublic static int getIndent(java.lang.String s)
Details: getIndent
calls getIndent (s, STANDARD_TAB_SIZE) and returns the result. See that method for more details.
s
- the stringpublic static java.lang.String setIndent(java.lang.String s, int i, int ts)
Details: setIndent
trims s of spaces (on both sides) and then prefixes the string with a number of spaces and tabs sufficient to indent the string by i spaces. Tabs are assumed to be ts
spaces. The re-indented string is returned.
s
- the stringi
- the amount of indentts
- the tab sizepublic static java.lang.String setIndent(java.lang.String s, int i)
Details: This method forwards to setIndent (s, i, STANDARD_TAB_SIZE). See that method for more details.
s
- the stringi
- the amount of indentpublic static java.lang.String convertTabs(java.lang.String s, int ts)
Details: convertTabs
replaces tabs in a string with the correct number of spaces to maintain the string's original spacing, assuming a tab size of ts. Tabs occuring in the middle of a tab block are handled correctly.
s
- the string to convertts
- the tab sizepublic static final java.lang.String convertTabs(java.lang.String s)
Details: This implementation of convertTabs forwards to convertTabs (s, STANDARD_TAB_SIZE). See convertTabs(String,int) for more details.
s
- the string to convert
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |