<commit_before>package railo.runtime.db;

import java.io.Serializable;

import railo.commons.lang.SizeOf;
import railo.runtime.type.Sizeable;




/**
 * represents a SQL Statement with his defined arguments for a prepared statement
 */
public final class SQLImpl implements SQL,Serializable,Sizeable {
    
    private String strSQL;
    private SQLItem[] items;
    private int position=0;

    /**
     * Constructor only with SQL String
     * @param strSQL SQL String
     */
    public SQLImpl(String strSQL) {
        this.strSQL=strSQL;
        this.items=new SQLItem[0];
    }
    
    /**
     * Constructor with SQL String and SQL Items
     * @param strSQL SQL String
     * @param items SQL Items
     */
    public SQLImpl(String strSQL, SQLItem[] items) {
        this.strSQL=strSQL;
        this.items=items;
    }
    
    /**
     * @see railo.runtime.db.SQL#getItems()
     */
    public void addItems(SQLItem item) {
    	SQLItem[] tmp=new SQLItem[items.length+1];
    	for(int i=0;i<items.length;i++) {
    		tmp[i]=items[i];
    	}
    	tmp[items.length]=item;
    	items=tmp;
    }
    
    /**
     * @see railo.runtime.db.SQL#getItems()
     */
    public SQLItem[] getItems() {
        return items;
    }

    /**
     * @see railo.runtime.db.SQL#getPosition()
     */
    public int getPosition() {
        return position;
    }
    
    /**
     * @see railo.runtime.db.SQL#setPosition(int)
     */
    public void setPosition(int position) {
        this.position = position;
    }    
    

    /**
     * @see railo.runtime.db.SQL#getSQLString()
     */
    public String getSQLString() {
        return strSQL;
    }
    
    /**
     * @see railo.runtime.db.SQL#setSQLString(java.lang.String)
     */
    public void setSQLString(String strSQL) {
        this.strSQL= strSQL;
    }

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        if(items.length==0) return strSQL;
        StringBuffer sb=new StringBuffer();
        int pos;
        int last=0;
        for(int i=0;i<items.length;i++) {
            pos=strSQL.indexOf('?',last);
            if(pos==-1) {
                sb.append(strSQL.substring(last));
                break;
            }
            sb.append(strSQL.substring(last,pos));
            if(items[i].isNulls()) sb.append("null");
            else sb.append(SQLCaster.toString(items[i]));
            last=pos+1;
        }
        sb.append(strSQL.substring(last));
        return sb.toString();
    }    
    
    /**
     * @see railo.runtime.db.SQL#toHashString()
     */
    public String toHashString() {
        if(items.length==0) return strSQL;
        StringBuffer sb=new StringBuffer(strSQL);
        for(int i=0;i<items.length;i++) {
            sb.append(items[i].toString());
        }
        return sb.toString();
    }

	public long sizeOf() {
		return SizeOf.size(strSQL)+SizeOf.size(position)+SizeOf.size(items);
	}

	public static SQL duplicate(SQL sql) {
		if(!(sql instanceof SQLImpl)) return sql;
		return ((SQLImpl) sql).duplicate();
	}

	public SQL duplicate() {
		SQLImpl rtn=new SQLImpl(strSQL);
		rtn.position=position;
		rtn.items=new SQLItem[items.length];
		for(int i=0;i<items.length;i++){
			rtn.items[i]=SQLItemImpl.duplicate(items[i]);
		}
		<commit_msg>solved ticket https://issues.jboss.org/browse/RAILO-1703<commit_after>package railo.runtime.db;

import java.io.Serializable;

import railo.commons.lang.SizeOf;
import railo.runtime.type.Sizeable;




/**
 * represents a SQL Statement with his defined arguments for a prepared statement
 */
public final class SQLImpl implements SQL,Serializable,Sizeable {
    
    private String strSQL;
    private SQLItem[] items;
    private int position=0;

    /**
     * Constructor only with SQL String
     * @param strSQL SQL String
     */
    public SQLImpl(String strSQL) {
        this.strSQL=strSQL;
        this.items=new SQLItem[0];
    }
    
    /**
     * Constructor with SQL String and SQL Items
     * @param strSQL SQL String
     * @param items SQL Items
     */
    public SQLImpl(String strSQL, SQLItem[] items) {
        this.strSQL=strSQL;
        this.items=items;
    }
    
    /**
     * @see railo.runtime.db.SQL#getItems()
     */
    public void addItems(SQLItem item) {
    	SQLItem[] tmp=new SQLItem[items.length+1];
    	for(int i=0;i<items.length;i++) {
    		tmp[i]=items[i];
    	}
    	tmp[items.length]=item;
    	items=tmp;
    }
    
    /**
     * @see railo.runtime.db.SQL#getItems()
     */
    public SQLItem[] getItems() {
        return items;
    }

    /**
     * @see railo.runtime.db.SQL#getPosition()
     */
    public int getPosition() {
        return position;
    }
    
    /**
     * @see railo.runtime.db.SQL#setPosition(int)
     */
    public void setPosition(int position) {
        this.position = position;
    }    
    

    /**
     * @see railo.runtime.db.SQL#getSQLString()
     */
    public String getSQLString() {
        return strSQL;
    }
    
    /**
     * @see railo.runtime.db.SQL#setSQLString(java.lang.String)
     */
    public void setSQLString(String strSQL) {
        this.strSQL= strSQL;
    }

    /**
     * @see java.lang.Object#toString()
     */
    public String toString() {
        if(items.length==0) return strSQL;
        StringBuffer sb=new StringBuffer();
        int pos;
        int last=0;
        for(int i=0;i<items.length;i++) {
            pos=strSQL.indexOf('?',last);
            if(pos==-1) {
                sb.append(strSQL.substring(last));
                break;
            }
            sb.append(strSQL.substring(last,pos));
            if(items[i].isNulls()) sb.append("null");
            else sb.append(SQLCaster.toString(items[i]));
            last=pos+1;
        }
        sb.append(strSQL.substring(last));
        return sb.toString();
    }    
    
    /**
     * @see railo.runtime.db.SQL#toHashString()
     */
    public String toHashString() {
        if(items.length==0) return strSQL;
        StringBuffer sb=new StringBuffer(strSQL);
        for(int i=0;i<items.length;i++) {
            sb.append(';').append(items[i].toString());
        }
        return sb.toString();
    }

	public long sizeOf() {
		return SizeOf.size(strSQL)+SizeOf.size(position)+SizeOf.size(items);
	}

	public static SQL duplicate(SQL sql) {
		if(!(sql instanceof SQLImpl)) return sql;
		return ((SQLImpl) sql).duplicate();
	}

	public SQL duplicate() {
		SQLImpl rtn=new SQLImpl(strSQL);
		rtn.position=position;
		rtn.items=new SQLItem[items.length];
		for(int i=0;i<items.length;i++){
			rtn.items[i]=SQLItemImpl.duplicate(items[i]);
		}
		
{'fraction_non_alphanumeric': 0.1384406575177198, 'fraction_numerical': 0.004222590861106922, 'mean_word_length': 2.1777671298514614, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2556546', 'n_tokens_mistral': 2205, 'n_tokens_neox': 2151, 'n_words': 400}