// Path: src/net/zhuoweizhang/pocketinveditor/material/Material.java
// public class Material {
// 
// 	public static List<Material> materials;
// 
// 	public static Map<MaterialKey, Material> materialMap = new HashMap<MaterialKey, Material>();
// 
// 	private int id;
// 
// 	private String name;
// 
// 	private short damage;
// 
// 	private boolean hasSubtypes;
// 
// 	private boolean damageable = false;
// 
// 	public Material(int id, String name) {
// 		this(id, name, (short) 0, false);
// 	}
// 
// 	public Material(int id, String name, short damage) {
// 		this(id, name, damage, true);
// 	}
// 
// 	public Material(int id, String name, short damage, boolean hasSubtypes) {
// 		this.id = id;
// 		this.name = name;
// 		this.damage = damage;
// 		this.hasSubtypes = hasSubtypes;
// 	}
// 
// 	public int getId() {
// 		return id;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public short getDamage() {
// 		return damage;
// 	}
// 
// 	public boolean hasSubtypes() {
// 		return hasSubtypes;
// 	}
// 
// 	public void setDamageable(boolean damageable) {
// 		this.damageable = damageable;
// 	}
// 
// 	public boolean isDamageable() {
// 		return damageable;
// 	}
// 
// 	public String toString() {
// 		return getName() + " : " + getId() + (damage != 0 ? ":" + damage : "");
// 	}
// }
// 
// Path: src/net/zhuoweizhang/pocketinveditor/material/MaterialKey.java
// public final class MaterialKey {
// 
// 	public short typeId;
// 
// 	public short damage;
// 
// 	/**
// 	 * @param damage the damage/data value of the material. -1 is a pseudo-value that tells any replacement routines to match all data values.
// 	 */
// 	public MaterialKey(short typeId, short damage) {
// 		this.typeId = typeId;
// 		this.damage = damage;
// 	}
// 
// 	public MaterialKey(MaterialKey other) {
// 		this(other.typeId, other.damage);
// 	}
// 
// 	@Override
// 	public boolean equals(Object other) {
// 		if (other == this) return true;
// 		if (!(other instanceof MaterialKey)) return false;
// 		MaterialKey another = (MaterialKey) other;
// 		return another.typeId == this.typeId && another.damage == this.damage;
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result + typeId;
// 		result = prime * result + damage;
// 		return result;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "MaterialKey[typeId=" + typeId + ";damage=" + damage + "]";
// 	}
// 
// 	public static MaterialKey parse(String str, int radix) {
// 		String[] parts = str.split(":");
// 		if (parts.length == 0) throw new IllegalArgumentException("Why is the string blank?!");
// 		else if (parts.length == 1) {
// 			return new MaterialKey(Short.parseShort(parts[0], radix), (short) -1);
// 		} else {
// 			return new MaterialKey(Short.parseShort(parts[0], radix), Short.parseShort(parts[1], radix));
// 		}
// 	}
// }


import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import android.content.res.XmlResourceParser;
import net.zhuoweizhang.pocketinveditor.material.Material;
import net.zhuoweizhang.pocketinveditor.material.MaterialKey;
package net.zhuoweizhang.pocketinveditor.io.xml;





public final class MaterialLoader implements Runnable {

	public XmlResourceParser parser;

	public MaterialLoader(XmlResourceParser parser) {
		this.parser = parser;
	}

	public void run() {
		try {
			List<Material> materials = loadMaterials(parser);
			Material.materials = materials;
		} finally {
			parser.close();
		}
	}

