FileDocCategorySizeDatePackage
Result.javaAPI DocGlassfish v2 API7009Fri May 04 22:34:10 BST 2007com.sun.enterprise.admin.verifier

Result.java

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 * 
 * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
 * 
 * The contents of this file are subject to the terms of either the GNU
 * General Public License Version 2 only ("GPL") or the Common Development
 * and Distribution License("CDDL") (collectively, the "License").  You
 * may not use this file except in compliance with the License. You can obtain
 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
 * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
 * language governing permissions and limitations under the License.
 * 
 * When distributing the software, include this License Header Notice in each
 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
 * Sun designates this particular file as subject to the "Classpath" exception
 * as provided by Sun in the GPL Version 2 section of the License file that
 * accompanied this code.  If applicable, add the following below the License
 * Header, with the fields enclosed by brackets [] replaced by your own
 * identifying information: "Portions Copyrighted [year]
 * [name of copyright owner]"
 * 
 * Contributor(s):
 * 
 * If you wish your version of this file to be governed by only the CDDL or
 * only the GPL Version 2, indicate your decision by adding "[Contributor]
 * elects to include this software in this distribution under the [CDDL or GPL
 * Version 2] license."  If you don't indicate a single choice of license, a
 * recipient has the option to distribute your version of this file under
 * either the CDDL, the GPL Version 2 or to extend the choice of license to
 * its licensees as provided above.  However, if you add GPL Version 2 code
 * and therefore, elected the GPL Version 2 license, then the option applies
 * only if the new code is made subject to such option by the copyright
 * holder.
 */
package com.sun.enterprise.admin.verifier;

import java.util.*;
import com.sun.enterprise.util.LocalStringManagerImpl;

public class Result {

    public static final int PASSED = 0;
    public static final int FAILED = 1;
    public static final int WARNING = 2;
    public static final int NOT_APPLICABLE = 3;
    public static final int NOT_RUN = 4;
    public static final int NOT_IMPLEMENTED = 5;
    
    private int status = NOT_RUN;
    private String componentName;
    private String assertion;
    private String testName;
    private final Vector errorDetails =  new Vector();
    private final Vector goodDetails =  new Vector();
    private final Vector warningDetails =  new Vector();
    private final Vector naDetails =  new Vector();
    //boolean debug = Verifier.getDebug();
    final boolean debug = false;

    /**
     * Result Constructor
     *
     */
    public Result(){
    }


    /**
     * Initialize the Result object
     *
     * @param c Class of the current test/assertion
     */
    public void init(Class c){
	//setAssertion(StringManagerHelper.getLocalStringsManager().getLocalString((c.getName() + ".assertion"), ""));
	String this_package = "com.sun.enterprise.admin.verifier.";
        //START OF IASRI 4686336 verifier tool for S1AS 
        if(c.getName().indexOf("com.iplanet.ias")!=-1)
            this_package = "com.sun.enterprise.admin.verifier.";
        //END OF IASRI 4686336
	setTestName(c.getName().substring(this_package.length()));
    }

    /**
     * Store passed info
     *
     * @param detail Details of passed test
     */
    public void passed(String detail){
	setStatus(PASSED);
	addGoodDetails(detail);
    }

    /**
     * Store warning info 
     *
     * @param detail Details of warning test
     */
    public void warning(String detail){
	setStatus(WARNING);
	addWarningDetails(detail);
    }

    /**
     * Store Not Applicable info
     *
     * @param detail Details of not applicable test
     */
    public void notApplicable(String detail){
	setStatus(NOT_APPLICABLE);
	addNaDetails(detail);
    }

    /**
     * Store Failed info
     *
     * @param detail Details of failed test
     */
    public void failed(String detail){
	setStatus(FAILED);
	addErrorDetails(detail);
    }

    /**
     * Retrieve Not Applicable details
     *
     * @return <code>Vector</code> not applicable details
     */
    public Vector getNaDetails(){
	return naDetails;
    }

    /**
     * Retrieve Warning details
     *
     * @return <code>Vector</code> warning details
     */
    public Vector getWarningDetails(){
	return warningDetails;
    }

    /**
     * Retrieve Not Applicable details
     *
     * @param s not applicable details
     */
    public void addNaDetails(String s){
	naDetails.addElement(s);
	if (debug) {
	    System.out.println (s);
        }
    }

    /**
     * Retrieve Good details
     *
     * @return <code>Vector</code> good details
     */
    public Vector getGoodDetails(){
	return goodDetails;
    }

    /**
     * Fill in Good details 
     *
     * @param s good detail string
     */
    public void addGoodDetails(String s){
	goodDetails.addElement(s);
	if (debug)
	    System.out.println (s);
    }

    /**
     * Fill in Warning details
     *
     * @param s warning detail string
     */
    public void addWarningDetails(String s){
	warningDetails.addElement(s);
	if (debug)
	    System.out.println (s);
    }

    /**
     * Retrieve Error details
     *
     * @return <code>Vector</code> error details
     */
    public Vector getErrorDetails(){
	return errorDetails;
    }

    /**
     * Fill in Error details
     *
     * @param s  error detail string
     */
    public void addErrorDetails(String s){
	errorDetails.addElement(s);
	if (debug)
	    System.out.println (s);
    }

    /**
     * Retrieve test result status
     *
     * @return <code>int</code> test result status
     */
    public int getStatus(){
	return status;
    }

    /**
     * Set test result status
     *
     * @param s test result status
     */
    public void setStatus(int s){
	status = s;
    }

    /**
     * Retrieve assertion
     *
     * @return <code>String</code> assertion string
     */
    public String getAssertion(){
	return assertion;
    }

    /**
     * Set assertion 
     *
     * @param s assertion string
     */
    public void setAssertion(String s){
	assertion = s;
    }

    /**
     * Retrieve component/module name
     *
     * @return <code>String</code> component/module name
     */
    public String getComponentName(){
	return componentName;
    }

    /**
     * Set component/module name
     *
     * @param s component/module name
     */
    public void setComponentName(String s){
	componentName = s;
    }

    /**
     * Retrieve test name
     *
     * @return <code>String</code> test name
     */
    public String getTestName(){
	return testName;
    }

    /**
     * Set test name
     *
     * @param s test name
     */
    public void setTestName(String s){
	testName = s;
    }

} // Result class