org.schmant.task.meta
Class ChangeExtensionTargetStrategy

java.lang.Object
  extended by org.schmant.support.AbstractArgumentChecker
      extended by org.schmant.task.meta.ChangeExtensionTargetStrategy
All Implemented Interfaces:
TargetStrategy

public class ChangeExtensionTargetStrategy
extends AbstractArgumentChecker
implements TargetStrategy

This target entity strategy can change a processed entity's name's extension. It has a collection of extension translations, i.e. mappings between old and new file name extensions. If an entity does not match any of the translations, it keeps its old extension.

Since:
0.5
Author:
Karl Gustafsson
Task_package:
org.schmant.task.base

Constructor Summary
ChangeExtensionTargetStrategy()
          Create a case sensitive strategy object.
ChangeExtensionTargetStrategy(boolean cs)
          Create a strategy object.
 
Method Summary
 Object getTarget(ProcessTaskSpec<?> t, DirectoryView base, RelativeLocation rel)
          Create the target location for the entity being processed.
 ChangeExtensionTargetStrategy putExtensionTranslation(String oldE, String newE)
          Add a translation between an old and a new file name extension.
 ChangeExtensionTargetStrategy putExtensionTranslations(Map<String,String> m)
          Add a map of translation between old and new file name extensions.
 
Methods inherited from class org.schmant.support.AbstractArgumentChecker
check, check, check, check
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangeExtensionTargetStrategy

public ChangeExtensionTargetStrategy()
Create a case sensitive strategy object.


ChangeExtensionTargetStrategy

public ChangeExtensionTargetStrategy(boolean cs)
Create a strategy object.

Parameters:
cs - Should it be case sensitive?
Method Detail

putExtensionTranslation

public ChangeExtensionTargetStrategy putExtensionTranslation(String oldE,
                                                             String newE)
Add a translation between an old and a new file name extension. All files (and directories) with the old extension will be renamed to use the new extension. Several extension mappings can be added by calling this method several times.

Parameters:
oldE - The old file name extension.
newE - The new file name extension.
Returns:
this
See Also:
putExtensionTranslations(Map)

putExtensionTranslations

public ChangeExtensionTargetStrategy putExtensionTranslations(Map<String,String> m)
Add a map of translation between old and new file name extensions. All files (and directories) that have any of the old file name extensions will be renamed to use the corresponding new file name extension.

This method can be called several times to add several maps.

Parameters:
m - The extension map.
Returns:
this
See Also:
putExtensionTranslation(String, String)

getTarget

public Object getTarget(ProcessTaskSpec<?> t,
                        DirectoryView base,
                        RelativeLocation rel)
Description copied from interface: TargetStrategy
Create the target location for the entity being processed.

Specified by:
getTarget in interface TargetStrategy
Parameters:
t - The task to get the target for. This method should not set the task's target property. (Or any other property, for that matter.) The source property is set on the task. If the task factory is a closure, this parameter will be null.
base - The base target directory for the process.
rel - The processed entity's location relative to its base directory.
Returns:
The target location for the processed entity. This can for instance be a FutureEntity. The object that is returned here is set to the nested task's target property. See the task factory documentation for the nested task for the different kinds of object types that it can handle.