/** * Returns the given ISO 19115 metadata as a {@code Person} instance. * This method copies the data only if needed. * * @param r the ISO 19115 metadata, or {@code null}. * @param locale the locale to use for localized strings. * @return the GPX metadata, or {@code null}. */ public static Person castOrCopy(final ResponsibleParty r, final Locale locale) { if (r == null || r instanceof Person) { return (Person) r; } final Role role = r.getRole(); final boolean isCreator = Role.ORIGINATOR.equals(role); if (isCreator || Role.AUTHOR.equals(role)) { final String name = r.getIndividualName(); if (name != null) { final Person pr = new Person(); pr.name = name; pr.isCreator = isCreator; return pr; } } return null; }
/** * Adds role, name, contact and position information for an individual or organization that is responsible * for the resource. This method can be used as an alternative to {@link #addAuthor(CharSequence)} when the * caller needs to create the responsibly party itself. * * <p>If the given {@code role} is non-null, then this method will ensure that the added party has the given * role. A copy of the given party will be created if needed (the given party will never be modified).</p> * * Storage locations are: * * <ul> * <li>{@code metadata/identificationInfo/citation/citedResponsibleParty}</li> * <li>{@code metadata/identificationInfo/citation/citedResponsibleParty/role}</li> * </ul> * * @param party the individual or organization that is responsible, or {@code null} for no-operation. * @param role the role to set, or {@code null} for leaving it unchanged. */ public final void addCitedResponsibleParty(ResponsibleParty party, final Role role) { if (party != null) { if (role != null && !role.equals(party.getRole())) { party = new DefaultResponsibleParty(party); ((DefaultResponsibility) party).setRole(role); } addIfNotPresent(citation().getCitedResponsibleParties(), party); } }
/** * Adds role, name, contact and position information for an individual or organization that is responsible * for the resource. This method can be used as an alternative to {@link #addAuthor(CharSequence)} when the * caller needs to create the responsibly party itself. * * <p>If the given {@code role} is non-null, then this method will ensure that the added party has the given * role. A copy of the given party will be created if needed (the given party will never be modified).</p> * * Storage locations are: * * <ul> * <li>{@code metadata/identificationInfo/citation/citedResponsibleParty}</li> * <li>{@code metadata/identificationInfo/citation/citedResponsibleParty/role}</li> * </ul> * * @param party the individual or organization that is responsible, or {@code null} for no-operation. * @param role the role to set, or {@code null} for leaving it unchanged. */ public final void addCitedResponsibleParty(ResponsibleParty party, final Role role) { if (party != null) { if (role != null && !role.equals(party.getRole())) { party = new DefaultResponsibleParty(party); ((DefaultResponsibility) party).setRole(role); } addIfNotPresent(citation().getCitedResponsibleParties(), party); } }