示例#1
0
  public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    int width = Caster.toIntValue(parameters.get(KeyImpl.init("Width")));
    int height = Caster.toIntValue(parameters.get(KeyImpl.init("Height")));
    setHeight(height);
    setWidth(width);

    dst = ImageUtil.createBufferedImage(dst, width, height);

    return filter(src, dst);
  }
示例#2
0
  @Override
  public Object get(Collection.Key key) throws ExpressionException {
    /*if(NullSupportHelper.full()) {
    	Object o=super.get(key,NullSupportHelper.NULL());
    	if(o!=NullSupportHelper.NULL())return o;

    	o=get(Caster.toIntValue(key.getString(),-1),NullSupportHelper.NULL());
    	if(o!=NullSupportHelper.NULL())return o;
    	throw new ExpressionException("key ["+key.getString()+"] doesn't exist in argument scope. existing keys are ["+
    			lucee.runtime.type.List.arrayToList(CollectionUtil.keys(this),", ")
    			+"]");
    }*/

    // null is supported as returned value with argument scope
    Object o = super.g(key, Null.NULL);
    if (o != Null.NULL) return o;

    o = get(Caster.toIntValue(key.getString(), -1), Null.NULL);
    if (o != Null.NULL) return o;

    throw new ExpressionException(
        "key ["
            + key.getString()
            + "] doesn't exist in argument scope. existing keys are ["
            + lucee.runtime.type.util.ListUtil.arrayToList(CollectionUtil.keys(this), ", ")
            + "]");
  }
示例#3
0
 /**
  * @param suggestions the suggestions to set
  * @throws ApplicationException
  */
 public void setSuggestions(String suggestions) throws PageException {
   if (StringUtil.isEmpty(suggestions)) return;
   suggestions = suggestions.trim().toLowerCase();
   if ("always".equals(suggestions)) this.suggestions = SUGGESTIONS_ALWAYS;
   else if ("never".equals(suggestions)) this.suggestions = SUGGESTIONS_NEVER;
   else if (Decision.isNumber(suggestions)) {
     this.suggestions = Caster.toIntValue(suggestions);
   } else
     throw new ApplicationException(
         "attribute suggestions has an invalid value ["
             + suggestions
             + "], valid values are [always,never,<positive numeric value>]");
 }
示例#4
0
  public static int getAddressSize() {
    try {
      Class unsafe = ClassUtil.loadClass(null, "sun.misc.Unsafe", null);
      if (unsafe == null) return 0;

      Field unsafeField = unsafe.getDeclaredField("theUnsafe");
      unsafeField.setAccessible(true);
      Object obj = unsafeField.get(null);
      Method addressSize = unsafe.getMethod("addressSize", new Class[0]);

      Object res = addressSize.invoke(obj, new Object[0]);
      return Caster.toIntValue(res, 0);
    } catch (Throwable t) {
      return 0;
    }
  }
示例#5
0
  @Override
  public Object get(Collection.Key key, Object defaultValue) {
    /*if(NullSupportHelper.full()) {
    	Object o=super.get(key,NullSupportHelper.NULL());
    	if(o!=NullSupportHelper.NULL())return o;

    	o=get(Caster.toIntValue(key.getString(),-1),NullSupportHelper.NULL());
    	if(o!=NullSupportHelper.NULL())return o;
    	return defaultValue;
    }*/

    Object o = super.g(key, Null.NULL);
    if (o != Null.NULL) return o;

    o = get(Caster.toIntValue(key.getString(), -1), Null.NULL);
    if (o != Null.NULL) return o;
    return defaultValue;
  }
  private static SQLItem fill(SQLItem item, Struct sct) throws DatabaseException, PageException {
    // type (optional)
    Object oType = sct.get(KeyConstants._cfsqltype, null);
    if (oType == null) oType = sct.get(KeyConstants._sqltype, null);
    if (oType == null) oType = sct.get(KeyConstants._type, null);
    if (oType != null) {
      item.setType(SQLCaster.toSQLType(Caster.toString(oType)));
    }

    // nulls (optional)
    Object oNulls = sct.get(KeyConstants._nulls, null);
    if (oNulls != null) {
      item.setNulls(Caster.toBooleanValue(oNulls));
    }

    // scale (optional)
    Object oScale = sct.get(KeyConstants._scale, null);
    if (oScale != null) {
      item.setScale(Caster.toIntValue(oScale));
    }

    /* list
    if(Caster.toBooleanValue(sct.get("list",null),false)) {
    	String separator=Caster.toString(sct.get("separator",null),",");
    	String v = Caster.toString(item.getValue());
       	Array arr=null;
       	if(StringUtil.isEmpty(v)){
       		arr=new ArrayImpl();
       		arr.append("");
       	}
       	else arr=ListUtil.listToArrayRemoveEmpty(v,separator);

    	int len=arr.size();
    	StringBuilder sb=new StringBuilder();
    	for(int i=1;i<=len;i++) {
    	    query.setParam(item.clone(check(arr.getE(i))));
            if(i>1)sb.append(',');
            sb.append('?');
    	}
    	write(sb.toString());
    }*/
    return item;
  }
示例#7
0
 /**
  * set the value port The port number on the server from which the task is being scheduled.
  * Default is 80. When used with resolveURL, the URLs of retrieved documents that specify a port
  * number are automatically resolved to preserve links in the retrieved document.
  *
  * @param port value to set
  * @throws PageException
  */
 public void setPort(Object oPort) throws PageException {
   if (StringUtil.isEmpty(oPort)) return;
   this.port = Caster.toIntValue(oPort);
 }
示例#8
0
 int callint(PageContext pc, Component cfc, String methodName, Object[] args)
     throws PageException {
   return Caster.toIntValue(call(pc, cfc, methodName, args));
 }