Example usage for org.jdom2 Element getAttribute

List of usage examples for org.jdom2 Element getAttribute

Introduction

In this page you can find the example usage for org.jdom2 Element getAttribute.

Prototype

public Attribute getAttribute(final String attname) 

Source Link

Document

This returns the attribute for this element with the given name and within no namespace, or null if no such attribute exists.

Usage

From source file:tinyequationscoringengine.TinyEqCustomOpFactory.java

License:Open Source License

public Expression createExpression(Element customOperatorNode) {
    Element coElement = (Element) customOperatorNode;

    return (Expression) _eqConstructors.get(coElement.getAttribute("functionName").getValue())
            .geteqConstructors(coElement);
}

From source file:tinygrscoringengine.TinyGRCustomOpFactory.java

License:Open Source License

public boolean supportsOperator(Element customOperatorNode) {
    Element coElement = (Element) customOperatorNode;

    if (!("GRAPHIC".equals(coElement.getAttribute("type").getValue()))) {
        return false;
    }//  w w  w. j a v  a  2  s.  com
    return _tgrConstructors.containsKey(coElement.getAttribute("functionName").getValue());
}

From source file:tinygrscoringengine.TinyGRCustomOpFactory.java

License:Open Source License

@Override
public Expression createExpression(Element customOperatorNode) {
    Element coElement = (Element) customOperatorNode;
    return (Expression) _tgrConstructors.get(coElement.getAttribute("functionName").getValue())
            .getTGRConstructor(coElement);
}

From source file:tinytablescoringengine.TinyTableCustomOpFactory.java

License:Open Source License

@Override
public boolean supportsOperator(Element customOperatorNode) {
    Element coElement = customOperatorNode;
    if (!StringUtils.equals("TABLE", coElement.getAttribute("type").getValue())) {
        return false;
    }//from   w  w  w.j  a v  a 2s .c o m
    return _ttConstructors.containsKey(coElement.getAttribute("functionName").getValue());
}

From source file:tinytablescoringengine.TinyTableCustomOpFactory.java

License:Open Source License

@Override
public Expression createExpression(Element customOperatorNode) {
    Element coElement = customOperatorNode;
    return (Expression) _ttConstructors.get(coElement.getAttribute("functionName").getValue())
            .getTTConstructor(coElement);
}

From source file:tools.ResourceManager.java

License:Open Source License

protected void loadImageE(Element elem) {
    String id = elem.getAttributeValue("id");

    switch (elem.getAttributeValue("src")) {
    case "file":
        loadImage(id, elem.getText());//from   w  w  w  .j av a2s  .  c o m
        break;
    case "spritesheet":
        try {
            loadImage(id, elem.getAttributeValue("idSpriteSheet"), elem.getAttribute("x").getIntValue(),
                    elem.getAttribute("y").getIntValue());
        } catch (DataConversionException e) {
            this.log.error("could not load image: " + id + " because wrong format of attribute 'x' or 'y'");
        }
        break;
    default:
        this.log.error("could not load image: " + id + ", unknown value: " + elem.getAttributeValue("src")
                + " of attribute 'src'");
    }
}

From source file:tools.ResourceManager.java

License:Open Source License

protected void loadSpriteSheetE(Element elem) {
    try {// ww w.  java 2 s.c o m
        loadSpriteSheet(elem.getAttributeValue("id"), elem.getText(), elem.getAttribute("th").getIntValue(),
                elem.getAttribute("tw").getIntValue());
    } catch (DataConversionException e) {
        this.log.error("could not load spriteSheet at: " + elem.getText()
                + " because wrong format of attribute 'tw' or 'th'");
    }
}

From source file:tools.ResourceManager.java

License:Open Source License

