ErrMessage.java 6.07 KB
/*
 * Decompiled with CFR 0_118.
 */
package com.scene7.is.ipp.messages;

import com.scene7.is.ipp.messages.InMessage;
import com.scene7.is.ipp.messages.Ipp;
import com.scene7.is.ipp.messages.IppErrorType;
import com.scene7.is.ipp.messages.IppInt;
import com.scene7.is.ipp.messages.IppLongString;
import com.scene7.is.ipp.messages.IppProp;
import com.scene7.is.ipp.messages.Offset;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.io.Writer;

public class ErrMessage
extends InMessage {
    static int MessageNumber = 67456;
    private boolean isOld_ = false;
    private String[] what_;
    private int errorType_;
    private IppProp[] props_;
    private String[] whatFile_;
    private int[] whatLine_;

    public ErrMessage(int tag, String[] what, int errorType, IppProp[] props, String[] whatFile, int[] whatLine, int headClientId) {
        int i;
        this.tag_ = tag;
        this.headerClientId_ = headClientId;
        this.what_ = what;
        this.errorType_ = errorType;
        this.props_ = props;
        this.whatFile_ = whatFile;
        this.whatLine_ = whatLine;
        int fixedLength = 52;
        Offset varPos = new Offset(fixedLength);
        if (what != null) {
            varPos.val = varPos.val + 3 & -4;
            varPos.val += what.length * 4;
            for (i = 0; i < what.length; ++i) {
                try {
                    varPos.val += what[i].getBytes("UTF-8").length + 1;
                    continue;
                }
                catch (UnsupportedEncodingException e) {
                    throw new AssertionError(e);
                }
            }
        }
        if (props != null) {
            varPos.val = varPos.val + 7 & -8;
            varPos.val += props.length * 48;
            for (i = 0; i < props.length; ++i) {
                props[i].adjustVarPos(varPos);
            }
        }
        if (whatFile != null) {
            varPos.val = varPos.val + 3 & -4;
            varPos.val += whatFile.length * 4;
            for (i = 0; i < whatFile.length; ++i) {
                try {
                    varPos.val += whatFile[i].getBytes("UTF-8").length + 1;
                    continue;
                }
                catch (UnsupportedEncodingException e) {
                    throw new AssertionError(e);
                }
            }
        }
        if (whatLine != null) {
            varPos.val = varPos.val + 3 & -4;
            varPos.val += whatLine.length * 4;
        }
        this.messageLength_ = varPos.val;
        varPos.val = fixedLength;
        Offset pos = new Offset(0);
        this.headBuffer_ = new byte[32];
        this.bodyBuffer_ = new byte[this.messageLength_];
        Ipp.StuffHeader(this.headBuffer_, this.headerClientId_, tag, MessageNumber, this.messageLength_);
        IppLongString.StuffArray(this.bodyBuffer_, pos, varPos, this.what_);
        IppInt.Stuff(this.bodyBuffer_, pos, null, this.errorType_);
        IppProp.StuffArray(this.bodyBuffer_, pos, varPos, this.props_);
        IppLongString.StuffArray(this.bodyBuffer_, pos, varPos, this.whatFile_);
        IppInt.StuffArray(this.bodyBuffer_, pos, varPos, this.whatLine_);
        Ipp.Assert(pos.val == fixedLength, "IppWatermarkType length");
    }

    public ErrMessage() {
    }

    public void process(int headClientId, int tg, byte[] bf) {
        this.headerClientId_ = headClientId;
        this.tag_ = tg;
        this.messageLength_ = bf.length;
        this.headBuffer_ = new byte[16];
        Ipp.StuffHeader(this.headBuffer_, this.headerClientId_, this.tag_, MessageNumber, this.messageLength_);
        this.bodyBuffer_ = bf;
        Offset pos = new Offset(0);
        this.what_ = IppLongString.UnstuffArray(this.bodyBuffer_, pos);
        if (this.isOld_) {
            return;
        }
        this.errorType_ = IppInt.Unstuff(this.bodyBuffer_, pos);
        this.props_ = IppProp.UnstuffArray(this.bodyBuffer_, pos);
        this.whatFile_ = IppLongString.UnstuffArray(this.bodyBuffer_, pos);
        this.whatLine_ = IppInt.UnstuffArray(this.bodyBuffer_, pos);
    }

    public int classification() {
        return 1;
    }

    public int id() {
        return MessageNumber;
    }

    public void print(Writer tf, String heading) throws IOException {
        tf.write("\n");
        tf.write(heading);
        tf.write(": ErrMessage ");
        Ipp.PrintHex(tf, MessageNumber);
        tf.write("\n");
        tf.write("headClientId: " + this.headerClientId() + "\n");
        Ipp.PrintTag(tf, "tag: ", this.tag());
        tf.write("length: " + this.length());
        tf.write("\n");
        IppLongString.PrintArray(tf, "what: ", this.what_);
        IppErrorType.Print(tf, "errorType: ", this.errorType_);
        IppProp.PrintArray(tf, "props: ", this.props_);
        IppLongString.PrintArray(tf, "whatFile: ", this.whatFile_);
        IppInt.PrintArray(tf, "whatLine: ", this.whatLine_);
    }

    public String toString() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("ErrMessage                    ");
        buffer.append("[what: " + String.valueOf(this.what_) + "],");
        buffer.append("[errorType: " + String.valueOf(this.errorType_) + "],");
        buffer.append("[props: " + String.valueOf(this.props_) + "],");
        buffer.append("[whatFile: " + String.valueOf(this.whatFile_) + "],");
        buffer.append("[whatLine: " + String.valueOf(this.whatLine_) + "],");
        return buffer.toString();
    }

    public String[] what() {
        return this.what_;
    }

    public int errorType() {
        return this.errorType_;
    }

    public IppProp[] props() {
        return this.props_;
    }

    public String[] whatFile() {
        return this.whatFile_;
    }

    public int[] whatLine() {
        return this.whatLine_;
    }

    public ErrMessage(String what) {
        this.what_ = new String[1];
        this.what_[0] = what;
        this.errorType_ = 822214656;
    }

    public ErrMessage(String[] what) {
        this.what_ = what;
        this.errorType_ = 822214656;
    }

    public ErrMessage(int oldMsgId) {
        this.isOld_ = true;
        this.errorType_ = 822247423;
    }
}