Search in sources :

Example 1 with DefaultKeywords

use of org.apache.sis.metadata.iso.identification.DefaultKeywords in project sis by apache.

the class MetadataBuilder method addKeywords.

/**
 * Adds keywords if at least one non-empty element exists in the {@code keywords} array.
 * Other arguments have no impact on whether keywords are added or not because only the
 * {@code MD_Keywords.keyword} property is mandatory.
 * Storage locations are:
 *
 * <ul>
 *   <li>{@code metadata/identificationInfo/descriptiveKeywords}</li>
 *   <li>{@code metadata/identificationInfo/thesaurusName/title}</li>
 *   <li>{@code metadata/identificationInfo/type}</li>
 * </ul>
 *
 * @param  keywords       word(s) used to describe the subject, or {@code null} for no-operation.
 * @param  type           subject matter used to group similar keywords, or {@code null} if none.
 * @param  thesaurusName  name of the formally registered thesaurus, or {@code null} if none.
 */
public final void addKeywords(final Iterable<? extends CharSequence> keywords, final KeywordType type, final CharSequence thesaurusName) {
    if (keywords != null) {
        DefaultKeywords group = null;
        Collection<InternationalString> list = null;
        for (final CharSequence kw : keywords) {
            final InternationalString i18n = trim(kw);
            if (i18n != null) {
                if (list == null) {
                    group = new DefaultKeywords();
                    group.setType(type);
                    group.setThesaurusName(sharedCitation(trim(thesaurusName)));
                    list = group.getKeywords();
                }
                list.add(i18n);
            }
        }
        if (group != null) {
            addIfNotPresent(identification().getDescriptiveKeywords(), group);
        }
    }
}
Also used : DefaultKeywords(org.apache.sis.metadata.iso.identification.DefaultKeywords) InternationalString(org.opengis.util.InternationalString)

Aggregations

DefaultKeywords (org.apache.sis.metadata.iso.identification.DefaultKeywords)1 InternationalString (org.opengis.util.InternationalString)1