/** * Localize the specified property name. In current version, this is merely a hook for future * development. For now we reformat the programatic name. */ private String localize(final CodeList code) { return code.name().trim().replace('_', ' ').toLowerCase(locale); }
/** * Returns the exception code, or {@code null} if none. */ public CodeList getCode() { return CodeList.valueOf(CodeList.class, code); }
/** * Returns {@code true} if the given name matches the {@linkplain #name name}, {@linkplain * #identifier identifier} or any other identification string of this code list element. The * comparison is case-insensitive. * * @param name The name to check. * @return {@code true} if the given name matches the code name or identifier. * @since GeoAPI 2.2 */ public boolean matches(String name) { if (name == null) { return false; } if (name.equalsIgnoreCase(this.name)) { return true; } final String identifier = identifier(); return (identifier != null) && name.equalsIgnoreCase(identifier); }
return null; String id = code.identifier(); final String name = code.name(); if (id == null) { id = name; for (final String candidate : code.names()) { if (!candidate.equals(name) && candidate.length() >= id.length()) { id = candidate;
/** * Returns the ISO name (if available) or the Java name (as a fallback) of the given enumeration or code list * value. If the value has no {@link UML} identifier, then the programmatic name is used as a fallback. * * <div class="note"><b>Examples:</b> * <ul> * <li>{@code getCodeName(ParameterDirection.IN_OUT)} returns {@code "in/out"}.</li> * <li>{@code getCodeName(AxisDirection.NORTH)} returns {@code "north"}.</li> * <li>{@code getCodeName(CharacterSet.UTF_8)} returns {@code "utf8"}.</li> * <li>{@code getCodeName(ImagingCondition.BLURRED_IMAGE)} returns {@code "blurredImage"}.</li> * </ul> * </div> * * @param code the code for which to get the name, or {@code null}. * @return the UML identifiers or programmatic name for the given code, or {@code null} if the given code is null. * * @see #getCodeLabel(CodeList) * @see #getCodeTitle(CodeList) * @see #getDescription(CodeList) * @see #forCodeName(Class, String, boolean) */ public static String getCodeName(final CodeList<?> code) { if (code == null) { return null; } final String id = code.identifier(); return (id != null && !id.isEmpty()) ? id : code.name(); }
@Override public boolean accept(final CodeList<?> code) { for (final String n : code.names()) { if (name.equalsIgnoreCase(n)) { return true; } } return false; } });
protected Object readResolve() throws ObjectStreamException { CodeList[] arrayOfCodeList = family(); for (int i = 0; i < arrayOfCodeList.length; i++) { assert (arrayOfCodeList[i].ordinal == i) : i; if (name.equals(arrayOfCodeList[i].name)) return arrayOfCodeList[i]; } throw new InvalidObjectException(toString()); } }
protected CodeList(String paramString, Collection paramCollection) { name = (paramString = paramString.trim()); synchronized (paramCollection) { ordinal = paramCollection.size(); assert (!contains(paramCollection, paramString)) : paramString; if (!paramCollection.add(this)) throw new IllegalArgumentException(String.valueOf(paramCollection)); } }
return null; String id = code.identifier(); final String name = code.name(); if (id == null) { id = name; for (final String candidate : code.names()) { if (!candidate.equals(name) && candidate.length() >= id.length()) { id = candidate;
/** * Returns the ISO name (if available) or the Java name (as a fallback) of the given enumeration or code list * value. If the value has no {@link UML} identifier, then the programmatic name is used as a fallback. * * <div class="note"><b>Examples:</b> * <ul> * <li>{@code getCodeName(ParameterDirection.IN_OUT)} returns {@code "in/out"}.</li> * <li>{@code getCodeName(AxisDirection.NORTH)} returns {@code "north"}.</li> * <li>{@code getCodeName(CharacterSet.UTF_8)} returns {@code "utf8"}.</li> * <li>{@code getCodeName(ImagingCondition.BLURRED_IMAGE)} returns {@code "blurredImage"}.</li> * </ul> * </div> * * @param code the code for which to get the name, or {@code null}. * @return the UML identifiers or programmatic name for the given code, or {@code null} if the given code is null. * * @see #getCodeLabel(CodeList) * @see #getCodeTitle(CodeList) * @see #getDescription(CodeList) * @see #forCodeName(Class, String, boolean) */ public static String getCodeName(final CodeList<?> code) { if (code == null) { return null; } final String id = code.identifier(); return (id != null && !id.isEmpty()) ? id : code.name(); }
/** * Returns {@code true} if the given code matches the name we are looking for. */ @Override public boolean accept(final CodeList<?> code) { for (final String candidate : code.names()) { if (accept(candidate, codename)) { return true; } } return false; }
/** * Resolves the code list to an unique instance after deserialization. * The instance is resolved using its {@linkplain #name() name} only * (not its {@linkplain #ordinal() ordinal}). * * @return This code list as an unique instance. * @throws ObjectStreamException if the deserialization failed. */ protected Object readResolve() throws ObjectStreamException { final CodeList[] codes = family(); for (int i=0; i<codes.length; i++) { assert codes[i].ordinal == i : i; if (name.equals(codes[i].name)) { return codes[i]; } } throw new InvalidObjectException(toString()); } }
/** * Creates a new code list element and add it to the given collection. Subclasses * will typically give a static reference to an {@link java.util.ArrayList} for * the {@code values} argument. This list is used for {@code values()} * method implementations. * * @param name The code name. * @param values The collection to add the element to. */ protected CodeList(String name, final Collection values) { this.name = (name=name.trim()); synchronized (values) { this.ordinal = values.size(); assert !contains(values, name) : name; if (!values.add( this)) { throw new IllegalArgumentException(String.valueOf(values)); } } }
/** * Append a code list to the WKT. * * @param code The code list to format. */ public void append(final CodeList code) { if (code != null) { appendSeparator(false); setColor(CODELIST_COLOR); final String name = code.name(); final boolean needQuotes = (name.indexOf(' ') >= 0); if (needQuotes) { buffer.append(symbols.quote); } buffer.append(name); if (needQuotes) { buffer.append(symbols.quote); setInvalidWKT(code.getClass()); } resetColor(); } }
return valueOf(codeType, new Filter() { @Override public boolean accept(CodeList<?> code) {
/** * Returns {@code true} if the given code matches the name we are looking for. */ @Override public boolean accept(final CodeList<?> code) { for (final String candidate : code.names()) { if (accept(candidate, codename)) { return true; } } return false; }
public String[] names() { final String name = this.name; final String identifier = identifier(); if (identifier != null && !identifier.equals(name)) { return new String[] {name, identifier};
if (code >= 1 && code < values.length) { candidate = values[code - 1]; candidateName.append(candidate.name()); if (identifier.equals(geoApiToIso.getProperty(candidateName.toString()))) { return candidate; candidate = values[i]; candidateName.setLength(base); candidateName.append(candidate.name()); if (identifier.equals(geoApiToIso.getProperty(candidateName.toString()))) { return candidate;
return valueOf(codeType, new Filter() { @Override public boolean accept(CodeList<?> code) {
/** * Returns the programmatic name and the UML identifier of this code, together with alternative UML identifier * if any. In particular, {@link #CELL_CENTER} is known as both {@code "cell center"} (from ISO 19111:2007) and * {@code "cell centre"} (derived from ISO 19162:2015). * * @return Names of this code, including alternative names if any. */ @Override public String[] names() { if (this == CELL_CENTER) { return new String[] {name(), identifier(), "cell centre"}; } return super.names(); }