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

package oracle.portal.provider.v1;

import oracle.portal.provider.v1.http.UrlServicesUtils;
import oracle.portal.utils.xml.v1.XMLUtil;

/**
 * <p>
 *  Class which has an option to make portlet parameter either
 *  mandatory or optional. If a parameter is marked as mandatory
 *  while rendering the portlet we make sure that these parameters
 *  are set. Otherwise user will be prompted to go back to edit screen
 *  and define them.
 * </p>
 */

public class URLPortletParameter extends PortletParameter
{
  private boolean mIsMandatoryParameter = false;
  private String mParamValue = null;
  private String mDisplayName = null;

  /**
   *  Method which makes URLPortlet parameter either
   *  mandatory or optional.
   *  @param flag true/false
   */
  public void setIsMandatory(String flag)
  {
    mIsMandatoryParameter = XMLUtil.getBooleanValue(flag);
  }
  /**
   *  Method which informs about URL Portlet parameter type.
   *  Whether it is mandatory or optional.
   *  @return boolean true/false
   */
  public boolean isMandatory()
  {
    return mIsMandatoryParameter;
  }

  /**
   * Sets the parameter value.
   * @param value pre-populated parameter value.
   **/
  public void setValue(String value)
  {
    mParamValue = (value == null)?"":value;
  }

  /**
   * Returns the parameter value.
   * @return String parameter value.
   */
  public String getValue()
  {
    return mParamValue;
  }

  /**
   * Sets the parameter's display name.
   * @param dispName Display name for parameter
   **/
  public void setDisplayName(String dispName)
  {
    mDisplayName = dispName;
  }

  /**
   * Returns the parameter's display name.
   * If the display name is null, parameter name
   * is returned.
   * @return String parameter's display name.
   */
  public String getDisplayName()
  {
    if(mDisplayName == null)
      return this.getName();

    return mDisplayName;
  }

}//end of URLPortletParameter


