Package com.contentful.java.cda
Class LocalizedResource
- java.lang.Object
-
- com.contentful.java.cda.CDAResource
-
- com.contentful.java.cda.LocalizedResource
-
- All Implemented Interfaces:
java.io.Serializable
public abstract class LocalizedResource extends CDAResource
Represents a resource which may contain field values for multiple locales.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classLocalizedResource.Localizer
-
Constructor Summary
Constructors Constructor Description LocalizedResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetField(java.lang.String key)Get a field using the environments default locale.<T> TgetField(java.lang.String locale, java.lang.String key)Extracts a field from the fields set of the active locale, result type is inferred.LocalizedResource.Localizerlocalize(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()voidsetField(java.lang.String locale, java.lang.String key, java.lang.Object value)Internal method for updating contents of a field.-
Methods inherited from class com.contentful.java.cda.CDAResource
attrs, getAttribute, id, toString, type
-
-
-
-
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.
-
-