public int size() throws TemplateModelException { return ((TemplateHashModelEx) rootDataModel).size(); } }
@Override public boolean __nonzero__() { try { if (model instanceof TemplateBooleanModel) { return ((TemplateBooleanModel) model).getAsBoolean(); } if (model instanceof TemplateSequenceModel) { return ((TemplateSequenceModel) model).size() > 0; } if (model instanceof TemplateHashModel) { return !((TemplateHashModelEx) model).isEmpty(); } } catch (TemplateModelException e) { throw Py.JavaError(e); } return false; }
/** * Adds all object in the hash as shared variable to the configuration; it's like doing several * {@link #setSharedVariable(String, Object)} calls, one for each hash entry. It doesn't remove the already added * shared variable before doing this. * * <p>Never use <tt>TemplateModel</tt> implementation that is not thread-safe for shared shared variable values, * if the configuration is used by multiple threads! It is the typical situation for Servlet based Web sites. * * <p>This method is <b>not</b> thread safe; use it with the same restrictions as those that modify setting values. * * @param hash a hash model whose objects will be copied to the * configuration with same names as they are given in the hash. * If a shared variable with these names already exist, it will be replaced * with those from the map. * * @see #setSharedVaribles(Map) * @see #setSharedVariable(String,Object) * @see #setSharedVariable(String,TemplateModel) */ public void setAllSharedVariables(TemplateHashModelEx hash) throws TemplateModelException { TemplateModelIterator keys = hash.keys().iterator(); TemplateModelIterator values = hash.values().iterator(); while (keys.hasNext()) { setSharedVariable(((TemplateScalarModel) keys.next()).getAsString(), values.next()); } }
public TemplateCollectionModel keys() throws TemplateModelException { return ((TemplateHashModelEx) rootDataModel).keys(); }
public TemplateModel getValue() throws TemplateModelException { return hash.get(((TemplateScalarModel) key).getAsString()); }
public TemplateCollectionModel values() throws TemplateModelException { return ((TemplateHashModelEx) rootDataModel).values(); }
private TemplateHashModelExKeyValuePairIterator(TemplateHashModelEx hash) throws TemplateModelException { this.hash = hash; keyIter = hash.keys().iterator(); }
/** * Adds all object in the hash as shared variable to the configuration. * * <p>Never use <tt>TemplateModel</tt> implementation that is not thread-safe for shared variables, * if the configuration is used by multiple threads! It is the typical situation for Servlet based Web sites. * * @param hash a hash model whose objects will be copied to the * configuration with same names as they are given in the hash. * If a shared variable with these names already exist, it will be replaced * with those from the map. * * @see #setSharedVariable(String,Object) * @see #setSharedVariable(String,TemplateModel) */ public void setAllSharedVariables(TemplateHashModelEx hash) throws TemplateModelException { TemplateModelIterator keys = hash.keys().iterator(); TemplateModelIterator values = hash.values().iterator(); while(keys.hasNext()) { setSharedVariable(((TemplateScalarModel)keys.next()).getAsString(), values.next()); } }
public TemplateModel getValue() throws TemplateModelException { return hash.get(((TemplateScalarModel) key).getAsString()); }
@Override TemplateModel calculateResult(TemplateHashModelEx hashExModel, Environment env) throws TemplateModelException, InvalidReferenceException { TemplateCollectionModel values = hashExModel.values(); if (values == null) throw newNullPropertyException("values", hashExModel, env); return values instanceof TemplateSequenceModel ? values : new CollectionAndSequence(values); } }
TemplateCollectionModel keys = prefixMap.keys(); for (TemplateModelIterator it = keys.iterator(); it.hasNext();) { String prefix = ((TemplateScalarModel) it.next()).getAsString(); TemplateModel valueModel = prefixMap.get(prefix); if (!(valueModel instanceof TemplateScalarModel)) { {if (true) throw new ParseException("Non-string value in prefix to namespace hash.", exp);} TemplateCollectionModel keys = attributeMap.keys(); for (TemplateModelIterator it = keys.iterator(); it.hasNext();) { String attName = ((TemplateScalarModel) it.next()).getAsString(); Object attValue = DeepUnwrap.unwrap(attributeMap.get(attName)); template.setCustomAttribute(attName, attValue);
private TemplateHashModelExEnumeration(TemplateHashModelEx hashEx) throws TemplateModelException { it = hashEx.keys().iterator(); }
/** * Adds all object in the hash as shared variable to the configuration; it's like doing several * {@link #setSharedVariable(String, Object)} calls, one for each hash entry. It doesn't remove the already added * shared variable before doing this. * * <p>Never use <tt>TemplateModel</tt> implementation that is not thread-safe for shared shared variable values, * if the configuration is used by multiple threads! It is the typical situation for Servlet based Web sites. * * <p>This method is <b>not</b> thread safe; use it with the same restrictions as those that modify setting values. * * @param hash a hash model whose objects will be copied to the * configuration with same names as they are given in the hash. * If a shared variable with these names already exist, it will be replaced * with those from the map. * * @see #setSharedVaribles(Map) * @see #setSharedVariable(String,Object) * @see #setSharedVariable(String,TemplateModel) */ public void setAllSharedVariables(TemplateHashModelEx hash) throws TemplateModelException { TemplateModelIterator keys = hash.keys().iterator(); TemplateModelIterator values = hash.values().iterator(); while (keys.hasNext()) { setSharedVariable(((TemplateScalarModel) keys.next()).getAsString(), values.next()); } }
@Override public int size() { try { return getModelEx().size(); } catch (TemplateModelException e) { throw new UndeclaredThrowableException(e); } } };
public TemplateModel getValue() throws TemplateModelException { return hash.get(((TemplateScalarModel) key).getAsString()); }
public TemplateCollectionModel values() throws TemplateModelException { return ((TemplateHashModelEx) rootDataModel).values(); } public TemplateCollectionModel keys() throws TemplateModelException {
@Override public boolean __nonzero__() { try { if (model instanceof TemplateBooleanModel) { return ((TemplateBooleanModel) model).getAsBoolean(); } if (model instanceof TemplateSequenceModel) { return ((TemplateSequenceModel) model).size() > 0; } if (model instanceof TemplateHashModel) { return !((TemplateHashModelEx) model).isEmpty(); } } catch (TemplateModelException e) { throw Py.JavaError(e); } return false; }