2004.04.29


com.jdc.lang
Class ToString

java.lang.Object
  |
  +--com.jdc.lang.Object
        |
        +--com.jdc.lang.ToString

public class ToString
extends Object

ToString is a utility class used to create a toString representation of an object. The caller may specify a object title as well as any number of object attributes.

The String returned (by the ToString method toString) will have the format:

    title
    {
        attribute = value
        attribute = value
        attribute = value
        . . .
    }
 

Version:
1.0
Author:
Jay Damon

Field Summary
 
Fields inherited from class com.jdc.lang.Object
string
 
Constructor Summary
ToString()
          Constructs a new ToString object.
ToString(int indentLevel)
          Constructs a new ToString object with the specified indentation level.
ToString(Object object)
          Constructs a new ToString object for the specified object.
 
Method Summary
 void addAttribute(String attribute)
          Adds a toString attribute line.
 void addAttribute(String attribute, boolean value)
          Adds a toString attribute line for the specified attribute and boolean value.
 void addAttribute(String attribute, int value)
          Adds a toString attribute line for the specified attribute and int value.
 void addAttribute(String attribute, String value)
          Adds a toString attribute line for the specified attribute and String value.
 void addTitle(Object object)
          Adds a toString title line with the specified object Class name.
 void addTitle(String title)
          Adds a toString title line.
 String toString()
          Returns a toString representation for an object..
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ToString

public ToString()
Constructs a new ToString object.


ToString

public ToString(int indentLevel)
Constructs a new ToString object with the specified indentation level.


ToString

public ToString(Object object)
Constructs a new ToString object for the specified object.

Method Detail

addAttribute

public void addAttribute(String attribute)
Adds a toString attribute line.


addAttribute

public void addAttribute(String attribute,
                         boolean value)
Adds a toString attribute line for the specified attribute and boolean value.


addAttribute

public void addAttribute(String attribute,
                         int value)
Adds a toString attribute line for the specified attribute and int value.


addAttribute

public void addAttribute(String attribute,
                         String value)
Adds a toString attribute line for the specified attribute and String value.


addTitle

public void addTitle(String title)
Adds a toString title line.


addTitle

public void addTitle(Object object)
Adds a toString title line with the specified object Class name.


toString

public String toString()
Returns a toString representation for an object..

Overrides:
toString in class Object
Returns:
A toString representation for an object.

2004.04.29



Copyright © 2004 J. Damon & Co.; All Rights Reserved WorldWide.