|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nakedobjects.applib.util.TitleBuffer
public class TitleBuffer
Title buffer is a utility class to help produce titles for objects without having to add lots of guard code. It provides two basic method: one to concatenate a title to the buffer; another to append a title with a joiner string, taking care adding in necessary spaces. The benefits of using this class is that null references are safely ignored (rather than appearing as 'null'), and joiners (a space by default) are only added when needed.
| Constructor Summary | |
|---|---|
TitleBuffer()
Creates a new, empty, title object. |
|
TitleBuffer(Object object)
Creates a new title object, containing the title of the specified object. |
|
TitleBuffer(Object object,
String defaultTitle)
Creates a new title object, containing the title of the specified object. |
|
TitleBuffer(String text)
Creates a new title object, containing the specified text. |
|
| Method Summary | |
|---|---|
TitleBuffer |
append(int number)
|
TitleBuffer |
append(Object object)
Append the title of the specified object. |
TitleBuffer |
append(Object object,
String defaultValue)
Appends the title of the specified object, or the specified text if the objects title is null or empty. |
TitleBuffer |
append(String text)
Appends a space (if there is already some text in this title object) and then the specified text. |
TitleBuffer |
append(String joiner,
Object object)
Appends the joining string and the title of the specified object (from its toString
method). |
TitleBuffer |
append(String joiner,
Object object,
String defaultTitle)
Append the joiner text, a space, and the title of the specified naked object (object)
(got by calling the objects title() method) to the text of this TitleString object. |
TitleBuffer |
append(String joiner,
String text)
Appends the joiner text, a space, and the text to the text of this TitleString object. |
TitleBuffer |
appendSpace()
Append a space to the text of this TitleString object if, and only if, there is some existing text i.e., a space is only added to existing text and will not create a text entry consisting of only one space. |
TitleBuffer |
concat(Object object)
Concatenate the the title value (the result of calling an objects label() method) to this TitleString object. |
TitleBuffer |
concat(Object object,
String defaultValue)
Concatenate the the title value (the result of calling an objects label() method), or the specified default value if the title is equal to null or is empty, to this TitleString object. |
TitleBuffer |
concat(String text)
Concatenate the specified text on to the end of the text of this TitleString. |
TitleBuffer |
concat(String joiner,
Object object)
|
TitleBuffer |
concat(String joiner,
Object object,
String defaultValue)
|
static boolean |
isEmpty(Object object)
Determines if the specified object's title (from its toString method) is empty. |
static boolean |
isEmpty(String text)
Determines if the specified text is empty. |
String |
toString()
Returns a String that represents the value of this object. |
TitleBuffer |
truncate(int noWords)
Truncates this title so it has a maximum number of words. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TitleBuffer()
public TitleBuffer(Object object)
public TitleBuffer(Object object,
String defaultTitle)
public TitleBuffer(String text)
| Method Detail |
|---|
public static boolean isEmpty(Object object)
toString method) is empty. Will
return true if either: the specified reference is null; the object's toString method
returns null; or if the toString returns an empty string.
public static boolean isEmpty(String text)
public TitleBuffer append(int number)
public TitleBuffer append(Object object)
public TitleBuffer append(Object object,
String defaultValue)
object - the object whose title is to be appended to this title.defaultValue - a textual value to be used if the object's title is null or empty.
public TitleBuffer append(String text)
public TitleBuffer append(String joiner,
Object object)
toString
method). If the object is empty then nothing will be appended.
isEmpty(Object)
public TitleBuffer append(String joiner,
Object object,
String defaultTitle)
joiner text, a space, and the title of the specified naked object (object)
(got by calling the objects title() method) to the text of this TitleString object. If the title of the
specified object is null then use the defaultValue text. If both the objects title and
the default value are null or equate to a zero-length string then no text will be appended ; not even
the joiner text.
joiner - text to append before the titleobject - object whose title needs to be appendeddefaultTitle - the text to use if the the object's title is null.
public TitleBuffer append(String joiner,
String text)
public TitleBuffer appendSpace()
public final TitleBuffer concat(Object object)
object - the naked object to get a title from
public final TitleBuffer concat(Object object,
String defaultValue)
object - the naked object to get a title fromdefaultValue - the default text to use when the naked object is null
public final TitleBuffer concat(String text)
text - text to append
public final TitleBuffer concat(String joiner,
Object object)
public final TitleBuffer concat(String joiner,
Object object,
String defaultValue)
public String toString()
toString in class Objectpublic TitleBuffer truncate(int noWords)
noWords - the number of words to show
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||