// Path: cdi/src/main/java/org/onsteroids/eve/api/InternalApiException.java
// public final class InternalApiException extends ApiException {
// 	private static final Logger LOG = LoggerFactory.getLogger(InternalApiException.class);
// 
// 	public InternalApiException(String message) {
// 		super(message);
// 	}
// 
// 	public InternalApiException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public InternalApiException(Throwable cause) {
// 		super(cause);
// 	}
// }
// 
// Path: cdi/src/main/java/org/onsteroids/eve/api/XmlUtility.java
// public final class XmlUtility {
// 	private static final Logger LOG = LoggerFactory.getLogger(XmlUtility.class);
// 
// 	private Node node;
// 
// 	public XmlUtility(Node node) {
// 		this.node = Preconditions.checkNotNull(node, "Node");
// 	}
// 
// 
// 	public Node getNodeByName(String name) {
// 		return getNodeByName(name, node);
// 	}
// 
// 	public static Node getNodeByName(String name, Node parent) {
// 		Preconditions.checkNotNull(name, "Name");
// 		Preconditions.checkNotNull(parent, "Parent");
// 		NodeList list = parent.getChildNodes();
// 		for (int n = 0; n < list.getLength(); n++) {
// 			Node node = list.item(n);
// 			if (name.equals(node.getNodeName())) {
// 				return node;
// 			}
// 		}
// 		throw new IllegalArgumentException("Node " + name + " not found");
// 	}
// 
// 
// 	public boolean hasNodeWithName(String name) {
// 		return hasNodeWithName(name, node);
// 	}
// 
// 	public static boolean hasNodeWithName(String name, Node parent) {
// 		Preconditions.checkNotNull(name, "Name");
// 		Preconditions.checkNotNull(parent, "Parent");
// 		NodeList list = parent.getChildNodes();
// 		for (int n = 0; n < list.getLength(); n++) {
// 			Node node = list.item(n);
// 			if (name.equals(node.getNodeName())) {
// 				return true;
// 			}
// 		}
// 		return false;
// 	}
// 
// 
// 	public List<Node> getNodesByName(String name) {
// 		return getNodesByName(name, node);
// 	}
// 
// 	public static List<Node> getNodesByName(String name, Node parent) {
// 		Preconditions.checkNotNull(name, "Name");
// 		Preconditions.checkNotNull(parent, "Parent");
// 		List<Node> nodes = Lists.newArrayList();
// 		NodeList list = parent.getChildNodes();
// 		for (int n = 0; n < list.getLength(); n++) {
// 			Node node = list.item(n);
// 			if (name.equals(node.getNodeName())) {
// 				nodes.add(node);
// 			}
// 		}
// 		return nodes;
// 	}
// 
// 
// 	public String getContentOf(String nodeName) {
// 		return getContentOf(nodeName, node);
// 	}
// 
// 	public static String getContentOf(String nodeName, Node node) {
// 		Preconditions.checkNotNull(nodeName, "nodeName");
// 		Preconditions.checkNotNull(node, "node");
// 		return getNodeByName(nodeName, node).getTextContent();
// 	}
// 
// 
// 	public String getAttribute(String name) {
// 		return getAttribute(name, node);
// 	}
// 
// 	public static String getAttribute(String name, Node node) {
// 		Preconditions.checkNotNull(name, "Name");
// 		Preconditions.checkNotNull(node, "Node");
// 		Preconditions.checkNotNull(node.getAttributes().getNamedItem(name), "Attribute not found: " + name);
// 		return node.getAttributes().getNamedItem(name).getTextContent();
// 	}
// }
// 
// Path: cdi/src/main/java/org/onsteroids/eve/api/connector/XmlApiResult.java
// public interface XmlApiResult extends ApiResult {
// 
// 	/**
// 	 * @return returns the &lt;result&gt; node of the api response
// 	 */
// 	Node getResult();
//         
//     /**
//      * getTimeDifference = serverTime - localTime
//      *
//      * @return the time difference from server to local in milliseconds
//      */
//     long getTimeDifference();
// 
// }


import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import com.eveonline.api.ApiListResult;
import com.eveonline.api.exceptions.ApiException;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.onsteroids.eve.api.InternalApiException;
import org.onsteroids.eve.api.XmlUtility;
import org.onsteroids.eve.api.connector.XmlApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
/**
 * Copyright 2010 Tobias Sarnowski
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * (c) 2010 Tobias Sarnowski
 * All rights reserved.
 */
package org.onsteroids.eve.api.provider;



/**
 * @author Tobias Sarnowski
 */
public abstract class SerializableApiListResult<S extends SerializableApiResult> extends SerializableApiResult implements ApiListResult<S> {
	// because java doesn't support multi inheritance we have to choose between SerializableApiResult and ForwardingList
	// from google collections. We want to be immutable and using all features of ApiResult which can change quite often
	// so we implement the forwarding, immutable list ourself.

	private static final Logger LOG = LoggerFactory.getLogger(SerializableApiListResult.class);

	private List<S> results;


