
// Copyright (c) 2000 Oracle Corporation
package oracle.portal.provider.v1.http;

import java.io.*;
import java.util.*;
import oracle.portal.provider.v1.*;

/**
 * Base customization data class.  Manages customization data all portlets should
 * support.  Currently, this is just the portlets title.<p>
 * All portlets should support customization even if they only allow a user to
 * customize the titlebar.  Portlets providing further customization (data) should
 * subclass this class as built-in generic renderers that automatically rendeer the
 * titlebar rely on the data object being an instance of BaseCustomization to
 * access the customized title name to render in the titlebar.
 *
 * @deprecated Use {@link
 * oracle.portal.provider.v1.NameValuePersonalizationObject} instead.
 */
public class BaseCustomization extends Object implements Serializable, CustomizationObject {

    private String mTitle;

    /**
     * Null Constructor.
     */
    public BaseCustomization() {
    }

    /**
     *  Init method used to initialize the data object after instantiated via
     *  its null constructor.  Defined by the CustomizationObject interface.
     *  Personalization manager is expected to call the
     *  init method of data objects that implement the CustomizationObject
     *  interface.<p>
     *  Behavior is to initialize the title using the (static) title from the
     *  portlet metadata (<code>portlet.getTitle()</code>). The portlets
     *  default Locale is used to retrieve the title.
     *
     *  @param pr  the portlet reference that identifies the customization
     *  instance this object represents.
     */
    public void init(PortletReference pr) {

        try {
            mTitle = pr.getPortlet().getTitle(pr.getLocale());
            if (mTitle == null) {
                mTitle = "";
            }
        } catch (Exception e) {
            pr.getProvider().log("BaseCustomization.init failed:  unable to create Title.  " + e.getMessage());
        }
    }

    /**
     * @deprecated 	Use {@link BaseCustomization#init(PortletReference pr)} instead.
     */
    public void init(PortletReference pr, Class mlClass) {
        init(pr);
    }

    /**
     *  Gets the customized title.
     *
     *  @return the customized title.
     */
    public String getTitle() {
        return mTitle;
    }

    /**
     *  Sets the new customized title.
     *
     *  @param title the new title.
     */
    public void setTitle(String title) {
        mTitle = title;
    }

    /**
     * @deprecated 	Use {@link BaseCustomization#getTitle()} instead.
     */
    public String getTitle(Locale l) {
        return getTitle();
    }

    /**
     * @deprecated 	Use {@link BaseCustomization#setTitle(String title)} instead.
     */
    public void setTitle(String title, Locale l) {
        setTitle(title);
    }
}

 
