Class SpecialCases

java.lang.Object
org.apache.sis.metadata.PropertyAccessor
org.apache.sis.metadata.SpecialCases

final class SpecialCases extends PropertyAccessor
Substitute on-the-fly the values of some ISO 19115 properties handled in a special way. Current implementation handles the longitude and latitude bounds of GeographicBoundingBox, which are returned as Longitude or Latitude instances instead of Double.
Since:
0.4
Version:
1.3
  • Field Details

    • westBoundLongitude

      private final int westBoundLongitude
      Index of properties to handle in a special way.
    • eastBoundLongitude

      private final int eastBoundLongitude
      Index of properties to handle in a special way.
    • southBoundLatitude

      private final int southBoundLatitude
      Index of properties to handle in a special way.
    • northBoundLatitude

      private final int northBoundLatitude
      Index of properties to handle in a special way.
  • Constructor Details

    • SpecialCases

      SpecialCases(Class<?> type, Class<?> implementation, Class<?> standardImpl)
      Creates a new property accessor for the specified metadata implementation.
      Parameters:
      type - the interface implemented by the metadata, which must be the value returned by MetadataStandard.findInterface(CacheKey).
      implementation - the class of metadata implementations, or type if none.
      standardImpl - the implementation specified by the MetadataStandard, or null if none. This is the same than implementation unless a custom implementation is used.
  • Method Details

    • isSpecialCase

      static boolean isSpecialCase(Class<?> type)
      Returns true if the given class is a special case handled by the SpecialCases class.
      Parameters:
      type - the interface implemented by the metadata.
      Returns:
      true if the given type is a special case.
    • exclude

      static boolean exclude(Class<?> type, String method)
      Returns true if the given method should be excluded in current Apache SIS version. A future SIS version may handle that property as a special case instead.
      Parameters:
      type - the class or interface containing the method.
      method - the method to test for exclusion.
      Returns:
      true if the given method should be excluded.
    • type

      Class<?> type(int index, TypeValuePolicy policy)
      Delegates to PropertyAccessor.type(int, TypeValuePolicy), then substitutes the type for the properties handled in a special way.
      Overrides:
      type in class PropertyAccessor
      Parameters:
      index - the index of the property.
      policy - the kind of type to return.
      Returns:
      the type of property values, or null if unknown.
    • remarks

      CharSequence remarks(int index, Object metadata)
      Returns a remark or warning to format with the value at the given index, or null if none. This is used for notifying the user that a geographic box is crossing the anti-meridian.
      Overrides:
      remarks in class PropertyAccessor
    • get

      Object get(int index, Object metadata) throws BackingStoreException
      Delegates to PropertyAccessor.get(int, Object), then substitutes the value for the properties handled in a special way.
      Overrides:
      get in class PropertyAccessor
      Parameters:
      index - the index of the property for which to get a value.
      metadata - the metadata object to query.
      Returns:
      the value, or null if none or if the given is out of bounds.
      Throws:
      BackingStoreException - if the implementation threw a checked exception.
    • set

      Object set(int index, Object metadata, Object value, int mode) throws UnmodifiableMetadataException, ClassCastException, BackingStoreException
      Substitutes the value for the properties handled in a special way, then delegates to set(int, Object, Object, int).
      Overrides:
      set in class PropertyAccessor
      Parameters:
      index - the index of the property to set.
      metadata - the metadata object on which to set the value.
      value - the new value.
      mode - whether this method should first fetches the old value, as one of the constants listed in this method javadoc.
      Returns:
      the old value, or null if mode was RETURN_NULL or IGNORE_READ_ONLY.
      Throws:
      UnmodifiableMetadataException - if the property for the given key is read-only.
      ClassCastException - if the given value is not of the expected type.
      BackingStoreException - if the implementation threw a checked exception.
    • isLocaleAndCharset

      static boolean isLocaleAndCharset(PropertyAccessor accessor, int indexInData)
      Returns true if the property at the given index is a Map<Locale,Charset>.
    • rename

      static String rename(String name)
      Returns the identifier to use in replacement of the identifier given in UML annotations. We usually want to use those identifiers as-is because they were specified by ISO standards, but we may do an exception if the identifier is actually a construction of two or more identifiers like "defaultLocale+otherLocale".
      Parameters:
      name - the UML identifier(s) from ISO specification.
      Returns:
      the potentially simplified identifier to use for displaying purpose.