|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.kopitubruk.util.json.IndentPadding
public class IndentPadding
This class provides a way to do indented formatting of the output to make it easier to read for debugging. Each item is on its own line and indented to show nesting.
To use this, create the object and set any parameters you like and call
JSONConfig.setIndentPadding(IndentPadding) to add it to your config
object and use it when you convert to JSON.
This class is NOT thread safe. Do not reuse this object in different threads.
If you reuse JSONConfig objects in the same thread, then you should probably
call reset() before calling JSONUtil's toJSON() methods just to be
safe (but not inside JSONAbles that have a JSONConfig object sent to
them and use JSONUtil to generate their JSON).
| Constructor Summary | |
|---|---|
IndentPadding()
Create an indent padding object using four spaces and a standard newline. |
|
IndentPadding(String indent,
String newLine)
Create an indent padding object with the given indent and newLine strings. |
|
| Method Summary | |
|---|---|
IndentPadding |
clone()
|
void |
decrementLevel()
Decrement the level of indent. |
String |
getIndent()
Get the spacing for one indent level. |
String |
getNewLine()
Get the string to use for a new line (default \n) |
String |
getPadding()
Get the padding for the current indent level. |
void |
incrementLevel()
Increment the level of indent. |
void |
reset()
Reset this object's operating data. |
void |
setIndent(String indent)
Set the spacing for one indent level (default is 4 spaces). |
void |
setNewLine(String newLine)
Set the string to use for a new line (default \n). |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IndentPadding()
public IndentPadding(String indent,
String newLine)
indent - The indent string to use for one level.newLine - The new line string.| Method Detail |
|---|
public IndentPadding clone()
clone in class Objectpublic void reset()
public String getIndent()
public void setIndent(String indent)
indent - The spacing for one indent level.public void incrementLevel()
public void decrementLevel()
public String getNewLine()
public void setNewLine(String newLine)
Set the string to use for a new line (default \n). A string is used so that you can use \r\n or other new line sequences if you like.
For example, if you wanted a platform specific newLine, you could do this:
setNewLine(String.format("%n"));
newLine - The string to use for a new line (default \n)public String getPadding()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||