001 /** 002 * Implements the CFML Function structnew 003 */ 004 package railo.runtime.functions.struct; 005 006 import railo.runtime.PageContext; 007 import railo.runtime.exp.FunctionException; 008 import railo.runtime.ext.function.Function; 009 import railo.runtime.type.Struct; 010 import railo.runtime.type.StructImpl; 011 012 public final class StructNew implements Function { 013 public static Struct call(PageContext pc ) { 014 return new StructImpl(); 015 } 016 public static Struct call(PageContext pc ,String type) throws FunctionException { 017 type=type.toLowerCase(); 018 if(type.equals("linked")) return new StructImpl(Struct.TYPE_LINKED); 019 else if(type.equals("weak")) return new StructImpl(Struct.TYPE_WEAKED); 020 else if(type.equals("syncronized")) return new StructImpl(Struct.TYPE_SYNC); 021 else if(type.equals("synchronized")) return new StructImpl(Struct.TYPE_SYNC); 022 else if(type.equals("sync")) return new StructImpl(Struct.TYPE_SYNC); 023 else if(type.equals("soft")) return new StructImpl(StructImpl.TYPE_SOFT); 024 else if(type.equals("normal")) return new StructImpl(); 025 026 else throw new FunctionException(pc,"structNew",1,"type","valid values are [normal, weak, linked, soft, synchronized]"); 027 } 028 }