org.dtools.ini
Class IniValidator

java.lang.Object
  extended by org.dtools.ini.IniValidator
All Implemented Interfaces:
Cloneable

public class IniValidator
extends Object
implements Cloneable

An IniValidator provides IniFiles, IniSections, and IniItems a way of validating a name for an IniSection or IniItem which is performed by the methods:

This class also allows users to define their own definitions of valid names through the use of regular expressions and the object java.util.regex.Pattern being passed to one of the following methods:

Since:
0.1.12
Version:
1.0.0
Author:
David Lewis

Constructor Summary
IniValidator()
          Default constructor, creates a new IniValidator
 
Method Summary
 Object clone()
          The method provides cloning features to the IniValidator class.
 boolean equals(Object other)
          Predicate that returns true if another IniValidator is equal to this IniValidator.
 int hashCode()
          This overrides and implements Object's hashCode method, and produces a hash code for this object.
 boolean isValidItemName(String name)
          Predicate that returns true if the given name is valid for a IniItem.
 boolean isValidSectionName(String name)
          Predicate that returns true is the given name is valid for a IniSection.
 void setItemNameRegEx(Pattern itemNameRegEx)
          Sets the regular Expression pattern for a valid IniItem name.
 void setSectionNameRegEx(Pattern sectionNameRegEx)
          Sets the regular Expression pattern for a valid IniSection's name.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IniValidator

public IniValidator()
Default constructor, creates a new IniValidator

Since:
0.1.12
Method Detail

isValidItemName

public boolean isValidItemName(String name)
Predicate that returns true if the given name is valid for a IniItem.

Parameters:
name - The name of an IniItem.
Returns:
True if the given name is valid, false otherwise.
Since:
0.1.12

isValidSectionName

public boolean isValidSectionName(String name)
Predicate that returns true is the given name is valid for a IniSection.

Parameters:
name - The name of the IniSection.
Returns:
True if the given name is valid, false otherwise.
Since:
0.1.12

setItemNameRegEx

public void setItemNameRegEx(Pattern itemNameRegEx)
Sets the regular Expression pattern for a valid IniItem name. The Pattern will be used by the isValidItemName(String) method to validate names.

Parameters:
itemNameRegEx - the regular expression pattern for an item's name
Since:
0.1.12

setSectionNameRegEx

public void setSectionNameRegEx(Pattern sectionNameRegEx)
Sets the regular Expression pattern for a valid IniSection's name. The Pattern will be used by the isValidSectioname(String) method to validate names.

Parameters:
sectionNameRegEx - the regular expression pattern for a section's name
Since:
0.1.12

equals

public boolean equals(Object other)
Predicate that returns true if another IniValidator is equal to this IniValidator. Two IniValidators are considered equal if they both have the same regular expression used for for validating items names and section names.

Overrides:
equals in class Object
Parameters:
other - The other object to compare with
Returns:
boolean, true if the other object is equal to this one, false otherwise.
Since:
0.1.16

hashCode

public int hashCode()
This overrides and implements Object's hashCode method, and produces a hash code for this object.

Overrides:
hashCode in class Object
Returns:
a hash code which represents this object.
Since:
0.3.01

clone

public Object clone()
The method provides cloning features to the IniValidator class.

Overrides:
clone in class Object
Returns:
a new IniValidator object which is a clone of the current object.
Since:
1.0.00