Example usage for org.jdom2 Element getText

List of usage examples for org.jdom2 Element getText

Introduction

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

Prototype

public String getText() 

Source Link

Document

Returns the textual content directly held under this element as a string.

Usage

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

License:Apache License

/**
 * Utility method to parse a observation.
 * <p>/*from   w w w.jav  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./*from w w w  . j a  v a2s. 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./*w  w  w . j  a v  a 2s . 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 www  .j  a va2 s . c  om
 * <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  w w  w .  j a va  2 s  .c  om
 * <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./* w  w  w.  j a  v  a2  s  .c  om*/
 * <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./* w  ww. j ava2s .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./* w w  w  .j av a 2  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;
}

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

License:Open Source License

/**
 * Utility method to parse a list of subjects out of a list of elements.
 * <p>/*  ww  w .  j av a  2s  .  c o m*/
 *
 * @param eList the element list to parse.
 * @return a list of subjects parsed from the elements.
 */
protected final List<DCSubject> parseSubjects(final List<Element> eList) {

    final List<DCSubject> subjects = new ArrayList<DCSubject>();

    for (final Element eSubject : eList) {

        final Element description = eSubject.getChild("Description", getRDFNamespace());

        if (description != null) {

            final String taxonomy = getTaxonomy(description);

            final List<Element> values = description.getChildren("value", getRDFNamespace());
            for (final Element value : values) {

                final DCSubject subject = new DCSubjectImpl();
                subject.setTaxonomyUri(taxonomy);
                subject.setValue(value.getText());
                subjects.add(subject);

            }

        } else {
            final DCSubject subject = new DCSubjectImpl();
            subject.setValue(eSubject.getText());
            subjects.add(subject);
        }
    }

    return subjects;
}

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

License:Open Source License

/**
 * Utility method to parse a list of strings out of a list of elements.
 * <p>//  w  ww.java 2 s .c  o  m
 *
 * @param elements the list of elements to parse.
 * @return the list of strings
 */
protected final List<String> parseElementList(final List<Element> elements) {
    final List<String> values = new ArrayList<String>();
    for (final Element element : elements) {
        values.add(element.getText());
    }
    return values;
}