/**
 * BIN.java
 * <p>
 * File generated from the datatypes::BIN uml Class
 * Generated by IHE - europe, gazelle team
 */
package net.ihe.gazelle.hl7v3.datatypes;

import java.util.ArrayList;
import java.util.List;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlTransient;
import jakarta.xml.bind.annotation.XmlType;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import net.ihe.gazelle.gen.common.ConstraintValidatorModule;

import org.w3c.dom.Document;
import org.w3c.dom.Node;

/**
 * Description of the class BIN.
 *
 * 
 */

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "BIN", propOrder = { "representation" })
@XmlRootElement(name = "BIN")
public abstract class BIN extends ANY {

	/**
	 * 
	 Specifies the representation of the binary data that is the content of the binary data value. .
	 */
	@XmlAttribute(name = "representation")
	public net.ihe.gazelle.hl7v3.datatypes.BinaryDataEncoding representation;

	/**
	 * An attribute containing marshalled element node
	 */
	@XmlTransient
	private org.w3c.dom.Node _xmlNodePresentation;

	/**
	 * Return mixed.
	 * 
	 * @return mixed
	 */
	public List<java.io.Serializable> getMixed() {
		if (mixed == null) {
			mixed = new ArrayList<>();
		}
		return mixed;
	}

	/**
	 * Set a value to attribute mixed.
	 * 
	 * @param mixed
	 *            .
	 */
	public void setMixed(List<java.io.Serializable> mixed) {
		this.mixed = mixed;
	}

	/**
	 * Add a mixed to the mixed collection.
	 * 
	 * @param mixed_elt
	 *            Element to add.
	 */
	public void addMixed(java.io.Serializable mixed_elt) {
		if (this.mixed == null) {
			mixed = new ArrayList<>();
		}
		this.mixed.add(mixed_elt);
	}

	/**
	 * Remove a mixed to the mixed collection.
	 * 
	 * @param mixed_elt
	 *            Element to remove
	 */
	public void removeMixed(java.io.Serializable mixed_elt) {
		if (this.mixed != null) {
			this.mixed.remove(mixed_elt);
		}
	}

	/**
	 * Return representation.
	 * 
	 * @return representation : Specifies the representation of the binary data that is the content of the binary data value.
	 */
	public net.ihe.gazelle.hl7v3.datatypes.BinaryDataEncoding getRepresentation() {
		return representation;
	}

	/**
	 * Set a value to attribute representation.
	 * 
	 * @param representation
	 *            : Specifies the representation of the binary data that is the content of the binary data value.
	 */
	public void setRepresentation(net.ihe.gazelle.hl7v3.datatypes.BinaryDataEncoding representation) {
		this.representation = representation;
	}

	public Node get_xmlNodePresentation() {
		if (_xmlNodePresentation == null) {
			JAXBContext jc;
			DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
			dbf.setNamespaceAware(true);
			DocumentBuilder db = null;
			Document doc = null;
			try {
				db = dbf.newDocumentBuilder();
				doc = db.newDocument();
			} catch (ParserConfigurationException ignored) {
			}
			try {
				jc = JAXBContext.newInstance("net.ihe.gazelle.hl7v3.datatypes");
				Marshaller m = jc.createMarshaller();
				m.marshal(this, doc);
				_xmlNodePresentation = doc.getElementsByTagNameNS("urn:hl7-org:v3", "BIN").item(0);
			} catch (JAXBException e) {
				try {
					db = dbf.newDocumentBuilder();
					_xmlNodePresentation = db.newDocument();
				} catch (Exception ignored) {
				}
			}
		}
		return _xmlNodePresentation;
	}

	public void set_xmlNodePresentation(Node _xmlNodePresentation) {
		this._xmlNodePresentation = _xmlNodePresentation;
	}

	public List<String> getListStringValues() {
		List<String> res = new ArrayList<>();
		for (java.io.Serializable obj : this.getMixed()) {
			if (obj instanceof String) {
				res.add((String) obj);
			}
		}
		return res;
	}

	/**
	 * validate by a module of validation
	 * 
	 */
	public static void validateByModule(BIN bIN, String _location, ConstraintValidatorModule cvm,
			List<net.ihe.gazelle.validation.Notification> diagnostic) {
		cvm.validate(bIN, _location, diagnostic);
		if (bIN != null) {
			// net.ihe.gazelle.hl7v3.datatypes.ANY.validateByModule(bIN, _location, cvm, diagnostic);
		}
	}

}