Package de.lessvoid.xml.lwxs.processor

Source Code of de.lessvoid.xml.lwxs.processor.TypeProcessorElement

package de.lessvoid.xml.lwxs.processor;

import de.lessvoid.xml.lwxs.elements.Element;
import de.lessvoid.xml.lwxs.elements.OccursEnum;
import de.lessvoid.xml.lwxs.elements.Type;
import de.lessvoid.xml.xpp3.Attributes;
import de.lessvoid.xml.xpp3.XmlParser;
import de.lessvoid.xml.xpp3.XmlProcessor;

public class TypeProcessorElement implements XmlProcessor {
  private Type parent;

  public TypeProcessorElement(final Type parentParam) {
    parent = parentParam;
  }

  public void process(final XmlParser xmlParser, final Attributes attributes) throws Exception {
    String name = attributes.get("name");
    if (name == null) {
      throw new Exception("[name] attribute is a required attribute");
    }
    String type = attributes.get("type");
    if (type == null) {
      throw new Exception("[type] attribute is a required attribute");
    }
    OccursEnum occures = OccursEnum.optional;
    if (attributes.get("occurs") != null) {
      occures = OccursEnum.valueOf(attributes.get("occurs"));
    }
    Element element = new Element(name, type, occures);
    parent.addElement(element);

    xmlParser.nextTag();
  }
}
TOP

Related Classes of de.lessvoid.xml.lwxs.processor.TypeProcessorElement

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.