Java 类org.jdom2.DataConversionException 实例源码

项目:Arcade2    文件:SimpleGameManager.java   
@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) {
    }
}
项目:Arcade2    文件:XMLMapParser.java   
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;
}
项目:Arcade2    文件:XMLItemMeta.java   
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;
}
项目:Arcade2    文件:XMLItemStack.java   
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;
}
项目:Arcade2    文件:XMLItemStack.java   
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;
}
项目:Arcade2    文件:SoundContent.java   
@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;
}
项目:Arcade2    文件:XMLLocation.java   
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;
}
项目:DeadReckoning    文件:CarPark.java   
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;
}
项目:DeadReckoning    文件:CarParkGraph.java   
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;
}
项目:humfray    文件:ListFinderService.java   
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;

}
项目:Pixel-Planet    文件:SpriteSheet.java   
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();
    }
}
项目:jerry-core    文件:DomUtils.java   
/**
 * 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;
}
项目:stdlib    文件:CarbonJobInfo.java   
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;
    }
}
项目:jClipCorn    文件:CCBXMLReader.java   
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;
}
项目:jClipCorn    文件:CCBXMLReader.java   
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;
}
项目:Arcade2    文件:XMLTeam.java   
public static boolean parseFriendlyFire(Element xml) {
    Attribute attribute = xml.getAttribute("friendly-fire");
    if (attribute != null) {
        try {
            return attribute.getBooleanValue();
        } catch (DataConversionException ignored) {
        }
    }

    return false;
}
项目:Arcade2    文件:XMLTeam.java   
public static int parseMaxPlayers(Element xml) {
    Attribute attribute = xml.getAttribute("overfill");
    if (attribute != null) {
        try {
            return attribute.getIntValue();
        } catch (DataConversionException ignored) {
        }
    }

    return 0;
}
项目:Arcade2    文件:XMLTeam.java   
public static int parseMinPlayers(Element xml) {
    Attribute attribute = xml.getAttribute("min-players");
    if (attribute != null) {
        try {
            return attribute.getIntValue();
        } catch (DataConversionException ignored) {
        }
    }

    return 0;
}
项目:Arcade2    文件:XMLTeam.java   
public static int parseSlots(Element xml) {
    Attribute attribute = xml.getAttribute("slots");
    if (attribute != null) {
        try {
            return attribute.getIntValue();
        } catch (DataConversionException ignored) {
        }
    }

    return 0;
}
项目:Arcade2    文件:XMLMapParser.java   
private Location parseSpawn(Element parent) throws MapParserException {
    Element spawn = parent.getChild("spawn");
    if (spawn == null) {
        return new Location((World) null, XMLLocation.X, XMLLocation.Y, XMLLocation.Z);
    }

    try {
        return XMLLocation.parse(spawn);
    } catch (DataConversionException ex) {
        throw new MapParserException("<spawn> incorrect", ex);
    }
}
项目:Arcade2    文件:XMLMapParser.java   
private boolean parsePvp(Element parent) {
    if (parent != null) {
        Attribute attribute = parent.getAttribute("pvp");
        if (attribute != null) {
            try {
                return attribute.getBooleanValue();
            } catch (DataConversionException ignored) {
            }
        }
    }

    return true;
}
项目:Arcade2    文件:XMLItemStack.java   
private static int parseAmount(Element xml) {
    Attribute attribute = xml.getAttribute("amount");
    if (attribute != null) {
        try {
            return attribute.getIntValue();
        } catch (DataConversionException ignored) {
        }
    }

    return 1;
}
项目:Arcade2    文件:FlyContent.java   
@Override
public FlyContent parse(Element xml) throws DataConversionException {
    Attribute reset = xml.getAttribute("reset");
    if (reset != null) {
        return new FlyContent(DEFAULT_FLYING, DEFAULT_SPEED, DEFAULT_ALLOW_FLYING);
    }

    return null;
}
项目:Arcade2    文件:KnockbackContent.java   
@Override
public KnockbackContent parse(Element xml) throws DataConversionException {
    Attribute reset = xml.getAttribute("reset");
    if (reset != null && XMLParser.parseBoolean(reset.getValue())) {
        return new KnockbackContent(DEFAULT_KNOCKBACK);
    }

    try {
        return new KnockbackContent(Float.parseFloat(xml.getTextNormalize()));
    } catch (NumberFormatException ex) {
        return null;
    }
}
项目:Arcade2    文件:ArmorContent.java   
@Override
public ArmorContent parse(Element xml) throws DataConversionException {
    ItemStack helmetItem = null;
    ItemStack chestplateItem = null;
    ItemStack leggingsItem = null;
    ItemStack bootsItem = null;

    Element helmet = xml.getChild("helmet");
    if (helmet != null) {
        helmetItem = XMLItemStack.parse(helmet);
    }

    Element chestplate = xml.getChild("chestplate");
    if (chestplate != null) {
        chestplateItem = XMLItemStack.parse(chestplate);
    }

    Element leggings = xml.getChild("leggings");
    if (leggings != null) {
        leggingsItem = XMLItemStack.parse(leggings);
    }

    Element boots = xml.getChild("boots");
    if (boots != null) {
        bootsItem = XMLItemStack.parse(boots);
    }

    if (helmet != null || chestplate != null || leggings != null || boots != null) {
        return new ArmorContent(helmetItem, chestplateItem, leggingsItem, bootsItem);
    } else {
        return null;
    }
}
项目:Arcade2    文件:HealthContent.java   
@Override
public HealthContent parse(Element xml) throws DataConversionException {
    Attribute reset = xml.getAttribute("reset");
    if (reset != null && XMLParser.parseBoolean(reset.getValue())) {
        return new HealthContent(DEFAULT_HEALTH);
    }

    try {
        return new HealthContent(Double.parseDouble(xml.getTextNormalize()));
    } catch (NumberFormatException ex) {
        return null;
    }
}
项目:Arcade2    文件:WalkSpeedContent.java   
@Override
public WalkSpeedContent parse(Element xml) throws DataConversionException {
    Attribute reset = xml.getAttribute("reset");
    if (reset != null && XMLParser.parseBoolean(reset.getValue())) {
        return new WalkSpeedContent(DEFAULT_SPEED);
    }

    try {
        return new WalkSpeedContent(Float.parseFloat(xml.getTextNormalize()));
    } catch (NumberFormatException ex) {
        return null;
    }
}
项目:Arcade2    文件:SaturationContent.java   
@Override
public SaturationContent parse(Element xml) throws DataConversionException {
    Attribute attribute = xml.getAttribute("reset");
    if (attribute != null && XMLParser.parseBoolean(attribute.getValue())) {
        return new SaturationContent(DEFAULT_SATURATION);
    }

    try {
        return new SaturationContent(Float.parseFloat(xml.getTextNormalize()));
    } catch (NumberFormatException ex) {
        return null;
    }
}
项目:Arcade2    文件:FoodLevelContent.java   
@Override
public FoodLevelContent parse(Element xml) throws DataConversionException {
    Attribute reset = xml.getAttribute("reset");
    if (reset != null && XMLParser.parseBoolean(reset.getValue())) {
        return new FoodLevelContent(DEFAULT_LEVEL);
    }

    try {
        return new FoodLevelContent(Double.parseDouble(xml.getTextNormalize()));
    } catch (NumberFormatException ex) {
        return null;
    }
}
项目:Arcade2    文件:XMLKit.java   
public static Kit parseKit(ArcadePlugin plugin, Element xml) {
    String id = xml.getAttributeValue("id");
    if (id == null) {
        return null;
    }

    Kit kit = new Kit(plugin, id);
    for (Element contentElement : xml.getChildren()) {
        try {
            Object content = KitContentType.parseForName(contentElement.getName(), contentElement);
            if (content != null && content instanceof KitContent<?>) {
                kit.addContent((KitContent<?>) content);
            }
        } catch (DataConversionException ex) {
            return null;
        }
    }

    Attribute inheritAttribute = xml.getAttribute("inherit");
    if (inheritAttribute != null) {
        for (String inherit : parseArray(inheritAttribute.getValue())) {
            kit.addInherit(inherit);
        }
    }

    return kit;
}
项目:Arcade2    文件:ItemStackContent.java   
@Override
public ItemStackContent parse(Element xml) throws DataConversionException {
    ItemStackContent content = new ItemStackContent(XMLItemStack.parse(xml));

    int slot = this.parseSlot(xml);
    if (slot != SLOT_NULL) {
        content.setSlot(slot);
    }

    return content;
}
项目:Arcade2    文件:ItemStackContent.java   
private int parseSlot(Element xml) {
    Attribute attribute = xml.getAttribute("slot");
    if (attribute != null) {
        try {
            return attribute.getIntValue();
        } catch (DataConversionException ignored) {
        }
    }

    return SLOT_NULL;
}
项目:Arcade2    文件:MaxHealthContent.java   
@Override
public MaxHealthContent parse(Element xml) throws DataConversionException {
    Attribute attribute = xml.getAttribute("reset");
    if (attribute != null && XMLParser.parseBoolean(attribute.getValue())) {
        return new MaxHealthContent(DEFAULT_HEALTH);
    }

    try {
        return new MaxHealthContent(Double.parseDouble(xml.getTextNormalize()));
    } catch (NumberFormatException ex) {
        return null;
    }
}
项目:Arcade2    文件:XMLParser.java   
public static Attribute getAttribute(Element xml, String name, Object def) throws DataConversionException {
    Attribute attribute = xml.getAttribute(name);
    if (attribute != null) {
        return attribute;
    }

    return new Attribute(name, def.toString());
}
项目:Arcade2    文件:Settings.java   
private void setup(Element root) {
    Attribute enabled = root.getAttribute("enabled");
    if (enabled != null) {
        try {
            this.enabled = enabled.getBooleanValue();
        } catch (DataConversionException ex) {
            ex.printStackTrace();
        }
    }
}
项目:Arcade2    文件:XMLPotionEffect.java   
private static int parseAmplifier(Element xml) {
    Attribute attribute = xml.getAttribute("amplifier");
    if (attribute != null) {
        try {
            return attribute.getIntValue();
        } catch (DataConversionException ignored) {
        }
    }

    return 1;
}
项目:ldapchai    文件:ChaiResponseSet.java   
private static Challenge parseResponseElement( final Element loopResponseElement )
        throws DataConversionException
{
    final boolean required = loopResponseElement.getAttribute( XML_ATTRIBUTE_REQUIRED ).getBooleanValue();
    final boolean adminDefined = loopResponseElement.getAttribute( XML_ATTRIBUTE_ADMIN_DEFINED ).getBooleanValue();

    final String challengeText = loopResponseElement.getChild( XML_NODE_CHALLENGE ).getText();
    final int minLength = loopResponseElement.getAttribute( XNL_ATTRIBUTE_MIN_LENGTH ).getIntValue();
    final int maxLength = loopResponseElement.getAttribute( XNL_ATTRIBUTE_MAX_LENGTH ).getIntValue();

    return new ChaiChallenge( required, challengeText, minLength, maxLength, adminDefined, 0, false );
}
项目:DeadReckoning    文件:CarPark.java   
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;

}
项目:DeadReckoning    文件:CarParkGraph.java   
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;

}
项目:jodtemplate    文件:ImageService.java   
public void insertImage(final ImageField imageField, final Slide slide, final Resources resources,
        final Element pic) throws JODTemplateException {
    try {
        final InputStream is = imageField.getInputStream();
        if (is != null) {
            try (final InputStream bis = new BufferedInputStream(is)) {

                final byte[] imageContents = IOUtils.toByteArray(bis);

                final Image image = getImage(imageContents, slide.getPresentation(), resources);

                final Relationship imageRel = getImageRelationship(image, slide);

                final Attribute embed = pic
                        .getChild(PPTXDocument.BLIPFILL_ELEMENT, getPresentationmlNamespace())
                        .getChild(PPTXDocument.BLIP_ELEMENT, getDrawingmlNamespace())
                        .getAttribute(PPTXDocument.EMBED_ATTR, getRelationshipsNamespace());
                embed.setValue(imageRel.getId());

                setPicSize(pic, image);
            }
        } else {
            pic.getParent().removeContent(pic);
        }
    } catch (IOException | DataConversionException e) {
        throw new JODTemplateException(e);
    }
}