本文整理汇总了Java中lucee.runtime.Component.getComponentScope方法的典型用法代码示例。如果您正苦于以下问题:Java Component.getComponentScope方法的具体用法?Java Component.getComponentScope怎么用?Java Component.getComponentScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lucee.runtime.Component
的用法示例。
在下文中一共展示了Component.getComponentScope方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: _toPojo
import lucee.runtime.Component; //导入方法依赖的package包/类
private static Pojo _toPojo(PageContext pc, Pojo pojo, TypeMapping tm,TypeEntry typeEntry,QName type,Component comp, Set<Object> done) throws PageException {//print.ds();System.exit(0);
comp=ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE,comp);
ComponentScope scope = comp.getComponentScope();
// create Pojo
if(pojo==null) {
try {
pojo = (Pojo) ClassUtil.loadInstance(ComponentUtil.getComponentPropertiesClass(pc,comp));
} catch (ClassException e) {
throw Caster.toPageException(e);
}
}
// initialize Pojo
Property[] props=ComponentProUtil.getProperties(comp, false, true, false, false);
_initPojo(pc,typeEntry,type,pojo,props,scope,comp,tm,done);
return pojo;
}
示例2: inheritance
import lucee.runtime.Component; //导入方法依赖的package包/类
private static Query inheritance(PageContext pc,HibernateORMSession session,Component cfc,Query qry, String entityName) throws PageException {
Property[] properties = cfc.getProperties(true);
ComponentScope scope = cfc.getComponentScope();
Object value;
Array arr;
for(int i=0;i<properties.length;i++){
value=scope.get(CommonUtil.createKey(properties[i].getName()),null);
if(value instanceof Component){
qry=inheritance(pc,session,qry,cfc,(Component) value,entityName);
}
else if(CommonUtil.isArray(value)){
arr = CommonUtil.toArray(value);
Iterator<Object> it = arr.valueIterator();
while(it.hasNext()){
value=it.next();
if(value instanceof Component){
qry=inheritance(pc,session,qry,cfc,(Component) value,entityName);
}
}
}
}
return qry;
}
示例3: _toPojo
import lucee.runtime.Component; //导入方法依赖的package包/类
private static Pojo _toPojo(PageContext pc, Pojo pojo, TypeMapping tm,TypeEntry typeEntry,QName type,Component comp, Set<Object> done) throws PageException {//print.ds();System.exit(0);
comp=ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE,comp);
ComponentScope scope = comp.getComponentScope();
// create Pojo
if(pojo==null) {
try {
pojo = (Pojo) ClassUtil.loadInstance(ComponentUtil.getComponentPropertiesClass(pc,comp));
} catch (ClassException e) {
throw Caster.toPageException(e);
}
}
// initialize Pojo
Property[] props=comp.getProperties(false, true, false, false);
_initPojo(pc,typeEntry,type,pojo,props,scope,comp,tm,done);
return pojo;
}
示例4: _serializeComponent
import lucee.runtime.Component; //导入方法依赖的package包/类
/**
* serialize a Component
* @param component Component to serialize
* @param done
* @return serialized component
* @throws ConverterException
*/
private String _serializeComponent(Component component, Set<Object> done) throws ConverterException {
StringBuilder sb=new StringBuilder();
Component ca;
component=new ComponentSpecificAccess(Component.ACCESS_PRIVATE, ca=component);
boolean isPeristent=ComponentProUtil.isPersistent(ca);
deep++;
Object member;
Iterator<Key> it = component.keyIterator();
Collection.Key key;
while(it.hasNext()) {
key=Caster.toKey(it.next(),null);
member = component.get(key,null);
if(member instanceof UDF) continue;
sb.append(goIn()+"<var scope=\"this\" name="+del+XMLUtil.escapeXMLString(key.toString())+del+">");
sb.append(_serialize(member,done));
sb.append(goIn()+"</var>");
}
Property p;
Boolean remotingFetch;
Struct props = ignoreRemotingFetch?null:ComponentUtil.getPropertiesAsStruct(ca,false);
ComponentScope scope = ca.getComponentScope();
it=scope.keyIterator();
while(it.hasNext()) {
key=Caster.toKey(it.next(),null);
if(!ignoreRemotingFetch) {
p=(Property) props.get(key,null);
if(p!=null) {
remotingFetch=Caster.toBoolean(p.getDynamicAttributes().get(REMOTING_FETCH,null),null);
if(remotingFetch==null){
if(isPeristent && ORMUtil.isRelated(p)) continue;
}
else if(!remotingFetch.booleanValue()) continue;
}
}
member = scope.get(key,null);
if(member instanceof UDF || key.equals(KeyConstants._this)) continue;
sb.append(goIn()+"<var scope=\"variables\" name="+del+XMLUtil.escapeXMLString(key.toString())+del+">");
sb.append(_serialize(member,done));
sb.append(goIn()+"</var>");
}
deep--;
try {
//return goIn()+"<struct>"+sb+"</struct>";
return goIn()+"<component md5=\""+ComponentUtil.md5(component)+"\" name=\""+XMLUtil.escapeXMLString(component.getAbsName())+"\">"+sb+"</component>";
}
catch (Exception e) {
throw toConverterException(e);
}
}
示例5: _serializeComponent
import lucee.runtime.Component; //导入方法依赖的package包/类
/**
* serialize a Component
* @param component Component to serialize
* @param done
* @return serialized component
* @throws ConverterException
*/
private String _serializeComponent(Component component, Map<Object,String> done) throws ConverterException {
StringBuilder sb=new StringBuilder();
Component ca;
component=new ComponentSpecificAccess(Component.ACCESS_PRIVATE, ca=component);
boolean isPeristent=ComponentProUtil.isPersistent(ca);
deep++;
Object member;
Iterator<Key> it = component.keyIterator();
Collection.Key key;
while(it.hasNext()) {
key=it.next();
member = component.get(key,null);
if(member instanceof UDF) continue;
sb.append(goIn()+"<var scope=\"this\" name="+del+key.toString()+del+">");
sb.append(_serialize(member,done));
sb.append(goIn()+"</var>");
}
Property p;
Boolean remotingFetch;
Struct props = ignoreRemotingFetch?null:ComponentUtil.getPropertiesAsStruct(ca,false);
ComponentScope scope = ca.getComponentScope();
it=scope.keyIterator();
while(it.hasNext()) {
key=Caster.toKey(it.next(),null);
if(!ignoreRemotingFetch) {
p=(Property) props.get(key,null);
if(p!=null) {
remotingFetch=Caster.toBoolean(p.getDynamicAttributes().get(REMOTING_FETCH,null),null);
if(remotingFetch==null){
if(isPeristent && ORMUtil.isRelated(p)) continue;
}
else if(!remotingFetch.booleanValue()) continue;
}
}
member = scope.get(key,null);
if(member instanceof UDF || key.equals(KeyConstants._this)) continue;
sb.append(goIn()+"<var scope=\"variables\" name="+del+key.toString()+del+">");
sb.append(_serialize(member,done));
sb.append(goIn()+"</var>");
}
deep--;
try {
//return goIn()+"<struct>"+sb+"</struct>";
return goIn()+"<component md5=\""+ComponentUtil.md5(component)+"\" name=\""+component.getAbsName()+"\">"+sb+"</component>";
}
catch (Exception e) {
throw toConverterException(e);
}
}
示例6: _serializeStruct
import lucee.runtime.Component; //导入方法依赖的package包/类
/**
* serialize a Struct
* @param struct Struct to serialize
* @param sb
* @param serializeQueryByColumns
* @param addUDFs
* @param done
* @throws ConverterException
*/
public void _serializeStruct(PageContext pc,Set test,Struct struct, StringBuilder sb, boolean serializeQueryByColumns, boolean addUDFs, Set<Object> done) throws ConverterException {
// Component
if(struct instanceof Component){
String res = castToJson(pc, (Component)struct, NULL_STRING);
if(res!=NULL_STRING) {
sb.append(res);
return;
}
}
sb.append(goIn());
sb.append("{");
//Key[] keys = struct.keys();
//Key key;
Iterator<Entry<Key, Object>> it = struct.entryIterator();
Entry<Key, Object> e;
Object value;
boolean doIt=false;
while(it.hasNext()) {
e = it.next();
//key=keys[i];
value=e.getValue();
if(!addUDFs && (value instanceof UDF || value==null))continue;
if(doIt)sb.append(',');
doIt=true;
sb.append(StringUtil.escapeJS(e.getKey().getString(),'"',charsetEncoder));
sb.append(':');
_serialize(pc,test,value,sb,serializeQueryByColumns,done);
}
if(struct instanceof Component){
Boolean remotingFetch;
Component cfc = (Component)struct;
boolean isPeristent=false;
isPeristent=ComponentProUtil.isPersistent(cfc);
Property[] props = cfc.getProperties(false);
ComponentScope scope = cfc.getComponentScope();
for(int i=0;i<props.length;i++) {
if(!ignoreRemotingFetch) {
remotingFetch=Caster.toBoolean(props[i].getDynamicAttributes().get(REMOTING_FETCH,null),null);
if(remotingFetch==null){
if(isPeristent && ORMUtil.isRelated(props[i])) continue;
}
else if(!remotingFetch.booleanValue()) continue;
}
Key key = KeyImpl.getInstance(props[i].getName());
value=scope.get(key,null);
if(!addUDFs && (value instanceof UDF || value==null))continue;
if(doIt)sb.append(',');
doIt=true;
sb.append(StringUtil.escapeJS(key.getString(),'"',charsetEncoder));
sb.append(':');
_serialize(pc,test,value,sb,serializeQueryByColumns,done);
}
}
sb.append('}');
}
示例7: setInternalState
import lucee.runtime.Component; //导入方法依赖的package包/类
public static void setInternalState(Component comp, Struct sctThis, Struct sctVariables) throws PageException {
// this
// delete this scope data members
ComponentSpecificAccess cw = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE,comp);
Collection.Key[] cwKeys = CollectionUtil.keys(cw);
Object member;
for(int i=0;i<cwKeys.length;i++) {
member = cw.get(cwKeys[i]);
if(member instanceof UDF) continue;
cw.removeEL(cwKeys[i]);
}
// set this scope data members
Iterator<Entry<Key, Object>> it = sctThis.entryIterator();
Entry<Key, Object> e;
//keys = sctThis.keys();
while(it.hasNext()) {
e=it.next();
comp.set(e.getKey(),e.getValue());
}
// Variables
ComponentScope scope = comp.getComponentScope();
// delete variables scope data members
Key[] sKeys = CollectionUtil.keys(scope);
for(int i=0;i<sKeys.length;i++) {
if(KeyConstants._this.equals(sKeys[i])) continue;
if(scope.get(sKeys[i]) instanceof UDF) continue;
scope.removeEL(sKeys[i]);
}
// set variables scope data members
it=sctVariables.entryIterator();
//keys = sctVariables.keys();
while(it.hasNext()) {
e=it.next();
scope.set(e.getKey(),e.getValue());
}
}
示例8: loadByExample
import lucee.runtime.Component; //导入方法依赖的package包/类
private Object loadByExample(PageContext pc, Object obj, boolean unique) throws PageException {
Component cfc=HibernateCaster.toComponent(obj);
Key dsn = KeyImpl.init(ORMUtil.getDataSourceName(pc, cfc));
ComponentScope scope = cfc.getComponentScope();
String name=HibernateCaster.getEntityName(cfc);
Session sess = getSession(dsn);
Object rtn=null;
try{
//trans.begin();
ClassMetadata metaData = sess.getSessionFactory().getClassMetadata(name);
String idName = metaData.getIdentifierPropertyName();
Type idType = metaData.getIdentifierType();
Criteria criteria=sess.createCriteria(name);
if(!Util.isEmpty(idName)){
Object idValue = scope.get(CommonUtil.createKey(idName),null);
if(idValue!=null){
criteria.add(Restrictions.eq(idName, HibernateCaster.toSQL(idType, idValue,null)));
}
}
criteria.add(Example.create(cfc));
// execute
if(!unique){
rtn = criteria.list();
}
else {
//Map map=(Map) criteria.uniqueResult();
rtn= criteria.uniqueResult();
}
}
catch(Throwable t){
lucee.commons.lang.ExceptionUtil.rethrowIfNecessary(t);
// trans.rollback();
throw CommonUtil.toPageException(t);
}
//trans.commit();
return rtn;
}
示例9: toIdentifier
import lucee.runtime.Component; //导入方法依赖的package包/类
private Serializable toIdentifier(Serializable id) {
if(id instanceof Component) {
HashMap<String, Object> map = new HashMap<String, Object>();
Component cfc=(Component) id;
ComponentScope scope = cfc.getComponentScope();
lucee.runtime.component.Property[] props = HibernateUtil.getIDProperties(cfc, true,true);
lucee.runtime.component.Property p;
String name;
Object value;
for(int i=0;i<props.length;i++){
p=props[i];
name=p.getName();
value=scope.get(CommonUtil.createKey(name),null);
String type=p.getType();
if(Decision.isAnyType(type)) {
type="string";
try {
Object o=p.getMetaData();
if(o instanceof Struct) {
Struct meta=(Struct) o;
String gen = Caster.toString(meta.get(KeyConstants._generator, null),null);
if(!StringUtil.isEmpty(gen)){
type=HBMCreator.getDefaultTypeForGenerator(gen, "string");
}
}
}
catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
}
try {
value=HibernateCaster.toHibernateValue(ThreadLocalPageContext.get(), value, type);
}
catch (PageException pe) {}
map.put(name, value);
}
return map;
}
return id;
}
示例10: _serializeComponent
import lucee.runtime.Component; //导入方法依赖的package包/类
/**
* serialize a Component
* @param component Component to serialize
* @param done
* @return serialized component
* @throws ConverterException
*/
private String _serializeComponent(Component component, Set<Object> done) throws ConverterException {
StringBuilder sb=new StringBuilder();
Component ca;
component=new ComponentSpecificAccess(Component.ACCESS_PRIVATE, ca=component);
boolean isPeristent=ca.isPersistent();
deep++;
Object member;
Iterator<Key> it = component.keyIterator();
Collection.Key key;
while(it.hasNext()) {
key=Caster.toKey(it.next(),null);
member = component.get(key,null);
if(member instanceof UDF) continue;
sb.append(goIn()+"<var scope=\"this\" name="+del+XMLUtil.escapeXMLString(key.toString())+del+">");
sb.append(_serialize(member,done));
sb.append(goIn()+"</var>");
}
Property p;
Boolean remotingFetch;
Struct props = ignoreRemotingFetch?null:ComponentUtil.getPropertiesAsStruct(ca,false);
ComponentScope scope = ca.getComponentScope();
it=scope.keyIterator();
while(it.hasNext()) {
key=Caster.toKey(it.next(),null);
if(!ignoreRemotingFetch) {
p=(Property) props.get(key,null);
if(p!=null) {
remotingFetch=Caster.toBoolean(p.getDynamicAttributes().get(REMOTING_FETCH,null),null);
if(remotingFetch==null){
if(isPeristent && ORMUtil.isRelated(p)) continue;
}
else if(!remotingFetch.booleanValue()) continue;
}
}
member = scope.get(key,null);
if(member instanceof UDF || key.equals(KeyConstants._this)) continue;
sb.append(goIn()+"<var scope=\"variables\" name="+del+XMLUtil.escapeXMLString(key.toString())+del+">");
sb.append(_serialize(member,done));
sb.append(goIn()+"</var>");
}
deep--;
try {
//return goIn()+"<struct>"+sb+"</struct>";
return goIn()+"<component md5=\""+ComponentUtil.md5(component)+"\" name=\""+XMLUtil.escapeXMLString(component.getAbsName())+"\">"+sb+"</component>";
}
catch (Exception e) {
throw toConverterException(e);
}
}
示例11: _serializeComponent
import lucee.runtime.Component; //导入方法依赖的package包/类
/**
* serialize a Component
* @param component Component to serialize
* @param done
* @return serialized component
* @throws ConverterException
*/
private String _serializeComponent(Component component, Map<Object,String> done) throws ConverterException {
StringBuilder sb=new StringBuilder();
Component ca;
component=new ComponentSpecificAccess(Component.ACCESS_PRIVATE, ca=component);
boolean isPeristent=ca.isPersistent();
deep++;
Object member;
Iterator<Key> it = component.keyIterator();
Collection.Key key;
while(it.hasNext()) {
key=it.next();
member = component.get(key,null);
if(member instanceof UDF) continue;
sb.append(goIn()+"<var scope=\"this\" name="+del+key.toString()+del+">");
sb.append(_serialize(member,done));
sb.append(goIn()+"</var>");
}
Property p;
Boolean remotingFetch;
Struct props = ignoreRemotingFetch?null:ComponentUtil.getPropertiesAsStruct(ca,false);
ComponentScope scope = ca.getComponentScope();
it=scope.keyIterator();
while(it.hasNext()) {
key=Caster.toKey(it.next(),null);
if(!ignoreRemotingFetch) {
p=(Property) props.get(key,null);
if(p!=null) {
remotingFetch=Caster.toBoolean(p.getDynamicAttributes().get(REMOTING_FETCH,null),null);
if(remotingFetch==null){
if(isPeristent && ORMUtil.isRelated(p)) continue;
}
else if(!remotingFetch.booleanValue()) continue;
}
}
member = scope.get(key,null);
if(member instanceof UDF || key.equals(KeyConstants._this)) continue;
sb.append(goIn()+"<var scope=\"variables\" name="+del+key.toString()+del+">");
sb.append(_serialize(member,done));
sb.append(goIn()+"</var>");
}
deep--;
try {
//return goIn()+"<struct>"+sb+"</struct>";
return goIn()+"<component md5=\""+ComponentUtil.md5(component)+"\" name=\""+component.getAbsName()+"\">"+sb+"</component>";
}
catch (Exception e) {
throw toConverterException(e);
}
}
示例12: _serializeStruct
import lucee.runtime.Component; //导入方法依赖的package包/类
/**
* serialize a Struct
* @param struct Struct to serialize
* @param sb
* @param serializeQueryByColumns
* @param addUDFs
* @param done
* @throws ConverterException
*/
public void _serializeStruct(PageContext pc,Set test,Struct struct, StringBuilder sb, boolean serializeQueryByColumns, boolean addUDFs, Set<Object> done) throws ConverterException {
// Component
if(struct instanceof Component){
String res = castToJson(pc, (Component)struct, NULL_STRING);
if(res!=NULL_STRING) {
sb.append(res);
return;
}
}
sb.append(goIn());
sb.append("{");
//Key[] keys = struct.keys();
//Key key;
Iterator<Entry<Key, Object>> it = struct.entryIterator();
Entry<Key, Object> e;
Object value;
boolean doIt=false;
while(it.hasNext()) {
e = it.next();
//key=keys[i];
value=e.getValue();
if(!addUDFs && (value instanceof UDF || value==null))continue;
if(doIt)sb.append(',');
doIt=true;
sb.append(StringUtil.escapeJS(e.getKey().getString(),'"',charsetEncoder));
sb.append(':');
_serialize(pc,test,value,sb,serializeQueryByColumns,done);
}
if(struct instanceof Component){
Boolean remotingFetch;
Component comp = (Component)struct;
boolean isPeristent=false;
isPeristent=comp.isPersistent();
Property[] props = comp.getProperties(false);
ComponentScope scope = comp.getComponentScope();
for(int i=0;i<props.length;i++) {
if(!ignoreRemotingFetch) {
remotingFetch=Caster.toBoolean(props[i].getDynamicAttributes().get(REMOTING_FETCH,null),null);
if(remotingFetch==null){
if(isPeristent && ORMUtil.isRelated(props[i])) continue;
}
else if(!remotingFetch.booleanValue()) continue;
}
Key key = KeyImpl.getInstance(props[i].getName());
value=scope.get(key,null);
if(!addUDFs && (value instanceof UDF || value==null))continue;
if(doIt)sb.append(',');
doIt=true;
sb.append(StringUtil.escapeJS(key.getString(),'"',charsetEncoder));
sb.append(':');
_serialize(pc,test,value,sb,serializeQueryByColumns,done);
}
}
sb.append('}');
}