/*
 * TypeBinaryWriter.java
 * 
 * (C) 28.02.2005 Markus Schaber, Logi-Track ag, CH 8001 Zuerich
 * 
 * $Id: $
 */
package org.postgresql.types;

import java.io.IOException;
import java.io.Writer;
import java.sql.SQLException;

public interface TypeTextWriter extends TypeDriver {

    /**
     * Return the length of an encoded object in characters.
     * 
     * This method can calculate the length on actual data. You can call it with
     * any object the driver accepts via set* methods.
     * 
     * @return the lenght in bytes, -1 for unknown.
     * @throws SQLException if the driver does not know to handle the object or
     *             something else goes wrong.
     */
    int objectCharLength(Object data) throws SQLException;
    
    /** Render the object into the SQL text representation */
    String renderObject(Object data); 
    
    /** Render the object into the SQL text representation */
    void renderObject(Object data, StringBuffer sb);
    
    /** Render the object into the SQL text representation */
    void renderObject(Object data, char[] target, int startindex);
    
    /** Render the object into the SQL text representation 
     * @throws IOException */
    void renderObject(Object data, Writer target) throws IOException;
}
