/** * !!! all methods that use this method must be sync check if value is valid to insert to array * (to a multidimesnional array only array with one smaller dimension can be inserted) * * @param value value to check * @return checked value * @throws ExpressionException */ private Object checkValue(Object value) throws ExpressionException { // is a 1 > Array if (dimension > 1) { if (value instanceof Array) { if (((Array) value).getDimension() != dimension - 1) throw new ExpressionException( "You can only Append an Array with " + (dimension - 1) + " Dimension", "aray has wron dimension, now is " + (((Array) value).getDimension()) + " but it must be " + (dimension - 1)); } else throw new ExpressionException( "You can only Append an Array with " + (dimension - 1) + " Dimension", "now is a object of type " + Caster.toClassName(value)); } return value; }
public static InputSource toInputSource(PageContext pc, Object value) throws IOException, ExpressionException { if (value instanceof InputSource) { return (InputSource) value; } if (value instanceof String) { return toInputSource(pc, (String) value); } if (value instanceof StringBuffer) { return toInputSource(pc, value.toString()); } if (value instanceof Resource) { String str = IOUtil.toString(((Resource) value), null); return new InputSource(new StringReader(str)); } if (value instanceof File) { String str = IOUtil.toString(ResourceUtil.toResource(((File) value)), null); return new InputSource(new StringReader(str)); } if (value instanceof InputStream) { InputStream is = (InputStream) value; try { String str = IOUtil.toString(is, null); return new InputSource(new StringReader(str)); } finally { IOUtil.closeEL(is); } } if (value instanceof Reader) { Reader reader = (Reader) value; try { String str = IOUtil.toString(reader); return new InputSource(new StringReader(str)); } finally { IOUtil.closeEL(reader); } } if (value instanceof byte[]) { return new InputSource(new ByteArrayInputStream((byte[]) value)); } throw new ExpressionException( "cat cast object of type [" + Caster.toClassName(value) + "] to a Input for xml parser"); }