001    /**
002     * Implements the Cold Fusion 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("soft")) return new StructImpl(StructImpl.TYPE_SOFT);
022            else if(type.equals("normal")) return new StructImpl();
023            
024            else throw new FunctionException(pc,"structNew",1,"type","valid values are [normal, weak, linked,syncronized]");
025        }
026    }