package org.geotools.wms.v1_1_1.bindings;


import java.util.HashSet;
import java.util.Map;

import javax.xml.namespace.QName;

import org.geotools.metadata.iso.citation.ContactImpl;
import org.geotools.metadata.iso.citation.ResponsiblePartyImpl;
import org.geotools.metadata.iso.citation.TelephoneImpl;
import org.geotools.util.SimpleInternationalString;
import org.geotools.xml.AbstractComplexBinding;
import org.geotools.xml.ElementInstance;
import org.geotools.xml.Node;
import org.opengis.metadata.citation.Address;

/**
 * Binding object for the type :_ContactInformation.
 *
 * <p>
 *	<pre>
 *	 <code>
 *  &lt;xs:complexType name="_ContactInformation"&gt;
 *      &lt;xs:sequence&gt;
 *          &lt;xs:element minOccurs="0" ref="ContactPersonPrimary"/&gt;
 *          &lt;xs:element minOccurs="0" ref="ContactPosition"/&gt;
 *          &lt;xs:element minOccurs="0" ref="ContactAddress"/&gt;
 *          &lt;xs:element minOccurs="0" ref="ContactVoiceTelephone"/&gt;
 *          &lt;xs:element minOccurs="0" ref="ContactFacsimileTelephone"/&gt;
 *          &lt;xs:element minOccurs="0" ref="ContactElectronicMailAddress"/&gt;
 *      &lt;/xs:sequence&gt;
 *  &lt;/xs:complexType&gt; 
 *		
 *	  </code>
 *	 </pre>
 * </p>
 *
 * @generated
 */
public class _ContactInformationBinding extends AbstractComplexBinding {

	/**
	 * @generated
	 */
	public QName getTarget() {
		return WMSV1_1_1._ContactInformation;
	}
	
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 *	
	 * @generated modifiable
	 */	
	public Class getType() {
		return ResponsiblePartyImpl.class;
	}
	
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 *	
	 * @generated modifiable
	 */	
	public Object parse(ElementInstance instance, Node node, Object value) 
		throws Exception {
		ResponsiblePartyImpl ret = new ResponsiblePartyImpl();
		
		ContactImpl contactInfo = new ContactImpl();
		contactInfo.setAddress((Address)node.getChildValue("ContactAddress"));
		contactInfo.getAddress().getElectronicMailAddresses().add((String)node.getChildValue("ContactElectronicMailAddress"));
		
		TelephoneImpl tel = new TelephoneImpl();
		tel.setVoices(new HashSet());
		tel.getVoices().add(node.getChildValue("ContactVoiceTelephone"));
		tel.setFacsimiles(new HashSet());
		tel.getFacsimiles().add(node.getChildValue("ContactFacsimileTelephone"));
		
		contactInfo.setPhone(tel);
		ret.setContactInfo(contactInfo);
		
		Map cppInfo = (Map)node.getChildValue("ContactPersonPrimary");
		ret.setIndividualName((String)cppInfo.get("ContactPerson"));
		ret.setOrganisationName(new SimpleInternationalString((String)cppInfo.get("ContactOrganization")));
		ret.setPositionName(new SimpleInternationalString((String)node.getChildValue("ContactPosition")));
		
		return ret;
		
	}

}