public boolean hasNext() throws TemplateModelException { return keyIterator.hasNext(); }
public KeyValuePair next() throws TemplateModelException { final TemplateModel key = keyIter.next(); if (!(key instanceof TemplateScalarModel)) { throw _MessageUtil.newKeyValuePairListingNonStringKeyExceptionMessage(key, hash); } return new KeyValuePair() { public TemplateModel getKey() throws TemplateModelException { return key; } public TemplateModel getValue() throws TemplateModelException { return hash.get(((TemplateScalarModel) key).getAsString()); } }; }
public boolean hasNext() throws TemplateModelException { return keyIter.hasNext(); }
public Object nextElement() { try { return ((TemplateScalarModel) it.next()).getAsString(); } catch (TemplateModelException tme) { throw new UndeclaredThrowableException(tme); } } }
public boolean hasMoreElements() { try { return it.hasNext(); } catch (TemplateModelException tme) { throw new UndeclaredThrowableException(tme); } }
public Object next() { try { return wrapper.unwrap(i.next()); } catch (TemplateModelException e) { throw new UndeclaredThrowableException(e); } }
/** * Constructs a simple sequence from the passed collection model, which shouldn't be added to later. The internal * list will be build immediately (not lazily). The resulting sequence shouldn't be extended with * {@link #add(Object)}, because the appropriate {@link ObjectWrapper} won't be available; use * {@link #SimpleSequence(Collection, ObjectWrapper)} instead, if you need that. */ public SimpleSequence(TemplateCollectionModel tcm) throws TemplateModelException { ArrayList alist = new ArrayList(); for (TemplateModelIterator it = tcm.iterator(); it.hasNext(); ) { alist.add(it.next()); } alist.trimToSize(); list = alist; }
public boolean hasNext() { try { return i.hasNext(); } catch (TemplateModelException e) { throw new UndeclaredThrowableException(e); } }
public KeyValuePair next() throws TemplateModelException { final TemplateModel key = keyIter.next(); if (!(key instanceof TemplateScalarModel)) { throw _MessageUtil.newKeyValuePairListingNonStringKeyExceptionMessage(key, hash); } return new KeyValuePair() { public TemplateModel getKey() throws TemplateModelException { return key; } public TemplateModel getValue() throws TemplateModelException { return hash.get(((TemplateScalarModel) key).getAsString()); } }; }
public DebugModel[] getCollection() throws TemplateModelException, RemoteException { List list = new ArrayList(); TemplateModelIterator i = ((TemplateCollectionModel) model).iterator(); while (i.hasNext()) { list.add(getDebugModel(i.next())); } return (DebugModel[]) list.toArray(new DebugModel[list.size()]); }
static boolean isEmpty(TemplateModel model) throws TemplateModelException { if (model instanceof BeanModel) { return ((BeanModel) model).isEmpty(); } else if (model instanceof TemplateSequenceModel) { return ((TemplateSequenceModel) model).size() == 0; } else if (model instanceof TemplateScalarModel) { String s = ((TemplateScalarModel) model).getAsString(); return (s == null || s.length() == 0); } else if (model == null) { return true; } else if (model instanceof TemplateMarkupOutputModel) { // Note: happens just after FTL string check TemplateMarkupOutputModel mo = (TemplateMarkupOutputModel) model; return mo.getOutputFormat().isEmpty(mo); } else if (model instanceof TemplateCollectionModel) { return !((TemplateCollectionModel) model).iterator().hasNext(); } else if (model instanceof TemplateHashModel) { return ((TemplateHashModel) model).isEmpty(); } else if (model instanceof TemplateNumberModel || model instanceof TemplateDateModel || model instanceof TemplateBooleanModel) { return false; } else { return true; } }
public KeyValuePair next() throws TemplateModelException { final TemplateModel key = keyIter.next(); if (!(key instanceof TemplateScalarModel)) { throw _MessageUtil.newKeyValuePairListingNonStringKeyExceptionMessage(key, hash); } return new KeyValuePair() { public TemplateModel getKey() throws TemplateModelException { return key; } public TemplateModel getValue() throws TemplateModelException { return hash.get(((TemplateScalarModel) key).getAsString()); } }; }
protected int findInCol(TemplateModel searched, final int allowedRangeStart, final int allowedRangeEnd) throws TemplateModelException { if (allowedRangeEnd < 0) return -1; TemplateModelIterator it = m_col.iterator(); int foundAtIdx = -1; // -1 is the return value for "not found" int idx = 0; searchItem: while (it.hasNext()) { if (idx > allowedRangeEnd) break searchItem; TemplateModel current = it.next(); if (idx >= allowedRangeStart) { if (modelsEqual(idx, current, searched, m_env)) { foundAtIdx = idx; // Don't stop if it's "find last". if (findFirst) { break searchItem; } } } idx++; } return foundAtIdx; }
public boolean hasNext() throws TemplateModelException { return keyIterator.hasNext(); }
public Object next() { try { return wrapper.unwrap(i.next()); } catch(TemplateModelException e) { throw new UndeclaredThrowableException(e); } }
public Object exec(List args) throws TemplateModelException { checkMethodArgCount(args, 1); TemplateModel arg = (TemplateModel) args.get(0); TemplateModelIterator it = m_coll.iterator(); int idx = 0; while (it.hasNext()) { if (modelsEqual(idx, it.next(), arg, m_env)) return TemplateBooleanModel.TRUE; idx++; } return TemplateBooleanModel.FALSE; }
public boolean hasNext() throws TemplateModelException { return keyIterator.hasNext(); }
public Object next() { try { return wrapper.unwrap(i.next()); } catch (TemplateModelException e) { throw new UndeclaredThrowableException(e); } }