/*  Copyright (c) 2000 by Oracle Corporation. All Rights Reserved. */

package oracle.portal.provider.v1.http;

/**

 */
public class RenderPortletType extends Object {

    public static final int CUSTOM = 0;
    public static final int JSP = 1;
    public static final int SERVLET = 2;
    public static final int WEBBEAN = 3;

    public static final String CUSTOM_NAME = "custom";
    public static final String JSP_NAME = "jsp";
    public static final String SERVLET_NAME = "servlet";
    public static final String WEBBEAN_NAME = "webbean";

    /**
     *  return the name of a type.
     *
     *  @param type parameter type
     *  @return parameter type name
     */
    public static String toString(int type) throws IllegalArgumentException {
        switch (type) {
        case CUSTOM:
            return CUSTOM_NAME;
        case JSP:
            return JSP_NAME;
        case SERVLET:
            return SERVLET_NAME;
        case WEBBEAN:
            return WEBBEAN_NAME;
        default:
            throw new IllegalArgumentException("Invalid type parameter");
        }
    }

    /**
     *  return the type from name.
     *
     *  @param type parameter type name
     *  @return parameter type
     */
    public static int valueOf(String type) throws IllegalArgumentException {
        if (type.equalsIgnoreCase(CUSTOM_NAME)) {
            return CUSTOM;
        } else if (type.equalsIgnoreCase(JSP_NAME)) {
            return JSP;
        } else if (type.equalsIgnoreCase(SERVLET_NAME)) {
            return SERVLET;
        } else if (type.equalsIgnoreCase(WEBBEAN_NAME)) {
            return WEBBEAN;
        } else {
            throw new IllegalArgumentException(type + " isn't a valid parameter type name.");
        }
    }
}

 