AttrClassNamepublic class AttrClassName 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" /> |
Constructors Summary |
---|
public AttrClassName(String name, String type, boolean optional)
super(name,type, optional);
|
Methods Summary |
---|
public static boolean | isValidClassName(java.lang.String className)
boolean valid = true;
for(int i=0;i<className.length();i++) {
if(i == 0) {
if(!Character.isJavaIdentifierStart(className.charAt(i)))
valid = false;
}
if(!Character.isJavaIdentifierPart(className.charAt(i)))
valid = false;
}
return valid;
| public void | validate(java.lang.Object o, ValidationContext valCtx)
_logger.log(Level.CONFIG, "Testing attr: "+valCtx.attrName);
super.validate(o, valCtx); // call to common validator first
if(o == null)
return;
if(o.equals(""))
valCtx.result.failed(valCtx.smh.getLocalString(getClass().getName() + ".nullClassName",
"Attribute({0}=\"\" : ClassName not Valid", new Object[] {valCtx.attrName}));
// Remove the package, extract the identifier alone
String className = (String)o;
int classStart = className.lastIndexOf(".");
if(classStart != -1)
className = className.substring(classStart+1);
if(!isValidClassName(className)){
valCtx.result.failed(valCtx.smh.getLocalString(getClass().getName() + ".invalidClassName",
"Attribute({0}={1}) : ClassName not Valid", new Object[] {valCtx.attrName, (String)o}));
}
|
|