	public SerializableApiListResult() {
	}

// Path: cdi/src/main/java/org/onsteroids/eve/api/InternalApiException.java
// public final class InternalApiException extends ApiException {
// 	private static final Logger LOG = LoggerFactory.getLogger(InternalApiException.class);
// 
// 	public InternalApiException(String message) {
// 		super(message);
// 	}
// 
// 	public InternalApiException(String message, Throwable cause) {
// 		super(message, cause);
// 	}
// 
// 	public InternalApiException(Throwable cause) {
// 		super(cause);
// 	}
// }
// 
// Path: cdi/src/main/java/org/onsteroids/eve/api/XmlUtility.java
// public final class XmlUtility {
// 	private static final Logger LOG = LoggerFactory.getLogger(XmlUtility.class);
// 
// 	private Node node;
// 
// 	public XmlUtility(Node node) {
// 		this.node = Preconditions.checkNotNull(node, "Node");
// 	}
// 
// 
// 	public Node getNodeByName(String name) {
// 		return getNodeByName(name, node);
// 	}
// 
// 	public static Node getNodeByName(String name, Node parent) {
// 		Preconditions.checkNotNull(name, "Name");
// 		Preconditions.checkNotNull(parent, "Parent");
// 		NodeList list = parent.getChildNodes();
// 		for (int n = 0; n < list.getLength(); n++) {
// 			Node node = list.item(n);
// 			if (name.equals(node.getNodeName())) {
// 				return node;
// 			}
// 		}
// 		throw new IllegalArgumentException("Node " + name + " not found");
// 	}
// 
// 
// 	public boolean hasNodeWithName(String name) {
// 		return hasNodeWithName(name, node);
// 	}
// 
// 	public static boolean hasNodeWithName(String name, Node parent) {
// 		Preconditions.checkNotNull(name, "Name");
// 		Preconditions.checkNotNull(parent, "Parent");
// 		NodeList list = parent.getChildNodes();
// 		for (int n = 0; n < list.getLength(); n++) {
// 			Node node = list.item(n);
// 			if (name.equals(node.getNodeName())) {
// 				return true;
// 			}
// 		}
// 		return false;
// 	}
// 
// 
// 	public List<Node> getNodesByName(String name) {
// 		return getNodesByName(name, node);
// 	}
// 
// 	public static List<Node> getNodesByName(String name, Node parent) {
// 		Preconditions.checkNotNull(name, "Name");
// 		Preconditions.checkNotNull(parent, "Parent");
// 		List<Node> nodes = Lists.newArrayList();
// 		NodeList list = parent.getChildNodes();
// 		for (int n = 0; n < list.getLength(); n++) {
// 			Node node = list.item(n);
// 			if (name.equals(node.getNodeName())) {
// 				nodes.add(node);
// 			}
// 		}
// 		return nodes;
// 	}
// 
// 
// 	public String getContentOf(String nodeName) {
// 		return getContentOf(nodeName, node);
// 	}
// 
// 	public static String getContentOf(String nodeName, Node node) {
// 		Preconditions.checkNotNull(nodeName, "nodeName");
// 		Preconditions.checkNotNull(node, "node");
// 		return getNodeByName(nodeName, node).getTextContent();
// 	}
// 
// 
// 	public String getAttribute(String name) {
// 		return getAttribute(name, node);
// 	}
// 
// 	public static String getAttribute(String name, Node node) {
// 		Preconditions.checkNotNull(name, "Name");
// 		Preconditions.checkNotNull(node, "Node");
// 		Preconditions.checkNotNull(node.getAttributes().getNamedItem(name), "Attribute not found: " + name);
// 		return node.getAttributes().getNamedItem(name).getTextContent();
// 	}
// }
// 
// Path: cdi/src/main/java/org/onsteroids/eve/api/connector/XmlApiResult.java
// public interface XmlApiResult extends ApiResult {
// 
// 	/**
// 	 * @return returns the &lt;result&gt; node of the api response
// 	 */
// 	Node getResult();
//         
//     /**
//      * getTimeDifference = serverTime - localTime
//      *
//      * @return the time difference from server to local in milliseconds
//      */
//     long getTimeDifference();
// 
// }


// Path: cdi/src/main/java/org/onsteroids/eve/api/provider/SerializableApiListResult.java
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import com.eveonline.api.ApiListResult;
import com.eveonline.api.exceptions.ApiException;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.onsteroids.eve.api.InternalApiException;
import org.onsteroids.eve.api.XmlUtility;
import org.onsteroids.eve.api.connector.XmlApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;

/**
 * Copyright 2010 Tobias Sarnowski
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * (c) 2010 Tobias Sarnowski
 * All rights reserved.
 */
package org.onsteroids.eve.api.provider;



/**
 * @author Tobias Sarnowski
 */
public abstract class SerializableApiListResult<S extends SerializableApiResult> extends SerializableApiResult implements ApiListResult<S> {
	// because java doesn't support multi inheritance we have to choose between SerializableApiResult and ForwardingList
	// from google collections. We want to be immutable and using all features of ApiResult which can change quite often
	// so we implement the forwarding, immutable list ourself.

	private static final Logger LOG = LoggerFactory.getLogger(SerializableApiListResult.class);

	private List<S> results;


	public SerializableApiListResult() {
	}

	public SerializableApiListResult(XmlApiResult xmlApiResult, Node xmlResult) throws ApiException {