Methods Summary |
---|
public java.lang.String | getConstraints()
return constraints;
|
boolean | isValidConstraints(java.lang.String constraints)Checks if the given constraint set is a subset of valid constraint set.
if (constraints == null) { return false; }
final int length = constraints.length();
if ((length == 0) || (length > 4)) { return false; }
boolean isValid = true;
for (int i = 0; i < length; i++)
{
char ch = constraints.charAt(i);
switch (ch)
{
case 'r" :
case 'w" :
case 'x" :
case 'd" :
continue;
default :
isValid = false;
break;
}
}
return isValid;
|
public java.lang.String | setConstraints(java.lang.String constraints)Sets the current constraint set to the given set if it is a valid
constriant set.
if (isValidConstraints(constraints))
{
this.constraints = constraints;
}
return this.constraints;
|
public void | validate(java.lang.Object str)Validates the given File.
super.validate(str);
new StringValidator(getName()).validate(str);
File f = new File((String)str);
validateConstraints(f);
|
void | validateConstraints(java.io.File file)Validates the given File against the current constraint set.
final File f = FileUtils.safeGetCanonicalFile(file);
final String constriants = getConstraints();
char[] ca = constriants.toCharArray();
for (int i = 0; i < ca.length; i++)
{
switch (ca[i])
{
case 'r" :
if (!f.canRead())
{
throw new InvalidConfigException(
strMgr.getString("fileValidator.no_read",
f.getAbsolutePath()));
}
break;
case 'w" :
if (!f.canWrite())
{
throw new InvalidConfigException(
strMgr.getString("fileValidator.no_write",
f.getAbsolutePath()));
}
break;
case 'd" :
if (!f.isDirectory())
{
throw new InvalidConfigException(
strMgr.getString("fileValidator.not_a_dir",
f.getAbsolutePath()));
}
break;
case 'x" :
//do what
break;
default :
break;
}
}
|