当前位置: 首页>>代码示例>>Java>>正文


Java DataConversionException.printStackTrace方法代码示例

本文整理汇总了Java中org.jdom2.DataConversionException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java DataConversionException.printStackTrace方法的具体用法?Java DataConversionException.printStackTrace怎么用?Java DataConversionException.printStackTrace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdom2.DataConversionException的用法示例。


在下文中一共展示了DataConversionException.printStackTrace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNodes

import org.jdom2.DataConversionException; //导入方法依赖的package包/类
private static Map<Integer, GeoNode> getNodes(Document doc) {
	Map<Integer, GeoNode> nList = new HashMap<Integer, GeoNode>();

	XPathFactory xFactory = XPathFactory.instance();
	XPathExpression<Element> exprElement = xFactory.compile(
			"/osm/node[@id and @lat and @lon]", Filters.element());
	List<Element> nodesEle = exprElement.evaluate(doc);
	for (Element nele : nodesEle) {

		GeoNode n = null;
		try {
			int id = nele.getAttribute("id").getIntValue();
			double lat = nele.getAttribute("lat").getDoubleValue();
			double lon = nele.getAttribute("lon").getDoubleValue();
			n = new GeoNode(id, lat, lon, 0);
		} catch (DataConversionException e) {
			e.printStackTrace();
		}
		nList.put(n.id, n);
	}

	return nList;
}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:24,代码来源:CarPark.java

示例2: getNodes

import org.jdom2.DataConversionException; //导入方法依赖的package包/类
public static Map<Integer, GeoNode> getNodes(Document doc) {
	Map<Integer, GeoNode> nList = new HashMap<Integer, GeoNode>();

	XPathFactory xFactory = XPathFactory.instance();
	XPathExpression<Element> exprElement = xFactory.compile(
			"/osm/node[@id and @lat and @lon]", Filters.element());
	List<Element> nodesEle = exprElement.evaluate(doc);
	for (Element nele : nodesEle) {

		GeoNode n = null;
		try {
			int id = nele.getAttribute("id").getIntValue();
			double lat = nele.getAttribute("lat").getDoubleValue();
			double lon = nele.getAttribute("lon").getDoubleValue();
			n = new GeoNode(id, lat, lon, 0);
		} catch (DataConversionException e) {
			e.printStackTrace();
		}
		nList.put(n.id, n);
	}

	return nList;
}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:24,代码来源:CarParkGraph.java

示例3: SpriteSheet

import org.jdom2.DataConversionException; //导入方法依赖的package包/类
public SpriteSheet(String location) {
    Document document = GameResourceLoader.loadXML("res/textures/"+location+".xml");
    sheetImg = GameResourceLoader.loadTextureLinear(location+".png");
    Element root = document.getRootElement();
    try {
        for (Object spriteObject : root.getChildren()){
            Element spriteElement = (Element) spriteObject;
            String name = spriteElement.getAttributeValue("n");

            int x = spriteElement.getAttribute("x").getIntValue();
            int y = spriteElement.getAttribute("y").getIntValue();
            int w = spriteElement.getAttribute("w").getIntValue();
            int h = spriteElement.getAttribute("h").getIntValue();

            sprites.put(name, new Sprite(x, y, w, h));

        }
    } catch (DataConversionException e) {
        e.printStackTrace();
    }
}
 
开发者ID:Piratkopia13,项目名称:Pixel-Planet,代码行数:22,代码来源:SpriteSheet.java

示例4: getAttributeValueAsInt

import org.jdom2.DataConversionException; //导入方法依赖的package包/类
/**
 * Returns the integer value of the attribute from the element.
 *
 * @param element
 *            the element from which the attribute is to be read
 *
 * @param attributeName
 *            the attribute name
 *
 * @return the value of the attribute
 *
 * @throws IllegalArgumentException
 *             if <code>element</code> or <code>attributeName</code> are
 *             null
 */
public static int getAttributeValueAsInt(Element element, String attributeName) {
	if(element == null) {
		throw new IllegalArgumentException("Element cannot be null");
	}

	if(AssertUtils.isEmpty(attributeName)) {
		throw new IllegalArgumentException("Attribute name cannot be null/empty");
	}

	Attribute attribute = element.getAttribute(attributeName);
	if(attribute != null) {
		try {
			return attribute.getIntValue();
		} catch (DataConversionException e) {
			e.printStackTrace();
		}
	}

	return 0;
}
 
