@Override public Object get(String key) { return context.get(key); }
public Object get(String key) { return context.get(key); }
@Override public synchronized Object get(String key) { Object value = map.get(key); if (value == null && defaults != null) value = defaults.get(key); return value; }
@Override public Object get(String key) { for (int i = contexts.size() - 1; i >= 0; i--) { Object result = contexts.get(i).get(key); if (result != null) return result; } return null; }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { String[] cells = converter.convert(context.get("part")); for (int i = 0; i < cells.length; i++) out.write(cells[i]); out.write(SystemInfo.getLineSeparator()); } catch (ConversionException e) { throw new ScriptException(e); } } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { Object[] cellsOfCurrentRow = (Object[]) context.get("part"); for (int i = 0; i < cellsOfCurrentRow.length; i++) out.write(converters[i].convert(cellsOfCurrentRow[i])); out.write(SystemInfo.getLineSeparator()); } catch (ConversionException e) { throw new ScriptException(e); } } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { Object[] cellsOfCurrentRow = (Object[]) context.get("part"); out.write(descriptor.formatArray(cellsOfCurrentRow)); out.write(SystemInfo.getLineSeparator()); } catch (ConversionException e) { throw new ScriptException(e); } } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { elementCount++; String[] cells = converter.convert(context.get("part")); String prefix = ""; if (prefixFormat != null) { prefixFormat.format(new Integer[] {elementCount}, buffer, pos0); prefix = buffer.toString(); buffer.delete(0, buffer.length()); } for (int i = 0; i < cells.length; i++) { out.write(prefix); out.write(propertyNames[i]); out.write('='); out.write(StringUtil.escape(cells[i])); out.write(LINE_SEPARATOR); } } catch (ConversionException e) { throw new ScriptException(e); } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { String[] cells = converter.convert(context.get("part")); for (int i = 0; i < cells.length; i++) out.write(cells[i]); out.write(SystemInfo.getLineSeparator()); } catch (ConversionException e) { throw new ScriptException(e); } } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { elementCount++; String[] cells = converter.convert(context.get("part")); String prefix = ""; if (prefixFormat != null) { prefixFormat.format(new Integer[] {elementCount}, buffer, pos0); prefix = buffer.toString(); buffer.delete(0, buffer.length()); } for (int i = 0; i < cells.length; i++) { out.write(prefix); out.write(propertyNames[i]); out.write('='); out.write(StringUtil.escape(cells[i])); out.write(LINE_SEPARATOR); } } catch (ConversionException e) { throw new ScriptException(e); } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { Object[] cellsOfCurrentRow = (Object[]) context.get("part"); String text = converter.convert(cellsOfCurrentRow[0]); out.write(CSVUtil.renderCell(text, separator)); for (int i = 1; i < cellsOfCurrentRow.length; i++) { out.write(separator); out.write(converter.convert(cellsOfCurrentRow[i])); } out.write(SystemInfo.getLineSeparator()); } catch (ConversionException e) { throw new ScriptException(e); } } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { Object[] cellsOfCurrentRow = (Object[]) context.get("part"); String text = converter.convert(cellsOfCurrentRow[0]); out.write(CSVUtil.renderCell(text, separator)); for (int i = 1; i < cellsOfCurrentRow.length; i++) { out.write(separator); out.write(converter.convert(cellsOfCurrentRow[i])); } out.write(SystemInfo.getLineSeparator()); } catch (ConversionException e) { throw new ScriptException(e); } } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { String[] cells = converter.convert(context.get("part")); CSVUtil.writeRow(out, separator, cells); } catch (ConversionException e) { throw new ScriptException(e); } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { String[] cells = converter.convert(context.get("part")); CSVUtil.writeRow(out, separator, cells); } catch (ConversionException e) { throw new ScriptException(e); } }
return ((Map<String, Object>) target).get(featureName); else if (target instanceof Context) return ((Context) target).get(featureName); else if (target instanceof Composite) return ((Composite) target).getComponent(featureName);
private static Object invoke(String[] qn, int qnLength, String methodName, Object[] args, Context context) { String objectOrClassName = ArrayFormat.formatPart(".", 0, qnLength, qn); if (context.contains(objectOrClassName)) { Object target = context.get(objectOrClassName); return BeanUtil.invoke(target, methodName, args); } try { Class<?> type = DefaultClassProvider.resolveByObjectOrDefaultInstance(objectOrClassName, context); return BeanUtil.invokeStatic(type, methodName, false, args); } catch (ConfigurationError e) { if (LOGGER.isDebugEnabled()) LOGGER.debug("Class not found: " + objectOrClassName); } QNExpression ownerEx = new QNExpression(Arrays.copyOfRange(qn, 0, qnLength)); Object owner = ownerEx.evaluate(context); if (owner != null) return BeanUtil.invoke(false, owner, methodName, args); throw new UnsupportedOperationException("Cannot evaluate " + objectOrClassName); }
public static Object resolveNamePart(String[] qnParts, int qnLength, Context context) { String objectOrClassName = ArrayFormat.formatPart(".", 0, qnLength, qnParts); if (context.contains(objectOrClassName)) { return context.get(objectOrClassName); } else { try { return DefaultClassProvider.resolveByObjectOrDefaultInstance(objectOrClassName, context); } catch (ConfigurationError e) { // ignore errors signaling that a class was not found } LOGGER.debug("Class not found: {}", objectOrClassName); if (qnLength > 1) { return readField(qnParts, qnLength - 1, qnParts[qnLength - 1], context); } else throw new ObjectNotFoundException("'" + objectOrClassName + "' is not defined"); } }
public BeanSpec resolve(Context context) { String qn = ArrayFormat.format(".", qnParts); if (context.contains(qn)) { return BeanSpec.createReference(context.get(qn)); } else { try { Class<?> bean = DefaultClassProvider.resolveByObjectOrDefaultInstance(qn, context); return BeanSpec.createConstruction(bean); } catch (ConfigurationError e) { // ignore this } LOGGER.debug("Class not found: {}", qn); Object bean = readField(qnParts, qnParts.length - 1, ArrayUtil.lastElementOf(qnParts), context); return BeanSpec.createReference(bean); } }
public BeanSpec resolve(Context context) { String objectOrClassName = ArrayFormat.format(".", qn); try { if (context.contains(objectOrClassName)) return BeanSpec.createReference(context.get(objectOrClassName)); String className = objectOrClassName; Class<?> type = DefaultClassProvider.resolveByObjectOrDefaultInstance(className, context); return BeanSpec.createConstruction(BeanUtil.newInstance(type)); } catch (ConfigurationError e) { if (ExceptionUtil.getRootCause(e) instanceof ClassNotFoundException) return new QNExpression(qn).resolve(context); else throw new ConfigurationError("Cannot resolve " + objectOrClassName, e); } }