use of lucee.runtime.ComponentSpecificAccess in project Lucee by lucee.
the class JSONConverter method _serializeComponent.
/**
* serialize a Component
* @param component Component to serialize
* @param sb
* @param serializeQueryByColumns
* @param done
* @throws ConverterException
*/
private void _serializeComponent(PageContext pc, Set test, Component component, StringBuilder sb, boolean serializeQueryByColumns, Set<Object> done) throws ConverterException {
ComponentSpecificAccess cw = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE, component);
_serializeStruct(pc, test, cw, sb, serializeQueryByColumns, false, done);
}
use of lucee.runtime.ComponentSpecificAccess in project Lucee by lucee.
the class EvaluateComponent method setInternalState.
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());
}
}
use of lucee.runtime.ComponentSpecificAccess in project Lucee by lucee.
the class GetTagData method cfmlBasedTag.
private static Struct cfmlBasedTag(PageContext pc, TagLib tld, TagLibTag tag) throws PageException {
// Map attrs = tag.getAttributes();
TagLibTagAttr attrFilename = tag.getAttribute("__filename");
// TagLibTagAttr attrName = tag.getAttribute("__name");
TagLibTagAttr attrIsWeb = tag.getAttribute("__isweb");
String filename = Caster.toString(attrFilename.getDefaultValue());
String name = Caster.toString(attrFilename.getDefaultValue());
boolean isWeb = Caster.toBooleanValue(attrIsWeb.getDefaultValue());
InitFile source = CFTagCore.createInitFile(pc, isWeb, filename);
String callPath = ResourceUtil.removeExtension(source.getFilename(), source.getFilename());
Component cfc = ComponentLoader.loadComponent(pc, source.getPageSource(), callPath, false, true);
ComponentSpecificAccess cw = ComponentSpecificAccess.toComponentSpecificAccess(Component.ACCESS_PRIVATE, cfc);
Struct metadata = Caster.toStruct(cw.get("metadata", null), null, false);
Struct sct = new StructImpl();
sct.set("nameSpaceSeperator", tld.getNameSpaceSeparator());
sct.set("nameSpace", tld.getNameSpace());
sct.set(KeyConstants._name, name.substring(0, name.lastIndexOf('.')));
sct.set("hasNameAppendix", Boolean.FALSE);
sct.set(KeyConstants._status, "implemeted");
sct.set(KeyConstants._type, "cfml");
sct.set("bodyType", getBodyType(tag));
sct.set("attrMin", Caster.toDouble(0));
sct.set("attrMax", Caster.toDouble(0));
sct.set("attributeCollection", getSupportAttributeCollection(tag));
// TODO add support for script for cfml tags
Struct scp = new StructImpl();
sct.set(KeyConstants._script, scp);
scp.set("rtexpr", Boolean.FALSE);
scp.set(KeyConstants._type, "none");
if (metadata != null) {
sct.set(KeyConstants._description, metadata.get("hint", ""));
sct.set("attributeType", metadata.get("attributeType", ""));
sct.set("parseBody", Caster.toBoolean(metadata.get("parseBody", Boolean.FALSE), Boolean.FALSE));
Struct _attrs = new StructImpl();
sct.set(KeyConstants._attributes, _attrs);
Struct srcAttrs = Caster.toStruct(metadata.get(KeyConstants._attributes, null), null, false);
Struct src;
if (srcAttrs != null) {
// Key[] keys = srcAttrs.keys();
Iterator<Entry<Key, Object>> it = srcAttrs.entryIterator();
Entry<Key, Object> e;
while (it.hasNext()) {
e = it.next();
src = Caster.toStruct(e.getValue(), null, false);
if (Caster.toBooleanValue(src.get(KeyConstants._hidden, null), false))
continue;
Struct _attr = new StructImpl();
_attr.set(KeyConstants._status, "implemeted");
_attr.set(KeyConstants._description, src.get(KeyConstants._hint, ""));
_attr.set(KeyConstants._type, src.get(KeyConstants._type, "any"));
_attr.set(KeyConstants._required, Caster.toBoolean(src.get(KeyConstants._required, ""), null));
_attr.set("scriptSupport", "none");
_attrs.setEL(e.getKey().getLowerString(), _attr);
}
}
}
return sct;
}
Aggregations