ro.isdc.wro.model.resource.support.hash
Class ConfigurableHashStrategy

java.lang.Object
  extended by ro.isdc.wro.model.resource.support.AbstractConfigurableStrategySupport<S,P>
      extended by ro.isdc.wro.model.resource.support.AbstractConfigurableSingleStrategy<HashStrategy,HashStrategyProvider>
          extended by ro.isdc.wro.model.resource.support.hash.ConfigurableHashStrategy
All Implemented Interfaces:
HashBuilder, HashStrategy

public class ConfigurableHashStrategy
extends AbstractConfigurableSingleStrategy<HashStrategy,HashStrategyProvider>
implements HashStrategy

Uses the HashStrategy implementation associated with an alias read from properties file.

Since:
1.4.7
Author:
Alex Objelean

Field Summary
static String KEY
          Property name to specify alias.
 
Constructor Summary
ConfigurableHashStrategy()
           
 
Method Summary
protected  HashStrategy getDefaultStrategy()
          
 String getHash(InputStream inputStream)
          
protected  Class<HashStrategyProvider> getProviderClass()
          
protected  Map<String,HashStrategy> getStrategies(HashStrategyProvider provider)
          
protected  String getStrategyKey()
          
 
Methods inherited from class ro.isdc.wro.model.resource.support.AbstractConfigurableSingleStrategy
getConfiguredStrategy
 
Methods inherited from class ro.isdc.wro.model.resource.support.AbstractConfigurableStrategySupport
copyAll, getAvailableAliases, getAvailableStrategies, getConfiguredValue, getProviderFinder, getStrategyForAlias, newProperties, overrideDefaultStrategyMap, setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY

public static final String KEY
Property name to specify alias.

See Also:
Constant Field Values
Constructor Detail

ConfigurableHashStrategy

public ConfigurableHashStrategy()
Method Detail

getHash

public String getHash(InputStream inputStream)
               throws IOException

Specified by:
getHash in interface HashBuilder
Parameters:
inputStream - to digest.
Returns:
the hash of the content.
Throws:
IOException - if there was an error during reading the stream content.

getStrategyKey

protected String getStrategyKey()

Specified by:
getStrategyKey in class AbstractConfigurableStrategySupport<HashStrategy,HashStrategyProvider>
Returns:
the key of the strategy property.

getDefaultStrategy

protected HashStrategy getDefaultStrategy()

Specified by:
getDefaultStrategy in class AbstractConfigurableSingleStrategy<HashStrategy,HashStrategyProvider>
Returns:
the default strategy implementation to use when no key is configured is provided.

getStrategies

protected Map<String,HashStrategy> getStrategies(HashStrategyProvider provider)

Specified by:
getStrategies in class AbstractConfigurableStrategySupport<HashStrategy,HashStrategyProvider>
Parameters:
provider - the instance responsible for strategy lookup.
Returns:
the map of provided strategies.

getProviderClass

protected Class<HashStrategyProvider> getProviderClass()

Overrides:
getProviderClass in class AbstractConfigurableStrategySupport<HashStrategy,HashStrategyProvider>
Returns:
the class of the provider of type P. Uses ParameterizedType to compute the class. Override it to support anonymous classes which do not play well with ParameterizedType's.


Copyright © 2008-2013. All Rights Reserved.