// Path: dalesbred/src/main/java/org/dalesbred/datatype/InputStreamWithSize.java
// public final class InputStreamWithSize extends FilterInputStream {
// 
//     private final long size;
// 
//     public InputStreamWithSize(@NotNull InputStream in, long size) {
//         super(in);
// 
//         if (size < 0) throw new IllegalArgumentException("negative size: " + size);
// 
//         this.size = size;
//     }
// 
//     public long getSize() {
//         return size;
//     }
// }
// 
// Path: dalesbred/src/main/java/org/dalesbred/datatype/ReaderWithSize.java
// public final class ReaderWithSize extends FilterReader {
// 
//     private final long size;
// 
//     public ReaderWithSize(@NotNull Reader reader, long size) {
//         super(reader);
// 
//         if (size < 0) throw new IllegalArgumentException("negative size: " + size);
// 
//         this.size = size;
//     }
// 
//     public long getSize() {
//         return size;
//     }
// }
// 
// Path: dalesbred/src/main/java/org/dalesbred/datatype/SqlArray.java
// public final class SqlArray {
// 
//     /** Database specific type name of the array */
//     private final @NotNull String type;
// 
//     /** Values for the array */
//     private final @NotNull List<?> values;
// 
//     private SqlArray(@NotNull String type, @NotNull Collection<?> values) {
//         this.type = requireNonNull(type);
//         this.values = unmodifiableList(new ArrayList<>(values));
//     }
// 
//     /**
//      * Constructs array of specified type.
//      *
//      * @param type database type for the array
//      * @param values for the array
//      */
//     public static @NotNull SqlArray of(@NotNull String type, @NotNull Collection<?> values) {
//         return new SqlArray(type, values);
//     }
// 
//     /**
//      * Constructs array of specified type.
//      *
//      * @param type database type for the array
//      * @param values for the array
//      */
//     public static @NotNull SqlArray of(@NotNull String type, @NotNull Object[] values) {
//         return of(type, asList(values));
//     }
// 
//     /**
//      * Constructs varchar array of given values.
//      */
//     public static @NotNull SqlArray varchars(@NotNull Collection<String> values) {
//         return of("varchar", values);
//     }
// 
//     /**
//      * Constructs varchar array of given values.
//      */
//     public static @NotNull SqlArray varchars(@NotNull String... values) {
//         return varchars(asList(values));
//     }
// 
//     /**
//      * Returns the database type for the array.
//      */
//     public @NotNull String getType() {
//         return type;
//     }
// 
//     /**
//      * Returns the values of the array.
//      */
//     public @NotNull List<?> getValues() {
//         return values;
//     }
// 
//     @Override
//     public String toString() {
//         return "SQLArray[type=" + type + ", values=" + values + ']';
//     }
// }


import java.io.InputStream;
import java.io.Reader;
import java.sql.Array;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.SQLXML;
import org.dalesbred.datatype.InputStreamWithSize;
import org.dalesbred.datatype.ReaderWithSize;
import org.dalesbred.datatype.SqlArray;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.w3c.dom.Document;
import javax.xml.transform.dom.DOMResult;
/*
 * Copyright (c) 2015 Evident Solutions Oy
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package org.dalesbred.internal.jdbc;



public final class ArgumentBinder {

    private ArgumentBinder() {
    }

    public static void bindArgument(@NotNull PreparedStatement ps, int index, @Nullable Object value) throws SQLException {
        if (value instanceof InputStream) {
            bindInputStream(ps, index, (InputStream) value);

        } else if (value instanceof Reader) {
            bindReader(ps, index, (Reader) value);

        } else if (value instanceof Document) {
            bindXmlDocument(ps, index, (Document) value);

// Path: dalesbred/src/main/java/org/dalesbred/datatype/InputStreamWithSize.java
// public final class InputStreamWithSize extends FilterInputStream {
// 
//     private final long size;
// 
//     public InputStreamWithSize(@NotNull InputStream in, long size) {
//         super(in);
// 
//         if (size < 0) throw new IllegalArgumentException("negative size: " + size);
// 
//         this.size = size;
//     }
// 
//     public long getSize() {
//         return size;
//     }
// }
// 
// Path: dalesbred/src/main/java/org/dalesbred/datatype/ReaderWithSize.java
// public final class ReaderWithSize extends FilterReader {
// 
//     private final long size;
// 
//     public ReaderWithSize(@NotNull Reader reader, long size) {
//         super(reader);
// 
//         if (size < 0) throw new IllegalArgumentException("negative size: " + size);
// 
//         this.size = size;
//     }
// 
//     public long getSize() {
//         return size;
//     }
// }
// 
// Path: dalesbred/src/main/java/org/dalesbred/datatype/SqlArray.java
// public final class SqlArray {
// 
//     /** Database specific type name of the array */
//     private final @NotNull String type;
// 
//     /** Values for the array */
//     private final @NotNull List<?> values;
// 
//     private SqlArray(@NotNull String type, @NotNull Collection<?> values) {
//         this.type = requireNonNull(type);
//         this.values = unmodifiableList(new ArrayList<>(values));
//     }
// 
//     /**
//      * Constructs array of specified type.
//      *
//      * @param type database type for the array
//      * @param values for the array
//      */
//     public static @NotNull SqlArray of(@NotNull String type, @NotNull Collection<?> values) {
//         return new SqlArray(type, values);
//     }
// 
//     /**
//      * Constructs array of specified type.
//      *
//      * @param type database type for the array
//      * @param values for the array
//      */
//     public static @NotNull SqlArray of(@NotNull String type, @NotNull Object[] values) {
//         return of(type, asList(values));
//     }
// 
//     /**
//      * Constructs varchar array of given values.
//      */
//     public static @NotNull SqlArray varchars(@NotNull Collection<String> values) {
//         return of("varchar", values);
//     }
// 
//     /**
//      * Constructs varchar array of given values.
//      */
//     public static @NotNull SqlArray varchars(@NotNull String... values) {
//         return varchars(asList(values));
//     }
// 
//     /**
//      * Returns the database type for the array.
//      */
//     public @NotNull String getType() {
//         return type;
//     }
// 
//     /**
//      * Returns the values of the array.
//      */
//     public @NotNull List<?> getValues() {
//         return values;
//     }
// 
//     @Override
//     public String toString() {
//         return "SQLArray[type=" + type + ", values=" + values + ']';
//     }
// }


// Path: dalesbred/src/main/java/org/dalesbred/internal/jdbc/ArgumentBinder.java
import java.io.InputStream;
import java.io.Reader;
import java.sql.Array;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.SQLXML;
import org.dalesbred.datatype.InputStreamWithSize;
import org.dalesbred.datatype.ReaderWithSize;
import org.dalesbred.datatype.SqlArray;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.w3c.dom.Document;
import javax.xml.transform.dom.DOMResult;

/*
 * Copyright (c) 2015 Evident Solutions Oy
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package org.dalesbred.internal.jdbc;



public final class ArgumentBinder {

    private ArgumentBinder() {
    }

    public static void bindArgument(@NotNull PreparedStatement ps, int index, @Nullable Object value) throws SQLException {
        if (value instanceof InputStream) {
            bindInputStream(ps, index, (InputStream) value);

        } else if (value instanceof Reader) {
            bindReader(ps, index, (Reader) value);

        } else if (value instanceof Document) {
            bindXmlDocument(ps, index, (Document) value);

        } else if (value instanceof SqlArray) {