package com.ejie.ab61.comun.utilidades;

import java.util.HashMap;

import com.bea.xml.XmlOptions;

/**
 * 
 *  
 * 
 */
public class UtilXML {

	/**
	 * Contructor
	 */
	private UtilXML() {

	}

	/**
	 * @return XmlOptions
	 */
	public static XmlOptions getXmlOptions() {
		return UtilXML.getXmlOptions("com/ejie/r02r/xml");
	}

	/**
	 * 
	 * @param saveOuter
	 *            boolean
	 * @return XmlOptions
	 */
	public static XmlOptions getXmlOptions(boolean saveOuter) {
		return UtilXML.getXmlOptions("com/ejie/r02r/xml", saveOuter);
	}

	/**
	 * 
	 * @param namespace
	 *            name
	 * @return XmlOptions
	 */
	public static XmlOptions getXmlOptions(String namespace) {
		return UtilXML.getXmlOptions(namespace, true);
	}

	/**
	 * 
	 * @param namespace
	 *            name
	 * @param saveOuter
	 *            boolean
	 * @return XmlOptions
	 */
	public static XmlOptions getXmlOptions(String namespace, boolean saveOuter) {
		XmlOptions xmlOptions = new XmlOptions();
		HashMap<String, String> namespaceMap = new HashMap<String, String>();
		namespaceMap.put("", namespace);
		xmlOptions.setLoadTrimTextBuffer();
		xmlOptions.setValidateOnSet();
		xmlOptions.setUseDefaultNamespace();
		xmlOptions.setLoadSubstituteNamespaces(namespaceMap);
		if (saveOuter) {
			xmlOptions.setSaveOuter();
		}
		return xmlOptions;
	}
}
