Examples of ElementHandler


Examples of nexj.core.util.XMLUtil.ElementHandler

    */
   protected void loadSecurityDescriptor(final Element descriptorElement)
   {
      XMLMetadataHelper.verifyRootElement(descriptorElement, "SecurityDescriptor");

      XMLUtil.withFirstChildElement(descriptorElement, "Privileges", false, new ElementHandler()
      {
         public void handleElement(Element privilegesElement)
         {
            XMLUtil.forEachChildElement(privilegesElement, "Privilege",
               m_helper.new ElementHandler("privilege")
            {
               public void handleElement(Element privilegeElement, String sPrivilegeName)
               {
                  Privilege privilege = new PrimitivePrivilege(sPrivilegeName);

                  m_metadata.addPrivilege(privilege);
                  privilege.setCaption(XMLUtil.getStringAttr(privilegeElement,
                     "caption", privilege.getCaption()));
               }
            });
         }
      });

      XMLUtil.withFirstChildElement(descriptorElement, "PrivilegeGroups", false, new ElementHandler()
      {
         public void handleElement(Element privilegeGroupsElement)
         {
            XMLUtil.forEachChildElement(privilegeGroupsElement, "PrivilegeGroup",
               m_helper.new ElementHandler("privilegeGroup")
            {
               public void handleElement(Element privilegeGroupElement, String sPrivilegeSetName)
               {
                  final PrivilegeGroup privilegeGroup = new PrivilegeGroup(sPrivilegeSetName);

                  m_metadata.addPrivilege(privilegeGroup);
                  privilegeGroup.setCaption(XMLUtil.getStringAttr(privilegeGroupElement,
                     "caption", privilegeGroup.getCaption()));

                  XMLUtil.withFirstChildElement(privilegeGroupElement, "Privileges", false, new ElementHandler()
                  {
                     public void handleElement(Element privilegesElement)
                     {
                        XMLUtil.forEachChildElement(privilegesElement, "Privilege",
                           m_helper.new ElementHandler("privilege")
                        {
                           public void handleElement(Element privilegeElement, final String sPrivilegeName)
                           {
                              m_privilegeFixupList.add(new ContextFixup(m_helper)
                              {
View Full Code Here

Examples of nexj.core.util.XMLUtil.ElementHandler

            {
               metaclass.addAspectOverride(m_metadata.defineClassAspect(sName, metaclass), bInclusive);
            }
         });

      XMLUtil.withFirstChildElement(classElement, "Attributes", false, new ElementHandler()
      {
         public void handleElement(Element attributesElement)
         {
            XMLUtil.forEachChildElement(attributesElement, "Attribute",
               m_helper.new ElementHandler("attribute")
            {
               public void handleElement(Element attributeElement, String sAttributeName)
               {
                  XMLMetadataHelper.validateName(sAttributeName);

                  Attribute attribute = new Attribute(sAttributeName);

                  attribute.setMetaclass(metaclass);
                  attribute.setDeclarator(metaclass);
                  loadAttribute(attributeElement, attribute);
                  metaclass.addAttribute(attribute);
               }
            });
         }
      });

      XMLUtil.withFirstChildElement(classElement, "Events", false, new ElementHandler()
      {
         public void handleElement(Element eventsElement)
         {
            XMLUtil.forEachChildElement(eventsElement, "Event",
               m_helper.new ElementHandler("event")
            {
               public void handleElement(Element eventElement, String sEventName)
               {
                  XMLMetadataHelper.validateName(sEventName);
View Full Code Here

Examples of nexj.core.util.XMLUtil.ElementHandler

         });
      }

      // Queue for second pass only if a persistence mapping element is present

      XMLUtil.withFirstChildElement(classElement, "PersistenceMapping", false, new ElementHandler()
      {
         public void handleElement(Element element)
         {
            final String sResourceName = m_helper.getCurResourceName();
            final Element clone = (Element)m_tmpDocument.importNode(element, true);
View Full Code Here

Examples of nexj.core.util.XMLUtil.ElementHandler

            {
               aspect.addPointcutPattern(sPattern, bInclusive);
            }
         });

      XMLUtil.withFirstChildElement(aspectElement, "PersistenceMappings", false, new ElementHandler()
      {
         public void handleElement(Element persistenceMappingsElement)
         {
            XMLUtil.forEachChildElement(persistenceMappingsElement, "PersistenceMapping", new ElementHandler()
            {
               public void handleElement(Element persistenceMappingElement)
               {
                  final String sResourceName = m_helper.getCurResourceName();
                  final Element clone = (Element)m_tmpDocument.importNode(persistenceMappingElement, true);
View Full Code Here

Examples of nexj.core.util.XMLUtil.ElementHandler

      event.setPrivilege(getPrivilege(eventElement, "privilege"));
      event.setTransactionMode(parseTransactionMode(XMLUtil.getStringAttr(eventElement, "transaction"), Event.TX_DEFAULT));
      event.setAudited(XMLUtil.getBooleanObjAttr(eventElement, "audit"));
      event.setVarArg(XMLUtil.getBooleanAttr(eventElement, "vararg", false));

      XMLUtil.withFirstChildElement(eventElement, "Result", false, new ElementHandler()
      {
         public void handleElement(Element resultElement)
         {
            event.setResult(loadArgument(resultElement, null));
         }
      });

      String sArgList = XMLUtil.getStringAttr(eventElement, "args");
      final Lookup/*<String, Argument>*/ argMap = new HashTab/*<String, Argument>*/();

      XMLUtil.withFirstChildElement(eventElement, "Arguments", false, new ElementHandler()
      {
         public void handleElement(Element argsElement)
         {
            XMLUtil.forEachChildElement(argsElement, "Argument",
               m_helper.new ElementHandler("argument")
            {
               protected void handleElement(Element argElement, String sArgName)
               {
                  argMap.put(sArgName, loadArgument(argElement, sArgName));
               }
            });
         }
      });

      if (sArgList != null)
      {
         for (StringTokenizer tokenizer = new StringTokenizer(sArgList); tokenizer.hasMoreTokens();)
         {
            String sArgName = tokenizer.nextToken();
            Argument arg = (Argument)argMap.remove(sArgName);

            XMLMetadataHelper.validateName(sArgName);
            event.addArgument((arg == null) ? new Argument(sArgName) : arg);
         }
      }

      MetadataCompoundValidationException e = null;

      for (Iterator/*<Argument>*/ itr = argMap.valueIterator(); itr.hasNext();)
      {
         if (e == null)
         {
            e = new MetadataCompoundValidationException();
         }

         e.addException(
            new MetadataException("err.meta.argLookup", new Object[]{itr.next(), event}));
      }

      if (e != null)
      {
         throw e;
      }

      event.addVariables((Pair)m_helper.parse(XMLUtil.getStringAttr(eventElement, "variables"), true, null, null, m_metadata.getGlobalEnvironment()));

      final String sAccessAttributeName = XMLUtil.getStringAttr(eventElement, "access");

      if (sAccessAttributeName != null)
      {
         m_attributeFixupList.add(new ContextFixup(m_helper)
         {
            public void fixup()
            {
               event.setAccessAttribute(event.getMetaclass().getAttribute(sAccessAttributeName));
            }
         });
      }

      XMLUtil.withFirstChildElement(eventElement, "Actions", false, new ElementHandler()
      {
         public void handleElement(Element actionsElement)
         {
            XMLUtil.forEachChildElement(actionsElement, "Action",
               m_helper.new ElementHandler("action")
            {
               public void handleElement(Element actionElement, String sActionName)
               {
                  String sGroupName = null;
                  int i = sActionName.indexOf(':');
View Full Code Here

Examples of nexj.core.util.XMLUtil.ElementHandler

    */
   public static void loadEnumerationValues(Element enumerationElement, final Collection valueCollection)
   {
      XMLMetadataHelper.verifyRootElement(enumerationElement, "Enumeration");

      XMLUtil.withFirstChildElement(enumerationElement, "Values", false, new ElementHandler()
      {
         public void handleElement(Element valuesElement)
         {
            XMLUtil.forEachChildElement(valuesElement, "Value",
               new XMLUtil.ElementHandler()
View Full Code Here

Examples of nexj.core.util.XMLUtil.ElementHandler

         });
      }

      if (m_bValidatedOnly)
      {
         XMLUtil.withFirstChildElement(enumerationElement, "Locales", false, new ElementHandler()
         {
            public void handleElement(Element localesElement)
            {
               final Set localeSet = new HashHolder();

               XMLUtil.forEachChildElement(localesElement, "Locale",
                  m_helper.new ElementHandler("locale")
               {
                  public void handleElement(Element localeElement, String sLocale)
                  {
                     if (!localeSet.add(sLocale))
                     {
                        throw new MetadataException("err.meta.enumLocaleDup",
                           new Object[]{sLocale, sEnumerationName});
                     }

                     XMLUtil.getReqStringAttr(localeElement, "caption");
                  }
               });
            }
         });
      }

      final Set valueSet = new HashHolder();
      m_enumerationValueMap.put(sEnumerationName, valueSet);

      XMLUtil.withFirstChildElement(enumerationElement, "Values", false, new ElementHandler()
      {
         public void handleElement(Element valuesElement)
         {
            final Set nameSet = new HashHolder();
            final Set behaveAsSet = new HashHolder();
            final Set externSet = new HashHolder();
            final List fixupList = new ArrayList();

            XMLUtil.forEachChildElement(valuesElement, "Value",
               m_helper.new ElementHandler("value")
            {
               public void handleElement(Element valueElement, String sName)
               {
                  XMLMetadataHelper.validateName(sName);

                  fixupList.add(sName);

                  if (!nameSet.add(sName))
                  {
                     throw new MetadataException("err.meta.enumValueNameDup",
                        new Object[]{sName, sEnumerationName});
                  }

                  final String sValue = XMLUtil.getReqStringAttr(valueElement, "value");

                  if (!valueSet.add(sValue))
                  {
                     throw new MetadataException("err.meta.enumValueDup",
                        new Object[]{sValue, sEnumerationName});
                  }

                  fixupList.add(sValue);

                  boolean bHasBehavior = XMLUtil.getBooleanAttr(valueElement, "hasBehavior", false);

                  fixupList.add(Boolean.valueOf(bHasBehavior));

                  String sBehaveAsValue = XMLUtil.getStringAttr(valueElement, "behaveAsValue");

                  if (sBehaveAsValue != null)
                  {
                     if (bHasBehavior)
                     {
                        if (!sBehaveAsValue.equals(sValue))
                        {
                           throw new MetadataException("err.meta.enumBehaveAsValueMismatch",
                              new Object[]{sBehaveAsValue, sValue, sEnumerationName});
                        }
                     }
                     else
                     {
                        if (sBehaveAsValue.equals(sValue))
                        {
                           throw new MetadataException("err.meta.enumInvalidSelfReference",
                              new Object[]{sValue, sEnumerationName});
                        }

                        behaveAsSet.add(sBehaveAsValue);
                     }
                  }

                  String sExternValue = XMLUtil.getStringAttr(valueElement, "externalValue");

                  if (sExternValue != null)
                  {
                     if (!externSet.add(sExternValue))
                     {
                        throw new MetadataException("err.meta.enumExternValueDup",
                           new Object[]{sExternValue, sEnumerationName});
                     }
                  }

                  final String sParentValue = XMLUtil.getStringAttr(valueElement, "parentValue");

                  if (sParentValue != null)
                  {
                     if (sParentEnumeration == null)
                     {
                        throw new MetadataException("err.meta.enumParentValue", new Object[]{sEnumerationName});
                     }

                     m_inheritanceFixupList.add(new ContextFixup(m_helper)
                     {
                        public void fixup()
                        {
                           Metaclass parent = m_metadata.getMetaclass(sParentEnumeration);

                           if (!((Set)m_enumerationValueMap.get(sParentEnumeration)).contains(parent.getAttribute("value").getType().convert(sParentValue)))
                           {
                              throw new MetadataLookupException("err.meta.enumParentValueLookup", sParentValue, sParentEnumeration);
                           }
                        }
                     });
                  }
                  else
                  {
                     if (sParentEnumeration != null)
                     {
                        throw new MetadataException("err.meta.enumNoParentValue", new Object[]{sValue, sEnumerationName});
                     }
                  }

                  if (m_bValidatedOnly)
                  {
                     XMLUtil.withFirstChildElement(valueElement, "Locales", false, new ElementHandler()
                     {
                        public void handleElement(Element localesElement)
                        {
                           final Set localeSet = new HashHolder();

                           XMLUtil.forEachChildElement(localesElement, "Locale",
                              m_helper.new ElementHandler("locale")
                           {
                              public void handleElement(Element localeElement, String sLocale)
                              {
                                 if (!localeSet.add(sLocale))
                                 {
View Full Code Here

Examples of nexj.core.util.XMLUtil.ElementHandler

      XMLUtil.withFirstChildElement(macroElement, "Arguments", false, new XMLUtil.ElementHandler()
      {
         public void handleElement(Element argumentsElement)
         {
            XMLUtil.forEachChildElement(argumentsElement, "Argument", m_helper.new ElementHandler("argument")
            {
               protected void handleElement(Element argumentElement, String sName)
               {
                  FlowMacro.Argument arg = new FlowMacro.Argument(sName);
                  String sTypeName = XMLUtil.getReqStringAttr(argumentElement, "type");
View Full Code Here

Examples of nexj.core.util.XMLUtil.ElementHandler

      fork.setActivity(assignment.getActivity());
      decision.setActivity(assignment.getActivity());

      XMLUtil.forEachChildElement(queueElement, null,
         m_helper.new ElementHandler("queueEvent")
      {
         private boolean m_bTimer;

         protected String getName(Element eventElement)
         {
View Full Code Here

Examples of nexj.core.util.XMLUtil.ElementHandler

    * @param loader The branch loader.
    */
   public static void loadDecision(Element element, final Decision decision,
      final XMLMetadataHelper helper, final Metadata metadata, final BranchLoader loader)
   {
      XMLUtil.forEachChildElement(element, loader.getElementName(), new ElementHandler()
      {
         public void handleElement(Element branchElement)
         {
            Branch branch = loader.createBranch();

View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.