Package com.google.code.or.io.util

Examples of com.google.code.or.io.util.XDeserializer


  /**
   *
   */
  public static ResultSetFieldPacket valueOf(Packet packet) throws IOException {
    final XDeserializer d = new XDeserializer(packet.getPacketBody());
    final ResultSetFieldPacket r = new ResultSetFieldPacket();
    r.fieldLength = packet.getLength();
    r.sequence = packet.getSequence();
    r.catalog = d.readLengthCodedString();
    r.db = d.readLengthCodedString();
    r.table = d.readLengthCodedString();
    r.orginalTable = d.readLengthCodedString();
    r.column = d.readLengthCodedString();
    r.originalColumn = d.readLengthCodedString();
    r.fixed12 = d.readInt(1);
    r.charset = d.readInt(2);
    r.fieldLength = d.readLong(4);
    r.fieldType = d.readInt(1);
    r.fieldOptions = d.readInt(2);
    r.decimalPrecision = d.readInt(1);
    r.reserved = d.readInt(2);
    if(d.available() > 0) r.defaultValue = d.readLengthCodedString();
    return r;
  }
View Full Code Here


 
  /**
   *
   */
  public static GreetingPacket valueOf(Packet packet) throws IOException {
    final XDeserializer d = new XDeserializer(packet.getPacketBody());
    final GreetingPacket r = new GreetingPacket();
    r.length = packet.getLength();
    r.sequence = packet.getSequence();
    r.protocolVersion = d.readInt(1);
    r.serverVersion = d.readNullTerminatedString();
    r.threadId = d.readLong(4);
    r.scramble1 = d.readNullTerminatedString();
    r.serverCapabilities = d.readInt(2);
    r.serverCollation = d.readInt(1);
    r.serverStatus = d.readInt(2);
    d.skip(13); // reserved, all 0
    r.scramble2 = d.readNullTerminatedString();
    if(d.hasMore()) r.pluginProvidedData = d.readNullTerminatedString();
    return r;
  }
View Full Code Here

 
  /**
   *
   */
  public static ResultSetRowPacket valueOf(Packet packet) throws IOException {
    final XDeserializer d = new XDeserializer(packet.getPacketBody());
    final ResultSetRowPacket r = new ResultSetRowPacket();
    r.length = packet.getLength();
    r.sequence = packet.getSequence();
    r.setColumns(new LinkedList<StringColumn>());
    while(d.available() > 0) {
      r.getColumns().add(d.readLengthCodedString());
    }
    return r;
  }
View Full Code Here

  /**
   *
   */
  public static OKPacket valueOf(Packet packet) throws IOException {
    final XDeserializer d = new XDeserializer(packet.getPacketBody());
    final OKPacket r = new OKPacket();
    r.length = packet.getLength();
    r.sequence = packet.getSequence();
    r.packetMarker = d.readInt(1);
    r.affectedRows = d.readUnsignedLong();
    r.insertId = d.readUnsignedLong();
    r.serverStatus = d.readInt(2);
    r.warningCount = d.readInt(2);
    if(d.available() > 0) r.message = d.readFixedLengthString(d.available());
    return r;
  }
View Full Code Here

  /**
   *
   */
  public static ErrorPacket valueOf(Packet packet) throws IOException {
    final XDeserializer d = new XDeserializer(packet.getPacketBody());
    final ErrorPacket r = new ErrorPacket();
    r.length = packet.getLength();
    r.sequence = packet.getSequence();
    r.packetMarker = d.readInt(1);
    r.errorCode = d.readInt(2);
    r.slash = d.readFixedLengthString(1);
    r.sqlState = d.readFixedLengthString(5);
    r.errorMessage = d.readFixedLengthString(d.available());
    return r;
  }
View Full Code Here

   *
   */
  protected List<StatusVariable> parseStatusVariables(byte[] data)
  throws IOException {
    final List<StatusVariable> r = new ArrayList<StatusVariable>();
    final XDeserializer d = new XDeserializer(data);
    boolean abort = false;
    while(!abort && d.available() > 0) {
      final int type = d.readInt(1);
      switch(type) {
      case QAutoIncrement.TYPE: r.add(QAutoIncrement.valueOf(d)); break;
      case QCatalogCode.TYPE: r.add(QCatalogCode.valueOf(d)); break;
      case QCatalogNzCode.TYPE: r.add(QCatalogNzCode.valueOf(d)); break;
      case QCharsetCode.TYPE: r.add(QCharsetCode.valueOf(d)); break;
View Full Code Here

   *
   */
  public static final Metadata valueOf(byte[] type, byte[] data)
  throws IOException {
    final int[] metadata = new int[type.length];
    final XDeserializer d = new XDeserializer(data);
    for(int i = 0; i < type.length; i++) {
      final int t = CodecUtils.toUnsigned(type[i]);
      switch(t) {
      case MySQLConstants.TYPE_FLOAT:
      case MySQLConstants.TYPE_DOUBLE:
      case MySQLConstants.TYPE_TINY_BLOB:
            case MySQLConstants.TYPE_BLOB:
            case MySQLConstants.TYPE_MEDIUM_BLOB:
            case MySQLConstants.TYPE_LONG_BLOB:
              metadata[i] = d.readInt(1);
              break;
            case MySQLConstants.TYPE_BIT:
            case MySQLConstants.TYPE_VARCHAR:
      case MySQLConstants.TYPE_NEWDECIMAL: 
        metadata[i] = d.readInt(2); // Little-endian
              break;
      case MySQLConstants.TYPE_SET:
            case MySQLConstants.TYPE_ENUM:
            case MySQLConstants.TYPE_STRING:
              metadata[i] = CodecUtils.toInt(d.readBytes(2), 0, 2); // Big-endian
              break;
            case MySQLConstants.TYPE_TIME2:
            case MySQLConstants.TYPE_DATETIME2:
            case MySQLConstants.TYPE_TIMESTAMP2:
              metadata[i] = d.readInt(1);
              break;
            default:
              metadata[i] = 0;
      }
    }
View Full Code Here

TOP

Related Classes of com.google.code.or.io.util.XDeserializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.