001 /** 002 * Implements the Cold Fusion Function bitmaskset 003 */ 004 package railo.runtime.functions.math; 005 006 import railo.runtime.PageContext; 007 import railo.runtime.exp.FunctionException; 008 import railo.runtime.ext.function.Function; 009 010 public final class BitMaskSet implements Function { 011 012 public static double call(PageContext pc , double dnumber, double dmask, double dstart, double dlength) throws FunctionException { 013 014 int number=(int)dnumber, mask=(int)dmask, start=(int)dstart, length=(int)dlength; 015 016 if(start > 31 || start < 0) 017 throw new FunctionException(pc,"bitMaskSet",2,"start","must be beetween 0 and 31 now "+start); 018 if(length > 31 || length < 0) 019 throw new FunctionException(pc,"bitMaskSet",3,"length","must be beetween 0 and 31 now "+length); 020 021 int tmp = (1 << length) - 1 << start; 022 mask &= (1 << length) - 1; 023 return number & ~tmp | mask << start; 024 } 025 }