FileDocCategorySizeDatePackage
Validator.javaAPI DocGlassfish v2 API3747Fri May 04 22:24:30 BST 2007com.sun.enterprise.admin.servermgmt

Validator

public class Validator extends Object
Base class for all domain config validators. Validates the non-null ness of a domain config entry and its type.

Fields Summary
private static final com.sun.enterprise.util.i18n.StringManager
strMgr
i18n strings manager object
private final Class
type
The accepted type of an entry.
private final String
name
The name of an entry that is used in case of validation error.
Constructors Summary
public Validator(String name, Class type)
Constructs new Validator object.

param
name Name of an entry that is used in case of validation errors. If the name is null "" is used instead.
param
type


                                       
        
    
        this.name = (name != null) ? name : "";
        this.type = (type != null) ? type : java.lang.Object.class;
    
Methods Summary
public java.lang.StringgetName()
Returns the name of the entry.

        return name;
    
public voidvalidate(java.lang.Object obj)
Checks the validity of the given value for the entry. This method does basic checks such as null ness & type.

param
obj
Throws
InvalidConfigException

        if (obj == null)
        {
            throw new InvalidConfigException(
                strMgr.getString("validator.invalid_value", getName(), null));
        }
        Class c = obj.getClass();
        if (!type.isAssignableFrom(c))
        {
            throw new InvalidConfigException(
                strMgr.getString("validator.invalid_type", 
                    getName(), type.getName(), c.getName()));
        }