/** * @return the explicit methods map (Unmodifiable Map). */ public Map<String, Closure> getExplicitMethods() { return Collections.unmodifiableMap(getProxyBuilder().explicitMethods); }
/** * Add a preInstantiate delegate so it can intercept nodes before they are * created. PreInstantiate delegates are fired in a FILO pattern, so that * nested delegates get first crack. * * @param delegate the closure to invoke * @return delegate */ public Closure addPreInstantiateDelegate(Closure delegate) { getProxyBuilder().preInstantiateDelegates.addFirst(delegate); return delegate; }
/** * Add a nodeCompletion delegate so it can intercept nodes after they done * with building. NodeCompletion delegates are fired in a FILO pattern, so * that nested delegates get first crack. * * @param delegate the closure to invoke * @return delegate */ public Closure addPostNodeCompletionDelegate(Closure delegate) { getProxyBuilder().postNodeCompletionDelegates.addFirst(delegate); return delegate; }
/** * @return the explicit properties map (Unmodifiable Map). */ public Map<String, Closure[]> getExplicitProperties() { return Collections.unmodifiableMap(getProxyBuilder().explicitProperties); }
/** * Add an attribute delegate so it can intercept attributes being set. * Attribute delegates are fired in a FILO pattern, so that nested delegates * get first crack. * * @param attrDelegate the closure to be called * @return attrDelegate */ public Closure addAttributeDelegate(Closure attrDelegate) { getProxyBuilder().attributeDelegates.addFirst(attrDelegate); return attrDelegate; }
/** * @return the factory map (Unmodifiable Map). */ public Map<String, Factory> getFactories() { return Collections.unmodifiableMap(getProxyBuilder().factories); }
/** * Remove the most recently added instance of the attribute delegate. * * @param attrDelegate the instance of the closure to be removed */ public void removeAttributeDelegate(Closure attrDelegate) { getProxyBuilder().attributeDelegates.remove(attrDelegate); }
/** * Remove the most recently added instance of the nodeCompletion delegate. * * @param delegate the closure to be removed */ public void removePostNodeCompletionDelegate(Closure delegate) { getProxyBuilder().postNodeCompletionDelegates.remove(delegate); }
/** * Remove the most recently added instance of the preInstantiate delegate. * * @param delegate the closure to invoke */ public void removePreInstantiateDelegate(Closure delegate) { getProxyBuilder().preInstantiateDelegates.remove(delegate); }
/** * Add a postInstantiate delegate so it can intercept nodes after they are * created. PostInstantiate delegates are fired in a FILO pattern, so that * nested delegates get first crack. * * @param delegate the closure to invoke * @return delegate */ public Closure addPostInstantiateDelegate(Closure delegate) { getProxyBuilder().postInstantiateDelegates.addFirst(delegate); return delegate; }
/** * Remove the most recently added instance of the postInstantiate delegate. * * @param delegate the closure to invoke */ public void removePostInstantiateDelegate(Closure delegate) { getProxyBuilder().postInstantiateDelegates.remove(delegate); }
/** * @return the stack of available contexts. */ protected LinkedList<Map<String, Object>> getContexts() { LinkedList<Map<String, Object>> contexts = getProxyBuilder().contexts.get(); if (contexts == null) { contexts = new LinkedList<Map<String, Object>>(); getProxyBuilder().contexts.set(contexts); } return contexts; }
/** * @return the context of the current node. */ public Map<String, Object> getContext() { LinkedList<Map<String, Object>> contexts = getProxyBuilder().contexts.get(); if (contexts != null && !contexts.isEmpty()) { return contexts.getFirst(); } return null; }
/** * Convenience method when no arguments are required * * @param methodName the name of the method to invoke * @return the result of the call */ public Object invokeMethod(String methodName) { return getProxyBuilder().invokeMethod(methodName, null); }
/** * Sets the value of the given variable * * @param name the name of the variable to set * @param value the new value for the given variable */ public void setVariable(String name, Object value) { getProxyBuilder().doSetVariable(name, value); }
/** * Overloaded to make variables appear as bean properties or via the subscript operator */ public void setProperty(String property, Object newValue) { getProxyBuilder().doSetProperty(property, newValue); }
/** * Removes the last context from the stack. * * @return the content just removed */ protected Map<String, Object> popContext() { if (!getProxyBuilder().getContexts().isEmpty()) { return getProxyBuilder().getContexts().removeFirst(); } return null; }
/** * Clears the context stack. */ protected void reset() { getProxyBuilder().getContexts().clear(); }
/** * A hook to allow nodes to be processed once they have had all of their * children applied. * * @param node the current node being processed * @param parent the parent of the node being processed */ protected void nodeCompleted(Object parent, Object node) { getProxyBuilder().getCurrentFactory().onNodeCompleted(getProxyBuilder().getChildBuilder(), parent, node); }
/** * Registers a factory for a node name. * * @param name the name of the node * @param groupName thr group to register this node in * @param factory the factory to return the values */ public void registerFactory(String name, String groupName, Factory factory) { getProxyBuilder().factories.put(name, factory); getRegistrationGroup(groupName).add(name); factory.onFactoryRegistration(this, name, groupName); }