@Nonnull public JSFunction function (@Nonnull final String sName) throws JSNameAlreadyExistsException { final JSFunction aFunction = new JSFunction (sName); return addDeclaration (aFunction); }
@Override public boolean equals (final Object o) { if (o == this) return true; if (!super.equals (o)) return false; final JSConstructor rhs = (JSConstructor) o; return m_aClass.name ().equals (rhs.m_aClass.name ()); }
@Override public void customizeNode (@Nonnull final IHCNode aNode, @Nonnull final EHTMLVersion eHTMLVersion, @Nonnull final IHCHasChildrenMutable <?, ? super IHCNode> aTargetNode) { if (aNode instanceof IHCElement && !(aNode instanceof IHCScript <?>)) { final JSEventMap aEventMap = ((IHCElement <?>) aNode).getEventMap (); if (aEventMap != null) for (final Map.Entry <EJSEvent, CollectingJSCodeProvider> aEntry : aEventMap.getAllEventHandler ().entrySet ()) { // "ag" for "automatically generated" final JSFunction aFunc = new JSFunction ("_photon_ag" + GlobalIDFactory.getNewIntID ()); aFunc.body ().add (aEntry.getValue ()); aTargetNode.addChild (new HCScriptInline (aFunc)); aEventMap.setHandler (aEntry.getKey (), aFunc.invoke ()); } } } }
@Override public int hashCode () { return HashCodeGenerator.getDerived (super.hashCode ()).append (m_aOwnerClass.name ()).getHashCode (); }
@Override public String toString () { return ToStringGenerator.getDerived (super.toString ()).append ("ownerClass", m_aOwnerClass.name ()).toString (); } }
@Nonnull public static JSRef ref (@Nonnull @Nonempty final JSFunction aFunction) { return new JSRef (aFunction.name ()); }
@Nonnull public JSInvocation invoke (@Nonnull final JSFunction aFunction) { ValueEnforcer.notNull (aFunction, "Function"); return addStatement (aFunction.invoke ()); }
@Override public void declare (@Nonnull final JSFormatter aFormatter) { if (m_aJSDoc != null) aFormatter.generatable (m_aJSDoc); aFormatter.plain ("function ").plain (m_sName).plain ('('); boolean bFirst = true; for (final JSVar aParam : m_aParams) { if (bFirst) bFirst = false; else aFormatter.plain (','); aFormatter.var (aParam); } aFormatter.plain (')').stmt (body ()); }
@Override public void customizeNode (@Nonnull final IHCNode aNode, @Nonnull final EHTMLVersion eHTMLVersion, @Nonnull final IHCHasChildrenMutable <?, ? super IHCNode> aTargetNode) { if (aNode instanceof IHCElement && !(aNode instanceof IHCScript <?>)) { final JSEventMap aEventMap = ((IHCElement <?>) aNode).getEventMap (); if (aEventMap != null) for (final Map.Entry <EJSEvent, CollectingJSCodeProvider> aEntry : aEventMap.getAllEventHandler ().entrySet ()) { // "ag" for "automatically generated" final JSFunction aFunc = new JSFunction ("_photon_ag" + GlobalIDFactory.getNewIntID ()); aFunc.body ().add (aEntry.getValue ()); aTargetNode.addChild (new HCScriptInline (aFunc)); aEventMap.setHandler (aEntry.getKey (), aFunc.invoke ()); } } } }
@Override public int hashCode () { return HashCodeGenerator.getDerived (super.hashCode ()).append (m_aClass.name ()).getHashCode (); }
@Override public String toString () { return ToStringGenerator.getDerived (super.toString ()).append ("ownerClass", m_aOwnerClass.name ()).getToString (); } }
@Nonnull public static JSRef ref (@Nonnull @Nonempty final JSFunction aFunction) { return new JSRef (aFunction.name ()); }
@Nonnull public JSInvocation invoke (@Nonnull final JSFunction aFunction) { ValueEnforcer.notNull (aFunction, "Function"); return addStatement (aFunction.invoke ()); }
@Override public void declare (@Nonnull final JSFormatter aFormatter) { if (m_aJSDoc != null) aFormatter.generatable (m_aJSDoc); aFormatter.plain ("function ").plain (m_sName).plain ('('); boolean bFirst = true; for (final JSVar aParam : m_aParams) { if (bFirst) bFirst = false; else aFormatter.plain (','); aFormatter.var (aParam); } aFormatter.plain (')').stmt (body ()); }
/** * @return <code>$</code> or <code>jQuery</code> as a function */ @Nonnull public static JSFunction jQueryFunction () { return new JSFunction (isUseDollarForJQuery () ? "$" : "jQuery"); }
@Override public int hashCode () { return HashCodeGenerator.getDerived (super.hashCode ()).append (m_aClass.name ()).getHashCode (); }
@Override public boolean equals (final Object o) { if (o == this) return true; if (!super.equals (o)) return false; final JSMethod rhs = (JSMethod) o; return m_aOwnerClass.name ().equals (rhs.m_aOwnerClass.name ()); }
@Override public String toString () { return ToStringGenerator.getDerived (super.toString ()).append ("class", m_aClass.name ()).getToString (); } }