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

📄 mimeheaderfield.java

📁 一个简单的visio程序。
💻 JAVA
字号:

package servlet.http;

import java.io.IOException;
import javax.servlet.ServletOutputStream;

// Referenced classes of package servlet.http:
//            HttpDate, MessageString

public class MimeHeaderField
{

    public MimeHeaderField()
    {
        type = 0;
    }

    public void reset()
    {
        name.reset();
        value.reset();
        type = 0;
    }

    public void setName(String s)
    {
        name.setString(s);
    }

    public void setName(byte abyte0[], int i, int j)
    {
        name.setBytes(abyte0, i, j);
    }

    public void setValue(String s)
    {
        value.setString(s);
        type = 1;
    }

    public void setValue(byte abyte0[], int i, int j)
    {
        value.setBytes(abyte0, i, j);
        type = 1;
    }

    public void setIntValue(int i)
    {
        intValue = i;
        type = 2;
    }

    public void setDateValue(long l)
    {
        dateValue.setTime(l);
        type = 3;
    }

    public void setDateValue()
    {
        dateValue.setTime();
        type = 3;
    }

    public String getName()
    {
        return name.toString();
    }

    public String getValue()
    {
        switch(type)
        {
        case 1: /* '\001' */
            return value.toString();

        case 2: /* '\002' */
            return String.valueOf(intValue);

        case 3: /* '\003' */
            return dateValue.toString();

        }
        return null;
    }

    public int getIntValue()
        throws NumberFormatException
    {
        switch(type)
        {
        case 2: /* '\002' */
            return intValue;

        case 1: /* '\001' */
            return value.toInteger();

        }
        throw new NumberFormatException("invalid integer format");
    }

    public long getDateValue()
        throws IllegalArgumentException
    {
        switch(type)
        {
        case 3: /* '\003' */
            return dateValue.getTime();

        case 1: /* '\001' */
            return value.toDate(dateValue);

        case 2: /* '\002' */
        default:
            throw new IllegalArgumentException("invalid date format");

        }
    }

    private int intGetBytes(int i, byte abyte0[], int j)
    {
        int k = 0x3b9aca00;
        int i1 = 0;
        if(i == 0)
        {
            abyte0[j] = charval[0];
            return 1;
        }
        for(; k > 0; k /= 10)
        {
            int l = i / k;
            if(l != 0 || i1 > 0)
                abyte0[j + i1++] = charval[l];
            i %= k;
        }

        return i1;
    }

    public int getBytes(byte abyte0[], int i)
    {
        int j = i;
        i += name.getBytes(abyte0, i);
        abyte0[i++] = 58;
        abyte0[i++] = 32;
        switch(type)
        {
        case 1: /* '\001' */
            i += value.getBytes(abyte0, i);
            break;

        case 2: /* '\002' */
            i += intGetBytes(intValue, abyte0, i);
            break;

        case 3: /* '\003' */
            i += dateValue.getBytes(abyte0, i, HttpDate.DATELEN);
            break;

        }
        abyte0[i++] = 13;
        abyte0[i++] = 10;
        return i - j;
    }

    public void parse(byte abyte0[], int i, int j)
        throws IllegalArgumentException
    {
        int k = i;
        byte byte0;
        while((byte0 = abyte0[i++]) != 58 && byte0 != 32) 
            if(byte0 == 10)
                throw new IllegalArgumentException("invalid header format");

        setName(abyte0, k, i - k - 1);
        for(; byte0 == 32; byte0 = abyte0[i++]);
        if(byte0 != 58)
            throw new IllegalArgumentException("invalid header format");
        while((byte0 = abyte0[i++]) == 32) ;
        setValue(abyte0, i - 1, j - (i - k - 1));
    }

    public void write(ServletOutputStream servletoutputstream)
        throws IOException
    {
        name.write(servletoutputstream);
        servletoutputstream.print(": ");
        switch(type)
        {
        case 1: /* '\001' */
            value.write(servletoutputstream);
            servletoutputstream.println();
            return;

        case 2: /* '\002' */
            servletoutputstream.println(intValue);
            return;

        case 3: /* '\003' */
            dateValue.write(servletoutputstream);
            servletoutputstream.println();
            return;

        }
        servletoutputstream.println();
    }

    public boolean nameEquals(String s)
    {
        return name.equalsIgnoreCase(s);
    }

    public boolean nameEquals(byte abyte0[], int i, int j)
    {
        return name.equalsIgnoreCase(abyte0, i, j);
    }

    public String toString()
    {
        StringBuffer stringbuffer = new StringBuffer();
        stringbuffer.append(name.toString());
        stringbuffer.append(": ");
        switch(type)
        {
        case 1: /* '\001' */
            stringbuffer.append(value.toString());
            break;

        case 2: /* '\002' */
            stringbuffer.append(intValue);
            break;

        case 3: /* '\003' */
            stringbuffer.append(dateValue.toString());
            break;

        }
        return stringbuffer.toString();
    }

    protected final MessageString name = new MessageString();
    protected final MessageString value = new MessageString();
    protected int intValue;
    protected final HttpDate dateValue = new HttpDate(0L);
    protected int type;
    protected static final int T_NULL = 0;
    protected static final int T_STR = 1;
    protected static final int T_INT = 2;
    protected static final int T_DATE = 3;
    private static final byte charval[] = {
        48, 49, 50, 51, 52, 53, 54, 55, 56, 57
    };

}

⌨️ 快捷键说明

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