	public static List<Material> loadMaterials(XmlPullParser parser) {
		List<Material> materials = new ArrayList<Material>();
		try {
			while (parser.next() != XmlPullParser.END_DOCUMENT) {
				String tagName = parser.getName();
				int itemId = 0;
				String itemName = null;
				short itemDamage = 0;
				boolean itemHasSubtypes = false;
				if (tagName != null && tagName.equals("item")) {
					int size = parser.getAttributeCount();
					for (int i = 0; i < size; i++) { 
						String attrName = parser.getAttributeName(i);
						String attrValue = parser.getAttributeValue(i);
						if (attrName == null) continue;
// Path: src/net/zhuoweizhang/pocketinveditor/material/Material.java
// public class Material {
// 
// 	public static List<Material> materials;
// 
// 	public static Map<MaterialKey, Material> materialMap = new HashMap<MaterialKey, Material>();
// 
// 	private int id;
// 
// 	private String name;
// 
// 	private short damage;
// 
// 	private boolean hasSubtypes;
// 
// 	private boolean damageable = false;
// 
// 	public Material(int id, String name) {
// 		this(id, name, (short) 0, false);
// 	}
// 
// 	public Material(int id, String name, short damage) {
// 		this(id, name, damage, true);
// 	}
// 
// 	public Material(int id, String name, short damage, boolean hasSubtypes) {
// 		this.id = id;
// 		this.name = name;
// 		this.damage = damage;
// 		this.hasSubtypes = hasSubtypes;
// 	}
// 
// 	public int getId() {
// 		return id;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public short getDamage() {
// 		return damage;
// 	}
// 
// 	public boolean hasSubtypes() {
// 		return hasSubtypes;
// 	}
// 
// 	public void setDamageable(boolean damageable) {
// 		this.damageable = damageable;
// 	}
// 
// 	public boolean isDamageable() {
// 		return damageable;
// 	}
// 
// 	public String toString() {
// 		return getName() + " : " + getId() + (damage != 0 ? ":" + damage : "");
// 	}
// }
// 
// Path: src/net/zhuoweizhang/pocketinveditor/material/MaterialKey.java
// public final class MaterialKey {
// 
// 	public short typeId;
// 
// 	public short damage;
// 
// 	/**
// 	 * @param damage the damage/data value of the material. -1 is a pseudo-value that tells any replacement routines to match all data values.
// 	 */
// 	public MaterialKey(short typeId, short damage) {
// 		this.typeId = typeId;
// 		this.damage = damage;
// 	}
// 
// 	public MaterialKey(MaterialKey other) {
// 		this(other.typeId, other.damage);
// 	}
// 
// 	@Override
// 	public boolean equals(Object other) {
// 		if (other == this) return true;
// 		if (!(other instanceof MaterialKey)) return false;
// 		MaterialKey another = (MaterialKey) other;
// 		return another.typeId == this.typeId && another.damage == this.damage;
// 	}
// 
// 	@Override
// 	public int hashCode() {
// 		final int prime = 31;
// 		int result = 1;
// 		result = prime * result + typeId;
// 		result = prime * result + damage;
// 		return result;
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return "MaterialKey[typeId=" + typeId + ";damage=" + damage + "]";
// 	}
// 
// 	public static MaterialKey parse(String str, int radix) {
// 		String[] parts = str.split(":");
// 		if (parts.length == 0) throw new IllegalArgumentException("Why is the string blank?!");
// 		else if (parts.length == 1) {
// 			return new MaterialKey(Short.parseShort(parts[0], radix), (short) -1);
// 		} else {
// 			return new MaterialKey(Short.parseShort(parts[0], radix), Short.parseShort(parts[1], radix));
// 		}
// 	}
// }


// Path: src/net/zhuoweizhang/pocketinveditor/io/xml/MaterialLoader.java
import java.util.ArrayList;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import android.content.res.XmlResourceParser;
import net.zhuoweizhang.pocketinveditor.material.Material;
import net.zhuoweizhang.pocketinveditor.material.MaterialKey;

package net.zhuoweizhang.pocketinveditor.io.xml;





public final class MaterialLoader implements Runnable {

	public XmlResourceParser parser;

	public MaterialLoader(XmlResourceParser parser) {
		this.parser = parser;
	}

	public void run() {
		try {
			List<Material> materials = loadMaterials(parser);
			Material.materials = materials;
		} finally {
			parser.close();
		}
	}

	public static List<Material> loadMaterials(XmlPullParser parser) {
		List<Material> materials = new ArrayList<Material>();
		try {
			while (parser.next() != XmlPullParser.END_DOCUMENT) {
				String tagName = parser.getName();
				int itemId = 0;
				String itemName = null;
				short itemDamage = 0;
				boolean itemHasSubtypes = false;
				if (tagName != null && tagName.equals("item")) {
					int size = parser.getAttributeCount();
					for (int i = 0; i < size; i++) { 
						String attrName = parser.getAttributeName(i);
						String attrValue = parser.getAttributeValue(i);
						if (attrName == null) continue;
						if (attrName.equals("dec")) {