Package org.jbpm.pvm.internal.wire.descriptor

Examples of org.jbpm.pvm.internal.wire.descriptor.MapDescriptor


  public MapBinding() {
    super("map");
  }

  public Object parse(Element element, Parse parse, Parser parser) {
    MapDescriptor descriptor = new MapDescriptor();
    String className = XmlUtil.attribute(element,"class");
    if (AbstractCollectionBinding.verify(className, Map.class, parse, parser)) {
      descriptor.setClassName(className);
    }
   
    Boolean isSynchronized = XmlUtil.attributeBoolean(element, "synchronized", false, parse);
    if (isSynchronized!=null) {
      descriptor.setSynchronized(isSynchronized.booleanValue());
    }

    List<Descriptor> keyDescriptors = new ArrayList<Descriptor>();
    List<Descriptor> valueDescriptors = new ArrayList<Descriptor>();
    List<Element> elements = XmlUtil.elements(element);
    for (Element entryElement: elements) {
      if ("entry".equals(XmlUtil.getTagLocalName(entryElement))) {
        // key
        Element keyElement = XmlUtil.element(entryElement, "key");
        Element keyDescriptorElement = (keyElement!=null ? XmlUtil.element(keyElement) : null);
        Descriptor keyDescriptor = (Descriptor) parser.parseElement(keyDescriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);
        // value
        Element valueElement = XmlUtil.element(entryElement, "value");
        Element valueDescriptorElement = (valueElement!=null ? XmlUtil.element(valueElement) : null);
        Descriptor valueDescriptor = (Descriptor) parser.parseElement(valueDescriptorElement, parse, WireParser.CATEGORY_DESCRIPTOR);

        if ( (keyDescriptor!=null)
             && (valueDescriptor!=null)
           ) {
          keyDescriptors.add(keyDescriptor);
          valueDescriptors.add(valueDescriptor);
        } else {
          parse.addProblem("entry must have key and value element with a single descriptor as contents: "+XmlUtil.toString(entryElement), element);
        }
      } else {
        parse.addProblem("map can only contain entry elements: "+XmlUtil.toString(entryElement));
      }
    }

    descriptor.setKeyDescriptors(keyDescriptors);
    descriptor.setValueDescriptors(valueDescriptors);
    return descriptor;
  }
View Full Code Here

TOP

Related Classes of org.jbpm.pvm.internal.wire.descriptor.MapDescriptor

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.