|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.dtools.ini.IniItem
public class IniItem
The IniItem class represents the simplest element of an INI file, an item, which has only two important properties, a name and a value.
Any primitive type can be saved as a value of this item, and any objects
saved as a value are converted to a String via the object's
toString(), however all values returned by an item are returned
as a String.
| Field Summary |
|---|
| Fields inherited from interface org.dtools.ini.Commentable |
|---|
COMMENT_SYMBOL |
| Constructor Summary | |
|---|---|
IniItem(String name)
Default constructor which creates a new instance of this IniItem and sets the IniItem to have a
default IniValidator and to be case insensitive. |
|
IniItem(String name,
boolean caseSensitive)
Default constructor which creates a new instance of this IniItem and sets the IniItem to have a
default IniValidator. |
|
IniItem(String name,
IniValidator validator)
Default constructor which creates a new instance of this IniItem and sets the IniItem to be case
insensitive. |
|
IniItem(String name,
IniValidator validator,
boolean caseSensitive)
Default constructor which creates a new instance of this IniItem. |
|
| Method Summary | |
|---|---|
boolean |
clear()
This method clears the value of this item. |
Object |
clone()
|
boolean |
equals(Object otherObject)
This predicate returns true if this IniItem is equal to
the given object. |
String |
getEndLineComment()
Returns the comment that comes after the object on the same line. |
String |
getName()
Returns the name of this item, note that the item cannot change its name and one would need to create a new item to do so. |
String |
getPostComment()
Returns the comment that comes after the object. |
String |
getPreComment()
Returns the comment that comes before the object. |
IniValidator |
getValidator()
Gets a reference to this object's IniValidator. |
String |
getValue()
This returns the String which this items stores. |
int |
hashCode()
|
boolean |
hasValue()
Predicate that returns true if this item has a value, or false if it is empty |
boolean |
isCaseSensitive()
Predicate that returns true if this IniItem is case
sensitive, or false if this IniItem is
case insensitive. |
void |
removeEndLineComment()
Removes an end line comment from the object. |
void |
removePostComment()
Removes a post-comment from the object. |
void |
removePreComment()
Removes a pre-comment from the object. |
void |
setEndLineComment(String comment)
Set the comment that comes after the object but on the same line. |
void |
setPostComment(String comment)
Set the comment that comes after the object. |
void |
setPreComment(String comment)
Set the comment that comes before the object. |
void |
setValue(boolean value)
Set the value as a boolean value |
void |
setValue(char value)
Set the value as a character value |
void |
setValue(double value)
Set the value as a double value |
void |
setValue(long value)
Set the value as a float value |
void |
setValue(Object value)
This set the value to an Object when it has been converted to a String. |
void |
setValue(String value)
Set the value as a String value |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public IniItem(String name)
Default constructor which creates a new instance of this
IniItem and sets the IniItem to have a
default IniValidator and to be case insensitive.
name - The name of this IniItem.
InvalidNameException - if the name of the IniItem
given is not considered valid by this object's IniValidator.
public IniItem(String name,
boolean caseSensitive)
Default constructor which creates a new instance of this
IniItem and sets the IniItem to have a
default IniValidator.
name - The name of this IniItem.caseSensitive - Sets whether this IniItem is case
sensitive.
InvalidNameException - if the name of the IniItem
given is not considered valid by this object's IniValidator.
public IniItem(String name,
IniValidator validator)
Default constructor which creates a new instance of this
IniItem and sets the IniItem to be case
insensitive.
name - The name of this IniItem.validator - The validator of this IniItem.
InvalidNameException - if the name of the IniItem
given is not considered valid by this object's IniValidator.
public IniItem(String name,
IniValidator validator,
boolean caseSensitive)
Default constructor which creates a new instance of this
IniItem.
name - The name of this IniItem.validator - The validator of this IniItem.caseSensitive - Sets whether this IniItem is case
sensitive.
InvalidNameException - if the name of the IniItem
given is not considered valid by this object's IniValidator.| Method Detail |
|---|
public boolean clear()
public boolean equals(Object otherObject)
This predicate returns true if this IniItem is equal to
the given object. For otherObject to be equal to this one it
must:
IniItem.IniItem.
IniValidator as this
IniItem's IniValidator.IniItem.*IniItem.*IniItem.*IniItem.*IniItem.** If the two IniItems are
case-sensitive, then these are compared using the
equals(Object) method. If the two IniItems are
case-insensitive, then these are compared using the
String.equalsIgnoreCase(String) method.
equals in class ObjectotherObject - The other Object to test for equality.
public String getEndLineComment()
CommentableReturns the comment that comes after the object on the same line. If not such comment exists an empty string is returned.
getEndLineComment in interface Commentablepublic String getName()
public String getPostComment()
CommentableReturns the comment that comes after the object. If not such comment exists an empty string is returned.
getPostComment in interface Commentablepublic String getPreComment()
CommentableReturns the comment that comes before the object. If not such comment exists an empty string is returned.
getPreComment in interface Commentablepublic IniValidator getValidator()
Gets a reference to this object's IniValidator.
IniValidator used by this
IniItem.public String getValue()
public int hashCode()
hashCode in class Objectpublic boolean hasValue()
public boolean isCaseSensitive()
Predicate that returns true if this IniItem is case
sensitive, or false if this IniItem is
case insensitive.
public void removeEndLineComment()
CommentablesetEndLineComment("");
removeEndLineComment in interface Commentablepublic void removePostComment()
CommentablesetPostComment("");
removePostComment in interface Commentablepublic void removePreComment()
CommentablesetPreComment("");
removePreComment in interface Commentablepublic void setEndLineComment(String comment)
CommentableSet the comment that comes after the object but on the same line.
setEndLineComment in interface Commentablecomment - The text comment, if this value is null, then the comment
is set to an empty string.public void setPostComment(String comment)
Commentable
setPostComment in interface Commentablecomment - the text comment, if this value is null, then the comment
is set to an empty string.public void setPreComment(String comment)
CommentableSet the comment that comes before the object.
setPreComment in interface Commentablecomment - the text comment, if this value is null, then the comment
is set to an empty string.public void setValue(boolean value)
value - The value to set.public void setValue(char value)
value - The value to set.public void setValue(double value)
value - The value to set.public void setValue(long value)
value - the value to setpublic void setValue(Object value)
value - the value to setpublic void setValue(String value)
value - the value to setpublic String toString()
toString in class Objectpublic Object clone()
clone in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||