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

📄 netlogwriter.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                // check for valid dss header or not all of dss block                if ((len < 10) || (len > fullLen)) {                    len = fullLen;                }                // subtract that length from the full length                fullLen -= len;                // The data will only be written if there is a non-zero positive length.                if (len != 0) {                    String codePointName = null;                    // If the length <= 10, lookup the first codepoint so it's name can be printed                    if (len >= 10) {                        // Get the int value of the two byte unsigned codepoint.                        int codePoint = getCodePoint(buff, offset + 8);                        codePointName = codePointNameTable__.lookup(codePoint);                        // if this is not a valid codepoint then format the entire buffer                        // as one block.                        if (codePointName == null) {                            len += fullLen;                            fullLen = 0;                        }                    }                    if (!printColPos) { // not 1st Dss header of this buffer, write seperator                        dncnetprintln("");                    }                    if (codePointName == null) {                        // codePointName was still null so either < 10 bytes were given or                        // the codepoint wasn't found in the table.  Just print the plain send header.                        dncnetprintln(getHeader(type));                    } else {                        // codePointName isn't null so the name of the codepoint will be printed.                        printHeaderWithCodePointName(codePointName, type);                    }                    // Print the col position header in the trace.                    if (printColPos) { // first Dss header of buffer, need column position header                        dncnetprintln(colPosHeader__);                        printColPos = false;                    }                    // A char array will be used to translate the bytes to their character                    // representations along with ascii and ebcdic representations.                    char trcDump[] = new char[77];                    // bCounter, aCounter, eCounter are offsets used to help position the characters                    short bCounter = 7;                    short aCounter = 43;                    short eCounter = 61;                    // The lines will be counted starting at zero.                    // This is hard coded since we are at the beginning.                    trcDump[0] = zeroChar__;                    trcDump[1] = zeroChar__;                    trcDump[2] = zeroChar__;                    trcDump[3] = zeroChar__;                    // The 0's are already in the trace so bump the line counter up a row.                    int lineCounter = 0x10;                    // Make sure the character array has all blanks in it.                    // Some of these blanks will be replaced later with values.                    // The 0's were not wrote over.                    for (int j = 4; j < 77; j++) {                        trcDump[j] = spaceChar__;                    }                    // i will maintain the position in the byte array to be traced.                    int i = 0;                    do {                        // Get the unsigned value of the byte.                        //                  int num = b[off++] & 0xff;                        int num = (buff[offset] < 0) ? buff[offset] + 256 : buff[offset];                        offset++;                        i++;                        // Place the characters representing the bytes in the array.                        trcDump[bCounter++] = hexDigit__[((num >>> 4) & 0xf)];                        trcDump[bCounter++] = hexDigit__[(num & 0xf)];                        // Place the ascii and ebcdc representations in the array.                        trcDump[aCounter++] = asciiChar__[num];                        trcDump[eCounter++] = ebcdicChar__[num];                        if (((i % 8) == 0)) {                            if (((i % 16) == 0)) {                                // Print the array each time 16 bytes are processed.                                dncnetprintln(trcDump);                                if (i != len) {                                    // Not yet at the end of the byte array.                                    if ((len - i) < 16) {                                        // This is the last line so blank it all out.                                        // This keeps the last line looking pretty in case                                        // < 16 bytes remain.                                        for (int j = 0; j < trcDump.length; j++) {                                            trcDump[j] = spaceChar__;                                        }                                    }                                    // Reset the counters.                                    bCounter = 0;                                    aCounter = 43;                                    eCounter = 61;                                    // Reset the lineCounter if it starts to get too large.                                    if (lineCounter == 0x100000) {                                        lineCounter = 0;                                    }                                    // Place the characters representing the line counter in the array.                                    trcDump[bCounter++] = hexDigit__[((lineCounter >>> 12) & 0xf)];                                    trcDump[bCounter++] = hexDigit__[((lineCounter >>> 8) & 0xf)];                                    trcDump[bCounter++] = hexDigit__[((lineCounter >>> 4) & 0xf)];                                    trcDump[bCounter++] = hexDigit__[(lineCounter & 0xf)];                                    bCounter += 3;                                    // Bump up the line counter.                                    lineCounter += 0x10;                                }                            } else {                                // 8 bytes were processed so move the counter to adjust for                                // spaces between the columns of bytes.                                bCounter += 2;                            }                        }                        // do this until we all the data has been traced.                    } while (i < len);                    // print the last line and add some blank lines to make it easier to read.                    if (len % 16 != 0) {                        dncnetprintln(trcDump);                    }                }            }            dncnetprintln("");        }    }    // Gets the int value of the two byte unsigned codepoint.    private static int getCodePoint(byte[] buff, int offset) {        return ((buff[offset++] & 0xff) << 8) +                ((buff[offset] & 0xff) << 0);    }    private static String getHeader(int type) {        switch (type) {        case TYPE_TRACE_SEND:            return sendHeader__;        case TYPE_TRACE_RECEIVE:            return receiveHeader__;        default:            return null;        }    }    private static int getStartPosition(int type) {        switch (type) {        case TYPE_TRACE_SEND:            return 20; // This is right after 'SEND BUFFER: '.        case TYPE_TRACE_RECEIVE:            return 23; // This is right after 'RECEIVE BUFFER: '.        default:            return 0;        }    }    private void printHeaderWithCodePointName(String codePointName, int type) {        // Create a char array so some of the characters        // can be replaced with the name of the codepoint.        char headerArray[] = getHeader(type).toCharArray();        // At most, 16 character name will be used.  This is so        // the headers on top of the ascii and ebcdic rows aren't shifted.        int replaceLen = (codePointName.length() < 17) ? codePointName.length() : 16;        int offset = getStartPosition(type);        for (int i = 0; i < replaceLen; i++) {            headerArray[offset++] = codePointName.charAt(i);        }        dncnetprintln(headerArray);    }    private void dncnetprint(String s) {        synchronized (printWriter_) {            printWriter_.print("[derby] " + s);            printWriter_.flush();        }    }    private void dncnetprintln(String s) {        synchronized (printWriter_) {            printWriter_.println("[derby] " + s);            printWriter_.flush();        }    }    private void dncnetprintln(char[] s) {        synchronized (printWriter_) {            printWriter_.print("[derby] ");            printWriter_.println(s);            printWriter_.flush();        }    }}

⌨️ 快捷键说明

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