<commit_before>package railo.runtime.type.scope;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import railo.commons.lang.CFTypes;
import railo.runtime.PageContext;
import railo.runtime.dump.DumpData;
import railo.runtime.dump.DumpProperties;
import railo.runtime.dump.DumpTable;
import railo.runtime.dump.DumpUtil;
import railo.runtime.dump.SimpleDumpData;
import railo.runtime.exp.ExpressionException;
import railo.runtime.exp.PageException;
import railo.runtime.op.Caster;
import railo.runtime.op.Decision;
import railo.runtime.type.Array;
import railo.runtime.type.ArrayImpl;
import railo.runtime.type.Collection;
import railo.runtime.type.KeyImpl;
import railo.runtime.type.Struct;
import railo.runtime.type.StructImpl;
import railo.runtime.type.UDF;
import railo.runtime.type.util.CollectionUtil;
import railo.runtime.type.util.MemberUtil;
import railo.runtime.type.wrap.ArrayAsList;

/**
 * implementation of the argument scope 
 */
public final class ArgumentImpl extends ScopeSupport implements Argument {
		
	private boolean bind;
	private Set functionArgumentNames;
	//private boolean supportFunctionArguments; 
	
	/**
	 * constructor of the class
	 */
	public ArgumentImpl() {
		super("arguments",SCOPE_ARGUMENTS,Struct.TYPE_LINKED);
		//this(true);
	}


	/**
	 * @see railo.runtime.type.scope.ScopeSupport#release()
	 */
	public void release() {
		functionArgumentNames=null;
		super.release();
	}
	
	@Override
	public void release(PageContext pc) {
		functionArgumentNames=null;
		super.release(pc);
	}
	
	
	
     /**
     * @see railo.runtime.type.scope.Argument#setBind(boolean)
     */ 
    public void setBind(boolean bind) { 
            this.bind=bind; 
    }       
    
    /**
     * @see railo.runtime.type.scope.Argument#isBind()
     */ 
    public boolean isBind() { 
        return this.bind; 
    } 
    
    public Object getFunctionArgument(String key, Object defaultValue) {
		return getFunctionArgument(KeyImpl.getInstance(key), defaultValue);
	}

	public Object getFunctionArgument(Collection.Key key, Object defaultValue) {
		return super.get(key,defaultValue);
	}
	

	/**
	 * @see railo.runtime.type.scope.ArgumentPro#containsFunctionArgumentKey(railo.runtime.type.Collection.Key)
	 */
	public boolean containsFunctionArgumentKey(Key key) {
		return super.containsKey(key);//functionArgumentNames!=null && functionArgumentNames.contains(key);
	}
	
	
	
	/**
	 *
	 * @see railo.runtime.type.StructImpl#get(railo.runtime.type.Collection.Key, java.lang.Object)
	 */
	public Object get(Collection.Key key, Object defaultValue) {
		Object o=super.get(key,null);
		if(o!=null)return o;
		
		//char c = key.charAt(0);
    	//if(!Character.isDigit(c) && c!='+') return defaultValue; // it make sense to have this step between
    	
		
		
		o=get(Caster.toIntValue(key.getString(),-1),null);
		if(o!=null)return o;
		return defaultValue;
	}


	/**
	 *
	 * @see railo.runtime.type.StructImpl#get(railo.runtime.type.Collection.Key)
	 */
	public Object get(Collection.Key key) throws ExpressionException {
		Object o=super.get(key,null);
		if(o!=null)return o;

		//char c = key.charAt(0);
    	//if(Character.isDigit(c) || c=='+') {
    		o=get(Caster.toIntValue(key.getString(),-1),null);
    		if(o!=null)return o;
    	//}
    	
    	throw new ExpressionException("key ["+key.getString()+"] doesn't exist in argument scope. existing keys are ["+
			railo.runtime.type.List.arrayToList(CollectionUtil.keys(this),", ")
			+"]");
		
	}

