Example usage for org.jdom2 Element getChild

List of usage examples for org.jdom2 Element getChild

Introduction

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

Prototype

public Element getChild(final String cname, final Namespace ns) 

Source Link

Document

This returns the first child element within this element with the given local name and belonging to the given namespace.

Usage

From source file:com.rometools.rome.io.impl.CBModuleParser.java

License:Apache License

/**
 * Utility method to parse a otherStatistic.
 * <p>/*from   w  ww.  jav  a  2 s  .  c om*/
 *
 * @param the element to parse.
 * @return otherStatistic parsed from the element.
 */
protected final CBOtherStatistics parseOtherStatistic(final Element element) {
    final CBOtherStatistics otherStatistic = new CBOtherStatisticsImpl();

    final Element observation = element.getChild("observation", getCBNamespace());
    if (observation != null) {
        otherStatistic.setObservation(parseObservation(observation));
    }

    final Element topic = element.getChild("topic", getCBNamespace());
    if (topic != null) {
        otherStatistic.setTopic(topic.getText());
    }

    final Element coverage = element.getChild("coverage", getCBNamespace());
    if (coverage != null) {
        otherStatistic.setCoverage(coverage.getText());
    }

    final Element dataType = element.getChild("dataType", getCBNamespace());
    if (dataType != null) {
        otherStatistic.setDataType(dataType.getText());
    }

    final Element observationPeriod = element.getChild("observationPeriod", getCBNamespace());
    if (observationPeriod != null) {
        otherStatistic.setObservationPeriod(parseObservationPeriod(observationPeriod));
    }

    return otherStatistic;
}

From source file:com.rometools.rome.io.impl.CBModuleParser.java

License:Apache License

/**
 * Utility method to parse a observationPeriod.
 * <p>//w  w w .  ja  v a 2s.  c om
 *
 * @param the element to parse.
 * @return observationPeriod parsed from the element.
 */
protected final CBObservationPeriod parseObservationPeriod(final Element element) {
    final CBObservationPeriod observationPeriod = new CBObservationPeriodImpl();

    final Element frequency = element.getChild("frequency", getCBNamespace());
    if (frequency != null) {
        observationPeriod.setFrequency(frequency.getText());
    }

    final Element period = element.getChild("period", getCBNamespace());
    if (period != null) {
        observationPeriod.setPeriod(period.getText());
    }

    return observationPeriod;
}

From source file:com.rometools.rome.io.impl.CBModuleParser.java

License:Apache License

/**
 * Utility method to parse a observation.
 * <p>/*from w  w  w  . j av  a 2  s  .  c o m*/
 *
 * @param the element to parse.
 * @return observation parsed from the element.
 */
protected final CBObservation parseObservation(final Element element) {
    final CBObservation observation = new CBObservationImpl();

    final Element value = element.getChild("value", getCBNamespace());
    if (value != null) {
        observation.setValue(value.getText());
    }

    final Element unit = element.getChild("unit", getCBNamespace());
    if (unit != null) {
        observation.setUnit(unit.getText());
    }

    final Element unit_mult = element.getChild("unit_mult", getCBNamespace());
    if (unit_mult != null) {
        observation.setUnitMult(unit_mult.getText());
    }

    final Element decimals = element.getChild("decimals", getCBNamespace());
    if (decimals != null) {
        observation.setDecimal(decimals.getText());
    }

    return observation;
}

From source file:com.rometools.rome.io.impl.CBModuleParser.java

License:Apache License

/**
 * Utility method to parse a speech./*  ww w  . ja v a  2s.  c  o  m*/
 * <p>
 *
 * @param the element to parse.
 * @return speech parsed from the element.
 */
protected final CBSpeech parseSpeech(final Element element) {
    final CBSpeech speech = new CBSpeechImpl();

    final Element simpleTitle = element.getChild("simpleTitle", getCBNamespace());
    if (simpleTitle != null) {
        speech.setSimpleTitle(simpleTitle.getText());
    }

    final Element occurrenceDate = element.getChild("occurrenceDate", getCBNamespace());
    if (occurrenceDate != null) {
        speech.setOccurrenceDate(occurrenceDate.getText());
    }

    final Element institutionAbbrev = element.getChild("institutionAbbrev", getCBNamespace());
    if (institutionAbbrev != null) {
        speech.setInstitutionAbbrev(institutionAbbrev.getText());
    }

    final Element audience = element.getChild("audience", getCBNamespace());
    if (audience != null) {
        speech.setAudience(audience.getText());
    }

    final List<Element> keyList = element.getChildren("keyword", getCBNamespace());
    for (Element keyword : keyList) {
        speech.getKeywords().add(keyword.getText());
    }

    final Element resource = element.getChild("resource", getCBNamespace());
    if (resource != null) {
        speech.setResource(parseResource(resource));
    }

    final Element person = element.getChild("person", getCBNamespace());
    if (person != null) {
        speech.setPerson(parsePerson(person));
    }

    final Element venue = element.getChild("venue", getCBNamespace());
    if (venue != null) {
        speech.setVenue(venue.getText());
    }

    final Element locationAsWritten = element.getChild("locationAsWritten", getCBNamespace());
    if (locationAsWritten != null) {
        speech.setLocationAsWritten(locationAsWritten.getText());
    }

    final Element locationCountry = element.getChild("locationCountry", getCBNamespace());
    if (locationCountry != null) {
        speech.setLocationCountry(ISO3166CountyCode.fromValue(locationCountry.getText()));
    }

    final Element locationState = element.getChild("locationState", getCBNamespace());
    if (locationState != null) {
        speech.setLocationState(locationState.getText());
    }

    final Element locationCity = element.getChild("locationCity", getCBNamespace());
    if (locationCity != null) {
        speech.setLocationCity(locationCity.getText());
    }

    return speech;
}

