FileDocCategorySizeDatePackage
AbstractSchemaNameIsValidJavaIdentifier.javaAPI DocGlassfish v2 API6068Fri May 04 22:33:36 BST 2007com.sun.enterprise.tools.verifier.tests.ejb.entity

AbstractSchemaNameIsValidJavaIdentifier

public class AbstractSchemaNameIsValidJavaIdentifier extends com.sun.enterprise.tools.verifier.tests.ejb.EjbTest implements com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck
author
Sudipto Ghosh

Fields Summary
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.EjbDescriptor descriptor)
For an entity-bean the abstract-schema-name must be a valid Java identifier. See ejb specification 2.1 section 10.3.13

param
descriptor the Enterprise Java Bean deployment descriptor
return
Result the results for this assertion

        Result result = getInitializedResult();
        ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
        String abstractSchema = null;

        if(descriptor instanceof EjbEntityDescriptor) {
            if (((EjbEntityDescriptor)descriptor).getPersistenceType().equals(EjbEntityDescriptor.CONTAINER_PERSISTENCE)) {
                if (((EjbCMPEntityDescriptor) descriptor).getCMPVersion()==EjbCMPEntityDescriptor.CMP_2_x) {
                    abstractSchema = ((EjbCMPEntityDescriptor)descriptor).getAbstractSchemaName();
                    if(abstractSchema!=null) {
                        boolean isJavaIdentifier=true;
                        boolean startChar=Character.isJavaIdentifierStart(abstractSchema.charAt(0));
                        if (startChar) {
                            for(int i=1;i<abstractSchema.length();i++)
                                if(!Character.isJavaIdentifierPart(abstractSchema.charAt(i))) {
                                    isJavaIdentifier=false;
                                    break;
                                }
                        } else {
                            isJavaIdentifier=false;
                        }
                        if(isJavaIdentifier) {
                            result.addGoodDetails(smh.getLocalString
                                    ("tests.componentNameConstructor",
                                            "For [ {0} ]",
                                            new Object[] {compName.toString()}));
                            result.passed(smh.getLocalString
                                    (getClass().getName() + ".passed",
                                            "abstract-schema-name [ {0} ] within bean [ {1} ] is a valid java identifier",
                                            new Object[] {abstractSchema, descriptor.getName()}));
                        }else{
                            result.addErrorDetails(smh.getLocalString
                                    ("tests.componentNameConstructor",
                                            "For [ {0} ]",
                                            new Object[] {compName.toString()}));
                            result.failed(smh.getLocalString
                                    (getClass().getName() + ".failed",
                                            "abstract-schema-name [ {0} ] within bean [ {1} ] is not a valid java identifier",
                                            new Object[] {abstractSchema, descriptor.getName()}));
                        }
                    }
                }
            }
        }
        if(abstractSchema==null){
            result.addNaDetails(smh.getLocalString
                    ("tests.componentNameConstructor",
                            "For [ {0} ]",
                            new Object[] {compName.toString()}));
            result.notApplicable(smh.getLocalString
                    (getClass().getName() + ".notApplicable",
                            "abstract-schema-name is not defined or this is not applicable for this bean"));
        }
        return result;