protected void loadAnimationE(Element elem) {
    List<Element> listElem = elem.getChildren();
    List<AnimationData> listData = new ArrayList<AnimationData>();

    for (Element child : listElem) {
        switch (child.getName()) {
        case "Frame":
            AnimationData data = new AnimationData();
            try {
                data.duration = child.getAttribute("duration").getIntValue();
                data.x = child.getAttribute("x").getIntValue();
                data.y = child.getAttribute("y").getIntValue();

                listData.add(data);/*from  w w  w  .  j a  v  a2s .c  o m*/
            } catch (DataConversionException e) {
                this.log.error("could not load animation with id: " + elem.getAttributeValue("id")
                        + " because wrong format of attribute of Frame");
            }
            break;
        default:
            this.log.warn("load: unknown type object -> " + elem.getName());
            continue;
        }
    }

    loadAnimation(elem.getAttributeValue("id"), elem.getAttributeValue("idSpriteSheet"),
            listData.toArray(new AnimationData[0]));
}

From source file:tradingapp.Settings.java

public static void ReadSettings() {
    try {/*ww w  .j a  va 2 s  .c  o m*/
        File inputFile = new File(FilePaths.settingsPathFile);
        SAXBuilder saxBuilder = new SAXBuilder();
        Document document = saxBuilder.build(inputFile);

        Element rootElement = document.getRootElement();
        Attribute attribute;

        // connection
        Element connectionElement = rootElement.getChild("connection");

        attribute = connectionElement.getAttribute("port");
        port = attribute.getIntValue();

        attribute = connectionElement.getAttribute("clientId");
        clientId = attribute.getIntValue();

        // money
        Element moneyElement = rootElement.getChild("money");

        attribute = moneyElement.getAttribute("investCash");
        investCash = attribute.getDoubleValue();

        attribute = moneyElement.getAttribute("leverage");
        leverage = attribute.getDoubleValue();

        // mail
        Element mailElement = rootElement.getChild("mail");
        mailAddressTradeLog = mailElement.getAttribute("addressTradeLog").getValue();
        mailAddressCheck = mailElement.getAttribute("addressCheck").getValue();
        mailAddressError = mailElement.getAttribute("addressError").getValue();
        mailFrom = mailElement.getAttribute("from").getValue();
        mailPassword = mailElement.getAttribute("password").getValue();

        logger.fine("Updated Settings");
        logger.fine("Loaded Connection - port: " + port + ", clientId: " + clientId);
        logger.fine("Loaded money - investCash: " + investCash + ", leverage: " + leverage);
        logger.fine("Loaded mail - mailAddressTradeLog: " + mailAddressTradeLog + ", mailAddressCheck: "
                + mailAddressCheck + ", mailAddressError: " + mailAddressError + ", mailFrom: " + mailFrom
                + ", mailPassword: " + mailPassword);

    } catch (JDOMException e) {
        logger.severe("Error in loading from XML: JDOMException.\r\n" + e);
    } catch (IOException ioe) {
        logger.severe("Error in loading from XML: IOException.\r\n" + ioe);
    }
}

From source file:tradingapp.TradeTimer.java

public static void LoadSpecialTradingDays() {
    logger.fine("Loading special days!");
    specialTradingDays.clear();//w  w  w .  j  a v a2  s  .c o m
    try {
        File inputFile = new File(FilePaths.specialTradingDaysPathFile);
        SAXBuilder saxBuilder = new SAXBuilder();
        Document document = saxBuilder.build(inputFile);

        Element rootElement = document.getRootElement();
        List<Element> dayElements = rootElement.getChildren();

        for (Element dayElement : dayElements) {
            TradingDay day = new TradingDay();
            Attribute attribute = dayElement.getAttribute("date");
            if (attribute != null) {
                String dateStr = attribute.getValue();
                day.date = LocalDate.parse(dateStr);
            } else {
                logger.severe("Failed to load special trading day from " + inputFile.getAbsolutePath());
                continue;
            }

            attribute = dayElement.getAttribute("closeTime");
            if (attribute != null) {
                String timeStr = attribute.getValue();
                day.closingTime = LocalTime.parse(timeStr);
            } else {
                day.closingTime = null;
            }

            specialTradingDays.add(day);
        }

        logger.fine("Special days loaded: " + specialTradingDays.size());
    } catch (JDOMException e) {
        e.printStackTrace();
        logger.severe("Error in loading special days from XML: JDOMException.\r\n" + e);
    } catch (IOException ioe) {
        ioe.printStackTrace();
        logger.severe("Error in loading special days from XML: IOException.\r\n" + ioe);
    }
}