	/**
	 *
	 * @see railo.runtime.type.Array#get(int, java.lang.Object)
	 */
	public Object get(int intKey, Object defaultValue) {
		Iterator<Object> it = valueIterator(); //keyIterator();//getMap().keySet().iterator();
		int count=0;
		Object o;
		while(it.hasNext()) {<commit_msg>improve method containsKey in Argument Scope<commit_after>package railo.runtime.type.scope;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import railo.commons.lang.CFTypes;
import railo.runtime.PageContext;
import railo.runtime.dump.DumpData;
import railo.runtime.dump.DumpProperties;
import railo.runtime.dump.DumpTable;
import railo.runtime.dump.DumpUtil;
import railo.runtime.dump.SimpleDumpData;
import railo.runtime.exp.ExpressionException;
import railo.runtime.exp.PageException;
import railo.runtime.op.Caster;
import railo.runtime.op.Decision;
import railo.runtime.type.Array;
import railo.runtime.type.ArrayImpl;
import railo.runtime.type.Collection;
import railo.runtime.type.KeyImpl;
import railo.runtime.type.Struct;
import railo.runtime.type.StructImpl;
import railo.runtime.type.UDF;
import railo.runtime.type.util.CollectionUtil;
import railo.runtime.type.util.MemberUtil;
import railo.runtime.type.wrap.ArrayAsList;

/**
 * implementation of the argument scope 
 */
public final class ArgumentImpl extends ScopeSupport implements Argument {
		
	private boolean bind;
	private Set functionArgumentNames;
	//private boolean supportFunctionArguments; 
	
	/**
	 * constructor of the class
	 */
	public ArgumentImpl() {
		super("arguments",SCOPE_ARGUMENTS,Struct.TYPE_LINKED);
		//this(true);
	}


	/**
	 * @see railo.runtime.type.scope.ScopeSupport#release()
	 */
	public void release() {
		functionArgumentNames=null;
		super.release();
	}
	
	@Override
	public void release(PageContext pc) {
		functionArgumentNames=null;
		super.release(pc);
	}
	
	
	
     /**
     * @see railo.runtime.type.scope.Argument#setBind(boolean)
     */ 
    public void setBind(boolean bind) { 
            this.bind=bind; 
    }       
    
    /**
     * @see railo.runtime.type.scope.Argument#isBind()
     */ 
    public boolean isBind() { 
        return this.bind; 
    } 
    
    public Object getFunctionArgument(String key, Object defaultValue) {
		return getFunctionArgument(KeyImpl.getInstance(key), defaultValue);
	}

	public Object getFunctionArgument(Collection.Key key, Object defaultValue) {
		return super.get(key,defaultValue);
	}
	

	/**
	 * @see railo.runtime.type.scope.ArgumentPro#containsFunctionArgumentKey(railo.runtime.type.Collection.Key)
	 */
	public boolean containsFunctionArgumentKey(Key key) {
		return super.containsKey(key);//functionArgumentNames!=null && functionArgumentNames.contains(key);
	}
	
	
	
	/**
	 *
	 * @see railo.runtime.type.StructImpl#get(railo.runtime.type.Collection.Key, java.lang.Object)
	 */
	public Object get(Collection.Key key, Object defaultValue) {
		Object o=super.get(key,null);
		if(o!=null)return o;
		
		//char c = key.charAt(0);
    	//if(!Character.isDigit(c) && c!='+') return defaultValue; // it make sense to have this step between
    	
		
		
		o=get(Caster.toIntValue(key.getString(),-1),null);
		if(o!=null)return o;
		if(super.containsKey(key)) return null;// that is only for compatibility to neo
		return defaultValue;
	}


	/**
	 *
	 * @see railo.runtime.type.StructImpl#get(railo.runtime.type.Collection.Key)
	 */
	public Object get(Collection.Key key) throws ExpressionException {
		Object o=super.get(key,null);
		if(o!=null)return o;

		//char c = key.charAt(0);
    	//if(Character.isDigit(c) || c=='+') {
    		o=get(Caster.toIntValue(key.getString(),-1),null);
    		if(o!=null)return o;
    	//}
    	if(super.containsKey(key)) return null;// that is only for compatibility to neo
    	throw new ExpressionException("key ["+key.getString()+"] doesn't exist in argument scope. existing keys are ["+
			railo.runtime.type.List.arrayToList(CollectionUtil.keys(this),", ")
			+"]");
		
	}

	/**
	 *
	 * @see railo.runtime.type.Array#get(int, java.lang.Object)
	 */
	public Object get(int intKey, Object defaultValue) {
		Iterator<Object> it = valueIterator(); //keyIterator();//getMap().keySet().iterator();
		int count=0;
		Object o;
		while(it.hasNext()) {
{'fraction_non_alphanumeric': 0.13534591194968554, 'fraction_numerical': 0.0012578616352201257, 'mean_word_length': 4.003775959723097, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, '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': '5775712', 'n_tokens_mistral': 2705, 'n_tokens_neox': 2539, 'n_words': 477}