FileDocCategorySizeDatePackage
AttrClassName.javaAPI DocGlassfish v2 API4154Fri May 04 22:24:36 BST 2007com.sun.enterprise.config.serverbeans.validation

AttrClassName

public 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" />
author
Srinivas Krishnan
version
2.0

Fields Summary
Constructors Summary
public AttrClassName(String name, String type, boolean optional)

        super(name,type, optional);
    
Methods Summary
public static booleanisValidClassName(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 voidvalidate(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}));
        }