Class LocalizedResource

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    CDAAsset, CDAEntry

    public abstract class LocalizedResource
    extends CDAResource
    Represents a resource which may contain field values for multiple locales.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> T getField​(java.lang.String key)
      Get a field using the environments default locale.
      <T> T getField​(java.lang.String locale, java.lang.String key)
      Extracts a field from the fields set of the active locale, result type is inferred.
      LocalizedResource.Localizer localize​(java.lang.String locale)
      Creates an object to be used for returning different field in one locale.
      java.util.Map<java.lang.String,​java.lang.Object> rawFields()  
      void setField​(java.lang.String locale, java.lang.String key, java.lang.Object value)
      Internal method for updating contents of a field.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • LocalizedResource

        public LocalizedResource()
    • Method Detail

      • localize

        public LocalizedResource.Localizer localize​(java.lang.String locale)
        Creates an object to be used for returning different field in one locale.
        Parameters:
        locale - pointing to a locale in the environment.
        Returns:
        localizer to localize the fields.
      • getField

        public <T> T getField​(java.lang.String key)
        Get a field using the environments default locale.
        Type Parameters:
        T - type.
        Parameters:
        key - field key.
        Returns:
        field value, null if it doesn't exist.
        See Also:
        localize(String)
      • getField

        public <T> T getField​(java.lang.String locale,
                              java.lang.String key)
        Extracts a field from the fields set of the active locale, result type is inferred.
        Type Parameters:
        T - type.
        Parameters:
        locale - locale to be used.
        key - field key.
        Returns:
        field value, null if it doesn't exist.
      • setField

        public void setField​(java.lang.String locale,
                             java.lang.String key,
                             java.lang.Object value)
        Internal method for updating contents of a field.

        This method is used by the SDK to generate objects based on raw fields. Do not use this field to update data on Contentful. Take a look at the CMA-SDK for that.

        Parameters:
        locale - locale to be updated.
        key - the key of the field to be updated.
        value - the value of the field to be used.
      • rawFields

        public java.util.Map<java.lang.String,​java.lang.Object> rawFields()
        Returns:
        raw unprocessed fields.