@SuppressWarnings("rawtypes") @Override public TemplateModel wrap(Object obj) throws TemplateModelException { if (obj == null) { return super.wrap(null); } if (obj instanceof TemplateModel) { return (TemplateModel) obj; } if (obj instanceof String) { return new SimpleScalar((String) obj); } if (obj instanceof Number) { return new SimpleNumber((Number) obj); } if (obj instanceof java.util.Date) { if(obj instanceof java.sql.Date) { return new SimpleDate((java.sql.Date) obj); } if(obj instanceof java.sql.Time) { return new SimpleDate((java.sql.Time) obj); } if(obj instanceof java.sql.Timestamp) { return new SimpleDate((java.sql.Timestamp) obj); } return new SimpleDate((java.util.Date) obj, getDefaultDateType()); } if (obj.getClass().isArray()) { obj = convertArray(obj); } if (obj instanceof Collection) { return new SimpleSequence((Collection) obj, this); } if (obj instanceof Boolean) { return obj.equals(Boolean.TRUE) ? TemplateBooleanModel.TRUE : TemplateBooleanModel.FALSE; } if (obj instanceof Iterator) { return new SimpleCollection((Iterator) obj, this); } return handleUnknownType(obj); }
@Override public TemplateCollectionModel keys() throws TemplateModelException { return new SimpleCollection(jsonObject.fieldNames(), getObjectWrapper()); }
@Override public TemplateCollectionModel values() throws TemplateModelException { return new SimpleCollection(jsonObject.getMap().values(), getObjectWrapper()); }
@Override public TemplateCollectionModel values() throws TemplateModelException { return new SimpleCollection(toWrap.keys(), wrapper); }