From source file:com.rometools.rome.io.impl.CBModuleParser.java

License:Apache License

/**
 * Utility method to parse an event./*from w  w w.  j ava2  s .  c  om*/
 * <p>
 *
 * @param the element to parse.
 * @return event parsed from the element.
 */
protected final CBEvent parseEvent(final Element element) {

    final CBEvent event = new CBEventImpl();

    final Element simpleTitle = element.getChild("simpleTitle", getCBNamespace());
    if (simpleTitle != null) {
        event.setSimpleTitle(simpleTitle.getText());
    }

    final Element occurenceDate = element.getChild("occurenceDate", getCBNamespace());
    if (occurenceDate != null) {
        event.setOccurenceDate(occurenceDate.getText());
    }

    final Element institutionAbbrev = element.getChild("institutionAbbrev", getCBNamespace());
    if (institutionAbbrev != null) {
        event.setInstitutionAbbrev(institutionAbbrev.getText());
    }

    final Element audience = element.getChild("audience", getCBNamespace());
    if (audience != null) {
        event.setAudience(audience.getText());
    }

    final List<Element> keyList = element.getChildren("keyword", getCBNamespace());
    for (Element keyword : keyList) {
        event.getKeywords().add(keyword.getText());
    }

    final Element resource = element.getChild("resource", getCBNamespace());
    if (resource != null) {
        event.setResource(parseResource(resource));
    }

    final Element person = element.getChild("person", getCBNamespace());
    if (person != null) {
        event.setPerson(parsePerson(person));
    }

    final Element venue = element.getChild("venue", getCBNamespace());
    if (venue != null) {
        event.setVenue(venue.getText());
    }

    final Element locationAsWritten = element.getChild("locationAsWritten", getCBNamespace());
    if (locationAsWritten != null) {
        event.setLocationAsWritten(locationAsWritten.getText());
    }

    final Element locationCountry = element.getChild("locationCountry", getCBNamespace());
    if (locationCountry != null) {
        event.setLocationCountry(locationCountry.getText());
    }

    final Element locationState = element.getChild("locationState", getCBNamespace());
    if (locationState != null) {
        event.setLocationState(locationState.getText());
    }

    final Element locationCity = element.getChild("locationCity", getCBNamespace());
    if (locationCity != null) {
        event.setLocationCity(locationCity.getText());
    }

    final Element eventDateEnd = element.getChild("eventDateEnd", getCBNamespace());
    if (eventDateEnd != null) {
        event.setEventDateEnd(eventDateEnd.getText());
    }

    return event;
}

From source file:com.rometools.rome.io.impl.CBModuleParser.java

License:Apache License

/**
 * Utility method to parse a paper.//from w  ww . ja  va  2s .  co m
 * <p>
 *
 * @param the element to parse.
 * @return paper parsed from the element.
 */
protected final CBPaper parsePaper(final Element element) {
    final CBPaper paperObj = new CBPaperImpl();

    final Element simpleTitle = element.getChild("simpleTitle", getCBNamespace());
    if (simpleTitle != null) {
        paperObj.setSimpleTitle(simpleTitle.getText());
    }

    final Element occurrenceDate = element.getChild("occurrenceDate", getCBNamespace());
    if (occurrenceDate != null) {
        paperObj.setOccurrenceDate(occurrenceDate.getText());
    }

    final Element institutionAbbrev = element.getChild("institutionAbbrev", getCBNamespace());
    if (institutionAbbrev != null) {
        paperObj.setInstitutionAbbrev(institutionAbbrev.getText());
    }

    final List<Element> keyList = element.getChildren("keyword", getCBNamespace());
    List<String> kList = new ArrayList<String>();
    for (Element keyword : keyList) {
        kList.add(keyword.getText());
    }
    paperObj.setKeywords(kList);

    final Element resource = element.getChild("resource", getCBNamespace());
    if (resource != null) {
        paperObj.setResource(parseResource(resource));
    }

    final Element person = element.getChild("person", getCBNamespace());
    if (person != null) {
        paperObj.setPerson(parsePerson(person));
    }

    final Element byline = element.getChild("byline", getCBNamespace());
    if (byline != null) {
        paperObj.setByline(byline.getText());
    }

    final Element publicationDate = element.getChild("publicationDate", getCBNamespace());
    if (publicationDate != null) {
        paperObj.setPublicationDate(publicationDate.getText());
    }

    final Element publication = element.getChild("publication", getCBNamespace());
    if (publication != null) {
        paperObj.setPublication(publication.getText());
    }

    final Element issue = element.getChild("issue", getCBNamespace());
    if (issue != null) {
        paperObj.setIssue(issue.getText());
    }

    final Element JELCode = element.getChild("JELCode", getCBNamespace());
    if (JELCode != null) {
        paperObj.setJELCode(JELCode.getText());
    }

    return paperObj;
}

