Code example for Attributes

Methods: getIndex, getValue

0
				throw new SAXException("Parse Error: Only one \"level\" tag allowed per level file!");
			} 
		} else if (TAG_NAME.equals(qName) || TAG_DIFFICULTY.equals(qName) || TAG_AUTHOR.equals(qName) || TAG_DATA.equals(qName)) {
			// Don't care here 
		} else if (Data.TAG_LIGHTSOURCE.equals(qName)) {
			if (as.getIndex("x") != -1 && as.getIndex("y") != -1 && as.getIndex("rot") != -1 && as.getIndex("color") != -1) {
				float x = Float.parseFloat(as.getValue("x"));
				float y = Float.parseFloat(as.getValue("y"));
				boolean moveable = as.getIndex("moveable") != -1 ? Boolean.parseBoolean(as.getValue("moveable")) : false;
				boolean rotatable = as.getIndex("rotatable") != -1 ? Boolean.parseBoolean(as.getValue("rotatable")) : true;
				float initialRotation = Float.parseFloat(as.getValue("rot"));
				int color = Color.parseColor(as.getValue("color"));
				curObject = new LightSource(x, y, moveable, rotatable, initialRotation, color);
			} else { 
				throw new SAXException("Parse Error: Required attributes missing for tag \"" + qName + "\".");
			} 
		} else if (Data.TAG_LIGHTTARGET.equals(qName)) {
			if (as.getIndex("x") != -1 && as.getIndex("y") != -1 && as.getIndex("size") != -1) {
				float x = Float.parseFloat(as.getValue("x"));
				float y = Float.parseFloat(as.getValue("y"));
				float size = Float.parseFloat(as.getValue("size"));
				boolean transparent = Boolean.parseBoolean(as.getValue("transparent"));
				curObject = new LightTarget(x, y, size, transparent);
			} else { 
				throw new SAXException("Parse Error: Required attributes missing for tag \"" + qName + "\".");
			} 
		} else if (Data.TAG_MIRROR.equals(qName)) {
			if (as.getIndex("x") != -1 && as.getIndex("y") != -1 && as.getIndex("rot") != -1 && as.getIndex("size") != -1) {
				float x = Float.parseFloat(as.getValue("x"));
				float y = Float.parseFloat(as.getValue("y"));
				boolean moveable = as.getIndex("moveable") != -1 ? Boolean.parseBoolean(as.getValue("moveable")) : false;
				boolean rotatable = as.getIndex("rotatable") != -1 ? Boolean.parseBoolean(as.getValue("rotatable")) : true;
				float initialRotation = Float.parseFloat(as.getValue("rot"));
				float length = Float.parseFloat(as.getValue("size"));
				curObject = new Mirror(x, y, moveable, rotatable, initialRotation, length);
			} else { 
				throw new SAXException("Parse Error: Required attributes missing for tag \"" + qName + "\".");
			} 
		} else if (Data.TAG_WALL.equals(qName)) {