Package com.contentful.java.cda
Class CDAAsset
- java.lang.Object
-
- com.contentful.java.cda.CDAResource
-
- com.contentful.java.cda.LocalizedResource
-
- com.contentful.java.cda.CDAAsset
-
- All Implemented Interfaces:
java.io.Serializable
public class CDAAsset extends LocalizedResource
Represents a single asset.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.contentful.java.cda.LocalizedResource
LocalizedResource.Localizer
-
-
Constructor Summary
Constructors Constructor Description CDAAsset()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TfileField(java.lang.String key)Helper method to extract a field from thefilemap.CDAMetadatametadata()java.lang.StringmimeType()java.lang.Stringtitle()java.lang.StringtoString()Return a string, showing the id and title.java.lang.Stringurl()java.lang.StringurlForImageWith(ImageOption... options)Returns a url with the given image manipulation.-
Methods inherited from class com.contentful.java.cda.LocalizedResource
getField, getField, localize, rawFields, setField
-
Methods inherited from class com.contentful.java.cda.CDAResource
attrs, getAttribute, id, type
-
-
-
-
Method Detail
-
metadata
public CDAMetadata metadata()
- Returns:
- the metadata set.
-
title
public java.lang.String title()
- Returns:
- title of this asset.
-
url
public java.lang.String url()
- Returns:
- url to the file of this asset.
-
urlForImageWith
public java.lang.String urlForImageWith(ImageOption... options)
Returns a url with the given image manipulation.If the asset is not pointing to an image (as identified by its mimetype) the
url()is returned. Same happens if the options are empty or non existing, then the url gets returned.In an error case (for instance, using the same option twice), the last option with the same operation will be used.
- Parameters:
options- to manipulate the image the returned url will be pointing to.- Returns:
- an url reflecting all the options given.
- Throws:
java.lang.IllegalArgumentException- if no options are given.java.lang.IllegalArgumentException- if no mimetype was set on asset.java.lang.IllegalArgumentException- if mimetype was not an image.- See Also:
ImageOption,url()
-
mimeType
public java.lang.String mimeType()
- Returns:
- mime-type of this asset.
-
fileField
public <T> T fileField(java.lang.String key)
Helper method to extract a field from thefilemap.- Type Parameters:
T- the type of this field.- Parameters:
key- the key who's value to be returned.- Returns:
- field of this file.
-
toString
public java.lang.String toString()
Return a string, showing the id and title.- Overrides:
toStringin classCDAResource- Returns:
- a human readable string
-
-