001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.runtime.functions.list; 020 021import lucee.runtime.PageContext; 022import lucee.runtime.exp.FunctionException; 023import lucee.runtime.exp.PageException; 024import lucee.runtime.functions.BIF; 025import lucee.runtime.functions.closure.Some; 026import lucee.runtime.op.Caster; 027import lucee.runtime.type.UDF; 028import lucee.runtime.type.util.StringListData; 029 030public class ListSome extends BIF { 031 032 private static final long serialVersionUID = -9092877950301316754L; 033 034 public static boolean call(PageContext pc , String list, UDF udf) throws PageException { 035 return call(pc, list, udf, ",", false, true,false, 20); 036 } 037 038 public static boolean call(PageContext pc , String list, UDF udf, String delimiter) throws PageException { 039 return call(pc, list, udf, delimiter, false, true,false, 20); 040 } 041 042 public static boolean call(PageContext pc , String list, UDF udf, String delimiter, boolean includeEmptyFields) throws PageException { 043 return call(pc, list, udf, delimiter, includeEmptyFields, true,false, 20); 044 } 045 046 public static boolean call(PageContext pc , String list, UDF udf, String delimiter, boolean includeEmptyFields, boolean multiCharacterDelimiter) throws PageException { 047 return call(pc, list, udf, delimiter, includeEmptyFields,multiCharacterDelimiter, false, 20); 048 } 049 050 public static boolean call(PageContext pc , String list, UDF udf, String delimiter, boolean includeEmptyFields, boolean multiCharacterDelimiter, boolean parallel) throws PageException { 051 return call(pc, list, udf, delimiter, includeEmptyFields,multiCharacterDelimiter, parallel, 20); 052 } 053 054 public static boolean call(PageContext pc , String list, UDF udf, String delimiter 055 , boolean includeEmptyFields, boolean multiCharacterDelimiter, boolean parallel, double maxThreads) throws PageException { 056 StringListData data=new StringListData(list,delimiter,includeEmptyFields,multiCharacterDelimiter); 057 058 return Some.call(pc, data, udf, parallel, maxThreads); 059 } 060 061 @Override 062 public Object invoke(PageContext pc, Object[] args) throws PageException { 063 064 if(args.length==2) 065 return call(pc, Caster.toString(args[0]), Caster.toFunction(args[1])); 066 if(args.length==3) 067 return call(pc, Caster.toString(args[0]), Caster.toFunction(args[1]),Caster.toString(args[2])); 068 if(args.length==4) 069 return call(pc, Caster.toString(args[0]), Caster.toFunction(args[1]),Caster.toString(args[2]),Caster.toBooleanValue(args[3])); 070 if(args.length==5) 071 return call(pc, Caster.toString(args[0]), Caster.toFunction(args[1]),Caster.toString(args[2]),Caster.toBooleanValue(args[3]), Caster.toBooleanValue(args[4])); 072 if(args.length==6) 073 return call(pc, Caster.toString(args[0]), Caster.toFunction(args[1]),Caster.toString(args[2]),Caster.toBooleanValue(args[3]), Caster.toBooleanValue(args[4]), Caster.toBooleanValue(args[5])); 074 if(args.length==7) 075 return call(pc, Caster.toString(args[0]), Caster.toFunction(args[1]),Caster.toString(args[2]),Caster.toBooleanValue(args[3]), Caster.toBooleanValue(args[4]), Caster.toBooleanValue(args[5]), Caster.toDoubleValue(args[6])); 076 077 throw new FunctionException(pc, "ListSome", 2, 7, args.length); 078 } 079 080}