All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.pgasync.impl.io.QueryEncoder Maven / Gradle / Ivy

There is a newer version: 0.9
Show newest version
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.pgasync.impl.io;

import com.github.pgasync.impl.message.Query;

import java.nio.ByteBuffer;

import static com.github.pgasync.impl.io.IO.putCString;

/**
 * See PostgreSQL message formats
 *
 * 
 * Query (F)
 *  Byte1('Q')
 *      Identifies the message as a simple query.
 *  Int32
 *      Length of message contents in bytes, including self.
 *  String
 *      The queryRows string itself.
 * 
* * @author Antti Laisi */ public class QueryEncoder implements Encoder { @Override public Class getMessageType() { return Query.class; } @Override public void write(Query msg, ByteBuffer buffer) { buffer.put((byte) 'Q'); buffer.putInt(0); putCString(buffer, msg.getQuery()); buffer.putInt(1, buffer.position() - 1); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy