Java Code Examples for com.mysql.jdbc.StringUtils#toString()

The following examples show how to use com.mysql.jdbc.StringUtils#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProfilerEvent.java    From r-course with MIT License 4 votes vote down vote up
/**
 * Unpacks a binary representation of this event.
 * 
 * @param buf
 *            the binary representation of this event
 * @return the unpacked Event
 * @throws Exception
 *             if an error occurs while unpacking the event
 */
public static ProfilerEvent unpack(byte[] buf) throws Exception {
    int pos = 0;

    byte eventType = buf[pos++];
    long connectionId = readInt(buf, pos);
    pos += 8;
    int statementId = readInt(buf, pos);
    pos += 4;
    int resultSetId = readInt(buf, pos);
    pos += 4;
    long eventCreationTime = readLong(buf, pos);
    pos += 8;
    long eventDuration = readLong(buf, pos);
    pos += 4;

    byte[] eventDurationUnits = readBytes(buf, pos);
    pos += 4;

    if (eventDurationUnits != null) {
        pos += eventDurationUnits.length;
    }

    readInt(buf, pos);
    pos += 4;
    byte[] eventCreationAsBytes = readBytes(buf, pos);
    pos += 4;

    if (eventCreationAsBytes != null) {
        pos += eventCreationAsBytes.length;
    }

    byte[] message = readBytes(buf, pos);
    pos += 4;

    if (message != null) {
        pos += message.length;
    }

    return new ProfilerEvent(eventType, "", "", connectionId, statementId, resultSetId, eventCreationTime, eventDuration,
            StringUtils.toString(eventDurationUnits, "ISO8859_1"), StringUtils.toString(eventCreationAsBytes, "ISO8859_1"), null,
            StringUtils.toString(message, "ISO8859_1"));
}
 
Example 2
Source File: ProfilerEvent.java    From Komondor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Unpacks a binary representation of this event.
 * 
 * @param buf
 *            the binary representation of this event
 * @return the unpacked Event
 * @throws Exception
 *             if an error occurs while unpacking the event
 */
public static ProfilerEvent unpack(byte[] buf) throws Exception {
    int pos = 0;

    byte eventType = buf[pos++];
    long connectionId = readInt(buf, pos);
    pos += 8;
    int statementId = readInt(buf, pos);
    pos += 4;
    int resultSetId = readInt(buf, pos);
    pos += 4;
    long eventCreationTime = readLong(buf, pos);
    pos += 8;
    long eventDuration = readLong(buf, pos);
    pos += 4;

    byte[] eventDurationUnits = readBytes(buf, pos);
    pos += 4;

    if (eventDurationUnits != null) {
        pos += eventDurationUnits.length;
    }

    readInt(buf, pos);
    pos += 4;
    byte[] eventCreationAsBytes = readBytes(buf, pos);
    pos += 4;

    if (eventCreationAsBytes != null) {
        pos += eventCreationAsBytes.length;
    }

    byte[] message = readBytes(buf, pos);
    pos += 4;

    if (message != null) {
        pos += message.length;
    }

    return new ProfilerEvent(eventType, "", "", connectionId, statementId, resultSetId, eventCreationTime, eventDuration,
            StringUtils.toString(eventDurationUnits, "ISO8859_1"), StringUtils.toString(eventCreationAsBytes, "ISO8859_1"), null,
            StringUtils.toString(message, "ISO8859_1"));
}