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


Java DataConversionException类代码示例

本文整理汇总了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) {
    }
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:18,代码来源:SimpleGameManager.java

示例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;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:17,代码来源:XMLMapParser.java

示例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;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:22,代码来源:XMLItemMeta.java

示例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;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:21,代码来源:XMLItemStack.java

示例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;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:24,代码来源:XMLItemStack.java

示例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;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:23,代码来源:SoundContent.java

示例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;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:19,代码来源:XMLLocation.java

示例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;
}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:24,代码来源:CarPark.java

示例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;
}
 
开发者ID:ianmalcolm,项目名称:DeadReckoning,代码行数:24,代码来源:CarParkGraph.java

示例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;

}
 
开发者ID:egavard,项目名称:humfray,代码行数:21,代码来源:ListFinderService.java

示例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();
    }
}
 
开发者ID:Piratkopia13,项目名称:Pixel-Planet,代码行数:22,代码来源:SpriteSheet.java

示例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;
}
 
开发者ID:sangupta,项目名称:jerry-core,代码行数:36,代码来源:DomUtils.java

示例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;
	}
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:21,代码来源:CarbonJobInfo.java

示例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;
}
 
开发者ID:Mikescher,项目名称:jClipCorn,代码行数:22,代码来源:CCBXMLReader.java

示例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;
}
 
开发者ID:Mikescher,项目名称:jClipCorn,代码行数:17,代码来源:CCBXMLReader.java


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