Class TextualBody
- java.lang.Object
-
- info.freelibrary.iiif.presentation.v3.TextualBody
-
- All Implemented Interfaces:
AnnotationBody<TextualBody>
,ContentResource<TextualBody>
,EmbeddedResource<TextualBody>
public class TextualBody extends Object implements AnnotationBody<TextualBody>, EmbeddedResource<TextualBody>
Text that can be embedded in the body of an annotation. This is different from TextContent which is external text which is referenced in an annotation's body.
-
-
Constructor Summary
Constructors Constructor Description TextualBody()
Creates a new textual body for an annotation.TextualBody(SkolemIriFactory aFactory)
Creates a new textual body for an annotation, supplying an ID factory for ID creation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<MediaType>
getFormat()
Gets TextualBody's format as a media type.URI
getID()
Gets the ID of the TextualBody if it's serializable; else, it returns a null.String
getLanguage()
Gets the TextualBody's ISO-639 language code.String
getType()
Gets the type of annotation body.String
getValue()
Gets the TextualBody's text value.TextualBody
serializeID(boolean aBoolFlag)
Indicates whether the ID should be serialized.TextualBody
setFormat(MediaType aMediaType)
Sets format of the TextualBody.TextualBody
setFormat(String aFormat)
Sets string form of the format of the TextualBody.TextualBody
setID(String aID)
Sets an ID that should be serialized into JSON.TextualBody
setID(URI aID)
Sets an ID that should be serialized into JSON.TextualBody
setLanguage(String aLangTag)
Sets the TextualBody's ISO-639 language code.TextualBody
setValue(String aValue)
Gets the TextualBody's text value.
-
-
-
Constructor Detail
-
TextualBody
public TextualBody()
Creates a new textual body for an annotation.
-
TextualBody
public TextualBody(SkolemIriFactory aFactory)
Creates a new textual body for an annotation, supplying an ID factory for ID creation.- Parameters:
aFactory
- A SkolemIriFactory that can create IDs
-
-
Method Detail
-
getID
public URI getID()
Gets the ID of the TextualBody if it's serializable; else, it returns a null.- Specified by:
getID
in interfaceAnnotationBody<TextualBody>
- Specified by:
getID
in interfaceContentResource<TextualBody>
- Specified by:
getID
in interfaceEmbeddedResource<TextualBody>
- Returns:
- A serializable ID
-
setID
public TextualBody setID(String aID)
Sets an ID that should be serialized into JSON.- Specified by:
setID
in interfaceAnnotationBody<TextualBody>
- Specified by:
setID
in interfaceContentResource<TextualBody>
- Specified by:
setID
in interfaceEmbeddedResource<TextualBody>
- Parameters:
aID
- A serializable ID in string form- Returns:
- This TextualBody
-
setID
public TextualBody setID(URI aID)
Sets an ID that should be serialized into JSON.- Specified by:
setID
in interfaceAnnotationBody<TextualBody>
- Specified by:
setID
in interfaceContentResource<TextualBody>
- Specified by:
setID
in interfaceEmbeddedResource<TextualBody>
- Parameters:
aID
- A serializable ID- Returns:
- This TextualBody
-
serializeID
public TextualBody serializeID(boolean aBoolFlag)
Indicates whether the ID should be serialized.- Parameters:
aBoolFlag
- True if the ID should be serialized; else, false- Returns:
- This TextualBody
-
setValue
public TextualBody setValue(String aValue)
Gets the TextualBody's text value.- Parameters:
aValue
- A text value- Returns:
- This TextualBody
-
getValue
public String getValue()
Gets the TextualBody's text value.- Returns:
- The text value
-
setLanguage
public TextualBody setLanguage(String aLangTag)
Sets the TextualBody's ISO-639 language code.- Parameters:
aLangTag
- A ISO-639 language code- Returns:
- This TextualBody
-
getLanguage
public String getLanguage()
Gets the TextualBody's ISO-639 language code.- Returns:
- This TextualBody
-
getFormat
public Optional<MediaType> getFormat()
Gets TextualBody's format as a media type.- Specified by:
getFormat
in interfaceContentResource<TextualBody>
- Returns:
- An optional media type form of format
-
setFormat
public TextualBody setFormat(String aFormat)
Sets string form of the format of the TextualBody.- Specified by:
setFormat
in interfaceContentResource<TextualBody>
- Parameters:
aFormat
- A TextualBody's format- Returns:
- This TextualBody
- Throws:
IllegalArgumentException
- If the supplied string isn't a media type
-
setFormat
public TextualBody setFormat(MediaType aMediaType)
Sets format of the TextualBody.- Specified by:
setFormat
in interfaceContentResource<TextualBody>
- Parameters:
aMediaType
- A TextualBody's format in MediaType form- Returns:
- This TextualBody
-
getType
public String getType()
Description copied from interface:AnnotationBody
Gets the type of annotation body.- Specified by:
getType
in interfaceAnnotationBody<TextualBody>
- Specified by:
getType
in interfaceContentResource<TextualBody>
- Specified by:
getType
in interfaceEmbeddedResource<TextualBody>
- Returns:
- The type of annotation body
-
-