All Downloads are FREE. Search and download functionalities are using the official Maven repository.

crawlers.elements.AuthorsElement Maven / Gradle / Ivy

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package crawlers.elements;

import java.util.HashSet;
import java.util.Set;
import backend.utils.NamesUtils;

/**
 * An author element stores a single string value with all the authors names and
 * provides a mean to extract a set of string, one for each author.
 *
 * @author zuacaldeiragmail.com
 */
public class AuthorsElement extends ArticleElement {

    /**
     * Initializes a new author element with the given value.
     *
     * @param value A comma-separated string with all authors names.
     */
    public AuthorsElement(String value) {
        super(value);
    }

    /**
     * Converts the single name string into a set of names.
     *
     * @return Return the set with names contained in the single name string. If
     * the name string is null or empty, returns an empty set.
     */
    public Set getAuthors() {
        if (getValue() != null && !getValue().isEmpty()) {
            return NamesUtils.getInstance().extractAuthorsNames(getValue());
        }
        return new HashSet<>();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy