本文整理汇总了Java中org.jdom2.DataConversionException类的典型用法代码示例。如果您正苦于以下问题:Java DataConversionException类的具体用法?Java DataConversionException怎么用?Java DataConversionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataConversionException类属于org.jdom2包,在下文中一共展示了DataConversionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setDefaultMaxGameId
import org.jdom2.DataConversionException; //导入依赖的package包/类
@Override
public void setDefaultMaxGameId() {
Element queueElement = plugin.getSettings().getData().getChild("queue");
if (queueElement == null) {
return;
}
Attribute attribute = queueElement.getAttribute("restart-after");
if (attribute == null) {
return;
}
try {
this.setMaxGameId(attribute.getIntValue());
} catch (DataConversionException ignored) {
}
}
示例2: parseSeed
import org.jdom2.DataConversionException; //导入依赖的package包/类
private long parseSeed(Element parent) throws MapParserException {
if (parent != null) {
try {
Element xml = parent.getChild("generator");
if (xml != null) {
Attribute seed = xml.getAttribute("seed");
if (seed != null) {
return seed.getLongValue();
}
}
} catch (DataConversionException ignored) {
}
}
return ArcadeMap.DEFAULT_SEED;
}
示例3: parseEnchantmentStorage
import org.jdom2.DataConversionException; //导入依赖的package包/类
public static EnchantmentStorageMeta parseEnchantmentStorage(Element xml, EnchantmentStorageMeta source) {
Element book = xml.getChild("enchanted-book");
if (book != null) {
for (Element enchantment : book.getChildren("enchantment")) {
Enchantment type = Enchantment.getByName(XMLParser.parseEnumValue(enchantment.getTextNormalize()));
int level = 1;
try {
Attribute levelAttribute = enchantment.getAttribute("level");
if (levelAttribute != null) {
level = levelAttribute.getIntValue();
}
} catch (DataConversionException ignored) {
}
source.addStoredEnchant(type, level, false);
}
}
return source;
}
示例4: parse
import org.jdom2.DataConversionException; //导入依赖的package包/类
public static ItemStack parse(Element xml) throws DataConversionException {
if (xml == null) {
return null;
}
ItemStackBuilder builder = new ItemStackBuilder()
.amount(parseAmount(xml))
.description(parseDescription(xml))
.displayName(parseDisplayName(xml))
.durability(parseDurability(xml))
.enchantments(parseEnchantments(xml))
.type(parseType(xml))
.unbreakable(parseUnbreakable(xml));
ItemStack item = builder.build();
item.setItemMeta(parseItemMeta(xml, item.getItemMeta()));
item.setDurability(parseData(xml));
return item;
}
示例5: parseEnchantments
import org.jdom2.DataConversionException; //导入依赖的package包/类
private static Map<Enchantment, Integer> parseEnchantments(Element xml) {
Map<Enchantment, Integer> enchantments = new HashMap<>();
Element element = xml.getChild("enchantments");
if (element != null) {
for (Element enchantment : element.getChildren("enchantment")) {
Enchantment type = Enchantment.getByName(XMLParser.parseEnumValue(enchantment.getTextNormalize()));
int level = 1;
try {
Attribute levelAttribute = enchantment.getAttribute("level");
if (levelAttribute != null) {
level = levelAttribute.getIntValue();
}
} catch (DataConversionException ignored) {
}
enchantments.put(type, level);
}
}
return enchantments;
}
示例6: parse
import org.jdom2.DataConversionException; //导入依赖的package包/类
@Override
public SoundContent parse(Element xml) throws DataConversionException {
Sound sound = XMLSound.parse(xml.getTextNormalize());
if (sound != null) {
SoundContent content = new SoundContent(sound);
content.setLocation(XMLLocation.parse(xml));
Attribute pitch = xml.getAttribute("sound-pitch");
if (pitch != null) {
content.setPitch(pitch.getFloatValue());
}
Attribute volume = xml.getAttribute("sound-volume");
if (volume != null) {
content.setVolume(volume.getFloatValue());
}
return content;
}
return null;
}
示例7: parse
import org.jdom2.DataConversionException; //导入依赖的package包/类
public static Location parse(Element xml,
double x,
double y,
double z,
float yaw,
float pitch) throws DataConversionException {
if (xml != null) {
double paramX = getAttribute(xml, ATTRIBUTE_X, X).getDoubleValue();
double paramY = getAttribute(xml, ATTRIBUTE_Y, Y).getDoubleValue();
double paramZ = getAttribute(xml, ATTRIBUTE_Z, Z).getDoubleValue();
float paramYaw = getAttribute(xml, ATTRIBUTE_YAW, YAW).getFloatValue();
float paramPitch = getAttribute(xml, ATTRIBUTE_PITCH, PITCH).getFloatValue();
return new Location((World) null, paramX, paramY, paramZ, paramYaw, paramPitch);
}
return null;
}
示例8: 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;
}
示例9: 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;
}
示例10: getFirstQuestion
import org.jdom2.DataConversionException; //导入依赖的package包/类
public QuestionAnswer getFirstQuestion() throws DataConversionException {
tool.initFile(LINK);
Element e = tool.getChildren("questionArray");
// retourne les questions
List<Element> array = tool.getListChildren(e, tool.getRoot());
// retourne les reponses de la premiere question
List<Element> array2 = array.get(0).getChildren();
Map<String, String> mp = new HashMap<String, String>();
for (Element tmp : array2) {
mp.put(tmp.getAttributeValue("id"), tmp.getAttributeValue("r"));
}
QuestionAnswer retour = new QuestionAnswer(array.get(0).getAttributeValue("q"),
array.get(0).getAttribute("id").getIntValue(), mp);
return retour;
}
示例11: 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();
}
}
示例12: 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;
}
示例13: getProgress
import org.jdom2.DataConversionException; //导入依赖的package包/类
public int getProgress()
{
Attribute attribute = element.getAttribute("Progress.DWD");
if (attribute != null)
{
try
{
return attribute.getIntValue();
}
catch (DataConversionException e)
{
throw new CarbonBuildException("Job Progress.DWD not an int: " + attribute.getValue(), e);
}
}
else
{
return 0;
}
}
示例14: parse
import org.jdom2.DataConversionException; //导入依赖的package包/类
public boolean parse() {
if (movielist == null) {
return false;
}
if (! loadXML()) {
return false;
}
movielist.clear();
try {
if (! createDatabaseElements()) {
return false;
}
} catch (DataConversionException | CCFormatException e) {
return false;
}
return true;
}
示例15: createDatabaseElements
import org.jdom2.DataConversionException; //导入依赖的package包/类
private boolean createDatabaseElements() throws DataConversionException, CCFormatException {
Element root = document.getRootElement().getChild("database");
if (root == null) return false;
for (Iterator<Element> it = root.getChildren().iterator(); it.hasNext();) {
Element e = it.next();
if (e.getName().equals("movie")) {
createMovie(e);
} else {
createSeries(e);
}
}
return true;
}