Package ch.ivyteam.ivy.cm
Interface IContentObjectValue
-
- All Superinterfaces:
org.eclipse.core.runtime.IAdaptable
,ch.ivyteam.ivy.cm.IContentManagementEntity
public interface IContentObjectValue extends ch.ivyteam.ivy.cm.IContentManagementEntity
Content Object Value- API:
- This is a public API.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
delete()
Deletes this content object valuevoid
exportContentToFile(File file, String encoding)
Exports the content to a file using the provided character encoding.InputStream
getContentAsBinaryStream()
Gets the content as binary stream.byte[]
getContentAsByteArray()
Allows to get binary content directly as an array of bytes.Reader
getContentAsCharacterStream()
Gets the content as character stream.String
getContentAsString()
Gets the content as string (works for string and text type).IContentObject
getContentObject()
Gets the associated ContentObject (= parent)IContentObjectType
getContentObjectType()
Gets the associated ContentObjectTypeLocale
getLanguage()
Gets the languagevoid
importContentFromFile(File file, String encoding)
Import the content from a file.default boolean
isValid()
Returns true if the entry is valid.void
setContent(InputStream content, int contentLength)
Sets the content from a binary stream.void
setContent(Reader content, int contentLength)
Sets the content from a character stream.void
setContent(String content)
Sets the content from a string
-
-
-
Method Detail
-
getLanguage
Locale getLanguage()
Gets the language- Returns:
- language
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
getContentObject
IContentObject getContentObject()
Gets the associated ContentObject (= parent)- Returns:
- associated content object
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
getContentObjectType
IContentObjectType getContentObjectType()
Gets the associated ContentObjectType- Returns:
- associated content object type
- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
getContentAsString
String getContentAsString()
Gets the content as string (works for string and text type). If no content exists or if content was set to empty string, thennull
will be returned.- Returns:
- content as string or
null
if no content exists - Throws:
UnsupportedOperationException
- if datatype is binary- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
getContentAsBinaryStream
InputStream getContentAsBinaryStream()
Gets the content as binary stream. If no content exists, thennull
will be returned.If this content value is a string or text type, then the string/text is UTF-8 encoded in the stream.
- Returns:
- content as binary stream or
null
if no content exists - API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
getContentAsCharacterStream
Reader getContentAsCharacterStream()
Gets the content as character stream. If no content exists, thennull
will be returned.- Returns:
- content as character stream or
null
if no content exists - Throws:
UnsupportedOperationException
- if datatype of value is not TEXT- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
getContentAsByteArray
byte[] getContentAsByteArray()
Allows to get binary content directly as an array of bytes. If no content exists, thennull
will be returned.If this content value is a string or text type, then the string/text is UTF-8 encoded in the byte array.
- Returns:
- the content of this value as a byte array or
null
if no content exists - API:
- This public API is available in IvyScript and Java. It has the visibility ADVANCED.
-
setContent
void setContent(String content)
Sets the content from a string- Parameters:
content
- The content to set, can benull
- Throws:
UnsupportedOperationException
- if the datatype of this value is not STRING- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setContent
void setContent(InputStream content, int contentLength)
Sets the content from a binary stream. If contentLength is given as 0 (i.e. read all) then the stream will be closed as soon as the content is read, which means that the stream will be closed upon return. If contentLength is > 0 then the stream will still be open when the method returns.- Parameters:
content
- The content to set, can benull
contentLength
- length of the content to read and write (in bytes), 0 -> to end- Throws:
UnsupportedOperationException
- if the datatype of this value is not BINARY- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
setContent
void setContent(Reader content, int contentLength)
Sets the content from a character stream. If contentLength is given as 0 (i.e. read all) then the reader will be closed as soon as the content is read, which means that the reader will be closed upon return. If contentLength is > 0 then the reader will still be open when the method returns.- Parameters:
content
- The content to set, can benull
contentLength
- length of the content to read and write (in chars), 0 -> to end- Throws:
UnsupportedOperationException
- if the datatype of this value is not TEXT- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
importContentFromFile
void importContentFromFile(File file, String encoding) throws IOException
Import the content from a file. If this value has a non-image (i.e. non-binary) type, then the encoding of the file will be important. It should thus be provided, if non-binary data is read. If encoding is not provided, the platform's default encoding will be used.- Parameters:
file
- the file to importencoding
- the encoding of the file to be read (may be null, in which case the platform's default encoding will be assumed). if this value's datatype is "image", the encoding will not be considered.- Throws:
IOException
- if file could not be readUnsupportedEncodingException
- if provided encoding is not supportedUnsupportedOperationException
- if the datatype of this value is neither TEXT nor BINARY- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
exportContentToFile
void exportContentToFile(File file, String encoding) throws IOException
Exports the content to a file using the provided character encoding. If this value is not a character-based type (i.e. of type "image"), the encoding will be ignored. If no encoding is provided, the platform's default encoding will be used by exporting. If the provided file already exists it will be overwritten.- Parameters:
file
- the file to write toencoding
- the encoding of the file to be written (may be null, in which case the platform's default encoding will be assumed). If this value's datatype is "image", the encoding will be ignored.- Throws:
IOException
- if file could not be readUnsupportedEncodingException
- if provided encoding is not supported- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
delete
void delete()
Deletes this content object value- API:
- This public API is available in IvyScript and Java. It has the visibility NOVICE.
-
isValid
default boolean isValid()
Returns true if the entry is valid. False, if the entry is invalid and should no longer be used. E.g. the entry was deleted and this instance should no longer be used.- Returns:
- True if the entry is valid. False, if the entry is invalid.
- API:
- This public API is available in IvyScript and Java. It has the visibility ADVANCED.
-
-