Search in sources :

Example 26 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class MetadataBuilder method addSampleValueDescription.

/**
 * Adds a description of a particular sample value.
 * Storage location is:
 *
 * <ul>
 *   <li>{@code metadata/contentInfo/rangeElementDescription}</li>
 * </ul>
 *
 * <div class="note"><b>Note:</b>
 * ISO 19115 range elements are approximatively equivalent to
 * {@code org.apache.sis.coverage.Category} in the {@code sis-coverage} module.</div>
 *
 * @param  name        designation associated with a set of range elements, or {@code null} if none.
 * @param  definition  description of a set of specific range elements, or {@code null} if none.
 */
public void addSampleValueDescription(final CharSequence name, final CharSequence definition) {
    final InternationalString i18n = trim(name);
    final InternationalString def = trim(definition);
    if (i18n != null && def != null) {
        final DefaultRangeElementDescription element = new DefaultRangeElementDescription();
        element.setName(i18n);
        element.setDefinition(def);
        addIfNotPresent(coverageDescription().getRangeElementDescriptions(), element);
    }
}
Also used : InternationalString(org.opengis.util.InternationalString) DefaultRangeElementDescription(org.apache.sis.metadata.iso.content.DefaultRangeElementDescription)

Example 27 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class MetadataBuilder method addSupplementalInformation.

/**
 * Adds any other descriptive information about the resource.
 * If information already exists, the new one will be appended after a new line.
 * Storage location is:
 *
 * <ul>
 *   <li>{@code metadata/identificationInfo/supplementalInformation}</li>
 * </ul>
 *
 * @param info  any other descriptive information about the resource, or {@code null} for no-operation.
 */
public final void addSupplementalInformation(final CharSequence info) {
    final InternationalString i18n = trim(info);
    if (i18n != null) {
        final DefaultDataIdentification identification = identification();
        identification.setSupplementalInformation(append(identification.getSupplementalInformation(), i18n));
    }
}
Also used : InternationalString(org.opengis.util.InternationalString) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification)

Example 28 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class MetadataBuilder method append.

/**
 * Returns the concatenation of the given strings. The previous string may be {@code null}.
 * This method does nothing if the previous string already contains the one to append.
 */
private static InternationalString append(final InternationalString previous, final InternationalString toAdd) {
    if (previous == null) {
        return toAdd;
    }
    final String p = previous.toString();
    final String a = toAdd.toString();
    if (p.contains(a)) {
        return previous;
    }
    return Types.toInternationalString(p + System.lineSeparator() + a);
}
Also used : InternationalString(org.opengis.util.InternationalString)

Example 29 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class MetadataBuilder method addHostComputer.

/**
 * Adds information about the computer and/or operating system in use at the processing time.
 * This is added to the processing identified by last call to {@link #addProcessing(CharSequence, String)}.
 * Storage location is:
 *
 * <ul>
 *   <li>{@code metadata/resourceLineage/processStep/processingInformation/procedureDescription}</li>
 * </ul>
 *
 * @param  platform  name of the system on which the processing has been executed, or {@code null} for no-operation.
 */
public final void addHostComputer(final CharSequence platform) {
    InternationalString i18n = trim(platform);
    if (i18n != null) {
        i18n = Resources.formatInternational(Resources.Keys.ProcessingExecutedOn_1, i18n);
        final DefaultProcessing p = processing();
        p.setProcedureDescription(append(p.getProcedureDescription(), i18n));
    }
}
Also used : InternationalString(org.opengis.util.InternationalString) DefaultProcessing(org.apache.sis.metadata.iso.lineage.DefaultProcessing)

Example 30 with InternationalString

use of org.opengis.util.InternationalString in project sis by apache.

the class FeatureFormat method formatValue.

/**
 * Appends the given attribute value, in a truncated form if it exceed the maximal value length.
 *
 * @param  value   the value to append.
 * @param  table   where to append the value.
 * @param  length  number of characters appended before this method call in the current table cell.
 * @return number of characters appended after this method call in the current table cell, or -1 if
 *         the length exceed the maximal length (in which case the caller should break iteration).
 */
private int formatValue(final Object value, final TableAppender table, final int length) {
    String text;
    if (value instanceof InternationalString) {
        text = ((InternationalString) value).toString(displayLocale);
    } else if (value instanceof GenericName) {
        text = toString((GenericName) value);
    } else if (value instanceof AbstractIdentifiedType) {
        text = toString(((AbstractIdentifiedType) value).getName());
    } else if (value instanceof IdentifiedObject) {
        text = IdentifiedObjects.getIdentifierOrName((IdentifiedObject) value);
    } else if ((text = Geometries.toString(value)) == null) {
        text = value.toString();
    }
    final int remaining = MAXIMAL_VALUE_LENGTH - length;
    if (remaining >= text.length()) {
        table.append(text);
        return length + text.length();
    } else {
        table.append(text, 0, Math.max(0, remaining - 1)).append('…');
        return -1;
    }
}
Also used : GenericName(org.opengis.util.GenericName) InternationalString(org.opengis.util.InternationalString) InternationalString(org.opengis.util.InternationalString) IdentifiedObject(org.opengis.referencing.IdentifiedObject)

Aggregations

InternationalString (org.opengis.util.InternationalString)86 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)20 Test (org.junit.Test)17 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)13 IdentifiedObject (org.opengis.referencing.IdentifiedObject)10 ArrayList (java.util.ArrayList)7 Locale (java.util.Locale)6 GenericName (org.opengis.util.GenericName)6 Extent (org.opengis.metadata.extent.Extent)5 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)4 DependsOnMethod (org.apache.sis.test.DependsOnMethod)4 Vocabulary (org.apache.sis.util.resources.Vocabulary)4 Citation (org.opengis.metadata.citation.Citation)4 IllegalArgumentException (com.sun.star.lang.IllegalArgumentException)3 ResultSet (java.sql.ResultSet)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 TableAppender (org.apache.sis.io.TableAppender)3 AbstractIdentifiedObject (org.apache.sis.referencing.AbstractIdentifiedObject)3 DataStoreException (org.apache.sis.storage.DataStoreException)3