本文整理汇总了Java中lucee.runtime.type.Struct.keyIterator方法的典型用法代码示例。如果您正苦于以下问题:Java Struct.keyIterator方法的具体用法?Java Struct.keyIterator怎么用?Java Struct.keyIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lucee.runtime.type.Struct
的用法示例。
在下文中一共展示了Struct.keyIterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _serializeStruct
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
/**
* serialize a Struct
* @param struct Struct to serialize
* @param done
* @return serialized struct
* @throws ConverterException
*/
private String _serializeStruct(Struct struct, Set<Object> done) throws ConverterException {
StringBuilder sb=new StringBuilder(goIn()+"<struct>");
Iterator<Key> it = struct.keyIterator();
deep++;
while(it.hasNext()) {
Key key = it.next();
sb.append(goIn()+"<var name="+del+XMLUtil.escapeXMLString(key.toString())+del+">");
sb.append(_serialize(struct.get(key,null),done));
sb.append(goIn()+"</var>");
}
deep--;
sb.append(goIn()+"</struct>");
return sb.toString();
}
示例2: _serializeStruct
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
/**
* serialize a Struct
* @param struct Struct to serialize
* @param done
* @return serialized struct
* @throws ConverterException
*/
private String _serializeStruct(Struct struct, Map<Object,String> done, String id) throws ConverterException {
StringBuilder sb=new StringBuilder(goIn()+"<STRUCT ID=\""+id+"\">");
Iterator<Key> it = struct.keyIterator();
deep++;
while(it.hasNext()) {
Key key = it.next();
// <ENTRY NAME="STRING" TYPE="STRING">hello</ENTRY>
String value = _serialize(struct.get(key,null),done);
sb.append(goIn()+"<ENTRY NAME=\""+key.toString()+"\" TYPE=\""+type+"\">");
sb.append(value);
sb.append(goIn()+"</ENTRY>");
}
deep--;
sb.append(goIn()+"</STRUCT>");
type="STRUCT";
return sb.toString();
}
示例3: serialize
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
public static String serialize(Struct sct, Set ignoreSet) throws ConverterException {
StringBuilder sb=new StringBuilder();
Iterator it=sct.keyIterator();
boolean doIt=false;
Object oKey;
while(it.hasNext()) {
oKey=it.next();
if(ignoreSet!=null && ignoreSet.contains(oKey)) continue;
String key=Caster.toString(oKey,"");
if(doIt)sb.append('#');
doIt=true;
sb.append(escape(key));
sb.append('=');
sb.append(_serialize(sct.get(key,"")));
}
return sb.toString();
}
示例4: _serializeStruct
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
/**
* serialize a Struct
* @param struct Struct to serialize
* @param sb
* @param done
* @throws ConverterException
*/
public void _serializeStruct(Struct struct, StringBuilder sb, Set<Object> done) throws ConverterException {
sb.append(goIn());
sb.append('{');
Iterator it=struct.keyIterator();
boolean doIt=false;
deep++;
while(it.hasNext()) {
String key=Caster.toString(it.next(),"");
if(doIt)sb.append(',');
doIt=true;
sb.append('\'');
sb.append(escape(key));
sb.append('\'');
sb.append(':');
_serialize(struct.get(key,null),sb,done);
}
deep--;
sb.append('}');
}
示例5: invalidKey
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
/**
* throw exception for invalid key
* @param key Invalid key
* @return returns an invalid key Exception
*/
public static ExpressionException invalidKey(Config config,Struct sct,Key key, String in) {
String appendix=StringUtil.isEmpty(in,true)?"":" in the "+in;
Iterator<Key> it = sct.keyIterator();
Key k;
while(it.hasNext()){
k = it.next();
if( k.equals( key ) )
return new ExpressionException( "the value from key [" + key.getString() + "] "+appendix+" is NULL, which is the same as not existing in CFML" );
}
config=ThreadLocalPageContext.getConfig(config);
if(config!=null && config.debug())
return new ExpressionException(ExceptionUtil.similarKeyMessage(sct, key.getString(), "key", "keys",in,true));
return new ExpressionException( "key [" + key.getString() + "] doesn't exist"+appendix);
}
示例6: isCastableToArray
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
/**
* can this type be casted to a array
* @param o
* @return
* @throws PageException
*/
public static boolean isCastableToArray(Object o) {
if(isArray(o)) return true;
//else if(o instanceof XMLStruct) return true;
else if(o instanceof Struct) {
Struct sct=(Struct) o;
Iterator<Key> it = sct.keyIterator();
while (it.hasNext()) {
if (!isInteger( it.next(), false ))
return false;
}
return true;
}
return false;
}
示例7: setArgument
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
public Object setArgument(Object obj) throws PageException {
if(obj==this) return obj;
if(Decision.isStruct(obj)) {
clear(); // TODO bessere impl. anstelle vererbung wrao auf struct
Struct sct=Caster.toStruct(obj);
Iterator<Key> it = sct.keyIterator();
Key key;
while(it.hasNext()) {
key=it.next();
setEL(key, sct.get(key,null));
}
return obj;
}
throw new ExpressionException("can not overwrite arguments scope");
}
示例8: invalidKey
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
/**
* throw exception for invalid key
* @param key Invalid key
* @return returns an invalid key Exception
*/
public static ExpressionException invalidKey(Config config,Struct sct,Key key) {
Iterator<Key> it = sct.keyIterator();
Key k;
while(it.hasNext()){
k = it.next();
if( k.equals( key ) )
return new ExpressionException( "the value from key [" + key.getString() + "] is NULL, which is the same as not existing in CFML" );
}
config=ThreadLocalPageContext.getConfig(config);
if(config!=null && config.debug())
return new ExpressionException(ExceptionUtil.similarKeyMessage(sct, key.getString(), "key", "keys",true));
return new ExpressionException( "key [" + key.getString() + "] doesn't exist" );
}
示例9: _serializeStruct
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
/**
* serialize a Struct
* @param struct Struct to serialize
* @param sb
* @param done
* @throws ConverterException
*/
public void _serializeStruct(Struct struct, StringBuilder sb, Set<Object> done) throws ConverterException {
sb.append(goIn());
sb.append('{');
Iterator it=struct.keyIterator();
boolean doIt=false;
deep++;
while(it.hasNext()) {
String key=Caster.toString(it.next(),"");
if(doIt)sb.append(',');
doIt=true;
sb.append(QUOTE_CHR);
sb.append(escape(key));
sb.append(QUOTE_CHR);
sb.append(':');
_serialize(struct.get(key,null),sb,done);
}
deep--;
sb.append('}');
}
示例10: serializeStruct
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
public String serializeStruct(Struct struct, Set<Collection.Key> ignoreSet) throws ConverterException {
StringBuilder sb =new StringBuilder();
sb.append(goIn());
sb.append("{");
boolean hasIgnores=ignoreSet!=null;
Iterator<Key> it = struct.keyIterator();
boolean doIt=false;
deep++;
Key key;
while(it.hasNext()) {
key = it.next();
if(hasIgnores && ignoreSet.contains(key)) continue;
if(doIt)sb.append(',');
doIt=true;
sb.append(QUOTE_CHR);
sb.append(escape(key.getString()));
sb.append(QUOTE_CHR);
sb.append(':');
_serialize(struct.get(key,null),sb,new HashSet<Object>());
}
deep--;
return sb.append('}').toString();
}
示例11: setArgument
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
@Override
public Object setArgument(Object obj) throws PageException {
if(obj==this) return obj;
if(Decision.isStruct(obj)) {
clear(); // TODO bessere impl. anstelle vererbung wrao auf struct
Struct sct=Caster.toStruct(obj);
Iterator<Key> it = sct.keyIterator();
Key key;
while(it.hasNext()) {
key=it.next();
setEL(key, sct.get(key,null));
}
return obj;
}
throw new ExpressionException("can not overwrite arguments scope");
}
示例12: keySet
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
public static Set<String> keySet(Struct sct) {
boolean linked=sct instanceof StructSupport && ((StructSupport)sct).getType()==Struct.TYPE_LINKED;
Iterator<Key> it = sct.keyIterator();
Set<String> set=linked?new LinkedHashSet<String>():new HashSet<String>();
while(it.hasNext()){
set.add(it.next().getString());
}
return set;
}
示例13: call
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
public static String call(PageContext pc , Struct struct, String delimiter) {
//return KeyImpl.toList(CollectionUtil.keys(struct), delimiter);
if(struct==null) return "";
Iterator<Key> it = struct.keyIterator();
// first
if(!it.hasNext()) return "";
StringBuilder sb=new StringBuilder();
sb.append(it.next().getString());
// rest
if(delimiter.length()==1) {
char c=delimiter.charAt(0);
while(it.hasNext()){
sb.append(c);
sb.append(it.next().getString());
}
}
else {
while(it.hasNext()){
sb.append(delimiter);
sb.append(it.next().getString());
}
}
return sb.toString();
}
示例14: call
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
public static boolean call(PageContext pc , Struct struct1, Struct struct2, boolean overwrite) throws PageException {
Iterator<Key> it = struct2.keyIterator();
Key key;
while(it.hasNext()) {
key=KeyImpl.toKey(it.next());
if(overwrite || struct1.get(key,null)==null)
struct1.setEL(key,struct2.get(key,null));
}
return true;
}
示例15: keySet
import lucee.runtime.type.Struct; //导入方法依赖的package包/类
public static Set<String> keySet(Struct sct) {
boolean linked=sct instanceof StructImpl && ((StructImpl)sct).getType()==Struct.TYPE_LINKED;
Iterator<Key> it = sct.keyIterator();
Set<String> set=linked?new LinkedHashSet<String>():new HashSet<String>();
while(it.hasNext()){
set.add(it.next().getString());
}
return set;
}