Package nexj.core.util.XMLUtil

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


         });
      }

      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

      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

      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

    * @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

      final ActivityLoader loader)
   {
      final Pair codeHolder = new Pair(null);
      Step outerStep;

      XMLUtil.withFirstChildElement(element, "Finally", false, new ElementHandler()
      {
         public void handleElement(Element finallyElement)
         {
            codeHolder.setHead(
                  helper.parse(helper.getElementValue(finallyElement),
                  true, outerActivity.getFlow().getPosMap(),
                  null, metadata.getGlobalEnvironment()
               )
            );
         }
      });

      if (codeHolder.getHead() != null)
      {
         Block block = new Block(tryCatch.getName() + ".finalizer");

         block.setActivity(outerActivity);
         block.setCleanupCode((Pair)codeHolder.getHead());
         tryCatch.setActivity(block.getContainedActivity());
         block.getContainedActivity().addStep(tryCatch);
         outerStep = block;
      }
      else
      {
         tryCatch.setActivity(outerActivity);
         outerStep = tryCatch;
      }

      String sVariable = XMLUtil.getStringAttr(element, "variable");

      if (sVariable != null)
      {
         tryCatch.setExceptionVariable(outerActivity.getFlow().getVariable(sVariable));
      }

      XMLUtil.withFirstChildElement(element, "Try", false, new ElementHandler()
      {
         public void handleElement(Element tryElement)
         {
            loader.loadActivity(tryElement, tryCatch.getTry());
         }
View Full Code Here

               {
                  throw new MetadataException("err.meta.workflow.joinType",
                     new Object[]{sType, activity.getFlow().getFullName()});
               }

               XMLUtil.forEachChildElement(element, "Activity", new ElementHandler()
               {
                  public void handleElement(Element activityElement)
                  {
                     Concurrent concurrent = new Concurrent();
View Full Code Here

   protected void loadFormats(Element fmtElement)
   {
      XMLMetadataHelper.verifyRootElement(fmtElement, "Formats");

      XMLUtil.forEachChildElement(fmtElement, "Format",
         m_helper.new ElementHandler("format")
      {
         public void handleElement(Element element, String sName)
         {
            loadFormat(element, sName);
         }
View Full Code Here

      if (sExporter != null)
      {
         format.setExporter(m_helper.getClassObject(sExporter));
      }

      XMLUtil.withFirstChildElement(formatElement, "Parser", true, new ElementHandler()
      {
         public void handleElement(Element componentElement)
         {
            Component parser = new Component("<MessageParser:" + sName + ">");

            loadComponent(componentElement, parser);
            format.setParser(parser);
         }
      });

      XMLUtil.withFirstChildElement(formatElement, "Formatter", true, new ElementHandler()
      {
         public void handleElement(Element componentElement)
         {
            Component formatter = new Component("<MessageFormatter:" + sName + ">");
View Full Code Here

    */
   protected void loadCompositeMessagePart(Element partElement, final CompositeMessagePart composite, final Message message)
   {
      initCompositeMessagePart(partElement, composite, message);

      XMLUtil.withFirstChildElement(partElement, "Parts", false, new ElementHandler()
      {
         public void handleElement(Element partsElement)
         {
            XMLUtil.forEachChildElement(partsElement, null,
               m_helper.new ElementHandler("messagePart")
            {
               protected void handleElement(Element element, String sName)
               {
                  if (element.getNodeName().equals("Message"))
                  {
                     if (!loadMessageRef(composite, message, element, sName))
                     {
                        CompositeMessagePart part = new CompositeMessagePartInstance(sName);

                        composite.addPart(part);
                        loadCompositeMessagePart(element, part, message);
                     }
                  }
                  else if (element.getNodeName().equals("Value"))
                  {
                     final PrimitiveMessagePart part = new PrimitiveMessagePart(sName);

                     composite.addPart(part);
                     part.setType(Primitive.parse(XMLUtil.getReqStringAttr(element, "type")));
                     loadMessagePart(element, part, message);

                     XMLUtil.withFirstChildElement(element, "Enumerations", false, new ElementHandler()
                     {
                        public void handleElement(Element enumerationsElement)
                        {
                           XMLUtil.forEachChildElement(enumerationsElement, "Enumeration", new ElementHandler()
                           {
                              public void handleElement(Element enumerationElement)
                              {
                                 part.addEnumeration(XMLUtil.getReqStringAttr(enumerationElement, "value"));
                              }
View Full Code Here

TOP

Related Classes of nexj.core.util.XMLUtil.ElementHandler

Copyright © 2018 www.massapicom. 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.