All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.spun.util.io.xml.XmlMapExtractor Maven / Gradle / Ivy

There is a newer version: 24.9.0
Show newest version
package com.spun.util.io.xml;

import com.spun.util.ClassUtils;
import com.spun.util.ObjectUtils;
import org.w3c.dom.Node;

public class XmlMapExtractor implements XmlExtractor
{
  private Class      clazz;
  private XmlTranslator translator;
  public XmlMapExtractor(XmlMap[] xmlMaps, Class clazz)
  {
    this.clazz = clazz;
    this.translator = XmlMapTranslator.get(clazz, xmlMaps);
  }
  public XmlMapExtractor(Class clazz)
  {
    this(ClassUtils.create(clazz).getXmlMap(), clazz);
  }
  public Object extractObjectForNode(Node node)
  {
    try
    {
      Object object = ClassUtils.create(clazz);
      XmlExtractorUtil.extractAndTranslateForNode(node, object, translator);
      return object;
    }
    catch (Exception e)
    {
      throw ObjectUtils.throwAsError(e);
    }
  }
  public String toString()
  {
    return ClassUtils.getClassName(clazz) + ".extractor";
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy