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:de.bund.bfr.knime.pmm.common.MiscXml.java

License:Open Source License

public MiscXml(Element el) {
    this(XmlHelper.getInt(el, ATT_ID), XmlHelper.getString(el, ATT_NAME),
            XmlHelper.getString(el, ATT_DESCRIPTION), XmlHelper.getDouble(el, ATT_VALUE), null,
            XmlHelper.getString(el, ATT_UNIT), XmlHelper.getString(el, ATT_ORIGUNIT),
            XmlHelper.getString(el, ATT_DBUUID));
    categories = new ArrayList<>();

    for (int i = 0;; i++) {
        if (el.getAttribute(ATT_CATEGORY + i) == null) {
            break;
        }/*from w  w  w .  j a v  a  2  s .  c  o m*/

        categories.add(XmlHelper.getString(el, ATT_CATEGORY + i));
    }
}

From source file:de.herm_detlef.java.application.io.Import.java

License:Apache License

private static void createNode(Element child) {

    List<Element> children = child.getChildren();

    if (children.isEmpty()) {

        switch (TAG.getValueOf(child.getName())) {
        case ID://from w ww  .  ja  va2s. com
            exerciseItem.setItemId(Integer.parseInt(child.getTextTrim()));
            break;
        case TEXT: {
            final String str = child.getTextTrim();
            if (isQuestionPart) {
                exerciseItem.addQuestionText(str);
            } else if (isAnswerPart) {
                Attribute mark = child
                        .getAttribute(ApplicationConstants.NAME_OF_XML_ATTRIBUTE_ANSWER_TEXT_MARK);
                if (mark != null) {
                    try {
                        exerciseItem.addAnswerText(str, mark.getBooleanValue());
                    } catch (DataConversionException e) {
                        Utilities.showErrorMessage(e.getClass().getSimpleName(), e.getMessage());
                        assert false : String.format("DataConversionException: %s", mark.toString()); // TODO
                        exerciseItem.addAnswerText(str, false);
                    }
                } else {
                    exerciseItem.addAnswerText(str, false);
                }

            } else if (isSolutionPart) {
                exerciseItem.addSolutionText(str);
            }
            break;
        }
        case CODE:
            if (isQuestionPart) {
                exerciseItem.addQuestionCode(child.getTextTrim());
            }
            break;
        case TEXT2:
            if (isQuestionPart) {
                exerciseItem.addQuestionText2(child.getTextTrim());
            }
            break;
        case CATALOG:
            // TODO empty catalog file
            break;
        default:
            assert false : String.format("%s", TAG.getValueOf(child.getName()).name()); // TODO
        }

        return;
    }

    for (Element aChild : children) {

        switch (TAG.getValueOf(aChild.getName())) {
        case ITEM:
            exerciseItem = new ExerciseItem();
            exerciseItemList.add(exerciseItem);
            break;
        case QUESTION:
            signalQuestion();
            break;
        case SINGLE_CHOICE_ANSWER:
            signalSingleChoiceAnswer();
            exerciseItem.createSingleChoiceModel();
            break;
        case MULTIPLE_CHOICE_ANSWER:
            signalMultipleChoiceAnswer();
            exerciseItem.createMultipleChoiceModel();
            break;
        case SOLUTION:
            signalSolution();
            break;
        case ID:
        case TEXT:
        case CODE:
        case TEXT2:
            break;
        default:
            assert false : String.format("%s", TAG.getValueOf(aChild.getName()).name()); // TODO
        }

        createNode(aChild);
    }
}

From source file:de.mud.flash.FlashTerminal.java

License:Open Source License

/**
 * Handle XML Commands sent by the remote host.
 * // w w  w  . ja v a  2  s . c o  m
 * @param xml
 *            string containing the xml commands
 */
private void handleXMLCommand(String xml) {
    log.error("handleXMLCommand(" + xml + ")");
    StringReader src = new StringReader("<root>" + xml.replace('\0', ' ') + "</root>");
    try {
        Element root = builder.build(src).getRootElement();
        Iterator<?> cmds = root.getChildren().iterator();
        while (cmds.hasNext()) {
            Element command = (Element) cmds.next();
            String name = command.getName();
            if ("mode".equals(name)) {
                simpleMode = "true".equals(command.getAttribute("simple").getValue().toLowerCase());
            } else if ("timestamp".equals(name)) {
                perf(command.getAttribute("msg").getValue());
            } else if ("start".equals(name)) {
                terminalReady = true;
                buffer.update[0] = true;
                redraw();
            }
        }
    } catch (JDOMException e) {
        log.error("error reading command: " + e);
    } catch (IOException e) {
        log.error(e.getMessage());
    }
}

From source file:de.nava.informa.parsers.Atom_0_3_Parser.java

License:Open Source License

/**
 * @see de.nava.informa.core.ChannelParserIF#parse(de.nava.informa.core.ChannelBuilderIF, org.jdom2.Element)
 *//*from  w  w  w.j  a  v a2  s.  com*/
public ChannelIF parse(ChannelBuilderIF cBuilder, Element channel) throws ParseException {
    if (cBuilder == null) {
        throw new RuntimeException("Without builder no channel can " + "be created.");
    }

    Date dateParsed = new Date();
    Namespace defNS = ParserUtils.getDefaultNS(channel);

    if (defNS == null) {
        defNS = Namespace.NO_NAMESPACE;
        LOGGER.info("No default namespace found.");
    }

    // RSS 1.0 Dublin Core Module namespace
    Namespace dcNS = ParserUtils.getNamespace(channel, "dc");

    if (dcNS == null) {
        LOGGER.debug("No namespace for dublin core found");
        dcNS = defNS;
    }

    LOGGER.debug("start parsing.");

    // get version attribute
    String formatVersion = "0.3";

    if (channel.getAttribute("version") != null) {
        formatVersion = channel.getAttribute("version").getValue().trim();
        LOGGER.debug("Atom version " + formatVersion + " specified in document.");
    } else {
        LOGGER.info("No format version specified, using default.");
    }

    // --- read in channel information

    // Lower the case of these tags to simulate case-insensitive parsing
    ParserUtils.matchCaseOfChildren(channel, new String[] { "title", "description", "tagline", "ttl",
            "modified", "author", "generator", "copyright", "link", "entry" });

    // title element
    ChannelIF chnl = cBuilder.createChannel(channel, channel.getChildTextTrim("title", defNS));

    // TODO: support attributes: type, mode
    chnl.setFormat(ChannelFormat.ATOM_0_3);

    // language
    String language = channel.getAttributeValue("lang", Namespace.XML_NAMESPACE);

    if (language != null) {
        chnl.setLanguage(language);
    }

    // description element
    if (channel.getChild("description") != null) {
        chnl.setDescription(channel.getChildTextTrim("description", defNS));
    } else {
        // fallback
        chnl.setDescription(channel.getChildTextTrim("tagline", defNS));
    }

    // ttl in dc namespace
    Element ttl = channel.getChild("ttl", dcNS);

    if (ttl != null) {
        String ttlString = ttl.getTextTrim();

        if (ttlString != null) {
            chnl.setTtl(Integer.parseInt(ttlString));
        }
    }

    //  lastbuild element : modified ?
    Element modified = channel.getChild("modified", defNS);

    if (modified != null) {
        chnl.setPubDate(ParserUtils.getDate(modified.getTextTrim()));
    }

    // TODO : issued value
    /*
    if (modified != null) {
      modified = channel.getChild("issued", defNS);
      chnl.setLastBuildDate (ParserUtils.getDate(modified.getTextTrim()));
    }
    */

    // author element
    Element author = channel.getChild("author", defNS);

    if (author != null) {
        ParserUtils.matchCaseOfChildren(author, "name");
        chnl.setCreator(author.getChildTextTrim("name", defNS));
    }

    // generator element
    Element generator = channel.getChild("generator", defNS);

    if (generator != null) {
        chnl.setGenerator(generator.getTextTrim());
    }

    // copyright element
    Element copyright = channel.getChild("copyright", defNS);

    if (copyright != null) {
        chnl.setCopyright(getCopyright(copyright));
    }

    // n link elements
    // TODO : type attribut of link (text, application...)
    List links = channel.getChildren("link", defNS);
    Iterator i = links.iterator();

    while (i.hasNext()) {
        Element linkElement = (Element) i.next();

        // use first 'alternate' link
        String rel = linkElement.getAttributeValue("rel");
        String href = linkElement.getAttributeValue("href");

        if ((rel != null) && (href != null) && rel.equals("alternate")) {
            URL linkURL = ParserUtils.getURL(href);

            chnl.setSite(linkURL);

            break;
        }

        // TODO: further extraction of link information
    }

    // 1..n entry elements
    List items = channel.getChildren("entry", defNS);

    i = items.iterator();

    while (i.hasNext()) {
        Element item = (Element) i.next();

        // Lower the case of these tags to simulate case-insensitive parsing
        ParserUtils.matchCaseOfChildren(item,
                new String[] { "title", "link", "content", "summary", "issued", "subject" });

        // get title element
        // TODO : deal with type attribut
        Element elTitle = item.getChild("title", defNS);
        String strTitle = "<No Title>";

        if (elTitle != null) {
            strTitle = getTitle(elTitle);
            LOGGER.debug("Parsing title " + elTitle.getTextTrim() + "->" + strTitle);
        }

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Entry element found (" + strTitle + ").");
        }

        // get link element
        String strLink = AtomParserUtils.getItemLink(item, defNS);

        // get description element
        String strDesc = getDescription(item, defNS);

        // generate new news item (link to article)
        ItemIF curItem = cBuilder.createItem(item, chnl, strTitle, strDesc, ParserUtils.getURL(strLink));

        curItem.setFound(dateParsed);

        // get issued element (required)
        Element elIssued = item.getChild("issued", defNS);

        if (elIssued == null) {
            // [adewale@gmail.com, 01-May-2005] Fix for blogs which have
            // 'created' dates, but not 'issued' dates -- in clear contravention
            // of the Atom 0.3 spec.
            Element elCreated = item.getChild("created", defNS);

            if (elCreated != null) {
                curItem.setDate(ParserUtils.getDate(elCreated.getTextTrim()));
            }
        } else {
            curItem.setDate(ParserUtils.getDate(elIssued.getTextTrim()));
        }

        // get subject element
        Element elSubject = item.getChild("subject", dcNS);

        if (elSubject != null) {
            // TODO: Mulitple subject elements not handled currently
            curItem.setSubject(elSubject.getTextTrim());
        }
    }

    // set to current date
    chnl.setLastUpdated(dateParsed);

    return chnl;
}

From source file:de.nava.informa.parsers.FeedParser.java

License:Open Source License

private static synchronized ChannelIF parse(ChannelBuilderIF cBuilder, Document doc) throws ParseException {

    if (cBuilder == null) {
        throw new RuntimeException("Without builder no channel can " + "be created.");
    }//from   w  w w . jav  a 2 s.  co m
    LOGGER.debug("start parsing.");
    // Get the root element (must be rss)
    Element root = doc.getRootElement();
    String rootElement = root.getName().toLowerCase();
    // Decide which parser to use
    if (rootElement.startsWith("rss")) {
        String rssVersion = root.getAttribute("version").getValue();
        if (rssVersion.contains("0.91")) {
            LOGGER.info("Channel uses RSS root element (Version 0.91).");
            return RSS_0_91_Parser.getInstance().parse(cBuilder, root);
        } else if (rssVersion.contains("0.92")) {
            LOGGER.info("Channel uses RSS root element (Version 0.92).");
            // logger.warn("RSS 0.92 not fully supported yet, fall back to 0.91.");
            // TODO: support RSS 0.92 when aware of all subtle differences.
            return RSS_0_91_Parser.getInstance().parse(cBuilder, root);
        } else if (rootElement.contains("0.93")) {
            LOGGER.info("Channel uses RSS root element (Version 0.93).");
            LOGGER.warn("RSS 0.93 not fully supported yet, fall back to 0.91.");
            // TODO: support RSS 0.93 when aware of all subtle differences.
        } else if (rootElement.contains("0.94")) {
            LOGGER.info("Channel uses RSS root element (Version 0.94).");
            LOGGER.warn("RSS 0.94 not fully supported yet, will use RSS 2.0");
            // TODO: support RSS 0.94 when aware of all subtle differences.
            return RSS_2_0_Parser.getInstance().parse(cBuilder, root);
        } else if (rssVersion.contains("2.0") || rssVersion.equals("2")) {
            LOGGER.info("Channel uses RSS root element (Version 2.0).");
            return RSS_2_0_Parser.getInstance().parse(cBuilder, root);
        } else {
            throw new UnsupportedFormatException("Unsupported RSS version [" + rssVersion + "].");
        }
    } else if (rootElement.contains("rdf")) {
        return RSS_1_0_Parser.getInstance().parse(cBuilder, root);
    } else if (rootElement.contains("feed")) {
        Attribute versionAttr = root.getAttribute("version");
        Namespace namespace = ParserUtils.getDefaultNS(root);
        if (versionAttr != null) {
            String feedVersion = versionAttr.getValue();
            if (feedVersion.contains("0.1") || feedVersion.contains("0.2")) {
                LOGGER.info("Channel uses feed root element (Version " + feedVersion + ").");
                LOGGER.warn("This atom version is not really supported yet, assume Atom 0.3 format");
                return Atom_0_3_Parser.getInstance().parse(cBuilder, root);
            } else if (feedVersion.contains("0.3")) {
                LOGGER.info("Channel uses feed root element (Version 0.3).");
                return Atom_0_3_Parser.getInstance().parse(cBuilder, root);
            }
        } else if (namespace != null && namespace.getURI() != null) {
            if (!namespace.getURI().equals("http://www.w3.org/2005/Atom")) {
                LOGGER.warn("Channel uses unknown namespace in feed root element, assume Atom 1.0 format.");
            } else {
                LOGGER.info("Channel uses feed root element (Atom 1.0 format).");
            }
            return Atom_1_0_Parser.getInstance().parse(cBuilder, root);
        }
    }

    // did not match anything
    throw new UnsupportedFormatException("Unsupported root element [" + rootElement + "].");
}

From source file:de.nava.informa.parsers.OPMLParser.java

License:Open Source License

private static synchronized Collection<FeedIF> parse(Document doc) throws ParseException {

    logger.debug("start parsing.");
    // Get the root element (must be opml)
    Element root = doc.getRootElement();
    String rootElement = root.getName().toLowerCase();
    String opmlVersion;/*w  w w.j  av  a  2s .  c om*/

    // Decide which parser to use
    if (rootElement.startsWith("opml")) {
        Attribute attrOpmlVersion = root.getAttribute("version");

        // there is no version information set
        if (attrOpmlVersion == null) {
            // there seems to be no opml version set, so we'll try to parse it with 1.1..
            // TODO is it worth to implement also a opml 1.0 parser? are there markable differences between opml 1.1 and 1.0?
            logger.info(
                    "Collection uses OPML root element (no version information available), trying to parse with 1.1 anyway.");
            return OPML_1_1_Parser.parse(root);
        } else {
            // version information seems to be set, so go get it
            opmlVersion = attrOpmlVersion.getValue();
        }

        // version information is set
        if (opmlVersion.contains("1.1")) {
            // OPML 1.1 version information is set, so we'll parse it with 1.1!
            logger.info("Collection uses OPML root element (Version 1.1).");
            return OPML_1_1_Parser.parse(root);
        } else if (opmlVersion.contains("1.0")) {
            // TODO is it worth to implement also a opml 1.0 parser? are there markable differences between opml 1.1 and 1.0?
            // OPML 1.0 version information is set, we'll try to parse it using 1.1 anyway..
            logger.info("Collection uses OPML root element (Version 1.0), trying to parse with 1.1 anyway.");
            return OPML_1_1_Parser.parse(root);
        } else {
            // since it is neither a 1.0 nor 1.1 opml feed we maybe cannot handle it, so it's better to throw some exception..
            throw new UnsupportedFormatException(
                    MessageFormat.format("Unsupported OPML version information [{0}].", opmlVersion));
        }
    }

    // did not match anything
    throw new UnsupportedFormatException(
            MessageFormat.format("Unsupported OPML root element [{0}].", rootElement));
}

From source file:de.nava.informa.parsers.OPML_1_1_Parser.java

License:Open Source License

static Collection<FeedIF> parse(Element root) {

    Collection<FeedIF> feedColl = new ArrayList<>();

    Date dateParsed = new Date();
    logger.debug("start parsing.");

    // Lower the case of these tags to simulate case-insensitive parsing
    ParserUtils.matchCaseOfChildren(root, "body");

    // Get the head element (only one should occur)
    //    Element headElem = root.getChild("head");
    //    String title = headElem.getChildTextTrim("title");

    // Get the body element (only one occurs)
    Element bodyElem = root.getChild("body");

    // 1..n outline elements
    ParserUtils.matchCaseOfChildren(bodyElem, "outline");
    List feeds = bodyElem.getChildren("outline");
    for (Object feed1 : feeds) {
        Element feedElem = (Element) feed1;
        // get title attribute
        Attribute attrTitle = feedElem.getAttribute("title");
        String strTitle = "[No Title]";
        if (attrTitle != null) {
            strTitle = attrTitle.getValue();
        }//from  w w  w  .  j a  va  2  s . c  om
        FeedIF feed = new Feed(strTitle);
        if (logger.isDebugEnabled()) {
            logger.debug("Feed element found (" + strTitle + ").");
        }
        // get text attribute
        Attribute attrText = feedElem.getAttribute("text");
        String strText = "[No Text]";
        if (attrText != null) {
            strText = attrText.getValue();
        }
        feed.setText(strText);
        // get attribute type (for example: 'rss')
        Attribute attrType = feedElem.getAttribute("type");
        String strType = "text/xml";
        if (attrType != null) {
            strType = attrType.getValue();
        }
        feed.setContentType(strType);

        // TODO: handle attribute version (for example: 'RSS')

        // get attribute xmlUrl
        Attribute attrXmlUrl = feedElem.getAttribute("xmlUrl");
        if (attrXmlUrl != null && attrXmlUrl.getValue() != null) {
            feed.setLocation(ParserUtils.getURL(attrXmlUrl.getValue()));
        }
        // get attribute htmllUrl
        Attribute attrHtmlUrl = feedElem.getAttribute("htmlUrl");
        if (attrHtmlUrl != null && attrHtmlUrl.getValue() != null) {
            feed.setSite(ParserUtils.getURL(attrHtmlUrl.getValue()));
        }
        // set current date
        feed.setDateFound(dateParsed);
        // add feed to collection
        feedColl.add(feed);
    }

    return feedColl;
}

From source file:de.nava.informa.parsers.RSS_0_91_Parser.java

License:Open Source License

/**
 * @see de.nava.informa.core.ChannelParserIF#parse(de.nava.informa.core.ChannelBuilderIF, org.jdom2.Element)
 *//*from   ww  w  .ja v  a2  s.c  o m*/
