/** Parses the items as if they are native and they will become a property * rather than child components. */ private void parseAsProperty(PageDefinition pgdef, ComponentInfo compInfo, String name, Collection items, AnnotationHelper annHelper, ConditionImpl cond) throws Exception { final NativeInfo nativeInfo = new NativeInfo(compInfo.getEvaluatorRef(), pgdef.getLanguageDefinition().getNativeDefinition(), ""); //Note: nativeInfo can not be a child. Rather, it will be a property parseItems(pgdef, nativeInfo, items, annHelper, true); compInfo.addProperty(name, nativeInfo, cond); }
/** Parses from the specified reader. * * @param extension the default extension if doc (of reader) doesn't specify * an language. Ignored if null. * If extension is null and the content doesn't specify a language, * the language called "xul/html" is assumed. */ public PageDefinition parse(Reader reader, String extension) throws Exception { //if (log.isDebugEnabled()) log.debug("Parsing "+reader); return parse(TreeBuilderFactory.makeBuilder(extension).parse(reader), extension); }
/** Constructs a {@link ZScriptInfo} with an URL, which might contain an EL * expression. * * @param url the URL. It may contain XEL expressions. * @param locator the locator used to locate the zscript file */ public ZScriptInfo(NodeInfo parent, String zslang, String url, Locator locator, ConditionImpl cond) { super(parent, cond); _zs = new ZScript(parent.getEvaluatorRef(), zslang, url, locator); }
public void appendChild(NodeInfo child) { NodeInfo oldp = child.getParent(); if (oldp != null) oldp.removeChild(child); _children.add(child); ((LeafInfo) child).setParentDirectly(this); //except root, all are LeafInfo BranchInfo.fixEvaluatorRefDown(child, getEvaluatorRef()); //Use getEvaluatorRef() to force _evalr being assigned }
protected PageDefinition parse(String path, URL url, Object extra) throws Exception { final Locator locator = extra != null ? (Locator) extra : getLocator(_wapp, path); return new Parser(_wapp, locator).parse(url, path); } }
private ComponentInfo newComponentInfo(NodeInfo parent, String text) { if (_compdef == null) //no sync since racing is OK _compdef = getComponentDefinition(_name); final ComponentInfo info = new ComponentInfo(parent, _compdef, null); info.addProperty(_prop, text, null); return info; } }
public ComponentDefinition getComponentDefinition(Class<? extends Component> cls, boolean recurse) { final ComponentDefinition compdef = _compdefs.get(cls); if (!recurse || compdef != null) return compdef; try { return _langdef.getComponentDefinition(cls); } catch (DefinitionNotFoundException ex) { try { // try with shadow element return _langdef.getShadowDefinition(cls); } catch (DefinitionNotFoundException eex) { } } return null; }
/*package*/ static ComponentDefinition getDefinitionByDeviceType(Component comp, String deviceType, String name) { for (LanguageDefinition ld : LanguageDefinition.getByDeviceType(deviceType)) { try { final ComponentDefinition def = ld.getComponentDefinition(name); if (def.isInstance(comp)) return def; } catch (DefinitionNotFoundException ex) { //ignore } } return null; }
private static final LanguageDefinition getLanguageDefinition(NodeInfo node) { for (; node != null; node = node.getParent()) { if (node instanceof ComponentInfo) { LanguageDefinition langdef = ((ComponentInfo) node).getLanguageDefinition(); if (langdef != null) return langdef; } else if (node instanceof PageDefinition) { return ((PageDefinition) node).getLanguageDefinition(); } else if (node instanceof ShadowInfo) { return ((ShadowInfo) node).getLanguageDefinition(); } } return null; }
/** Returns the language definition that this richlet belongs to. * Don't return null. * * <p> It is called when creating a new page for this richlet to serve. * * <p>Default: return the language definition called "xul/html". */ public LanguageDefinition getLanguageDefinition() { return LanguageDefinition.lookup("xul/html"); } }
/** Creates and returns the function mapper for the specified pagedefinition and page. */ public FunctionMapper newFunctionMapper(PageDefinition pgdef, Page page) throws Exception { return newFunctionMapper(pgdef.getEvaluator(), page); }
/** Applies the custom attributes. * <p>Note: this method does nothing if {@link #isEffective} returns false. */ public void apply(Component comp) { if (_props != null && isEffective(comp)) { for (Property prop : _props) { prop.assign(comp); } } }
/** Creates and returns the variable resolver for the specified page. */ public VariableResolver newVariableResolver(PageDefinition pgdef, Page page) throws Exception { return newVariableResolver(pgdef.getEvaluator(), page); }
/*package*/ static final void fixEvaluatorRefDown(NodeInfo child, EvaluatorRef evalr) { if (child instanceof LeafInfo) ((LeafInfo) child)._evalr = evalr; final List<NodeInfo> children = child.getChildren(); if (children != null) //it is null if this method is called in constructor for (NodeInfo c : children) fixEvaluatorRefDown(c, evalr); }
/** Creates and returns the initiator, or null if no initiator is resolved. * Notice that {@link Initiator#doInit} was called before returned. */ public Initiator newInitiator(PageDefinition pgdef, Page page) throws Exception { return newInitiator(pgdef.getEvaluator(), page); }
public ZScript getEventHandler(String evtnm) { final EventHandler evthd = _auxinf != null && _auxinf.evthds != null ? _auxinf.evthds.get(this, evtnm) : null; return evthd != null ? evthd.getZScript() : null; }
/** Returns {@link ComponentDefinition} of the specified name, or null * if not found. * It is the same as {@link #getShadowDefinition}, except this method * won't throw any exception. * * @param name the name of the shadow element definition. * @since 8.0.0 */ public ComponentDefinition getShadowDefinitionIfAny(String name) { return _shadowdefs.get(name); }
public void appendChild(NodeInfo child) { NodeInfo oldp = child.getParent(); if (oldp != null) oldp.removeChild(child); _children.add(child); ((LeafInfo) child).setParentDirectly(this); //except root, all are LeafInfo fixEvaluatorRefDown(child, _evalr); }
public ComponentDefinition getComponentDefinition(String name, boolean recurse) { final ComponentDefinition compdef = _compdefs.get(name); if (!recurse || compdef != null) return compdef; try { return _langdef.getComponentDefinition(name); } catch (DefinitionNotFoundException ex) { try { // try with shadow element return _langdef.getShadowDefinition(name); } catch (DefinitionNotFoundException exe) { } } return null; }
/** Returns {@link ComponentDefinition} of the specified name, or null * if not found. * It is the same as {@link #getComponentDefinition}, except this method * won't throw any exception. * * @param name the name of the component definition. * @since 3.0.2 */ public ComponentDefinition getComponentDefinitionIfAny(String name) { return _compdefs.get(name); }