本文整理汇总了Java中lucee.runtime.type.Struct类的典型用法代码示例。如果您正苦于以下问题:Java Struct类的具体用法?Java Struct怎么用?Java Struct使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Struct类属于lucee.runtime.type包,在下文中一共展示了Struct类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import lucee.runtime.type.Struct; //导入依赖的package包/类
public void init(String cacheName, Struct arguments) throws IOException, PageException {
CFMLEngine engine = CFMLEngineFactory.getInstance();
caster = engine.getCastUtil();
MongoConnection.init(arguments);
this.persists = caster.toBoolean(arguments.get("persist"));
this.database = caster.toString(arguments.get("database"));
this.collectionName = caster.toString(arguments.get("collection"));
//clean the collection on startup if required
if (!persists) {
getCollection().drop();
}
//create the indexes
createIndexes();
// start the cleaner schdule that remove entries by expires time and idle time
startCleaner();
}
示例2: _toDBObject
import lucee.runtime.type.Struct; //导入依赖的package包/类
private DBObject _toDBObject(Object obj) throws PageException {
if(obj instanceof DBObject) return (DBObject) obj;
Struct sct = caster.toStruct(obj,null);
if(sct==null)
throw exp.createExpressionException("only a DBObject or Struct/Map can be set to define a DBCollection, " +
"a Structs/Map can have the following possible parameters:\n" +
"- capped:boolean: if the collection is capped\n" +
"- size:int: collection size\n" +
"- max:int: max number of documents"
);
BasicDBObject bo=new BasicDBObject();
// capped
Boolean capped = caster.toBoolean(sct.get("capped",null),null);
if(capped!=null)bo.put("capped", capped);
// size
Integer size = caster.toInteger(sct.get("size",null),null);
if(size!=null)bo.put("size", size);
// max
Integer max = caster.toInteger(sct.get("max",null),null);
if(max!=null)bo.put("max", max);
return bo;
}
示例3: propTag
import lucee.runtime.type.Struct; //导入依赖的package包/类
private void propTag(Struct props,StringBuffer xml, int count,String[] srcNames,String trgName,String[][] attrNames, boolean childrenAsTag) throws PageException {
Object value;
for(int i=0;i<srcNames.length;i++) {
value=props.get(srcNames[i], null);
if(value instanceof Array){
Array arr = (Array)value;
int size = arr.size();
for(int y=1;y<=size;y++) {
propTag(xml, count, arr.get(y, null), trgName, attrNames, childrenAsTag);
}
break;
}
if(value !=null) {
propTag(xml, count, value, trgName, attrNames, childrenAsTag);
break;
}
}
}
示例4: _call
import lucee.runtime.type.Struct; //导入依赖的package包/类
protected static Struct _call(Object[] objArr,String expMessage, int type) throws PageException {
StructImpl sct=type<0?new StructImpl():new StructImpl(type);
FunctionValueImpl fv;
for(int i=0;i<objArr.length;i++) {
if(objArr[i] instanceof FunctionValue) {
fv=((FunctionValueImpl)objArr[i]);
if(fv.getNames()==null) {
sct.set(fv.getNameAsKey(),fv.getValue());
}
else {
String[] arr = fv.getNames();
Struct s=sct;
for(int y=0;y<arr.length-1;y++) {
s=touch(s,arr[y]);
}
s.set(KeyImpl.init(arr[arr.length-1]), fv.getValue());
}
}
else {
throw new ExpressionException(expMessage);
}
}
return sct;
}
示例5: fromStruct
import lucee.runtime.type.Struct; //导入依赖的package包/类
private static InternetAddress fromStruct( Struct sct ) throws MailException, UnsupportedEncodingException {
String name = Caster.toString(sct.get("label",null),null);
if ( name == null )
name=Caster.toString(sct.get("name",null),null);
String email = Caster.toString(sct.get("email",null),null);
if ( email == null )
email = Caster.toString(sct.get("e-mail",null),null);
if ( email == null )
email = Caster.toString(sct.get("mail",null),null);
if( StringUtil.isEmpty(email) )
throw new MailException("missing e-mail definition in struct");
if(name==null) name="";
return new InternetAddress( email, name );
}
示例6: filter
import lucee.runtime.type.Struct; //导入依赖的package包/类
@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {BufferedImage dst=ImageUtil.createBufferedImage(src);
Object o;
if((o=parameters.removeEL(KeyImpl.init("Amount")))!=null)setAmount(ImageFilterUtil.toFloatValue(o,"Amount"));
if((o=parameters.removeEL(KeyImpl.init("Threshold")))!=null)setThreshold(ImageFilterUtil.toIntValue(o,"Threshold"));
if((o=parameters.removeEL(KeyImpl.init("Radius")))!=null)setRadius(ImageFilterUtil.toFloatValue(o,"Radius"));
if((o=parameters.removeEL(KeyImpl.init("EdgeAction")))!=null)setEdgeAction(ImageFilterUtil.toString(o,"EdgeAction"));
if((o=parameters.removeEL(KeyImpl.init("UseAlpha")))!=null)setUseAlpha(ImageFilterUtil.toBooleanValue(o,"UseAlpha"));
if((o=parameters.removeEL(KeyImpl.init("PremultiplyAlpha")))!=null)setPremultiplyAlpha(ImageFilterUtil.toBooleanValue(o,"PremultiplyAlpha"));
// check for arguments not supported
if(parameters.size()>0) {
throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter"+(parameters.size()>1?"s":"")+" ["+CollectionUtil.getKeyList(parameters,", ")+"] "+(parameters.size()>1?"are":"is")+" not allowed, only the following parameters are supported [Amount, Threshold, Radius, Kernel, EdgeAction, UseAlpha, PremultiplyAlpha]");
}
return filter(src, dst);
}
示例7: toData
import lucee.runtime.type.Struct; //导入依赖的package包/类
private static Array[] toData(Object obj, Key[] columns, int rowcount) throws PageException {
if(columns==null || rowcount==-1) return null;
Struct sct = Caster.toStruct(obj,null,false);
if(sct!=null && sct.size()==columns.length) {
Array[] datas=new Array[columns.length];
Array col;
int colLen=-1;
for(int i=0;i<columns.length;i++) {
col=Caster.toArray(sct.get(columns[i],null),null);
if(col==null || colLen!=-1 && colLen!=col.size()) return null;
datas[i]=(Array) toQuery(col,CollectionUtil.keys(col));
colLen=col.size();
}
return datas;
}
return null;
}
示例8: call
import lucee.runtime.type.Struct; //导入依赖的package包/类
public static Struct call(PageContext pc ) throws PageException {
Struct sct=new StructImpl();
Struct web=new StructImpl();
Struct server=new StructImpl();
ConfigWeb config = pc.getConfig();
web.set(SECURITY_KEY, ((ConfigImpl)config).getSecurityKey());
web.set(KeyConstants._id, config.getId());
sct.set(KeyConstants._web, web);
if(config instanceof ConfigWebImpl){
ConfigWebImpl cwi = (ConfigWebImpl)config;
server.set(SECURITY_KEY, cwi.getServerSecurityKey());
server.set(KeyConstants._id, cwi.getServerId());
server.set(ID_PRO, cwi.getServerIdPro());
sct.set(KeyConstants._server, server);
}
sct.set(KeyConstants._request, Caster.toString(pc.getId()));
return sct;
}
示例9: filter
import lucee.runtime.type.Struct; //导入依赖的package包/类
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {BufferedImage dst=null;//ImageUtil.createBufferedImage(src);
Object o;
if((o=parameters.removeEL(KeyImpl.init("Amount")))!=null)setAmount(ImageFilterUtil.toFloatValue(o,"Amount"));
if((o=parameters.removeEL(KeyImpl.init("Turbulence")))!=null)setTurbulence(ImageFilterUtil.toFloatValue(o,"Turbulence"));
if((o=parameters.removeEL(KeyImpl.init("XScale")))!=null)setXScale(ImageFilterUtil.toFloatValue(o,"XScale"));
if((o=parameters.removeEL(KeyImpl.init("YScale")))!=null)setYScale(ImageFilterUtil.toFloatValue(o,"YScale"));
if((o=parameters.removeEL(KeyImpl.init("EdgeAction")))!=null)setEdgeAction(ImageFilterUtil.toString(o,"EdgeAction"));
if((o=parameters.removeEL(KeyImpl.init("Interpolation")))!=null)setInterpolation(ImageFilterUtil.toString(o,"Interpolation"));
// check for arguments not supported
if(parameters.size()>0) {
throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter"+(parameters.size()>1?"s":"")+" ["+CollectionUtil.getKeyList(parameters,", ")+"] "+(parameters.size()>1?"are":"is")+" not allowed, only the following parameters are supported [Amount, Turbulence, XScale, YScale, EdgeAction, Interpolation]");
}
return filter(src, dst);
}
示例10: call
import lucee.runtime.type.Struct; //导入依赖的package包/类
public static Struct call(PageContext pc, String id, String cacheName) throws PageException {
try {
Cache cache = CacheUtil.getCache(pc,cacheName,Config.CACHE_TYPE_OBJECT);
CacheEntry entry = cache.getCacheEntry(CacheUtil.key(id));
Struct info=new StructImpl();
info.set(CACHE_HITCOUNT, new Double(cache.hitCount()));
info.set(CACHE_MISSCOUNT, new Double(cache.missCount()));
info.set(CACHE_CUSTOM, cache.getCustomInfo());
info.set(KeyConstants._custom, entry.getCustomInfo());
info.set(CREATED_TIME, entry.created());
info.set(KeyConstants._hitcount, new Double(entry.hitCount()));
info.set(IDLE_TIME, new Double(entry.idleTimeSpan()));
info.set(LAST_HIT, entry.lastHit());
info.set(LAST_UPDATED, entry.lastModified());
info.set(KeyConstants._size, new Double(entry.size()));
info.set(KeyConstants._timespan, new Double(entry.liveTimeSpan()));
return info;
} catch (IOException e) {
throw Caster.toPageException(e);
}
}
示例11: loadForeignCFC
import lucee.runtime.type.Struct; //导入依赖的package包/类
private static Component loadForeignCFC(PageContext pc,Component cfc,Property prop, Struct meta, SessionFactoryData data) throws PageException {
// entity
String str=toString(cfc,prop,meta,"entityName",data);
Component fcfc=null;
if(!Util.isEmpty(str,true)) {
fcfc = data.getEntityByEntityName(str, false);
if(fcfc!=null) return fcfc;
}
str = toString(cfc,prop,meta,"cfc",false,data);
if(!Util.isEmpty(str,true)){
return data.getEntityByCFCName(str, false);
}
return null;
}
示例12: getName
import lucee.runtime.type.Struct; //导入依赖的package包/类
public static String getName(Object o) {
if(o == null) return "null";
if(o instanceof UDF) return "user defined function ("+(((UDF)o).getFunctionName())+")";
else if(o instanceof Boolean) return "Boolean";
else if(o instanceof Number) return "Number";
else if(o instanceof TimeSpan) return "TimeSpan";
else if(o instanceof Array) return "Array";
else if(o instanceof Component) return "Component "+((Component)o).getAbsName();
else if(o instanceof Scope) return ((Scope)o).getTypeAsString();
else if(o instanceof Struct) {
if(o instanceof XMLStruct)return "XML";
return "Struct";
}
else if(o instanceof Query) return "Query";
else if(o instanceof DateTime) return "DateTime";
else if(o instanceof byte[]) return "Binary";
else {
String className=o.getClass().getName();
if(className.startsWith("java.lang.")) {
return className.substring(10);
}
return className;
}
}
示例13: toArray1
import lucee.runtime.type.Struct; //导入依赖的package包/类
private static Array toArray1(List<BundleDefinition> list) {
Struct sct;
Array arr=new ArrayImpl();
Iterator<BundleDefinition> it = list.iterator();
BundleDefinition bd;
VersionDefinition vd;
while(it.hasNext()) {
bd=it.next();
sct=new StructImpl();
sct.setEL(KeyConstants._bundleName, bd.getName());
vd = bd.getVersionDefiniton();
if(vd!=null) {
sct.setEL(KeyConstants._bundleVersion, vd.getVersionAsString());
sct.setEL("operator", vd.getOpAsString());
}
arr.appendEL(sct);
}
return arr;
}
示例14: getCustomInfo
import lucee.runtime.type.Struct; //导入依赖的package包/类
public Struct getCustomInfo() {
Struct info=super.getCustomInfo();
try {
CacheConfiguration conf = rest.getMeta(name).getCacheConfiguration();
info.setEL("disk_expiry_thread_interval", new Double(conf.getDiskExpiryThreadIntervalSeconds()));
info.setEL("disk_spool_buffer_size", new Double(conf.getDiskSpoolBufferSize()));
info.setEL("max_elements_in_memory", new Double(conf.getMaxElementsInMemory()));
info.setEL("max_elements_on_disk", new Double(conf.getMaxElementsOnDisk()));
info.setEL("time_to_idle", new Double(conf.getTimeToIdleSeconds()));
info.setEL("time_to_live", new Double(conf.getTimeToLiveSeconds()));
info.setEL(KeyConstants._name, conf.getName());
}
catch(Throwable t){
ExceptionUtil.rethrowIfNecessary(t);
//print.printST(t);
}
return info;
}
示例15: toMailServer
import lucee.runtime.type.Struct; //导入依赖的package包/类
public static Server toMailServer(Config config,Struct data, Server defaultValue) {
String hostName = Caster.toString(data.get(KeyConstants._host,null),null);
if(StringUtil.isEmpty(hostName,true)) hostName = Caster.toString(data.get(KeyConstants._server,null),null);
if(StringUtil.isEmpty(hostName,true)) return defaultValue;
int port = Caster.toIntValue(data.get(KeyConstants._port,null),25);
String username = Caster.toString(data.get(KeyConstants._username,null),null);
if(StringUtil.isEmpty(username,true))username = Caster.toString(data.get(KeyConstants._user,null),null);
String password = ConfigWebUtil.decrypt(Caster.toString(data.get(KeyConstants._password,null),null));
TimeSpan lifeTimespan = Caster.toTimespan(data.get("lifeTimespan",null),null);
if(lifeTimespan==null)lifeTimespan = Caster.toTimespan(data.get("life",null),FIVE_MINUTES);
TimeSpan idleTimespan = Caster.toTimespan(data.get("idleTimespan",null),null);
if(idleTimespan==null)idleTimespan = Caster.toTimespan(data.get("idle",null),ONE_MINUTE);
boolean tls = Caster.toBooleanValue(data.get("tls",null),false);
boolean ssl = Caster.toBooleanValue(data.get("ssl",null),false);
return new ServerImpl(-1,hostName, port, username, password, lifeTimespan.getMillis(), idleTimespan.getMillis(), tls, ssl, false,ServerImpl.TYPE_LOCAL); // MUST improve store connection somehow
}