Search in sources :

Example 6 with Telephone

use of org.opengis.metadata.citation.Telephone in project sis by apache.

the class DefaultContact method getPhone.

/**
 * Returns telephone numbers at which the organization or individual may be contacted.
 * This method returns the first telephone number associated to {@code TelephoneType.VOICE}
 * or {@code TelephoneType.FACSIMILE FACSIMILE}.
 *
 * @return telephone numbers at which the organization or individual may be contacted, or {@code null}.
 *
 * @deprecated As of ISO 19115:2014, replaced by {@link #getPhones()}.
 */
@Override
@Deprecated
@Dependencies("getPhones")
@XmlElement(name = "phone", namespace = LegacyNamespaces.GMD)
public Telephone getPhone() {
    Telephone phone = null;
    if (FilterByVersion.LEGACY_METADATA.accept()) {
        final Collection<Telephone> phones = getPhones();
        if (phones != null) {
            // May be null on marshalling.
            CodeList<?> ignored = null;
            for (final Telephone c : phones) {
                if (c instanceof DefaultTelephone) {
                    String name;
                    final CodeList<?> type = ((DefaultTelephone) c).numberType;
                    if (type != null && ("VOICE".equals(name = type.name()) || "FACSIMILE".equals(name))) {
                        if (phone == null) {
                            phone = c;
                        }
                    } else if (ignored == null) {
                        ignored = type;
                    }
                }
            }
            if (ignored != null) {
                Context.warningOccured(Context.current(), DefaultContact.class, "getPhone", Messages.class, Messages.Keys.IgnoredPropertyAssociatedTo_1, ignored);
            }
        }
    }
    return phone;
}
Also used : Telephone(org.opengis.metadata.citation.Telephone) InternationalString(org.opengis.util.InternationalString) XmlElement(javax.xml.bind.annotation.XmlElement) Dependencies(org.apache.sis.internal.metadata.Dependencies)

Aggregations

Telephone (org.opengis.metadata.citation.Telephone)6 InternationalString (org.opengis.util.InternationalString)2 Collection (java.util.Collection)1 XmlElement (javax.xml.bind.annotation.XmlElement)1 Dependencies (org.apache.sis.internal.metadata.Dependencies)1 DefaultTelephone (org.apache.sis.metadata.iso.citation.DefaultTelephone)1