Package org.opencastproject.mediapackage
Class DefaultMediaPackageSerializerImpl
java.lang.Object
org.opencastproject.mediapackage.DefaultMediaPackageSerializerImpl
- All Implemented Interfaces:
MediaPackageSerializer
Default implementation of a
MediaPackageSerializer that is able to deal with relative urls in manifest.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected URLOptional package root filestatic final intIt's very likely that this should be the first serializer when encoding an URI, therefore choose a high ranking -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new package serializer that will work completely transparent, therefore resolving urls by simply returning them as is.DefaultMediaPackageSerializerImpl(File packageRoot) Creates a new package serializer that enables the resolution of relative urls from the manifest by takingpackageRootas the root directory.DefaultMediaPackageSerializerImpl(URL packageRoot) Creates a new package serializer that enables the resolution of relative urls from the manifest by takingpackageRootas the root url. -
Method Summary
Modifier and TypeMethodDescriptionThis serializer implementation tries to cope with relative urls.This serializer implementation tries to cope with relative urls.Returns the package root that is used determine and resolve relative paths.intIdentifies the serializer ranking number.voidsetPackageRoot(URL packageRoot) Sets the package root.
-
Field Details
-
packageRoot
Optional package root file -
RANKING
public static final int RANKINGIt's very likely that this should be the first serializer when encoding an URI, therefore choose a high ranking- See Also:
-
-
Constructor Details
-
DefaultMediaPackageSerializerImpl
public DefaultMediaPackageSerializerImpl()Creates a new package serializer that will work completely transparent, therefore resolving urls by simply returning them as is. -
DefaultMediaPackageSerializerImpl
Creates a new package serializer that enables the resolution of relative urls from the manifest by takingpackageRootas the root url.- Parameters:
packageRoot- the root url
-
DefaultMediaPackageSerializerImpl
Creates a new package serializer that enables the resolution of relative urls from the manifest by takingpackageRootas the root directory.- Parameters:
packageRoot- the root url- Throws:
MalformedURLException- if the file cannot be converted to a url
-
-
Method Details
-
getPackageRoot
Returns the package root that is used determine and resolve relative paths. Note that the package root may benull.- Returns:
- the packageRoot
-
setPackageRoot
Sets the package root.- Parameters:
packageRoot- the packageRoot to set- See Also:
-
encodeURI
This serializer implementation tries to cope with relative urls. Should the root url be set to any value other thannull, the serializer will try to convert element urls to relative paths if possible. .- Specified by:
encodeURIin interfaceMediaPackageSerializer- Parameters:
uri- the url to encode- Returns:
- the encoded path
- Throws:
URISyntaxException- if the resulting URI contains syntax errors- See Also:
-
decodeURI
This serializer implementation tries to cope with relative urls. Should the path start with neither a protocol nor a path separator, the packageRoot is used to create the url relative to the root url that was passed in the constructor.Note that for absolute paths without a protocol, the
file://protocol is assumed.- Specified by:
decodeURIin interfaceMediaPackageSerializer- Parameters:
uri- the original path from the manifest- Returns:
- the resolved url
- Throws:
URISyntaxException- if the path cannot be converted into a urlURISyntaxException- if the resulting URI contains syntax errors- See Also:
-
getRanking
public int getRanking()Description copied from interface:MediaPackageSerializerIdentifies the serializer ranking number. The ranking is respected when multiple serializers are chained. When encoding an URI, the serializer with the highest ranking is used first. If an URI needs to be decoded, the ranking is used in the opposite direction.- Specified by:
getRankingin interfaceMediaPackageSerializer- Returns:
- The service ranking number.
-