开发者ID:sangupta,项目名称:jerry-core,代码行数:36,代码来源:DomUtils.java

示例5: setup

import org.jdom2.DataConversionException; //导入方法依赖的package包/类
private void setup(Element root) {
    Attribute enabled = root.getAttribute("enabled");
    if (enabled != null) {
        try {
            this.enabled = enabled.getBooleanValue();
        } catch (DataConversionException ex) {
            ex.printStackTrace();
        }
    }
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:11,代码来源:Settings.java

示例6: getWays

import org.jdom2.DataConversionException; //导入方法依赖的package包/类
private static Map<Integer, Way> getWays(Document doc,
		Map<Integer, GeoNode> nodes) {
	Map<Integer, Way> ways = new HashMap<Integer, Way>();

	XPathFactory xFactory = XPathFactory.instance();
	XPathExpression<Element> expway = xFactory.compile(
			"/osm/way[tag/@k='highway' and tag/@v='service']",
			Filters.element());
	XPathExpression<Element> exponeway = xFactory.compile(
			"tag[@k='oneway' and tag/@v='yes']", Filters.element());
	XPathExpression<Attribute> expnd = xFactory.compile("nd/@ref",
			Filters.attribute());

	List<Element> waysEle = expway.evaluate(doc);
	for (Element wayEle : waysEle) {

		try {
			Element oneway = exponeway.evaluateFirst(wayEle);
			int wayId = wayEle.getAttribute("id").getIntValue();
			List<Attribute> ndAttrs = expnd.evaluate(wayEle);
			List<GeoNode> _ns = new LinkedList<GeoNode>();
			for (Attribute ndAttr : ndAttrs) {
				GeoNode _n = nodes.get(ndAttr.getIntValue());
				_ns.add(_n);
			}
			Way way = new Way(wayId, _ns, oneway != null);
			ways.put(wayId, way);
		} catch (DataConversionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	return ways;

}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:38,代码来源:CarPark.java

示例7: getWays

import org.jdom2.DataConversionException; //导入方法依赖的package包/类
public static Map<Integer, Way> getWays(Document doc,
		Map<Integer, GeoNode> nodes) {
	Map<Integer, Way> ways = new HashMap<Integer, Way>();

	XPathFactory xFactory = XPathFactory.instance();
	XPathExpression<Element> expway = xFactory.compile(
			"/osm/way[tag/@k='highway' and tag/@v='service']",
			Filters.element());
	XPathExpression<Element> exponeway = xFactory.compile(
			"tag[@k='oneway' and tag/@v='yes']", Filters.element());
	XPathExpression<Attribute> expnd = xFactory.compile("nd/@ref",
			Filters.attribute());

	List<Element> waysEle = expway.evaluate(doc);
	for (Element wayEle : waysEle) {

		try {
			Element oneway = exponeway.evaluateFirst(wayEle);
			int wayId = wayEle.getAttribute("id").getIntValue();
			List<Attribute> ndAttrs = expnd.evaluate(wayEle);
			List<GeoNode> _ns = new LinkedList<GeoNode>();
			for (Attribute ndAttr : ndAttrs) {
				GeoNode _n = nodes.get(ndAttr.getIntValue());
				_ns.add(_n);
			}
			Way way = new Way(wayId, _ns, oneway != null);
			ways.put(wayId, way);
		} catch (DataConversionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	return ways;

}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:38,代码来源:CarParkGraph.java

示例8: getStoreies

import org.jdom2.DataConversionException; //导入方法依赖的package包/类
private static List<Storey> getStoreies(Document doc, Map<Integer, Way> ways) {
	List<Storey> storeies = new LinkedList<Storey>();
	XPathFactory xFactory = XPathFactory.instance();
	XPathExpression<Element> exprElement = xFactory.compile("/osm/relation"
			+ "[@id]" + "[tag/@k='ele']" + "[tag/@k='image']",
			Filters.element());

	XPathExpression<Attribute> expname = xFactory.compile(
			"tag[@k='name']/@v", Filters.attribute());
	XPathExpression<Attribute> expele = xFactory.compile(
			"tag[@k='ele']/@v", Filters.attribute());
	XPathExpression<Attribute> expimg = xFactory.compile(
			"tag[@k='image']/@v", Filters.attribute());
	XPathExpression<Attribute> expul = xFactory.compile(
			"tag[@k='upperleft']/@v", Filters.attribute());
	XPathExpression<Attribute> explr = xFactory.compile(
			"tag[@k='lowerright']/@v", Filters.attribute());
	XPathExpression<Attribute> expmem = xFactory.compile("member/@ref",
			Filters.attribute());

	List<Element> rEles = exprElement.evaluate(doc);
	for (Element rel : rEles) {
		try {
			double ele = expele.evaluateFirst(rel).getDoubleValue();
			String name = expname.evaluateFirst(rel).getValue();
			String image = expimg.evaluateFirst(rel).getValue();
			String[] ul = expul.evaluateFirst(rel).getValue().split(",");
			String[] lr = explr.evaluateFirst(rel).getValue().split(",");
			List<Attribute> mAttrs = expmem.evaluate(rel);
			double[] upperleft = new double[] { Double.parseDouble(ul[0]),
					Double.parseDouble(ul[1]) };
			double[] lowerright = new double[] { Double.parseDouble(lr[0]),
					Double.parseDouble(lr[1]) };

			List<Way> ws = new LinkedList<Way>();
			for (Attribute m : mAttrs) {
				Way w = ways.get(m.getIntValue());
				ws.add(w);
			}

			Storey storey = new Storey(name, image, upperleft, lowerright,
					ele, ws);
			storeies.add(storey);
		} catch (DataConversionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	return storeies;

}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:53,代码来源:CarPark.java

示例9: getStoreies

import org.jdom2.DataConversionException; //导入方法依赖的package包/类
public static List<Storey> getStoreies(Document doc, Map<Integer, Way> ways) {
	List<Storey> storeies = new LinkedList<Storey>();
	XPathFactory xFactory = XPathFactory.instance();
	XPathExpression<Element> exprElement = xFactory.compile(
			"/osm/relation[@id]" + "[member/@type='way' and member/@ref]"
					+ "[tag/@k='image' and tag/@v]", Filters.element());

	XPathExpression<Attribute> expname = xFactory.compile(
			"tag[@k='name']/@v", Filters.attribute());
	XPathExpression<Attribute> expele = xFactory.compile(
			"tag[@k='ele']/@v", Filters.attribute());
	XPathExpression<Attribute> expimg = xFactory.compile(
			"tag[@k='image']/@v", Filters.attribute());
	XPathExpression<Attribute> expul = xFactory.compile(
			"tag[@k='upperleft']/@v", Filters.attribute());
	XPathExpression<Attribute> explr = xFactory.compile(
			"tag[@k='lowerright']/@v", Filters.attribute());
	XPathExpression<Attribute> expmem = xFactory.compile("member/@ref",
			Filters.attribute());

	List<Element> rEles = exprElement.evaluate(doc);
	for (Element rel : rEles) {
		try {
			double ele = expele.evaluateFirst(rel).getDoubleValue();
			String name = expname.evaluateFirst(rel).getValue();
			String image = expimg.evaluateFirst(rel).getValue();
			String[] ul = expul.evaluateFirst(rel).getValue().split(",");
			String[] lr = explr.evaluateFirst(rel).getValue().split(",");
			List<Attribute> mAttrs = expmem.evaluate(rel);
			double[] upperleft = new double[] { Double.parseDouble(ul[0]),
					Double.parseDouble(ul[1]) };
			double[] lowerright = new double[] { Double.parseDouble(lr[0]),
					Double.parseDouble(lr[1]) };

			List<Way> ws = new LinkedList<Way>();
			for (Attribute m : mAttrs) {
				Way w = ways.get(m.getIntValue());
				ws.add(w);
			}

			Storey storey = new Storey(name, image, upperleft, lowerright,
					ele, ws);
			storeies.add(storey);
		} catch (DataConversionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
	return storeies;

}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:53,代码来源:CarParkGraph.java


注:本文中的org.jdom2.DataConversionException.printStackTrace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。