Package com.exedio.cope.pattern
Class Media
java.lang.Object
com.exedio.cope.Feature
com.exedio.cope.Pattern
com.exedio.cope.pattern.MediaPath
com.exedio.cope.pattern.Media
- All Implemented Interfaces:
Copyable
,Settable<Media.Value>
,Serializable
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class com.exedio.cope.pattern.MediaPath
MediaPath.Locator, MediaPath.Log, MediaPath.NotFound
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.UsebodyMismatchesContentTypeIfSupported()
instead.The result may cause anUnsupportedQueryException
when used, if the field is stored in avault
.boolean
checkContentType
(String contentType) contentType
(String contentType) Creates a new media, that must contain the given content type only.contentType
(String contentType1, String contentType2) Creates a new media, that must contain one of the given content types only.contentType
(String contentType1, String contentType2, String contentType3) Creates a new media, that must contain one of the given content types only.contentType
(String contentType1, String contentType2, String contentType3, String contentType4) Creates a new media, that must contain one of the given content types only.contentType
(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5) Creates a new media, that must contain one of the given content types only.contentType
(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5, String contentType6) Creates a new media, that must contain one of the given content types only.contentType
(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5, String contentType6, String contentType7) Creates a new media, that must contain one of the given content types only.contentType
(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5, String contentType6, String contentType7, String contentType8) Creates a new media, that must contain one of the given content types only.contentType
(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5, String contentType6, String contentType7, String contentType8, String contentType9) Creates a new media, that must contain one of the given content types only.contentType
(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5, String contentType6, String contentType7, String contentType8, String contentType9, String contentType10) Creates a new media, that must contain one of the given content types only.contentTypeEqual
(String contentType) contentTypeLengthMax
(int maximumLength) contentTypeMajor
(String majorContentType) Deprecated.UsecontentTypeSub(String)
insteadcontentTypeSub
(String majorContentType) Creates a new media, that must contain the a content type with the given major part only.copy
(CopyMapper mapper) void
doGetAndCommit
(HttpServletRequest request, HttpServletResponse response, Item item) The implementor MUSTcommit
the transaction, if the method completes normally (without exception).SetValue<?>[]
execute
(Media.Value value, Item exceptionItem) static Media
getBody()
byte[]
Returns the body of this media.void
Writes the body of this media into the given file.void
getBody
(Item item, OutputStream body) Writes the body of this media into the given steam.void
getContentType
(Item item) Returns the content type of this media.int
Returns a list of content types allowed for this media.Returns the exceptions possibly thrown, when setting a value for this settable.Class<?>
getLastModified
(Item item) Returns the date of the last modification of this media.long
Returns the length of the body of this media.long
boolean
boolean
boolean
isFinal()
Returns, whether the contents of this media path may change or not.boolean
Returns true, if a value for the settable should be specified on the creation of an item.boolean
A MediaPath is "mandatory" ifMediaPath.getContentType(Item)
andMediaPath.getLocator(Item)
will not returnnull
for any item.Returns a condition matching all items, for whichMediaPath.getLocator(Item)
does not return null.Returns a condition matching all items, for whichMediaPath.getLocator(Item)
does not return null.isNull()
Returns a condition matching all items, for whichMediaPath.getLocator(Item)
returns null.boolean
Returns a condition matching all items, for whichMediaPath.getLocator(Item)
returns null.lengthMax
(long maximumLength) optional()
void
Sets the contents of this media.void
set
(Item item, Media.Value value) Sets the contents of this media.void
Sets the contents of this media.void
set
(Item item, InputStream body, String contentType) Sets the contents of this media.void
void
setLastModified
(Item item, Date value) toFinal()
static Media.Value
static Media.Value
toValue
(DataField.Value body, String contentType) static Media.Value
static Media.Value
toValue
(InputStream body, String contentType) static Media.Value
Methods inherited from class com.exedio.cope.pattern.MediaPath
commit, getExceptionLogs, getGuessedUrlLogs, getInfo, getInvalidSpecialLogs, getIsNullLogs, getLocator, getNamedURL, getNoSuchItemLogs, getNoSuchPath, getNoSuchPathLogs, getNotAnItemLogs, getNotComputableLogs, getURL, incrementDelivered, isUrlFingerPrinted, isUrlGuessingPrevented, isUrlGuessingPreventedSecurely, notFoundIsNull, notFoundNotComputable, onMount
Methods inherited from class com.exedio.cope.Pattern
addSource, addSource, addSource, addSource, addSourceFeature, addSourceFeature, addSourceFeature, annotationField, equals, getGeneratedTypes, getSourceFeatures, getSourceFeaturesGather, getSourceFields, getSources, getSourceTypes, getType, hashCode, initialize, newSourceType, newSourceType, newSourceType, newSourceType, newSourceType, newSourceType, newType, newType, registerSource
Methods inherited from class com.exedio.cope.Feature
afterModelCreated, getAbstractType, getAnnotation, getID, getLocalizationKeys, getName, getPattern, isAnnotationPresent, isSourceAlready, mount, readResolve, requireMounted, toString, toString, writeReplace
-
Field Details
-
DEFAULT_LENGTH
public static final long DEFAULT_LENGTH- See Also:
-
-
Constructor Details
-
Media
public Media() -
Media
Deprecated.usecontentType(String)
instead. -
Media
Deprecated.usecontentTypeSub(String)
instead.
-
-
Method Details
-
copy
-
toFinal
-
optional
-
lengthMax
-
contentType
Creates a new media, that must contain the given content type only. -
contentType
Creates a new media, that must contain one of the given content types only. -
contentType
Creates a new media, that must contain one of the given content types only. -
contentType
public Media contentType(String contentType1, String contentType2, String contentType3, String contentType4) Creates a new media, that must contain one of the given content types only. -
contentType
public Media contentType(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5) Creates a new media, that must contain one of the given content types only. -
contentType
public Media contentType(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5, String contentType6) Creates a new media, that must contain one of the given content types only. -
contentType
public Media contentType(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5, String contentType6, String contentType7) Creates a new media, that must contain one of the given content types only. -
contentType
public Media contentType(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5, String contentType6, String contentType7, String contentType8) Creates a new media, that must contain one of the given content types only. -
contentType
public Media contentType(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5, String contentType6, String contentType7, String contentType8, String contentType9) Creates a new media, that must contain one of the given content types only. -
contentType
public Media contentType(String contentType1, String contentType2, String contentType3, String contentType4, String contentType5, String contentType6, String contentType7, String contentType8, String contentType9, String contentType10) Creates a new media, that must contain one of the given content types only. -
contentTypeSub
Creates a new media, that must contain the a content type with the given major part only. -
contentTypeLengthMax
-
isFinal
public boolean isFinal()Description copied from class:MediaPath
Returns, whether the contents of this media path may change or not. The default implementation returns false.- Specified by:
isFinal
in interfaceSettable<Media.Value>
- Overrides:
isFinal
in classMediaPath
-
isMandatory
public boolean isMandatory()Description copied from class:MediaPath
A MediaPath is "mandatory" ifMediaPath.getContentType(Item)
andMediaPath.getLocator(Item)
will not returnnull
for any item.- Specified by:
isMandatory
in interfaceSettable<Media.Value>
- Specified by:
isMandatory
in classMediaPath
-
getInitialType
- Specified by:
getInitialType
in interfaceSettable<Media.Value>
-
checkContentType
-
getContentTypeMaximumLength
public int getContentTypeMaximumLength() -
getContentTypeDescription
-
getContentTypesAllowed
Returns a list of content types allowed for this media. Returns null, if such a list would not contain a finite number of elements. -
getMaximumLength
public long getMaximumLength() -
getBody
-
getContentType
-
getLastModified
-
getUnison
-
isAnnotatedVault
public boolean isAnnotatedVault() -
getInitialExceptions
Description copied from interface:Settable
Returns the exceptions possibly thrown, when setting a value for this settable.- Specified by:
getInitialExceptions
in interfaceSettable<Media.Value>
-
isContentTypeWrapped
public boolean isContentTypeWrapped()- Overrides:
isContentTypeWrapped
in classMediaPath
-
isInitial
public boolean isInitial()Description copied from interface:Settable
Returns true, if a value for the settable should be specified on the creation of an item.- Specified by:
isInitial
in interfaceSettable<Media.Value>
-
isNull
-
getContentType
Returns the content type of this media. Returns null, if this media is null.- Specified by:
getContentType
in classMediaPath
-
getLastModified
Returns the date of the last modification of this media. Returns null, if this media is null.- Overrides:
getLastModified
in classMediaPath
- Parameters:
item
- the item which has the LastModified information
-
setLastModified
-
getLength
Returns the length of the body of this media. Returns -1, if this media is null. -
set
Sets the contents of this media.- Parameters:
value
- give null to make this media null.- Throws:
MandatoryViolationException
- if body is null and field ismandatory
.DataLengthViolationException
- if body is longer thangetMaximumLength()
IOException
- if reading value throws an IOException.
-
getBody
Returns the body of this media. Returns null, if this media is null. -
set
Sets the contents of this media.- Parameters:
body
- give null to make this media null.- Throws:
MandatoryViolationException
- if body is null and field ismandatory
.DataLengthViolationException
- if body is longer thangetMaximumLength()
-
getBody
Writes the body of this media into the given steam. Does nothing, if this media is null.- Throws:
NullPointerException
- ifbody
is null.IOException
- if writingbody
throws an IOException.
-
set
Sets the contents of this media. Closesbody
after reading the contents of the stream.- Parameters:
body
- give null to make this media null.- Throws:
MandatoryViolationException
- ifbody
is null and field ismandatory
.DataLengthViolationException
- ifbody
is longer thangetMaximumLength()
IOException
- if readingbody
throws an IOException.
-
getBody
- Throws:
IOException
-
getBody
Writes the body of this media into the given file. Does nothing, if this media is null.- Throws:
NullPointerException
- ifbody
is null.IOException
- if writingbody
throws an IOException.
-
set
- Throws:
IOException
-
set
Sets the contents of this media.- Parameters:
body
- give null to make this media null.- Throws:
MandatoryViolationException
- ifbody
is null and field ismandatory
.DataLengthViolationException
- ifbody
is longer thangetMaximumLength()
IOException
- if readingbody
throws an IOException.
-
toValue
-
toValue
-
toValue
-
toValue
-
toValue
-
execute
- Specified by:
execute
in interfaceSettable<Media.Value>
-
get
-
doGetAndCommit
public void doGetAndCommit(HttpServletRequest request, HttpServletResponse response, Item item) throws IOException, MediaPath.NotFound Description copied from class:MediaPath
The implementor MUSTcommit
the transaction, if the method completes normally (without exception). Otherwise the implementor may or may not commit the transaction.- Specified by:
doGetAndCommit
in classMediaPath
- Throws:
IOException
MediaPath.NotFound
-
isNull
Description copied from class:MediaPath
Returns a condition matching all items, for whichMediaPath.getLocator(Item)
returns null. -
isNull
Description copied from class:MediaPath
Returns a condition matching all items, for whichMediaPath.getLocator(Item)
returns null. -
isNotNull
Description copied from class:MediaPath
Returns a condition matching all items, for whichMediaPath.getLocator(Item)
does not return null. -
isNotNull
Description copied from class:MediaPath
Returns a condition matching all items, for whichMediaPath.getLocator(Item)
does not return null. -
contentTypeEqual
-
bodyMismatchesContentTypeIfSupported
The result may cause anUnsupportedQueryException
when used, if the field is stored in avault
. -
bodyMismatchesContentType
Deprecated.UsebodyMismatchesContentTypeIfSupported()
instead. -
contentTypeMajor
Deprecated.UsecontentTypeSub(String)
instead
-
contentTypeSub(String)
instead.