org.alembik.util
Class JobUtils

java.lang.Object
  extended by org.alembik.util.JobUtils

public final class JobUtils
extends java.lang.Object

The class provides utility methods for performing conversions between a TranscodingJob object and a parameters map (ready to be sent as a URL query via HTTP API).

Since:
1.0-beta6

Constructor Summary
JobUtils()
           
 
Method Summary
static java.util.Map<java.lang.String,java.lang.String> abbreviate(java.util.Map<java.lang.String,java.lang.String> parameters)
          Returns a new parameters map built from the given one with all its names (keys) abbreviated (whenever possible), i.e. converted from absolute to abbreviated form.
static java.lang.String abbreviateParameter(java.lang.String name)
          Returns an abbreviated parameter name for its given absolute form.
static TranscodingJob getJob(java.util.Map<java.lang.String,java.lang.String> parameters)
          Converts the given parameters map instance into a transcoding job instance.
static java.util.Map<java.lang.String,java.lang.String> getMap(TranscodingJob job)
          Converts the given transcoding job instance into a parameters map.
static java.util.Map<java.lang.String,java.lang.String> normalize(java.util.Map<java.lang.String,java.lang.String> parameters)
          Returns a new parameters map built from the given one with all its names (keys) normalized, i.e. converted from abbreviated to absolute form.
static java.lang.String normalizeParameter(java.lang.String name)
          Returns an absolute parameter name for its given abbreviated form.
static void populateJob(TranscodingJob job, java.util.Map<java.lang.String,java.lang.String> parameters)
          Fills the given transcoding job with objects/values from the given parameters map.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobUtils

public JobUtils()
Method Detail

getMap

public static java.util.Map<java.lang.String,java.lang.String> getMap(TranscodingJob job)
                                                               throws java.lang.reflect.InvocationTargetException

Converts the given transcoding job instance into a parameters map. Each map entry corresponds to a URL parameter name and value.

Note that all parameter names in the returned map are absolute (i.e. not abbreviated).

Parameters:
job - transcoding job
Returns:
parameters map representing the job
Throws:
java.lang.reflect.InvocationTargetException - if the conversion fails
See Also:
getJob(Map), abbreviate(Map)

getJob

public static TranscodingJob getJob(java.util.Map<java.lang.String,java.lang.String> parameters)
                             throws java.lang.reflect.InvocationTargetException

Converts the given parameters map instance into a transcoding job instance. Each element set in the job object tree represents a single map entry.

Note that parameter names in the map cannot be abbreviated.

Parameters:
parameters - parameters map
Returns:
transcoding job instantiated with objects/values from the map
Throws:
java.lang.reflect.InvocationTargetException - if the conversion fails
See Also:
getMap(TranscodingJob), normalize(Map)

populateJob

public static void populateJob(TranscodingJob job,
                               java.util.Map<java.lang.String,java.lang.String> parameters)
                        throws java.lang.reflect.InvocationTargetException

Fills the given transcoding job with objects/values from the given parameters map. The new elements in the job object tree represent entries of the map.

Note that parameter names in the map cannot be abbreviated.

Parameters:
job - transcoding job
parameters - parameters map
Throws:
java.lang.reflect.InvocationTargetException - if the conversion fails
See Also:
getJob(Map), normalize(Map)

normalizeParameter

public static java.lang.String normalizeParameter(java.lang.String name)
Returns an absolute parameter name for its given abbreviated form. For example tp.sizeLimit gets resolved into target.transcodingParams.sizeLimit.

Parameters:
name - abbreviated parameter name
Returns:
absolute parameter name if the name appears to be abbreviated; otherwise name itself
See Also:
Constants.TARGET_PREFIX_SHORTCUT, Constants.TARGET_TRANSCODING_PARAMS_PREFIX_SHORTCUT, Constants.SOURCE_PREFIX_SHORTCUT, Constants.SOURCE_LOCATION_SHORTCUT, Constants.EXTENSION_DATA_PROPERTY_SHORTCUT, abbreviateParameter(String), normalize(Map)

normalize

public static java.util.Map<java.lang.String,java.lang.String> normalize(java.util.Map<java.lang.String,java.lang.String> parameters)
Returns a new parameters map built from the given one with all its names (keys) normalized, i.e. converted from abbreviated to absolute form.

Parameters:
parameters - parameters map to normalize
Returns:
new parameters map with absolute names
See Also:
normalizeParameter(String)

abbreviateParameter

public static java.lang.String abbreviateParameter(java.lang.String name)
Returns an abbreviated parameter name for its given absolute form. For example target.transcodingParams.sizeLimit gets resolved into tp.sizeLimit.

Parameters:
name - absolute parameter name
Returns:
abbreviated parameter name if the name appears to be absolute and there exists a shorter form; otherwise name itself
See Also:
Constants.TARGET_PREFIX_SHORTCUT, Constants.TARGET_TRANSCODING_PARAMS_PREFIX_SHORTCUT, Constants.SOURCE_PREFIX_SHORTCUT, Constants.SOURCE_LOCATION_SHORTCUT, Constants.EXTENSION_DATA_PROPERTY_SHORTCUT, normalizeParameter(String), abbreviate(Map)

abbreviate

public static java.util.Map<java.lang.String,java.lang.String> abbreviate(java.util.Map<java.lang.String,java.lang.String> parameters)
Returns a new parameters map built from the given one with all its names (keys) abbreviated (whenever possible), i.e. converted from absolute to abbreviated form.

Parameters:
parameters - parameters map to abbreviate
Returns:
new parameters map with abbreviated names
See Also:
abbreviateParameter(String)