package org.geotools.wms.v1_1_1.bindings;


import java.net.URL;
import java.util.Iterator;
import java.util.List;

import javax.xml.namespace.QName;

import org.geotools.data.ows.OperationType;
import org.geotools.xml.AbstractComplexBinding;
import org.geotools.xml.ElementInstance;
import org.geotools.xml.Node;

/**
 * Binding object for the type :_GetCapabilities.
 *
 * <p>
 *	<pre>
 *	 <code>
 *  &lt;xs:complexType name="_GetCapabilities"&gt;
 *      &lt;xs:sequence&gt;
 *          &lt;xs:element maxOccurs="unbounded" ref="Format"/&gt;
 *          &lt;xs:element maxOccurs="unbounded" ref="DCPType"/&gt;
 *      &lt;/xs:sequence&gt;
 *  &lt;/xs:complexType&gt; 
 *		
 *	  </code>
 *	 </pre>
 * </p>
 *
 * @generated
 */
public class _OperationTypeBinding extends AbstractComplexBinding {

	/**
	 * @generated
	 */
	public QName getTarget() {
		return WMSV1_1_1._GetCapabilities;
	}
	
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 *	
	 * @generated modifiable
	 */	
	public Class getType() {
		return OperationType.class;
	}
	
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 *	
	 * @generated modifiable
	 */	
	public Object parse(ElementInstance instance, Node node, Object value) 
		throws Exception {
		OperationType ret = new OperationType();
		ret.setFormats(node.getChildValues("Format"));
		
		Iterator dcpTypes = ((List)node.getChildValue("DCPType")).iterator();
		while (dcpTypes.hasNext()) {
			Object[] curOp = (Object[])dcpTypes.next();
			if (curOp[0].equals("Get")) {
				ret.setGet((URL)curOp[1]);
			} else if (curOp[0].equals("Post")) {
				ret.setPost((URL)curOp[1]);
			}
		}
		
		return ret;
	}

}