⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writetag.java

📁 反ajax原代码
💻 JAVA
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   WriteTag.java

package com.laoer.bbscs.web.tag;

import com.laoer.bbscs.sys.SysInfo;
import com.laoer.comm.util.Util;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Time;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.Format;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;

public class WriteTag extends TagSupport
{

    public static final String SQL_TIMESTAMP_FORMAT_KEY = "org.apache.struts.taglib.bean.format.sql.timestamp";
    public static final String SQL_DATE_FORMAT_KEY = "org.apache.struts.taglib.bean.format.sql.date";
    public static final String SQL_TIME_FORMAT_KEY = "org.apache.struts.taglib.bean.format.sql.time";
    public static final String DATE_FORMAT_KEY = "org.apache.struts.taglib.bean.format.date";
    public static final String INT_FORMAT_KEY = "org.apache.struts.taglib.bean.format.int";
    public static final String FLOAT_FORMAT_KEY = "org.apache.struts.taglib.bean.format.float";
    protected static MessageResources messages = MessageResources.getMessageResources("org.apache.struts.taglib.bean.LocalStrings");
    protected boolean filter;
    protected boolean ignore;
    protected String name;
    protected String property;
    protected String scope;
    protected String formatStr;
    protected String formatKey;
    protected String localeKey;
    protected String bundle;
    private String type;
    private boolean br;

    public WriteTag()
    {
        filter = true;
        ignore = false;
        name = null;
        property = null;
        scope = null;
        formatStr = null;
        formatKey = null;
        localeKey = null;
        bundle = null;
    }

    public boolean getFilter()
    {
        return filter;
    }

    public void setFilter(boolean filter)
    {
        this.filter = filter;
    }

    public boolean getIgnore()
    {
        return ignore;
    }

    public void setIgnore(boolean ignore)
    {
        this.ignore = ignore;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getProperty()
    {
        return property;
    }

    public void setProperty(String property)
    {
        this.property = property;
    }

    public String getScope()
    {
        return scope;
    }

    public void setScope(String scope)
    {
        this.scope = scope;
    }

    public String getFormat()
    {
        return formatStr;
    }

    public void setFormat(String formatStr)
    {
        this.formatStr = formatStr;
    }

    public String getFormatKey()
    {
        return formatKey;
    }

    public void setFormatKey(String formatKey)
    {
        this.formatKey = formatKey;
    }

    public String getLocale()
    {
        return localeKey;
    }

    public void setLocale(String localeKey)
    {
        this.localeKey = localeKey;
    }

    public String getBundle()
    {
        return bundle;
    }

    public void setBundle(String bundle)
    {
        this.bundle = bundle;
    }

    public int doStartTag()
        throws JspException
    {
        if(ignore && RequestUtils.lookup(pageContext, name, scope) == null)
            return 0;
        Object value = RequestUtils.lookup(pageContext, name, property, scope);
        if(value == null)
            return 0;
        String output = formatValue(value);
        if(type != null && type.equals("note"))
        {
            if(SysInfo.getInstance().getNotehtml() == 0)
            {
                if(br)
                    ResponseUtils.write(pageContext, Util.replaceBr(ResponseUtils.filter(output)));
                else
                    ResponseUtils.write(pageContext, ResponseUtils.filter(output));
            } else
            if(br)
                ResponseUtils.write(pageContext, Util.replaceBr(output));
            else
                ResponseUtils.write(pageContext, output);
        } else
        if(filter)
        {
            if(br)
                ResponseUtils.write(pageContext, Util.replaceBr(ResponseUtils.filter(output)));
            else
                ResponseUtils.write(pageContext, ResponseUtils.filter(output));
        } else
        if(br)
            ResponseUtils.write(pageContext, Util.replaceBr(output));
        else
            ResponseUtils.write(pageContext, output);
        return 0;
    }

    protected String retrieveFormatString(String formatKey)
        throws JspException
    {
        String result = RequestUtils.message(pageContext, bundle, localeKey, formatKey);
        if(result != null && (!result.startsWith("???") || !result.endsWith("???")))
            return result;
        else
            return null;
    }

    protected String formatValue(Object valueToFormat)
        throws JspException
    {
        Format format = null;
        Object value = valueToFormat;
        java.util.Locale locale = RequestUtils.retrieveUserLocale(pageContext, localeKey);
        boolean formatStrFromResources = false;
        String formatString = formatStr;
        if(value instanceof String)
            return (String)value;
        if(formatString == null && formatKey != null)
        {
            formatString = retrieveFormatString(formatKey);
            if(formatString != null)
                formatStrFromResources = true;
        }
        if(value instanceof Number)
        {
            if(formatString == null)
            {
                if((value instanceof Byte) || (value instanceof Short) || (value instanceof Integer) || (value instanceof Long) || (value instanceof BigInteger))
                    formatString = retrieveFormatString("org.apache.struts.taglib.bean.format.int");
                else
                if((value instanceof Float) || (value instanceof Double) || (value instanceof BigDecimal))
                    formatString = retrieveFormatString("org.apache.struts.taglib.bean.format.float");
                if(formatString != null)
                    formatStrFromResources = true;
            }
            if(formatString != null)
                try
                {
                    format = NumberFormat.getNumberInstance(locale);
                    if(formatStrFromResources)
                        ((DecimalFormat)format).applyLocalizedPattern(formatString);
                    else
                        ((DecimalFormat)format).applyPattern(formatString);
                }
                catch(IllegalArgumentException _e)
                {
                    JspException e = new JspException(messages.getMessage("write.format", formatString));
                    RequestUtils.saveException(pageContext, e);
                    throw e;
                }
        } else
        if(value instanceof Date)
        {
            if(formatString == null)
            {
                if(value instanceof Timestamp)
                    formatString = retrieveFormatString("org.apache.struts.taglib.bean.format.sql.timestamp");
                else
                if(value instanceof java.sql.Date)
                    formatString = retrieveFormatString("org.apache.struts.taglib.bean.format.sql.date");
                else
                if(value instanceof Time)
                    formatString = retrieveFormatString("org.apache.struts.taglib.bean.format.sql.time");
                else
                if(value instanceof Date)
                    formatString = retrieveFormatString("org.apache.struts.taglib.bean.format.date");
                if(formatString != null)
                    formatStrFromResources = true;
            }
            if(formatString != null)
                if(formatStrFromResources)
                    format = new SimpleDateFormat(formatString, locale);
                else
                    format = new SimpleDateFormat(formatString);
        }
        if(format != null)
            return format.format(value);
        else
            return value.toString();
    }

    public void release()
    {
        super.release();
        filter = true;
        ignore = false;
        name = null;
        property = null;
        scope = null;
        formatStr = null;
        formatKey = null;
        localeKey = null;
        bundle = null;
    }

    public String getType()
    {
        return type;
    }

    public void setType(String type)
    {
        this.type = type;
    }

    public boolean isBr()
    {
        return br;
    }

    public void setBr(boolean br)
    {
        this.br = br;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -