AttrFilepublic class AttrFile extends AttrType Class which contains Meta data for all types of attributes which is present in Validation Descriptor
XML File
Sample
type="address" />
type="integer" range="low,high" />
type="string" max-length="length" /> |
Fields Summary |
---|
boolean | checkExists |
Constructors Summary |
---|
public AttrFile(String name, String type, boolean optional)
super(name,type, optional);
checkExists = false;
|
Methods Summary |
---|
public void | setCheckExists(boolean flag)
checkExists = flag;
| public void | validate(java.lang.Object o, ValidationContext valCtx)
super.validate(o, valCtx); // call to common validator first
if(o == null || o.equals(""))
return;
if(checkExists || StaticTest.fileCheck) {
File f = new File((String)o);
if(!f.exists())
valCtx.result.failed(valCtx.smh.getLocalString(getClass().getName() + ".fileNotExists",
"Attribute({0}={1}) : {2} : Does not exists", new Object[] {valCtx.attrName, o, o}));
else if(!f.canRead())
valCtx.result.failed(valCtx.smh.getLocalString(getClass().getName() + ".filecannotRead",
"Attribute({0}={1}) : {2} : Does not have read permission", new Object[] {valCtx.attrName, o, o}));
}
|
|