public ChannelIF parse(ChannelBuilderIF cBuilder, Element root) throws ParseException {
    if (cBuilder == null) {
        throw new RuntimeException("Without builder no channel can " + "be created.");
    }
    Date dateParsed = new Date();
    logger.debug("start parsing.");

    // Get the channel element (only one occurs)
    ParserUtils.matchCaseOfChildren(root, "channel");
    Element channel = root.getChild("channel");
    if (channel == null) {
        logger.warn("Channel element could not be retrieved from feed.");
        throw new ParseException("No channel element found in feed.");
    }

    // --- read in channel information

    ParserUtils.matchCaseOfChildren(channel,
            new String[] { "title", "description", "link", "language", "item", "image", "textinput",
                    "copyright", "rating", "pubDate", "lastBuildDate", "docs", "managingEditor", "webMaster",
                    "cloud" });

    // 1 title element
    ChannelIF chnl = cBuilder.createChannel(channel, channel.getChildTextTrim("title"));

    chnl.setFormat(ChannelFormat.RSS_0_91);

    // 1 description element
    chnl.setDescription(channel.getChildTextTrim("description"));

    // 1 link element
    chnl.setSite(ParserUtils.getURL(channel.getChildTextTrim("link")));

    // 1 language element
    chnl.setLanguage(channel.getChildTextTrim("language"));

    // 1..n item elements
    List items = channel.getChildren("item");
    Iterator i = items.iterator();
    while (i.hasNext()) {
        Element item = (Element) i.next();

        ParserUtils.matchCaseOfChildren(item,
                new String[] { "title", "link", "description", "source", "enclosure" });

        // get title element
        Element elTitle = item.getChild("title");
        String strTitle = "<No Title>";
        if (elTitle != null) {
            strTitle = elTitle.getTextTrim();
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Item element found (" + strTitle + ").");
        }

        // get link element
        Element elLink = item.getChild("link");
        String strLink = "";
        if (elLink != null) {
            strLink = elLink.getTextTrim();
        }

        // get description element
        Element elDesc = item.getChild("description");
        String strDesc = "";
        if (elDesc != null) {
            strDesc = elDesc.getTextTrim();
        }

        // generate new RSS item (link to article)
        ItemIF rssItem = cBuilder.createItem(item, chnl, strTitle, strDesc, ParserUtils.getURL(strLink));
        rssItem.setFound(dateParsed);

        // get source element (an RSS 0.92 element)
        Element source = item.getChild("source");
        if (source != null) {
            String sourceName = source.getTextTrim();
            Attribute sourceAttribute = source.getAttribute("url");
            if (sourceAttribute != null) {
                String location = sourceAttribute.getValue().trim();
                ItemSourceIF itemSource = cBuilder.createItemSource(rssItem, sourceName, location, null);
                rssItem.setSource(itemSource);
            }
        }

        // get enclosure element (an RSS 0.92 element)
        Element enclosure = item.getChild("enclosure");
        if (enclosure != null) {
            URL location = null;
            String type = null;
            int length = -1;
            Attribute urlAttribute = enclosure.getAttribute("url");
            if (urlAttribute != null) {
                location = ParserUtils.getURL(urlAttribute.getValue().trim());
            }
            Attribute typeAttribute = enclosure.getAttribute("type");
            if (typeAttribute != null) {
                type = typeAttribute.getValue().trim();
            }
            Attribute lengthAttribute = enclosure.getAttribute("length");
            if (lengthAttribute != null) {
                try {
                    length = Integer.parseInt(lengthAttribute.getValue().trim());
                } catch (NumberFormatException e) {
                    logger.warn(e);
                }
            }
            ItemEnclosureIF itemEnclosure = cBuilder.createItemEnclosure(rssItem, location, type, length);
            rssItem.setEnclosure(itemEnclosure);
        }
    }

    // 0..1 image element
    Element image = channel.getChild("image");
    if (image != null) {

        ParserUtils.matchCaseOfChildren(image,
                new String[] { "title", "url", "link", "width", "height", "description" });

        ImageIF rssImage = cBuilder.createImage(image.getChildTextTrim("title"),
                ParserUtils.getURL(image.getChildTextTrim("url")),
                ParserUtils.getURL(image.getChildTextTrim("link")));
        Element imgWidth = image.getChild("width");
        if (imgWidth != null) {
            try {
                rssImage.setWidth(Integer.parseInt(imgWidth.getTextTrim()));
            } catch (NumberFormatException e) {
                logger.warn(e);
            }
        }
        Element imgHeight = image.getChild("height");
        if (imgHeight != null) {
            try {
                rssImage.setHeight(Integer.parseInt(imgHeight.getTextTrim()));
            } catch (NumberFormatException e) {
                logger.warn(e);
            }
        }
        Element imgDescr = image.getChild("description");
        if (imgDescr != null) {
            rssImage.setDescription(imgDescr.getTextTrim());
        }
        chnl.setImage(rssImage);
    }

    // 0..1 textinput element
    Element txtinp = channel.getChild("textinput");
    if (txtinp != null) {

        ParserUtils.matchCaseOfChildren(txtinp, new String[] { "title", "description", "name", "link" });

        TextInputIF rssTextInput = cBuilder.createTextInput(txtinp.getChild("title").getTextTrim(),
                txtinp.getChild("description").getTextTrim(), txtinp.getChild("name").getTextTrim(),
                ParserUtils.getURL(txtinp.getChild("link").getTextTrim()));
        chnl.setTextInput(rssTextInput);
    }

    // 0..1 copyright element
    Element copyright = channel.getChild("copyright");
    if (copyright != null) {
        chnl.setCopyright(copyright.getTextTrim());
    }

    // 0..1 rating element
    Element rating = channel.getChild("rating");
    if (rating != null) {
        chnl.setRating(rating.getTextTrim());
    }

    // 0..1 pubDate element
    Element pubDate = channel.getChild("pubDate");
    if (pubDate != null) {
        chnl.setPubDate(ParserUtils.getDate(pubDate.getTextTrim()));
    }

    // 0..1 lastBuildDate element
    Element lastBuildDate = channel.getChild("lastBuildDate");
    if (lastBuildDate != null) {
        chnl.setLastBuildDate(ParserUtils.getDate(lastBuildDate.getTextTrim()));
    }

    // 0..1 docs element
    Element docs = channel.getChild("docs");
    if (docs != null) {
        chnl.setDocs(docs.getTextTrim());
    }

    // 0..1 managingEditor element
    Element managingEditor = channel.getChild("managingEditor");
    if (managingEditor != null) {
        chnl.setCreator(managingEditor.getTextTrim());
    }

    // 0..1 webMaster element
    Element webMaster = channel.getChild("webMaster");
    if (webMaster != null) {
        chnl.setPublisher(webMaster.getTextTrim());
    }

    // 0..1 cloud element
    Element cloud = channel.getChild("cloud");
    if (cloud != null) {
        String _port = cloud.getAttributeValue("port");
        int port = -1;
        if (_port != null) {
            try {
                port = Integer.parseInt(_port);
            } catch (NumberFormatException e) {
                logger.warn(e);
            }
        }
        chnl.setCloud(
                cBuilder.createCloud(cloud.getAttributeValue("domain"), port, cloud.getAttributeValue("path"),
                        cloud.getAttributeValue("registerProcedure"), cloud.getAttributeValue("protocol")));
    }

    chnl.setLastUpdated(dateParsed);
    // 0..1 skipHours element
    // 0..1 skipDays element

    return chnl;
}

From source file:de.openVJJ.ImageListener.MJPEGServer.java

License:Open Source License

@Override
public void setConfig(Element element) {
    String serverPort = element.getAttribute("server.port").getValue();
    if (serverPort != null) {
        server.port = Integer.parseInt(serverPort);
    }//from w w  w .j  a v a 2s. c om
}

From source file:de.openVJJ.imagePublisher.IPCam_250E_IGuard.java

License:Open Source License

@Override
public void setConfig(Element element) {
    String port = element.getAttribute("port").getValue();
    if (port != null) {
        this.port = Integer.parseInt(port);
    }//from  w  ww  .j  a  v  a 2s.  com
    String networkAddress = element.getAttribute("networkAddress").getValue();
    if (networkAddress != null) {
        this.networkAddress = networkAddress;
    }
}