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 anUnsupportedQueryExceptionwhen used, if the field is stored in avault.booleancheckContentType(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) voiddoGetAndCommit(HttpServletRequest request, HttpServletResponse response, Item item) The implementor MUSTcommitthe transaction, if the method completes normally (without exception).SetValue<?>[]execute(Media.Value value, Item exceptionItem) static MediagetBody()byte[]Returns the body of this media.voidWrites the body of this media into the given file.voidgetBody(Item item, OutputStream body) Writes the body of this media into the given steam.voidgetContentType(Item item) Returns the content type of this media.intReturns 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.longReturns the length of the body of this media.longbooleanbooleanbooleanisFinal()Returns, whether the contents of this media path may change or not.booleanReturns true, if a value for the settable should be specified on the creation of an item.booleanA MediaPath is "mandatory" ifMediaPath.getContentType(Item)andMediaPath.getLocator(Item)will not returnnullfor 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.booleanReturns a condition matching all items, for whichMediaPath.getLocator(Item)returns null.lengthMax(long maximumLength) optional()voidSets the contents of this media.voidset(Item item, Media.Value value) Sets the contents of this media.voidSets the contents of this media.voidset(Item item, InputStream body, String contentType) Sets the contents of this media.voidvoidsetLastModified(Item item, Date value) toFinal()static Media.Valuestatic Media.ValuetoValue(DataField.Value body, String contentType) static Media.Valuestatic Media.ValuetoValue(InputStream body, String contentType) static Media.ValueMethods 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, onMountMethods 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, registerSourceMethods 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:MediaPathReturns, whether the contents of this media path may change or not. The default implementation returns false.- Specified by:
isFinalin interfaceSettable<Media.Value>- Overrides:
isFinalin classMediaPath
-
isMandatory
public boolean isMandatory()Description copied from class:MediaPathA MediaPath is "mandatory" ifMediaPath.getContentType(Item)andMediaPath.getLocator(Item)will not returnnullfor any item.- Specified by:
isMandatoryin interfaceSettable<Media.Value>- Specified by:
isMandatoryin classMediaPath
-
getInitialType
- Specified by:
getInitialTypein 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:SettableReturns the exceptions possibly thrown, when setting a value for this settable.- Specified by:
getInitialExceptionsin interfaceSettable<Media.Value>
-
isContentTypeWrapped
public boolean isContentTypeWrapped()- Overrides:
isContentTypeWrappedin classMediaPath
-
isInitial
public boolean isInitial()Description copied from interface:SettableReturns true, if a value for the settable should be specified on the creation of an item.- Specified by:
isInitialin interfaceSettable<Media.Value>
-
isNull
-
getContentType
Returns the content type of this media. Returns null, if this media is null.- Specified by:
getContentTypein classMediaPath
-
getLastModified
Returns the date of the last modification of this media. Returns null, if this media is null.- Overrides:
getLastModifiedin 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- ifbodyis null.IOException- if writingbodythrows an IOException.
-
set
Sets the contents of this media. Closesbodyafter reading the contents of the stream.- Parameters:
body- give null to make this media null.- Throws:
MandatoryViolationException- ifbodyis null and field ismandatory.DataLengthViolationException- ifbodyis longer thangetMaximumLength()IOException- if readingbodythrows 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- ifbodyis null.IOException- if writingbodythrows an IOException.
-
set
- Throws:
IOException
-
set
Sets the contents of this media.- Parameters:
body- give null to make this media null.- Throws:
MandatoryViolationException- ifbodyis null and field ismandatory.DataLengthViolationException- ifbodyis longer thangetMaximumLength()IOException- if readingbodythrows an IOException.
-
toValue
-
toValue
-
toValue
-
toValue
-
toValue
-
execute
- Specified by:
executein interfaceSettable<Media.Value>
-
get
-
doGetAndCommit
public void doGetAndCommit(HttpServletRequest request, HttpServletResponse response, Item item) throws IOException, MediaPath.NotFound Description copied from class:MediaPathThe implementor MUSTcommitthe transaction, if the method completes normally (without exception). Otherwise the implementor may or may not commit the transaction.- Specified by:
doGetAndCommitin classMediaPath- Throws:
IOExceptionMediaPath.NotFound
-
isNull
Description copied from class:MediaPathReturns a condition matching all items, for whichMediaPath.getLocator(Item)returns null. -
isNull
Description copied from class:MediaPathReturns a condition matching all items, for whichMediaPath.getLocator(Item)returns null. -
isNotNull
Description copied from class:MediaPathReturns a condition matching all items, for whichMediaPath.getLocator(Item)does not return null. -
isNotNull
Description copied from class:MediaPathReturns a condition matching all items, for whichMediaPath.getLocator(Item)does not return null. -
contentTypeEqual
-
bodyMismatchesContentTypeIfSupported
The result may cause anUnsupportedQueryExceptionwhen used, if the field is stored in avault. -
bodyMismatchesContentType
Deprecated.UsebodyMismatchesContentTypeIfSupported()instead. -
contentTypeMajor
Deprecated.UsecontentTypeSub(String)instead
-
contentTypeSub(String)instead.