GetStringPropertyTag.java :  » Portal » Open-Portal » com » sun » portal » desktop » taglib » providerContext » Java Open Source

Java Open Source » Portal » Open Portal 
Open Portal » com » sun » portal » desktop » taglib » providerContext » GetStringPropertyTag.java
/*
 * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
 * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
 */
package com.sun.portal.desktop.taglib.providerContext;

import javax.servlet.jsp.JspException;

import java.util.List;

import com.sun.portal.providers.Provider;
import com.sun.portal.providers.context.ProviderContext;
import com.sun.portal.providers.context.ProviderContextException;

import com.sun.portal.desktop.taglib.DesktopTaglibException;

public class GetStringPropertyTag
    extends BaseProviderContextTagSupport
{
    private String m_key = null;
    private String m_localized_raw = null;
    private List m_pflist = null;

    public void setKey( String key )
        throws DesktopTaglibException
    {
        m_key = resolveParameter( key ).toString();
    }

    public void setLocalized( String localized ) 
        throws DesktopTaglibException
    {
        m_localized_raw = localized;
    }    

    public void setPfList( String pflist )
        throws DesktopTaglibException
    {
        if( !isContextVariable( pflist ) ) {
            throw new DesktopTaglibException( DesktopTaglibException.INVALID_PARAMETER, pflist );
        }
        try {
            m_pflist = (List)resolveParameter( pflist );
        } catch ( ClassCastException cce ) {
            throw new DesktopTaglibException( DesktopTaglibException.INVALID_PARAMETER, pflist );
        }
    }

    public int doStartTag() throws JspException {
        ProviderContext pc = getCurrentProviderContext();
        String prop = null;
  Provider p = getCurrentObj();
        try {
         if( m_localized_raw == null ) {
                if( m_pflist == null ) {
              prop = pc.getStringProperty(p.getName(), m_key);
                } else {
              prop = pc.getStringProperty(p.getName(), m_key, m_pflist );
                }
      } else {
                Object obj = resolveParameter(m_localized_raw);
                if (obj != null) {
                    if (obj instanceof Boolean) {
                        prop = pc.getStringProperty(p.getName(), m_key, ((Boolean)obj).booleanValue());
                    } else if (obj instanceof String) {
                        prop = pc.getStringProperty(p.getName(), m_key, toBoolean((String)obj));
                    } else {
                        prop = pc.getStringProperty(p.getName(), m_key);
                    }
                } else {
                    prop = pc.getStringProperty(p.getName(), m_key);
                }
      }
        } catch (ProviderContextException pce) {
            throw new DesktopTaglibException( pce );
        }

        processResult( prop );
        return SKIP_BODY;
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.