本文整理汇总了Java中freemarker.template.TemplateModelIterator.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java TemplateModelIterator.hasNext方法的具体用法?Java TemplateModelIterator.hasNext怎么用?Java TemplateModelIterator.hasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类freemarker.template.TemplateModelIterator
的用法示例。
在下文中一共展示了TemplateModelIterator.hasNext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToSimpleMap
import freemarker.template.TemplateModelIterator; //导入方法依赖的package包/类
/**
* Adds to simple hash from source map.
* <p>
* <em>WARN</em>: This is not BeanModel-aware (complex map).
*/
public static void addToSimpleMap(SimpleHash dest, TemplateHashModelEx source) throws TemplateModelException {
TemplateCollectionModel keysModel = source.keys();
TemplateModelIterator modelIt = keysModel.iterator();
while(modelIt.hasNext()) {
String key = getAsStringNonEscaping((TemplateScalarModel) modelIt.next());
dest.put(key, source.get(key));
}
}
示例2: addModelsToMap
import freemarker.template.TemplateModelIterator; //导入方法依赖的package包/类
/**
* Adds the still-wrapped TemplateModels in hash to a java Map.
* <p>
* <em>WARN</em>: This is not BeanModel-aware (complex map).
*/
public static void addModelsToMap(Map<String, ? super TemplateModel> dest, TemplateHashModelEx source) throws TemplateModelException {
TemplateCollectionModel keysModel = source.keys();
TemplateModelIterator modelIt = keysModel.iterator();
while(modelIt.hasNext()) {
String key = getAsStringNonEscaping((TemplateScalarModel) modelIt.next());
dest.put(key, source.get(key));
}
}
示例3: toStringSet
import freemarker.template.TemplateModelIterator; //导入方法依赖的package包/类
/**
* To string set.
* <p>
* WARN: Bypasses auto-escaping, caller handles.
* (e.g. the object wrapper used to rewrap the result).
*/
public static Set<String> toStringSet(TemplateCollectionModel collModel) throws TemplateModelException {
Set<String> set = new HashSet<String>();
TemplateModelIterator modelIt = collModel.iterator();
while(modelIt.hasNext()) {
set.add(getAsStringNonEscaping((TemplateScalarModel) modelIt.next()));
}
return set;
}
示例4: addToStringSet
import freemarker.template.TemplateModelIterator; //导入方法依赖的package包/类
/**
* Add to string set.
* <p>
* WARN: bypasses auto-escaping, caller handles.
* (e.g. the object wrapper used to rewrap the result).
*/
public static void addToStringSet(Set<String> dest, TemplateCollectionModel collModel) throws TemplateModelException {
TemplateModelIterator modelIt = collModel.iterator();
while(modelIt.hasNext()) {
dest.add(getAsStringNonEscaping((TemplateScalarModel) modelIt.next()));
}
}
示例5: getAsStringSet
import freemarker.template.TemplateModelIterator; //导入方法依赖的package包/类
/**
* Gets collection as a keys.
* <p>
* WARN: This bypasses auto-escaping in all cases. Caller must decide how to handle.
* (e.g. the object wrapper used to rewrap the result).
*/
public static Set<String> getAsStringSet(TemplateModel model) throws TemplateModelException {
Set<String> exKeys = null;
if (model != null) {
if (model instanceof BeanModel && ((BeanModel) model).getWrappedObject() instanceof Set) {
// WARN: bypasses auto-escaping
exKeys = UtilGenerics.cast(((BeanModel) model).getWrappedObject());
}
else if (model instanceof TemplateCollectionModel) {
exKeys = new HashSet<String>();
TemplateModelIterator keysIt = ((TemplateCollectionModel) model).iterator();
while(keysIt.hasNext()) {
exKeys.add(getAsStringNonEscaping((TemplateScalarModel) keysIt.next()));
}
}
else if (model instanceof TemplateSequenceModel) {
TemplateSequenceModel seqModel = (TemplateSequenceModel) model;
exKeys = new HashSet<String>(seqModel.size());
for(int i=0; i < seqModel.size(); i++) {
exKeys.add(getAsStringNonEscaping((TemplateScalarModel) seqModel.get(i)));
}
}
else {
throw new TemplateModelException("Include/exclude keys argument not a collection or set of strings");
}
}
return exKeys;
}
示例6: toSimpleSequence
import freemarker.template.TemplateModelIterator; //导入方法依赖的package包/类
/**
* Supposed to convert to simple sequence.
* <p>
* WARN: Bypasses auto-escaping for complex maps, caller must decide how to handle.
* (e.g. the object wrapper used to rewrap the result).
* <p>
* DEV NOTE: I stopped writing/testing this when found out most of the problems w.r.t. collections are not
* the FTL types this time but the way they're used in Ofbiz templates.
* FTL's CollectionModel (subclass of TemplateCollectionModel) is supposed to cover everything and
* won't suffer from the same problems maps have.
*/
@SuppressWarnings("unchecked")
@Deprecated
private static TemplateSequenceModel toSimpleSequence(TemplateModel object, ObjectWrapper objectWrapper) throws TemplateModelException {
if (object instanceof TemplateSequenceModel) {
return (TemplateSequenceModel) object;
}
else if (object instanceof WrapperTemplateModel) {
WrapperTemplateModel wrapperModel = (WrapperTemplateModel) object;
// WARN: bypasses auto-escaping
Object wrappedObject = wrapperModel.getWrappedObject();
if (wrappedObject instanceof List) {
return DefaultListAdapter.adapt((List<Object>) wrappedObject, (RichObjectWrapper) objectWrapper);
}
else if (wrappedObject instanceof Object[]) {
return DefaultArrayAdapter.adapt((Object[]) wrappedObject, (ObjectWrapperAndUnwrapper) objectWrapper);
}
else if (wrappedObject instanceof Set) {
throw new UnsupportedOperationException("Not yet implemented");
}
else if (wrappedObject instanceof Collection) {
throw new UnsupportedOperationException("Not yet implemented");
}
else if (wrappedObject instanceof Iterable) {
throw new UnsupportedOperationException("Not yet implemented");
}
else {
throw new TemplateModelException("Cannot convert bean-wrapped object of type " + (object != null ? object.getClass() : "null") + " to simple sequence");
}
}
else if (object instanceof TemplateCollectionModel) {
TemplateCollectionModel collModel = (TemplateCollectionModel) object;
SimpleSequence res = new SimpleSequence(objectWrapper);
TemplateModelIterator it = collModel.iterator();
while(it.hasNext()) {
res.add(it.next());
}
return res;
}
else {
throw new TemplateModelException("Cannot convert object of type " + (object != null ? object.getClass() : "null") + " to simple sequence");
}
}
示例7: addToSimpleList
import freemarker.template.TemplateModelIterator; //导入方法依赖的package包/类
public static void addToSimpleList(SimpleSequence dest, TemplateCollectionModel source) throws TemplateModelException {
TemplateModelIterator it = source.iterator();
while(it.hasNext()) {
dest.add(it.next());
}
}