From source file:com.rometools.rome.io.impl.CBModuleParser.java

License:Apache License

/**
 * Utility method to parse a resource.//from   ww  w.j  av  a2 s  .co m
 * <p>
 *
 * @param the element to parse.
 * @return resource parsed from the element.
 */
protected final CBResource parseResource(final Element element) {
    final CBResource resource = new CBResourceImpl();

    final Element title = element.getChild("title", getCBNamespace());
    if (title != null) {
        resource.setTitle(title.getText());
    }

    final Element link = element.getChild("link", getCBNamespace());
    if (link != null) {
        resource.setLink(link.getText());
    }

    final Element description = element.getChild("description", getCBNamespace());
    if (description != null) {
        resource.setDescription(description.getText());
    }

    return resource;
}

From source file:com.rometools.rome.io.impl.CBModuleParser.java

License:Apache License

/**
 * Utility method to parse a person.//from w  w w .  j  av  a 2s.co m
 * <p>
 *
 * @param the element to parse.
 * @return person parsed from the element.
 */
protected final CBPerson parsePerson(final Element element) {
    final CBPerson person = new CBPersonImpl();

    final Element givenName = element.getChild("givenName", getCBNamespace());
    if (givenName != null) {
        person.setGivenName(givenName.getText());
    }

    final Element surname = element.getChild("surname", getCBNamespace());
    if (surname != null) {
        person.setSurname(surname.getText());
    }

    final Element personalTitle = element.getChild("personalTitle", getCBNamespace());
    if (personalTitle != null) {
        person.setPersonalTitle(personalTitle.getText());
    }

    final Element nameAsWritten = element.getChild("nameAsWritten", getCBNamespace());
    if (nameAsWritten != null) {
        person.setNameAsWritten(nameAsWritten.getText());
    }

    final Element role = element.getChild("role", getCBNamespace());
    if (nameAsWritten != null) {
        person.setRole(parseRole(role));
    }

    return person;
}

From source file:com.rometools.rome.io.impl.CBModuleParser.java

License:Apache License

/**
 * Utility method to parse a role.//from   www  .  ja  v a  2 s  .com
 * <p>
 *
 * @param the element to parse.
 * @return role parsed from the element.
 */
protected final CBRole parseRole(final Element element) {
    final CBRole role = new CBRoleImpl();

    final Element jobTitle = element.getChild("jobTitle", getCBNamespace());
    if (jobTitle != null) {
        role.setJobTitle(jobTitle.getText());
    }

    final Element affiliation = element.getChild("affiliation", getCBNamespace());
    if (affiliation != null) {
        role.setAffiliation(affiliation.getText());
    }

    return role;
}

From source file:com.rometools.rome.io.impl.CBModuleParser.java

License:Apache License

/**
 * Utility method to parse an news.//from  w  w  w .  j  a v  a2  s . c om
 * <p>
 *
 * @param the element to parse.
 * @return news parsed from the element.
 */
protected final CBNews parseNews(final Element element) {

    final CBNews news = new CBNewsImpl();

    final Element simpleTitle = element.getChild("simpleTitle", getCBNamespace());
    if (simpleTitle != null) {
        news.setSimpleTitle(simpleTitle.getText());
    }

    final Element occurenceDate = element.getChild("occurenceDate", getCBNamespace());
    if (occurenceDate != null) {
        news.setOccurenceDate(occurenceDate.getText());
    }

    final Element institutionAbbrev = element.getChild("institutionAbbrev", getCBNamespace());
    if (institutionAbbrev != null) {
        news.setInstitutionAbbrev(institutionAbbrev.getText());
    }

    final List<Element> keyList = element.getChildren("keyword", getCBNamespace());
    for (Element keyword : keyList) {
        news.getKeywords().add(keyword.getText());
    }

    final Element resource = element.getChild("resource", getCBNamespace());
    if (resource != null) {
        news.setResource(parseResource(resource));
    }

    final Element person = element.getChild("person", getCBNamespace());
    if (person != null) {
        news.setPerson(parsePerson(person));
    }

    return news;
}