signature:
public class XMemcachedCache { /** * { @ inheritDoc } */
@ Override public void deleteAll ( ) { } }

implementation: switch ( keyMode ) { case NAMESPACE : throw new CacheException . OperationNotSupportedException ( "Key mode[" + keyMode + "] does not support flushall operation." ) ; case MONOPOLISTIC : try { getMemcachedClient ( ) . flushAllWithNoReply ( ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } break ; case XNAMESPACE : try { getMemcachedClient ( ) . invalidateNamespace ( getName ( ) ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } break ; default : throw new IllegalStateException ( "Invalid key mode: " + keyMode ) ; }


signature:
public class XMemcachedCache { /** * { @ inheritDoc } */
@ Override public boolean exists ( String key ) { } }

implementation: switch ( keyMode ) { case MONOPOLISTIC : case NAMESPACE : final String KEY = keyMode == KeyMode . MONOPOLISTIC ? key : calcCacheKeyNamespace ( key ) ; try { return getMemcachedClient ( ) . get ( KEY ) != null ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } case XNAMESPACE : try { return getMemcachedClient ( ) . withNamespace ( getName ( ) , new MemcachedClientCallable < Boolean > ( ) { @ Override public Boolean call ( MemcachedClient client ) throws InterruptedException , MemcachedException , TimeoutException { return client . get ( key ) != null ; } } ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } default : throw new IllegalStateException ( "Invalid key mode: " + keyMode ) ; }


signature:
public class XMemcachedCache { /** * { @ inheritDoc } */
@ Override protected Object internalGet ( String key ) { } }

implementation: String _data = null ; switch ( keyMode ) { case MONOPOLISTIC : case NAMESPACE : final String KEY = keyMode == KeyMode . MONOPOLISTIC ? key : calcCacheKeyNamespace ( key ) ; try { _data = getMemcachedClient ( ) . get ( KEY ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } break ; case XNAMESPACE : try { _data = getMemcachedClient ( ) . withNamespace ( getName ( ) , new MemcachedClientCallable < String > ( ) { @ Override public String call ( MemcachedClient client ) throws MemcachedException , InterruptedException , TimeoutException { return client . get ( key ) ; } } ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } break ; default : throw new IllegalStateException ( "Invalid key mode: " + keyMode ) ; } if ( _data != null ) { byte [ ] data = Base64 . decodeBase64 ( _data ) ; CacheEntry ce = deserializeCacheEntry ( data ) ; if ( ce != null && ce . touch ( ) ) { set ( key , ce , ce . getExpireAfterWrite ( ) , ce . getExpireAfterAccess ( ) ) ; } return ce ; } return null ;


signature:
public class ClusteredRedisCache { /** * { @ inheritDoc } */
@ Override public ClusteredRedisCache init ( ) { } }

implementation:
super . init ( ) ; /* * Parse custom property : redis - hosts - and - ports */
String hostsAndPorts = getCacheProperty ( CACHE_PROP_REDIS_HOSTS_AND_PORTS ) ; if ( ! StringUtils . isBlank ( hostsAndPorts ) ) { this . redisHostsAndPorts = hostsAndPorts ; } if ( getJedisConnector ( ) == null ) { try { JedisConnector jedisConnector = new JedisConnector ( ) ; jedisConnector . setRedisHostsAndPorts ( redisHostsAndPorts ) . init ( ) ; setJedisConnector ( jedisConnector , true ) ; } catch ( Exception e ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } } return this ;


signature:
public class ClusteredRedisCache { /** * { @ inheritDoc }
 * Only { @ link KeyMode # HASH } is supported . This method returns { @ code - 1}
 * for other key modes . */
@ Override public long getSize ( ) { } }

implementation: switch ( keyMode ) { case HASH : try { return getJedis ( ) . hlen ( getName ( ) ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } default : return - 1 ; }


signature:
public class ClusteredRedisCache { /** * { @ inheritDoc } */
@ Override public void set ( String key , Object entry , long expireAfterWrite , long expireAfterAccess ) { } }

implementation:
final String KEY = calcCacheKey ( key ) ; try { JedisCluster jedisCluster = getJedis ( ) ; /* * Returns - 1 if no expiry , - 2 if key does not exist . */
final long currentTTL = jedisCluster . ttl ( KEY ) ; long ttl = TTL_NO_CHANGE ; if ( ! ( entry instanceof CacheEntry ) ) { CacheEntry ce = new CacheEntry ( key , entry , expireAfterWrite , expireAfterAccess ) ; entry = ce ; ttl = expireAfterAccess > 0 ? expireAfterAccess : ( expireAfterWrite > 0 ? expireAfterWrite : ( timeToLiveSeconds > 0 ? timeToLiveSeconds : 0 ) ) ; } else { CacheEntry ce = ( CacheEntry ) entry ; ttl = ce . getExpireAfterAccess ( ) ; } byte [ ] data = serializeCacheEntry ( ( CacheEntry ) entry ) ; // TTL Rules :
// 1 . New item : TTL is calculated as formula ( s ) above .
// 2 . Existing item :
// 2.1 . If [ keyMode = HASH ] : extends the current TTL ,
// 2.2 . Otherwise , extends the current TTL only when
// expireAfterAccess >
if ( currentTTL >= - 1 ) { // existing item
if ( keyMode == KeyMode . HASH ) // rule 2.1
ttl = currentTTL > 0 ? currentTTL : TTL_NO_CHANGE ; else // rule 2.2
ttl = expireAfterAccess > 0 ? expireAfterAccess : TTL_NO_CHANGE ; } if ( keyMode == KeyMode . HASH ) { jedisCluster . hset ( SafeEncoder . encode ( getName ( ) ) , SafeEncoder . encode ( KEY ) , data ) ; if ( ttl > 0 ) { jedisCluster . expire ( getName ( ) , ( int ) ttl ) ; } else if ( ttl == TTL_FOREVER && currentTTL >= - 1 ) { jedisCluster . persist ( getName ( ) ) ; } } else { if ( ttl > 0 ) { jedisCluster . setex ( SafeEncoder . encode ( KEY ) , ( int ) ttl , data ) ; } else { jedisCluster . set ( SafeEncoder . encode ( KEY ) , data ) ; if ( ttl == TTL_FOREVER ) { jedisCluster . persist ( KEY ) ; } else if ( currentTTL > 0 ) { jedisCluster . expire ( KEY , ( int ) currentTTL ) ; } } } } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class ClusteredRedisCache { /** * { @ inheritDoc } */
@ Override public void delete ( String key ) { } }

implementation: final String KEY = calcCacheKey ( key ) ; try { if ( keyMode == KeyMode . HASH ) { getJedis ( ) . hdel ( getName ( ) , KEY ) ; } else { getJedis ( ) . del ( KEY ) ; } } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class ClusteredRedisCache { /** * { @ inheritDoc } */
@ Override public void deleteAll ( ) { } }

implementation: switch ( keyMode ) { case NAMESPACE : throw new CacheException . OperationNotSupportedException ( "Key mode[" + keyMode + "] does not support 'deleteAll' operation." ) ; case MONOPOLISTIC : try { getJedis ( ) . getClusterNodes ( ) . forEach ( ( name , pool ) -> { try ( Jedis jedis = pool . getResource ( ) ) { jedis . flushAll ( ) ; } } ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } break ; case HASH : try { getJedis ( ) . del ( getName ( ) ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } break ; default : throw new IllegalStateException ( "Invalid key mode: " + keyMode ) ; }


signature:
public class ClusteredRedisCache { /** * { @ inheritDoc } */
@ Override protected Object internalGet ( String key ) { } }

implementation:
final String KEY = calcCacheKey ( key ) ; try { byte [ ] data = keyMode == KeyMode . HASH ? getJedis ( ) . hget ( SafeEncoder . encode ( getName ( ) ) , SafeEncoder . encode ( KEY ) ) : getJedis ( ) . get ( SafeEncoder . encode ( KEY ) ) ; if ( data != null ) { CacheEntry ce = deserializeCacheEntry ( data ) ; if ( ce != null && ce . touch ( ) ) { /* * Since v0.6.2 : use refreshTTL ( ) instead of set ( ) to save
 * traffic between client & Redis server */
// set ( key , ce , ce . getExpireAfterWrite ( ) ,
// ce . getExpireAfterAccess ( ) ) ;
refreshTTL ( key , ce ) ; } return ce ; } return null ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class GuavaCache { /** * { @ inheritDoc } */
@ Override public GuavaCache init ( ) { } }

implementation:
super . init ( ) ; /* * Parse custom property : clone - cache - entries */
boolean oldCloneCacheEntries = this . cloneCacheEntries ; try { this . cloneCacheEntries = Boolean . parseBoolean ( getCacheProperty ( CACHE_PROP_CLONE_CACHE_ENTRIES ) ) ; } catch ( Exception e ) { this . cloneCacheEntries = oldCloneCacheEntries ; if ( getCacheProperty ( CACHE_PROP_CLONE_CACHE_ENTRIES ) != null ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } } int numProcessores = Runtime . getRuntime ( ) . availableProcessors ( ) ; CacheBuilder < Object , Object > cacheBuilder = CacheBuilder . newBuilder ( ) . concurrencyLevel ( numProcessores * 2 ) ; if ( getCapacity ( ) > 0 ) { cacheBuilder . maximumSize ( getCapacity ( ) ) ; } long expireAfterAccess = getExpireAfterAccess ( ) ; long expireAfterWrite = getExpireAfterWrite ( ) ; if ( expireAfterAccess > 0 ) { cacheBuilder . expireAfterAccess ( expireAfterAccess , TimeUnit . SECONDS ) ; } else if ( expireAfterWrite > 0 ) { cacheBuilder . expireAfterWrite ( expireAfterWrite , TimeUnit . SECONDS ) ; } CacheLoader < String , Object > guavaCacheLoader = new CacheLoader < String , Object > ( ) { @ Override public Object load ( String key ) throws Exception { ICacheLoader cacheLoader = getCacheLoader ( ) ; Object result = cacheLoader != null ? cacheLoader . load ( key ) : null ; if ( result != null ) { return result ; } else { throw new CacheException . CacheEntryNotFoundException ( ) ; } } } ; cache = cacheBuilder . build ( guavaCacheLoader ) ; return this ;


signature:
public class GuavaCache { /** * { @ inheritDoc } */
@ Override public void destroy ( ) { } }

implementation:
try { super . destroy ( ) ; } finally { try { if ( cache != null ) { cache . invalidateAll ( ) ; cache = null ; } } catch ( Exception e ) { // EMPTY
} }


signature:
public class GuavaCache { /** * { @ inheritDoc } */
@ Override public void set ( String key , Object entry ) { } }

implementation: cache . put ( key , CacheUtils . tryClone ( entry ) ) ;


signature:
public class GuavaCache { /** * { @ inheritDoc } */
@ Override public void set ( String key , Object entry , long expireAfterWrite , long expireAfterAccess ) { } }

implementation: if ( ! ( entry instanceof CacheEntry ) ) { CacheEntry ce = new CacheEntry ( key , CacheUtils . tryClone ( entry ) , expireAfterWrite , expireAfterAccess ) ; entry = ce ; } else { entry = CacheUtils . tryClone ( entry ) ; } cache . put ( key , entry ) ;


signature:
public class GuavaCache { /** * { @ inheritDoc } */
@ Override protected Object internalGet ( String key ) { } }

implementation:
try { Object result = cache . get ( key ) ; if ( result instanceof CacheEntry ) { // update entry ' s private TTL if needed .
CacheEntry ce = ( CacheEntry ) result ; if ( ce . touch ( ) ) { set ( key , ce ) ; } } return cloneCacheEntries ? CacheUtils . tryClone ( result ) : result ; } catch ( Exception e ) { Throwable t = e . getCause ( ) ; if ( t instanceof CacheException . CacheEntryNotFoundException ) { return null ; } else { throw new RuntimeException ( e ) ; } }


signature:
public class LocalRemoteCacheFactory { /** * { @ inheritDoc } */
@ Override protected AbstractCache createCacheInternal ( String name , long capacity , long expireAfterWrite , long expireAfterAccess , Properties cacheProps ) { } }

implementation: ICache localCache = localCacheFactory != null ? localCacheFactory . createCache ( name , capacity , expireAfterWrite , expireAfterAccess ) : null ; ICache remoteCache = remoteCacheFactory != null ? remoteCacheFactory . createCache ( name , capacity , expireAfterWrite , expireAfterAccess ) : null ; LocalRemoteCache cache = new LocalRemoteCache ( ) ; cache . setName ( name ) . setCapacity ( capacity ) . setExpireAfterAccess ( expireAfterAccess ) . setExpireAfterWrite ( expireAfterWrite ) . setCacheProperties ( cacheProps ) ; cache . setLocalCache ( localCache ) . setRemoteCache ( remoteCache ) ; return cache ;


signature:
public class CacheEntry { /** * " Touch " the cache entry .
 * @ return
 * @ since 0.2.1 entry can be touched only if { @ code expireAfterAccess > 0 } . */
public boolean touch ( ) { } }

implementation: if ( expireAfterAccess > 0 ) { long now = System . currentTimeMillis ( ) ; if ( lastAccessTimestampMs + LAST_ACCESS_THRESHOLD_MS < now ) { lastAccessTimestampMs = now ; return true ; } } return false ;


signature:
public class CacheEntry { /** * { @ inheritDoc }
 * @ since 0.5.0 */
@ Override public byte [ ] toBytes ( ) throws SerializationException { } }

implementation: Map < String , Object > dataMap = new HashMap < > ( ) ; dataMap . put ( "k" , this . key ) ; dataMap . put ( "tac" , this . lastAccessTimestampMs ) ; dataMap . put ( "tcr" , this . creationTimestampMs ) ; dataMap . put ( "eac" , this . expireAfterAccess ) ; dataMap . put ( "ewr" , this . expireAfterWrite ) ; ClassLoader cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( value != null ) { dataMap . put ( "_c_" , value . getClass ( ) . getName ( ) ) ; dataMap . put ( "v" , SerializationUtils . toByteArray ( this . value , cl ) ) ; } return SerializationUtils . toByteArrayFst ( dataMap , cl ) ;


signature:
public class CacheEntry { /** * { @ inheritDoc }
 * @ since 0.5.0 */
@ SuppressWarnings ( "unchecked" ) @ Override public CacheEntry fromBytes ( byte [ ] data ) throws DeserializationException { } }

implementation: ClassLoader cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; Map < String , Object > dataMap = SerializationUtils . fromByteArrayFst ( data , Map . class , cl ) ; this . key = DPathUtils . getValue ( dataMap , "k" , String . class ) ; Long tAccess = DPathUtils . getValue ( dataMap , "tac" , Long . class ) ; this . lastAccessTimestampMs = tAccess != null ? tAccess . longValue ( ) : System . currentTimeMillis ( ) ; Long tCreate = DPathUtils . getValue ( dataMap , "tcr" , Long . class ) ; this . creationTimestampMs = tCreate != null ? tCreate . longValue ( ) : System . currentTimeMillis ( ) ; Long eAccess = DPathUtils . getValue ( dataMap , "eac" , Long . class ) ; this . expireAfterAccess = eAccess != null ? eAccess . longValue ( ) : - 1 ; Long eWrite = DPathUtils . getValue ( dataMap , "ewr" , Long . class ) ; this . expireAfterWrite = eWrite != null ? eWrite . longValue ( ) : - 1 ; String clazzName = DPathUtils . getValue ( dataMap , "_c_" , String . class ) ; if ( ! StringUtils . isBlank ( clazzName ) ) { try { byte [ ] valueData = DPathUtils . getValue ( dataMap , "v" , byte [ ] . class ) ; Class < ? > clazz = Class . forName ( clazzName , true , cl ) ; this . value = SerializationUtils . fromByteArray ( valueData , clazz , cl ) ; } catch ( ClassNotFoundException e ) { throw new DeserializationException ( e ) ; } } return this ;


signature:
public class TCacheEntry { /** * Returns true if field corresponding to fieldID is set ( has been assigned a value ) and false otherwise */
public boolean isSet ( _Fields field ) { } }

implementation: if ( field == null ) { throw new IllegalArgumentException ( ) ; } switch ( field ) { case KEY : return isSetKey ( ) ; case VALUE : return isSetValue ( ) ; case VALUE_CLASS : return isSetValueClass ( ) ; case CREATION_TIMESTAMP_MS : return isSetCreationTimestampMs ( ) ; case LAST_ACCESS_TIMESTAMP_MS : return isSetLastAccessTimestampMs ( ) ; case EXPIRE_AFTER_WRITE : return isSetExpireAfterWrite ( ) ; case EXPIRE_AFTER_ACCESS : return isSetExpireAfterAccess ( ) ; } throw new IllegalStateException ( ) ;


signature:
public class AbstractCacheEntrySerializer { /** * { @ inheritDoc } */
@ Override public byte [ ] serialize ( CacheEntry ce ) { } }

implementation: try { byte [ ] data = doSerialize ( ce ) ; return data != null ? ( compressor != null ? compressor . compress ( data ) : data ) : null ; } catch ( Exception e ) { LOGGER . error ( e . getMessage ( ) , e ) ; return null ; }


signature:
public class AbstractCacheEntrySerializer { /** * { @ inheritDoc } */
@ Override public CacheEntry deserialize ( byte [ ] _data ) { } }

implementation: try { byte [ ] data = _data != null ? ( compressor != null ? compressor . decompress ( _data ) : _data ) : null ; return data != null ? doDeserialize ( data ) : null ; } catch ( Exception e ) { LOGGER . error ( e . getMessage ( ) , e ) ; return null ; }


signature:
public class AbstractSerializingCacheFactory { /** * { @ inheritDoc } */
@ Override public AbstractSerializingCache createCache ( String name , ICacheLoader cacheLoader ) { } }

implementation: return ( AbstractSerializingCache ) super . createCache ( name , cacheLoader ) ;


signature:
public class AbstractSerializingCacheFactory { /** * { @ inheritDoc } */
@ Override public AbstractSerializingCache createCache ( String name , long capacity ) { } }

implementation: return ( AbstractSerializingCache ) super . createCache ( name , capacity ) ;


signature:
public class AbstractSerializingCacheFactory { /** * { @ inheritDoc } */
@ Override protected AbstractSerializingCache createAndInitCacheInstance ( String name , long capacity , long expireAfterWrite , long expireAfterAccess , ICacheLoader cacheLoader , Properties cacheProps ) { } }

implementation: AbstractSerializingCache cache = createCacheInternal ( name , capacity , expireAfterWrite , expireAfterAccess , cacheProps ) ; cache . setCacheEntrySerializer ( cacheEntrySerializer ) . setCacheLoader ( cacheLoader ) . setCacheFactory ( this ) ; cache . init ( ) ; return cache ;


signature:
public class ShardedRedisCache { /** * { @ inheritDoc } */
@ Override public void deleteAll ( ) { } }

implementation: switch ( keyMode ) { case NAMESPACE : throw new CacheException . OperationNotSupportedException ( "Key mode[" + keyMode + "] does not support 'deleteAll' operation." ) ; case MONOPOLISTIC : try ( ShardedJedis jedis = getJedis ( ) ) { jedis . getAllShards ( ) . forEach ( j -> j . flushAll ( ) ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } break ; case HASH : try ( ShardedJedis jedis = getJedis ( ) ) { jedis . del ( getName ( ) ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } break ; default : throw new IllegalStateException ( "Invalid key mode: " + keyMode ) ; }


signature:
public class ShardedRedisCache { /** * Refresh TTL of a cache entry .
 * @ param key
 * @ param ce
 * @ since 0.6.2 */
protected void refreshTTL ( String key , CacheEntry ce ) { } }

implementation: final String KEY = calcCacheKey ( key ) ; final long TTL = ce . getExpireAfterAccess ( ) ; try ( ShardedJedis jedis = getJedis ( ) ) { if ( TTL > 0 ) { if ( keyMode == KeyMode . HASH ) { jedis . expire ( getName ( ) , ( int ) TTL ) ; } else { jedis . expire ( SafeEncoder . encode ( KEY ) , ( int ) TTL ) ; } } } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class RedisCache { /** * { @ inheritDoc } */
@ Override public RedisCache init ( ) { } }

implementation:
super . init ( ) ; /* * Parse custom property : redis - host - and - port */
String hostAndPort = getCacheProperty ( CACHE_PROP_REDIS_HOST_AND_PORT ) ; if ( ! StringUtils . isBlank ( hostAndPort ) ) { this . redisHostAndPort = hostAndPort ; } if ( getJedisConnector ( ) == null ) { try { JedisConnector jedisConnector = new JedisConnector ( ) ; jedisConnector . setRedisHostsAndPorts ( redisHostAndPort ) . init ( ) ; setJedisConnector ( jedisConnector , true ) ; } catch ( Exception e ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } } return this ;


signature:
public class RedisCache { /** * { @ inheritDoc } */
@ Override public void deleteAll ( ) { } }

implementation: switch ( keyMode ) { case NAMESPACE : throw new CacheException . OperationNotSupportedException ( "Key mode[" + keyMode + "] does not support 'deleteAll' operation." ) ; case MONOPOLISTIC : try ( Jedis jedis = getJedis ( ) ) { jedis . flushAll ( ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } break ; case HASH : try ( Jedis jedis = getJedis ( ) ) { jedis . del ( getName ( ) ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } break ; default : throw new IllegalStateException ( "Invalid key mode: " + keyMode ) ; }


signature:
public class RedisCache { /** * { @ inheritDoc } */
@ Override public boolean exists ( String key ) { } }

implementation: final String KEY = calcCacheKey ( key ) ; try ( Jedis jedis = getJedis ( ) ) { if ( keyMode == KeyMode . HASH ) { return jedis . hget ( SafeEncoder . encode ( getName ( ) ) , SafeEncoder . encode ( KEY ) ) != null ; } else { return jedis . get ( SafeEncoder . encode ( KEY ) ) != null ; } } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class JdkDeflateCompressor { /** * { @ inheritDoc }
 * @ throws IOException */
@ Override public byte [ ] compress ( byte [ ] data ) throws IOException { } }

implementation: try ( ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ) { Deflater def = new Deflater ( compressionLevel , false ) ; try ( DeflaterOutputStream dos = new DeflaterOutputStream ( baos , def ) ) { dos . write ( data ) ; dos . finish ( ) ; return baos . toByteArray ( ) ; } }


signature:
public class JdkDeflateCompressor { /** * { @ inheritDoc }
 * @ throws IOException */
@ Override public byte [ ] decompress ( byte [ ] compressedData ) throws IOException { } }

implementation: try ( ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ) { try ( InflaterOutputStream ios = new InflaterOutputStream ( baos ) ) { ios . write ( compressedData ) ; ios . finish ( ) ; return baos . toByteArray ( ) ; } }


signature:
public class BaseRedisCacheFactory { /** * Attach a { @ link JedisConnector } to this cache .
 * @ param jedisConnector
 * @ param setMyOwnRedis
 * set { @ link # myOwnRedis } to { @ code true } or not .
 * @ return
 * @ since 0.6.3.3 */
protected BaseRedisCacheFactory setJedisConnector ( JedisConnector jedisConnector , boolean setMyOwnRedis ) { } }

implementation: if ( myOwnRedis && this . jedisConnector != null ) { this . jedisConnector . close ( ) ; } this . jedisConnector = jedisConnector ; myOwnRedis = setMyOwnRedis ; return this ;


signature:
public class RedisCacheFactory { /** * Creates a new { @ link JedisPool } , with specified database and default
 * timeout .
 * @ param hostAndPort
 * @ param password
 * @ param db
 * @ return */
public static JedisPool newJedisPool ( String hostAndPort , String password , int db ) { } }

implementation: return newJedisPool ( hostAndPort , password , db , Protocol . DEFAULT_TIMEOUT ) ;


signature:
public class RedisCacheFactory { /** * Creates a new { @ link JedisPool } .
 * @ param hostAndPort
 * @ param password
 * @ param db
 * @ param timeoutMs
 * @ return */
public static JedisPool newJedisPool ( String hostAndPort , String password , int db , long timeoutMs ) { } }

implementation:
final int maxTotal = Runtime . getRuntime ( ) . availableProcessors ( ) ; final int maxIdle = maxTotal / 2 ; JedisPoolConfig poolConfig = new JedisPoolConfig ( ) ; poolConfig . setMaxTotal ( maxTotal ) ; poolConfig . setMinIdle ( 1 ) ; poolConfig . setMaxIdle ( maxIdle > 0 ? maxIdle : 1 ) ; poolConfig . setMaxWaitMillis ( timeoutMs + 1000 ) ; // poolConfig . setTestOnBorrow ( true ) ;
poolConfig . setTestWhileIdle ( true ) ; String [ ] tokens = hostAndPort . split ( ":" ) ; String host = tokens . length > 0 ? tokens [ 0 ] : Protocol . DEFAULT_HOST ; int port = tokens . length > 1 ? Integer . parseInt ( tokens [ 1 ] ) : Protocol . DEFAULT_PORT ; JedisPool jedisPool = new JedisPool ( poolConfig , host , port , ( int ) timeoutMs , password , db ) ; return jedisPool ;


signature:
public class RedisCacheFactory { /** * { @ inheritDoc } */
@ Override protected RedisCache createCacheInternal ( String name , long capacity , long expireAfterWrite , long expireAfterAccess , Properties cacheProps ) { } }

implementation: RedisCache cache = new RedisCache ( keyMode ) ; cache . setName ( name ) . setCapacity ( capacity ) . setExpireAfterAccess ( expireAfterAccess ) . setExpireAfterWrite ( expireAfterWrite ) . setCacheProperties ( cacheProps ) ; cache . setRedisHostAndPort ( redisHostAndPort ) . setRedisPassword ( getRedisPassword ( ) ) ; cache . setJedisConnector ( getJedisConnector ( ) ) ; return cache ;


signature:
public class GuavaCacheFactory { /** * { @ inheritDoc } */
@ Override protected AbstractCache createCacheInternal ( String name , long capacity , long expireAfterWrite , long expireAfterAccess , Properties cacheProps ) { } }

implementation: GuavaCache cache = new GuavaCache ( ) ; cache . setName ( name ) . setCapacity ( capacity ) . setExpireAfterAccess ( expireAfterAccess ) . setExpireAfterWrite ( expireAfterWrite ) . setCacheProperties ( cacheProps ) ; cache . setCloneCacheEntries ( cloneCacheEntries ) ; return cache ;


signature:
public class CacheUtils { /** * Try cloning an object .
 * @ param toBeCloned
 * @ return result from object ' s { @ code clone ( ) } method if object implements
 * interface { @ link Cloneable } , otherwise the same object is
 * returned */
public static Object tryClone ( Object toBeCloned ) { } }

implementation: if ( toBeCloned == null ) { return null ; } Object clonedObj = null ; if ( toBeCloned instanceof Cloneable ) { try { Method method = Object . class . getDeclaredMethod ( "clone" ) ; method . setAccessible ( true ) ; clonedObj = method . invoke ( toBeCloned ) ; } catch ( Exception e ) { if ( e instanceof CloneNotSupportedException ) { clonedObj = toBeCloned ; } else { throw e instanceof RuntimeException ? ( RuntimeException ) e : new RuntimeException ( e ) ; } } } else { clonedObj = toBeCloned ; } return clonedObj ;


signature:
public class AbstractCache { /** * Initializes the cache before use . */
public AbstractCache init ( ) { } }

implementation:
/* * Parse custom property : capacity */
long oldCapacity = this . capacity ; try { String entry = getCacheProperty ( CACHE_PROP_CAPACITY ) ; if ( entry != null ) { this . capacity = Long . parseLong ( entry ) ; } } catch ( Exception e ) { this . capacity = oldCapacity ; LOGGER . warn ( e . getMessage ( ) , e ) ; } if ( capacity < - 1 ) { setCapacity ( - 1 ) ; } /* * Parse custom property : expire - after - access */
long oldExpireAfterAccess = this . expireAfterAccess ; try { String entry = getCacheProperty ( CACHE_PROP_EXPIRE_AFTER_ACCESS ) ; if ( entry != null ) { this . expireAfterAccess = Long . parseLong ( entry ) ; } } catch ( Exception e ) { this . expireAfterAccess = oldExpireAfterAccess ; LOGGER . warn ( e . getMessage ( ) , e ) ; } if ( expireAfterAccess < - 1 ) { setExpireAfterAccess ( - 1 ) ; } /* * Parse custom property : expire - after - write */
long oldExpireAfterWrite = this . expireAfterWrite ; try { String entry = getCacheProperty ( CACHE_PROP_EXPIRE_AFTER_WRITE ) ; if ( entry != null ) { this . expireAfterWrite = Long . parseLong ( entry ) ; } } catch ( Exception e ) { this . expireAfterWrite = oldExpireAfterWrite ; LOGGER . warn ( e . getMessage ( ) , e ) ; } if ( expireAfterWrite < - 1 ) { setExpireAfterWrite ( - 1 ) ; } return this ;


signature:
public class AbstractCache { /** * Cache ' s custom properties .
 * @ param cacheProps
 * @ return
 * @ since 0.6.1 */
public AbstractCache setCacheProperties ( Properties cacheProps ) { } }

implementation: this . cacheProps = cacheProps != null ? new Properties ( cacheProps ) : new Properties ( ) ; return this ;


signature:
public class AbstractCache { /** * Get cache ' s custom property .
 * @ param key
 * @ return
 * @ since 0.6.1 */
protected String getCacheProperty ( String key ) { } }

implementation: return cacheProps != null ? cacheProps . getProperty ( key ) : null ;


signature:
public class AbstractCache { /** * { @ inheritDoc } */
@ Override public Object get ( String key , ICacheLoader cacheLoader ) { } }

implementation: Object value = internalGet ( key ) ; boolean fromCacheLoader = false ; if ( value == null && cacheLoader != null ) { try { value = cacheLoader . load ( key ) ; fromCacheLoader = true ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } } if ( value instanceof CacheEntry ) { CacheEntry ce = ( CacheEntry ) value ; value = ce . getValue ( ) ; } if ( fromCacheLoader || value == null ) { stats . miss ( ) ; } else { stats . hit ( ) ; } return value ;


signature:
public class BaseRedisCache { /** * Attach a { @ link JedisConnector } to this cache .
 * @ param jedisConnector
 * @ param setMyOwnRedis
 * set { @ link # myOwnRedis } to { @ code true } or not .
 * @ return
 * @ since 0.6.3.3 */
protected BaseRedisCache setJedisConnector ( JedisConnector jedisConnector , boolean setMyOwnRedis ) { } }


signature:
public class BaseRedisCache { /** * { @ inheritDoc } */
@ Override public BaseRedisCache init ( ) { } }

implementation:
super . init ( ) ; long expireAfterWrite = getExpireAfterWrite ( ) ; long expireAfterAccess = getExpireAfterAccess ( ) ; if ( expireAfterAccess > 0 || expireAfterWrite > 0 ) { timeToLiveSeconds = expireAfterAccess > 0 ? expireAfterAccess : expireAfterWrite ; } else { timeToLiveSeconds = - 1 ; } /* * Parse custom property : key - mode */
KeyMode oldKeyMode = this . keyMode ; try { this . keyMode = KeyMode . valueOf ( getCacheProperty ( CACHE_PROP_KEY_MODE ) . toUpperCase ( ) ) ; } catch ( Exception e ) { this . keyMode = oldKeyMode ; if ( getCacheProperty ( CACHE_PROP_KEY_MODE ) != null ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } } /* * Parse custom property : ttl - seconds */
long oldTTL = this . timeToLiveSeconds ; try { this . timeToLiveSeconds = Long . parseLong ( getCacheProperty ( CACHE_PROP_TTL_SECONDS ) ) ; } catch ( Exception e ) { this . timeToLiveSeconds = oldTTL ; if ( getCacheProperty ( CACHE_PROP_TTL_SECONDS ) != null ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } } /* * Parse custom property : redis - password */
String password = getCacheProperty ( CACHE_PROP_REDIS_PASSWORD ) ; if ( ! StringUtils . isBlank ( password ) ) { this . redisPassword = password ; } return this ;


signature:
public class BaseRedisCache { /** * { @ inheritDoc }
 * @ since 0.6.3 */
@ Override public void destroy ( ) { } }

implementation: try { super . destroy ( ) ; } finally { if ( jedisConnector != null && myOwnRedis ) { try { jedisConnector . destroy ( ) ; } catch ( Exception e ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } finally { jedisConnector = null ; } } }


signature:
public class BaseRedisCache { /** * Calculates cache key based on the key mode .
 * < ul >
 * < li > HASH & MONOPOLISTIC mode : return the key as - is < / li >
 * < li > NAMESPACE mode : return { @ code cache _ name : key } < / li >
 * < / ul >
 * @ param key
 * @ return */
protected String calcCacheKey ( String key ) { } }

implementation: switch ( keyMode ) { case HASH : case MONOPOLISTIC : return key ; case NAMESPACE : return getName ( ) + ":" + key ; default : throw new IllegalStateException ( "Invalid key mode: " + keyMode ) ; }


signature:
public class ShardedRedisCacheFactory { /** * Creates a new { @ link ShardedJedisPool } , with default timeout .
 * @ param hostsAndPorts
 * format { @ code host1 : port1 , host2 : port2 . . . }
 * @ param password
 * @ return */
public static ShardedJedisPool newJedisPool ( String hostsAndPorts , String password ) { } }

implementation: return newJedisPool ( hostsAndPorts , password , Protocol . DEFAULT_TIMEOUT ) ;


signature:
public class ShardedRedisCacheFactory { /** * { @ inheritDoc } */
@ Override public ShardedRedisCacheFactory init ( ) { } }

implementation: super . init ( ) ; if ( getJedisConnector ( ) == null ) { try { JedisConnector jedisConnector = new JedisConnector ( ) ; jedisConnector . setRedisHostsAndPorts ( redisHostsAndPorts ) . setRedisPassword ( getRedisPassword ( ) ) . init ( ) ; setJedisConnector ( jedisConnector , true ) ; } catch ( Exception e ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } } return this ;


signature:
public class ShardedRedisCacheFactory { /** * { @ inheritDoc } */
@ Override protected ShardedRedisCache createCacheInternal ( String name , long capacity , long expireAfterWrite , long expireAfterAccess , Properties cacheProps ) { } }

implementation: ShardedRedisCache cache = new ShardedRedisCache ( keyMode ) ; cache . setName ( name ) . setCapacity ( capacity ) . setExpireAfterAccess ( expireAfterAccess ) . setExpireAfterWrite ( expireAfterWrite ) . setCacheProperties ( cacheProps ) ; cache . setRedisHostsAndPorts ( redisHostsAndPorts ) . setRedisPassword ( getRedisPassword ( ) ) ; cache . setJedisConnector ( getJedisConnector ( ) ) ; return cache ;


signature:
public class ThreadLocalCacheFactory { /** * { @ inheritDoc } */
@ Override protected AbstractCache createCacheInternal ( String name , long capacity , long expireAfterWrite , long expireAfterAccess , Properties cacheProps ) { } }

implementation: ICacheFactory cacheFactory = caches . get ( ) ; return ( AbstractCache ) cacheFactory . createCache ( name ) ;


signature:
public class XMemcachedCacheFactory { /** * Creates a new { @ link MemcachedClient } , with specified connection timeout
 * and connection pool size .
 * @ param hostsAndPorts
 * Memcached ' hosts and ports scheme ( format
 * { @ code host1 : port1 , host2 : port2 } ) .
 * @ param connTimeoutMs
 * @ param connPoolSize
 * @ return
 * @ throws IOException */
public static MemcachedClient newMemcachedClient ( String hostsAndPorts , long connTimeoutMs , int connPoolSize ) throws IOException { } }

implementation: hostsAndPorts = StringUtils . join ( hostsAndPorts . split ( "[\\s,;]+" ) , ' ' ) ; MemcachedClientBuilder builder = new XMemcachedClientBuilder ( AddrUtil . getAddresses ( hostsAndPorts ) ) ; builder . setConnectTimeout ( connTimeoutMs ) ; builder . setConnectionPoolSize ( connPoolSize ) ; return builder . build ( ) ;


signature:
public class XMemcachedCacheFactory { /** * Attach a { @ link XMemcachedConnector } to this cache factory .
 * @ param memcachedConnector
 * @ param setMyOwnMemcachedConnector
 * set { @ link # myOwnMemcachedConnector } to { @ code true } or not .
 * @ return
 * @ since 0.6.3.3 */
protected XMemcachedCacheFactory setMemcachedConnector ( XMemcachedConnector memcachedConnector , boolean setMyOwnMemcachedConnector ) { } }

implementation: if ( myOwnMemcachedConnector && this . memcachedConnector != null ) { this . memcachedConnector . close ( ) ; } this . memcachedConnector = memcachedConnector ; myOwnMemcachedConnector = setMyOwnMemcachedConnector ; return this ;


signature:
public class XMemcachedCacheFactory { /** * { @ inheritDoc } */
@ Override public XMemcachedCacheFactory init ( ) { } }

implementation: super . init ( ) ; if ( memcachedConnector == null ) { try { memcachedConnector = buildXmemcachedConnector ( ) ; } catch ( Exception e ) { LOGGER . warn ( e . getMessage ( ) , e ) ; } myOwnMemcachedConnector = true ; } return this ;


signature:
public class XMemcachedCacheFactory { /** * { @ inheritDoc } */
@ Override protected XMemcachedCache createCacheInternal ( String name , long capacity , long expireAfterWrite , long expireAfterAccess , Properties cacheProps ) { } }

implementation: XMemcachedCache cache = new XMemcachedCache ( keyMode ) ; cache . setName ( name ) . setCapacity ( capacity ) . setExpireAfterAccess ( expireAfterAccess ) . setExpireAfterWrite ( expireAfterWrite ) . setCacheProperties ( cacheProps ) ; cache . setMemcachedHostsAndPorts ( memcachedHostsAndPorts ) . setMemcachedConnector ( memcachedConnector ) ; return cache ;


signature:
public class AbstractCacheFactory { /** * Gets a cache ' s properties
 * @ param name
 * @ return */
protected Properties getCacheProperties ( String name ) { } }

implementation: return cacheProperties != null ? cacheProperties . get ( name ) : null ;


signature:
public class AbstractCacheFactory { /** * { @ inheritDoc } */
@ Override public AbstractCache createCache ( String name , ICacheLoader cacheLoader ) { } }

implementation: return createCache ( name , defaultCacheCapacity , defaultExpireAfterWrite , defaultExpireAfterAccess , cacheLoader ) ;


signature:
public class AbstractCacheFactory { /** * { @ inheritDoc } */
@ Override public AbstractCache createCache ( String name , long capacity ) { } }

implementation: return createCache ( name , capacity , null ) ;


signature:
public class AbstractCacheFactory { /** * { @ inheritDoc } */
@ Override public AbstractCache createCache ( String name , long capacity , long expireAfterWrite , long expireAfterAccess ) { } }

implementation: return createCache ( name , capacity , expireAfterWrite , expireAfterAccess , null ) ;


signature:
public class AbstractCacheFactory { /** * { @ inheritDoc } */
@ Override public AbstractCache createCache ( String name , long capacity , long expireAfterWrite , long expireAfterAccess , ICacheLoader cacheLoader ) { } }

implementation:
String cacheName = buildCacheName ( name ) ; try { AbstractCache cache = cacheInstances . get ( cacheName , new Callable < AbstractCache > ( ) { @ Override public AbstractCache call ( ) throws Exception { // check if custom cache settings exist
long cacheCapacity = capacity ; long cacheExpireAfterWrite = expireAfterWrite ; long cacheExpireAfterAccess = expireAfterAccess ; // yup , use " name " here ( not " cacheName ) is correct and
// intended !
Properties cacheProps = getCacheProperties ( name ) ; if ( cacheProps != null ) { try { cacheCapacity = Long . parseLong ( cacheProps . getProperty ( CACHE_PROP_CAPACITY ) ) ; } catch ( Exception e ) { cacheCapacity = capacity ; } try { cacheExpireAfterWrite = Long . parseLong ( cacheProps . getProperty ( CACHE_PROP_EXPIRE_AFTER_WRITE ) ) ; } catch ( Exception e ) { cacheExpireAfterWrite = expireAfterWrite ; } try { cacheExpireAfterAccess = Long . parseLong ( cacheProps . getProperty ( CACHE_PROP_EXPIRE_AFTER_ACCESS ) ) ; } catch ( Exception e ) { cacheExpireAfterAccess = expireAfterAccess ; } } return createAndInitCacheInstance ( cacheName , cacheCapacity , cacheExpireAfterWrite , cacheExpireAfterAccess , cacheLoader , cacheProps ) ; } } ) ; return cache ; } catch ( ExecutionException e ) { throw new RuntimeException ( e ) ; }


signature:
public class AbstractCacheFactory { /** * Creates and initializes an { @ link ICache } instance , ready for use .
 * @ param name
 * @ param capacity
 * @ param expireAfterWrite
 * @ param expireAfterAccess
 * @ param cacheLoader
 * @ param cacheProps
 * @ return */
protected AbstractCache createAndInitCacheInstance ( String name , long capacity , long expireAfterWrite , long expireAfterAccess , ICacheLoader cacheLoader , Properties cacheProps ) { } }

implementation: AbstractCache cache = createCacheInternal ( name , capacity , expireAfterWrite , expireAfterAccess , cacheProps ) ; cache . setCacheLoader ( cacheLoader ) . setCacheFactory ( this ) ; cache . init ( ) ; return cache ;


signature:
public class AbstractCacheFactory { /** * { @ inheritDoc } */
@ Override public void removeCache ( String name ) { } }

implementation: String cacheName = buildCacheName ( name ) ; cacheInstances . invalidate ( cacheName ) ;


signature:
public class LocalRemoteCache { /** * Puts an entry to both local and remote caches , with specified expiries . */
@ Override public void set ( String key , Object entry , long expireAfterWrite , long expireAfterAccess ) { } }

implementation: try { if ( localCache != null ) { localCache . set ( key , entry , expireAfterWrite , expireAfterAccess ) ; } if ( remoteCache != null ) { remoteCache . set ( key , entry , expireAfterWrite , expireAfterAccess ) ; } } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class LocalRemoteCache { /** * Delete an entry from both local and remote caches . */
@ Override public void delete ( String key ) { } }

implementation: try { if ( localCache != null ) { localCache . delete ( key ) ; } if ( remoteCache != null ) { remoteCache . delete ( key ) ; } } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class LocalRemoteCache { /** * Delete an entry from the local cache .
 * @ param key */
public void deleteLocal ( String key ) { } }

implementation: if ( localCache != null ) { try { localCache . delete ( key ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } }


signature:
public class LocalRemoteCache { /** * Deletes all entries in both local and remote caches . */
@ Override public void deleteAll ( ) { } }

implementation: try { if ( localCache != null ) { localCache . deleteAll ( ) ; } if ( remoteCache != null ) { remoteCache . deleteAll ( ) ; } } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class LocalRemoteCache { /** * Deletes all entries in the local cache . */
public void deleteAllLocal ( ) { } }

implementation: if ( localCache != null ) { try { localCache . deleteAll ( ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; } }


signature:
public class LocalRemoteCache { /** * Checks if an entry exists in the local cache .
 * @ param key */
public boolean existsLocal ( String key ) { } }

implementation: try { return localCache != null && localCache . exists ( key ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class LocalRemoteCache { /** * Checks if an entry exists in the local cache .
 * @ param key */
public boolean existsRemote ( String key ) { } }

implementation: try { return remoteCache != null && remoteCache . exists ( key ) ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class LocalRemoteCache { /** * { @ inheritDoc } */
@ Override protected Object internalGet ( String key ) { } }

implementation: try { Object value = localCache != null ? localCache . get ( key ) : null ; if ( value == null ) { value = remoteCache != null ? remoteCache . get ( key ) : null ; if ( value != null && localCache != null ) { localCache . set ( key , value ) ; } } return value ; } catch ( Exception e ) { throw e instanceof CacheException ? ( CacheException ) e : new CacheException ( e ) ; }


signature:
public class StringUtils { /** * checks if the original string is empty . if empty / null return the alternative , otherwise the
 * original
 * @ param original
 * @ param alternative
 * @ return */
public static String alternative ( final String original , final String alternative ) { } }

implementation: return isEmpty ( original ) ? alternative : original ;


signature:
public class FormChecker { /** * Deprecated : Use build ( Request _ req , FormCheckerForm form ) and put id into
 * the FormCheckerForm
 * @ param _ id
 * @ param _ req
 * @ param form
 * @ return */
@ Deprecated public static FormChecker build ( String _id , Request _req , FormCheckerForm form ) { } }

implementation: FormChecker fc = new FormChecker ( _id , _req ) ; fc . id = _id ; fc . addForm ( form ) ; return fc ;


signature:
public class FormChecker { /** * move to ViewFacade */
public String getLabelForElement ( FormCheckerElement e , Map < String , String > attribs ) { } }

implementation: return config . getFormBuilder ( ) . getLabelForElement ( e , new TagAttributes ( attribs ) , firstRun ) ;


signature:
public class FormChecker { /** * set up the config - object for formchecker ( handles absence of properties
 * and formBuider ) */
private void setupConfig ( ) { } }

implementation: if ( config == null ) { if ( tempFormBuilder == null ) { tempFormBuilder = new BasicFormBuilder ( ) ; } if ( tempProperties == null ) { tempProperties = new MinimalMessageSource ( ) ; } config = new FormCheckerConfig ( tempProperties , tempFormBuilder ) ; }


signature:
public class FormChecker { /** * resort tab - indexes */
private void sortTabIndexes ( ) { } }

implementation: int tabIndex = 100 ; for ( FormCheckerElement elem : form . getElements ( ) ) { elem . setTabIndex ( tabIndex ) ; tabIndex = elem . getLastTabIndex ( ) ; tabIndex ++ ; }


signature:
public class GenericFormBuilder { /** * Renders the html for the complete form with all elements within . */
@ Deprecated final public String generateGenericForm ( String formAction , boolean firstRun , FormCheckerForm form , Request req , FormCheckerConfig config ) { } }

implementation: return this . generateGenericForm ( formAction , firstRun , form , req , config . properties ) ;


signature:
public class GenericFormBuilder { /** * builds the html for one element */
String generateHtmlForElement ( boolean firstRun , MessageSource messageSource , FormCheckerElement elem , boolean html5Validation ) { } }

implementation:
InputElementStructure inputStruct = new InputElementStructure ( ) ; // errors
ValidationResult vr = getErrors ( elem , firstRun ) ; if ( ! vr . isValid ( ) ) { inputStruct . setErrors ( formatError ( messageSource . getMessage ( vr ) ) ) ; } // label
boolean displayLabel = ! StringUtils . isEmpty ( elem . getDescription ( ) ) ; if ( displayLabel ) { inputStruct . setLabel ( getLabelForElement ( elem , getLabelAttributes ( elem ) , firstRun ) ) ; } // input tag
Map < String , String > attribs = new LinkedHashMap < > ( ) ; addAttributesToInputFields ( attribs , elem ) ; inputStruct . setInput ( elem . getInputTag ( attribs , messageSource , html5Validation ) ) ; // help tag
if ( ! StringUtils . isEmpty ( elem . getHelpText ( ) ) ) { inputStruct . setHelp ( getHelpTag ( elem . getHelpText ( ) , elem ) ) ; } return getCompleteRenderedInput ( inputStruct , elem , firstRun ) ;


signature:
public class GenericFormBuilder { /** * override this , if you want to have a different order of the elements . */
public String getCompleteRenderedInput ( InputElementStructure inputStruct , FormCheckerElement elem , boolean firstRun ) { } }

implementation: StringBuilder elemHtml = new StringBuilder ( ) ; Wrapper elementWrapper = getWrapperForElem ( elem , firstRun ) ; elemHtml . append ( elementWrapper . start ) ; elemHtml . append ( inputStruct . getErrors ( ) ) ; Wrapper labelWrapper = getWrapperForLabel ( elem ) ; elemHtml . append ( labelWrapper . start ) . append ( inputStruct . getLabel ( ) ) . append ( labelWrapper . end ) ; Wrapper inputWrapper = getWrapperForInput ( elem ) ; elemHtml . append ( inputWrapper . start ) ; elemHtml . append ( inputStruct . getInput ( ) ) ; elemHtml . append ( inputStruct . getHelp ( ) ) ; elemHtml . append ( inputWrapper . end ) ; elemHtml . append ( elementWrapper . end ) ; return elemHtml . toString ( ) ;


signature:
public class View { /** * the access objects should only be build , if the template engine can ' t call methods with params .
 * Not capable templates that need this : mustache . . . */
public View generateAccessObjects ( ) { } }

implementation: elements = new HashMap < > ( ) ; inputs = new HashMap < > ( ) ; labels = new HashMap < > ( ) ; helps = new HashMap < > ( ) ; isError = new HashMap < > ( ) ; form . elements . forEach ( elem -> elements . put ( elem . getName ( ) , getElement ( elem . getName ( ) ) ) ) ; form . elements . forEach ( elem -> inputs . put ( elem . getName ( ) , getInput ( elem . getName ( ) ) ) ) ; form . elements . forEach ( elem -> labels . put ( elem . getName ( ) , getLabel ( elem . getName ( ) ) ) ) ; form . elements . forEach ( elem -> helps . put ( elem . getName ( ) , getHelp ( elem . getName ( ) ) ) ) ; form . elements . forEach ( elem -> isError . put ( elem . getName ( ) , isError ( elem . getName ( ) ) ) ) ; return this ;


signature:
public class View { /** * input - element via a macro ! */
public String getElement ( String name ) { } }

implementation: return formBuilder . generateHtmlForElement ( fc . firstRun , fc . config . getProperties ( ) , form . getElement ( name ) , this . form . isHtml5Validation ( ) ) ;


signature:
public class EmbeddedWebContextConnector { /** * Registers the specified embedded web context .
 * @ return the previously - registered { @ link ApplicationContext } or null if nothing previously - registered */
public static ApplicationContext registerAppContext ( String embeddedWebContext , ApplicationContext appContext ) { } }

implementation: return appContextMap . put ( embeddedWebContext , appContext ) ;


signature:
public class EmbeddedWebContextConnector { /** * Loads the parent { @ link ApplicationContext } for the { @ link ServletContext } by retrieving the previously
 * { @ link # registerAppContext ( String , ApplicationContext ) registered } one for the embedded web context . */
@ Override protected ApplicationContext loadParentContext ( ServletContext servletContext ) { } }

implementation: String name = servletContext . getInitParameter ( "embeddedWebContext" ) ; if ( name == null ) { throw new IllegalStateException ( "context param [embeddedWebContext] not specified for [" + servletContext . getServletContextName ( ) + "]" ) ; } ApplicationContext appContext = appContextMap . get ( name ) ; if ( appContext == null ) { throw new IllegalStateException ( "application context not registered for [" + name + "]" ) ; } return appContext ;


signature:
public class AjaxUtils { /** * returns json output in this format : http : / / labs . omniti . com / labs / jsend
 * { " status " : " fail " , " data " : { " title " : " A title is required " } }
 * { status : " success " , data : null }
 * @ param fc
 * @ return */
public static String getJsonOutput ( FormChecker fc ) { } }

implementation:
StringBuilder json = new StringBuilder ( ) ; String status = fc . isValidAndNotFirstRun ( ) ? "success" : "fail" ; json . append ( "{\"status\": \"" + status + "\"," ) ; json . append ( "\"data\":" ) ; // Problems :
if ( fc . isValidAndNotFirstRun ( ) ) { json . append ( "\"null\"," ) ; } else { // append errors :
json . append ( "{" ) ; String commaAppend = "" ; for ( FormCheckerElement elem : fc . getForm ( ) . getElements ( ) ) { if ( ! elem . isValid ( ) ) { json . append ( commaAppend ) ; json . append ( "\"" + elem . getName ( ) + "\":" + "\"" + elem . getValidationResult ( ) . getMessage ( ) + "\"" ) ; commaAppend = "," ; } } json . append ( "}," ) ; } // no problems
json . append ( "\"okdata\":" ) ; // append errors :
json . append ( "{" ) ; String commaAppend = "" ; for ( FormCheckerElement elem : fc . getForm ( ) . getElements ( ) ) { if ( elem . isValid ( ) ) { json . append ( commaAppend ) ; json . append ( "\"" + elem . getName ( ) + "\":" + "\"" + "OK" + "\"" ) ; commaAppend = "," ; } } json . append ( "}" ) ; json . append ( "}" ) ; return json . toString ( ) ;


signature:
public class SelectInput { /** * a map is not a good structure for that , because keys may be used more than once */
@ Deprecated public static SelectInput build ( String name , LinkedHashMap < String , String > possibleNames ) { } }

implementation: SelectInput si = SelectInput . build ( name ) ; si . setPossibleValues ( possibleNames ) ; return si ;


signature:
public class SelectInput { /** * convenience method */
public static SelectInput build ( String name , String keys [ ] , String values [ ] ) { } }

implementation: SelectInput si = SelectInput . build ( name ) ; if ( keys . length != values . length ) { throw new IllegalArgumentException ( "Key / Values with unequal length" ) ; } List < SelectInputEntry > entries = new ArrayList < > ( ) ; for ( int i = 0 ; i < keys . length ; i ++ ) { entries . add ( si . generateEntry ( keys [ i ] , values [ i ] ) ) ; } si . setEntries ( entries ) ; return si ;


signature:
public class SelectInput { /** * build a select - box with groups ( This may be impossible to build ) */
public static SelectInput build ( String name , List < SelectInputEntryGroup > inputGroups ) { } }

implementation: SelectInput si = SelectInput . build ( name ) ; si . setGroups ( inputGroups ) ; return si ;


signature:
public class AbstractInput { /** * builds attribs , elementId , TabIndex */
protected String buildAllAttributes ( TagAttributes tagAttributes , MessageSource messageSource , boolean html5Validation ) { } }

implementation:
StringBuilder allAttribs = new StringBuilder ( ) ; allAttribs . append ( AttributeUtils . buildAttributes ( tagAttributes ) ) ; allAttribs . append ( getElementId ( ) ) ; allAttribs . append ( getTabIndexTag ( ) ) ; if ( html5Validation ) { allAttribs . append ( buildRequiredAttribute ( ) ) ; allAttribs . append ( buildFcRequiredMessage ( messageSource ) ) ; } allAttribs . append ( buildSizeAttribute ( ) ) ; // help - text
if ( ! StringUtils . isEmpty ( helpText ) ) { allAttribs . append ( AttributeUtils . buildAttributes ( new TagAttributes ( "aria-describedby" , parent . getConfig ( ) . getFormBuilder ( ) . getHelpBlockId ( this ) ) ) ) ; } return allAttribs . toString ( ) ;


signature:
public class AbstractInput { /** * builds the maxlen attribute */
public String buildMaxLen ( ) { } }

implementation: List < Criterion > criteria = this . getCriteria ( ) ; if ( criteria != null ) { for ( Criterion criterion : criteria ) { if ( criterion instanceof MaxLength ) { return AttributeUtils . buildSingleAttribute ( "maxlength" , Integer . toString ( ( ( MaxLength ) criterion ) . getMaxLength ( ) ) ) ; } } } return "" ;


signature:
public class RadioInput { /** * order */
public static RadioInput build ( String name ) { } }

implementation: RadioInput i = new RadioInput ( ) ; i . name = name ; return i ;


signature:
public class RadioInput { /** * convenience method */
public static RadioInput build ( String name , LinkedHashMap < String , String > possibleNames ) { } }

implementation: RadioInput si = RadioInput . build ( name ) ; si . setPossibleValues ( possibleNames ) ; return si ;


signature:
public class RadioInput { /** * convenience method */
public static RadioInput build ( String name , String keys [ ] , String values [ ] ) { } }

implementation: RadioInput si = RadioInput . build ( name ) ; if ( keys . length != values . length ) { throw new IllegalArgumentException ( "Key / Values with unequal lenght" ) ; } LinkedHashMap < String , String > possibleNames = new LinkedHashMap < > ( ) ; for ( int i = 0 ; i < keys . length ; i ++ ) { possibleNames . put ( keys [ i ] , values [ i ] ) ; } si . setPossibleValues ( possibleNames ) ; return si ;


signature:
public class DefaultValidator { /** * ( non - Javadoc )
 * @ see de . jformchecker . validator . Validator # validate ( de . jformchecker .
 * FormCheckerElement ) */
@ Override public ValidationResult validate ( FormCheckerElement elem ) { } }

implementation:
String value = elem . getValue ( ) ; ValidationResult vr = ValidationResult . ok ( ) ; if ( value != null && ! "" . equals ( value ) ) { vr = allCriteriaSatisfied ( elem ) ; } else { // blank input is valid if it ' s not required
if ( elem . isRequired ( ) ) { vr = ValidationResult . fail ( "jformchecker.required" , "" ) ; } } return vr ;


signature:
public class DefaultValidator { /** * RFE : Maybe return here an array ? So we can have more than one error - message per field . */
private ValidationResult allCriteriaSatisfied ( FormCheckerElement elem ) { } }

implementation: for ( Criterion criterion : elem . getCriteria ( ) ) { ValidationResult vr = criterion . validate ( elem ) ; if ( ! vr . isValid ( ) ) { return vr ; } } return ValidationResult . ok ( ) ;


signature:
public class ValidationResult { /** * factory methods */
public static ValidationResult of_ ( boolean isValid , String message , Object ... errorVals ) { } }

implementation: return new ValidationResult ( isValid , message , errorVals , null ) ;


signature:
public class DateInputSelectCompound { /** * Get internal Date as Date ( Please avoid this , because LocalDate is far better . )
 * @ return */
public Date getLegacyDateValue ( ) { } }

implementation: if ( internalDate == null ) { return null ; } return Date . from ( internalDate . atStartOfDay ( ZoneId . systemDefault ( ) ) . toInstant ( ) ) ;


signature:
public class Resource { /** * Ensure most optimal match works */
private List < ContentType > getAcceptedContentTypes ( ) { } }

implementation: Annotation consumesAnnotation = referencedMethod . getAnnotation ( Consumes . class ) ; if ( null == consumesAnnotation ) consumesAnnotation = referencedClass . getAnnotation ( Consumes . class ) ; final List < ContentType > acceptedContentTypes = Lists . newArrayList ( ) ; if ( null != consumesAnnotation ) { for ( final String cts : ( ( Consumes ) consumesAnnotation ) . value ( ) ) { try { acceptedContentTypes . add ( ContentType . valueOf ( cts ) ) ; } catch ( IllegalArgumentException e ) { } } } return acceptedContentTypes ;


signature:
public class SessionChecker { /** * Checks if currently we are during same session that we were during
 * callback creation .
 * @ return True if we are still during same session , false otherwise . */
public boolean isSameSession ( ) { } }

implementation: String sessionId = sessionIdProvider . get ( ) ; if ( callbackStartSessionId == null ) { return sessionId == null ; } return callbackStartSessionId . equals ( sessionId ) ;


signature:
public class Tools { /** * Create an asynchronous operation that executes a provided task creating
 * an Android ' s { @ link android . os . AsyncTask } .
 * @ param task job to do
 * @ param < D > result data type
 * @ return implementation of { @ link Async } , never { @ code null } */
public static < D > Async < D > async ( final Callable < D > task ) { } }

implementation: return async ( null , task ) ;


signature:
public class Tools { /** * Create an asynchronous operation that executes a provided task creating
 * an Android ' s { @ link android . os . AsyncTask } with a specified executor .
 * @ param task job to do
 * @ param executor executor used by AsyncTask
 * @ param < D > result data type
 * @ return implementations of { @ link Async } , never { @ code null } */
public static < D > Async < D > async ( final Executor executor , final Callable < D > task ) { } }

implementation: return new TaskAsync < > ( task , executor ) ;


signature:
public class CursorAsyncBuilder { /** * Wrap a provided converter .
 * Returns a converter that creates of list of elements obtained with a provider converter . */
public static < D > CursorConverter < List < D > > listConverter ( final CursorConverter < D > converter ) { } }

implementation: return new ListConverter < > ( converter ) ;


signature:
public class CursorAsyncBuilder { /** * Convert { @ code Cursor } into a POJO using a { @ code CursorConverter } . */
public < D > BaseCursorAsyncBuilder < ? extends BaseCursorAsyncBuilder < ? , D > , D > convert ( final CursorConverter < D > converter ) { } }

implementation: return new ConvertedCursorAsyncBuilder < > ( resolver , converter , params ) ;


signature:
public class CursorAsyncBuilder { /** * Convert { @ code Cursor } into a POJO using a { @ code CursorConverter } .
 * Only the first cursor record will be converted . Provided { @ code CursorConverter } should not
 * invoke any { @ code move } methods on a cursor . */
public < D > BaseCursorAsyncBuilder < ? extends BaseCursorAsyncBuilder < ? , D > , D > convertFirst ( final CursorConverter < D > converter ) { } }

implementation: return convert ( singleRecordConverter ( converter ) ) ;


signature:
public class CursorAsyncBuilder { /** * Convert { @ code Cursor } into a { @ code List } creating each item with
 * a provided { @ code CursorConverter } .
 * Provided { @ code CursorConverter } should not invoke any { @ code move } methods on a cursor . */
public < D > BaseCursorAsyncBuilder < ? extends BaseCursorAsyncBuilder < ? , List < D > > , List < D > > convertList ( final CursorConverter < D > converter ) { } }

implementation: return convert ( listConverter ( converter ) ) ;


signature:
public class LoaderDescription { /** * Initialize already started loaders . */
void initStartedLoaders ( ) { } }

implementation: LoaderManager lm = operatorContext . loaderManager ; SparseArray < LoaderCookies > listenersMap = this . listenersMap ; int count = listenersMap . size ( ) ; for ( int i = 0 ; i < count ; i ++ ) { int loaderId = listenersMap . keyAt ( i ) ; Loader < ? > loader = lm . getLoader ( loaderId ) ; if ( loader != null && loader . isStarted ( ) ) { LoaderCookies cookies = listenersMap . valueAt ( i ) ; boolean notInit = ( cookies . options & LoaderCookies . ALREADY_INIT ) == 0 ; if ( notInit ) { Utils . initLoader ( operatorContext , loaderId , STUB_PROVIDER , ( cookies . options & LoaderCookies . DESTROY_ON_FINISH ) == LoaderCookies . DESTROY_ON_FINISH , this ) ; } } }


signature:
public class EventCallback { /** * Returns builder that creates { @ link EventCallback } .
 * To avoid passing all arguments on each callback creation it is suggested
 * to wrap this call in project . For example :
 * < pre > < code class = " java " >
 * class MyEventCallback & lt ; S & gt ; {
 * CallbackConfig config = injected ;
 * private EventCallbackBuilder & lt ; S , MyHandledErrorMsg & gt ; builder ( ) {
 * return EventCallback . builder ( config , new TypeToken & lt ; MyHandledErrorMsg & gt ; ( ) { } ) ;
 * public static & lt ; S & gt ; EventCallbackBuilder & lt ; S , MyHandledErrorMsg & gt ; ofType ( ) {
 * return new MyEventCallback & lt ; S & gt ; ( ) . builder ( responseType ) ;
 * < / code > < / pre >
 * @ param < S > Type of response returned by server onSuccess
 * @ param < E > Type of response returned by server onError
 * @ param config Shared configuration
 * @ param errorTypeToken TypeToken that provides information about expected
 * response returned by server
 * @ return Builder that assists in creating valid EventCallback in readable
 * way . */
public static < S , E > EventCallbackBuilder < S , E > builder ( @ Nonnull CallbackConfig config , @ Nonnull TypeToken < E > errorTypeToken ) { } }

implementation: return new EventCallbackBuilder < S , E > ( config , errorTypeToken ) ;


signature:
public class EventCallback { /** * Passes result to { @ link SuccessHandler } s from { @ link Callback }
 * @ param result response from the server that should be passed to listeners */
private void informSharedSuccessHandlers ( S result ) { } }

implementation:
if ( result == null ) { // no handler matches undefined result class
return ; } for ( Map . Entry < Class , SuccessHandler > handler : config . sharedSuccessHandlers . entrySet ( ) ) { if ( handler . getKey ( ) . isAssignableFrom ( result . getClass ( ) ) ) { handler . getValue ( ) . onCallSuccess ( result ) ; } }


signature:
public class EventCallback { /** * Checks if any actions is associated with response status code , and
 * execute it .
 * @ param response response from the server that can be checked for status
 * code . */
private void informStatusCodeListener ( @ Nullable Response response ) { } }

implementation: if ( response == null ) { return ; } ScheduledActions < CreateEvents > actions = onStatusCodeActions . get ( response . getStatus ( ) ) ; if ( actions != null ) { postHelper . executeCommonActions ( actions , sessionChecker . isSameSession ( ) ) ; }


signature:
public class SPFRemoteProfile { /** * Provides a reference to a remote profile . With this reference it is
 * possible to perform read operations and retrieve information from remote
 * people .
 * @ param p
 * - the { @ link SPFPerson } whose profile to load .
 * @ return an instance of { @ link RemoteProfile } to interact with the remote
 * profile . */
public RemoteProfile getProfileOf ( SPFPerson p ) { } }

implementation: if ( p == null ) { throw new NullPointerException ( ) ; } return new RemoteProfile ( p , mInterface ) ;


signature:
public class XsltTransformerExtensions { /** * Transform .
 * @ param xmlFile
 * the xml file
 * @ param xsltFile
 * the xslt file
 * @ param outputStream
 * the output stream
 * @ throws TransformerConfigurationException
 * is thrown if there are errors when parsing the < code > Source < / code > or it is not
 * possible to create a < code > Transformer < / code > instance .
 * @ throws TransformerException
 * is thrown if an unrecoverable error occurs during the course of the
 * transformation . */
public static void transform ( final @ NonNull File xmlFile , final @ NonNull File xsltFile , final OutputStream outputStream ) throws TransformerConfigurationException , TransformerException { } }

implementation: final Source xmlSource = new StreamSource ( xmlFile ) ; final Source xsltSource = new StreamSource ( xsltFile ) ; transform ( xmlSource , xsltSource , outputStream ) ;


signature:
public class XsltTransformerExtensions { /** * Transform .
 * @ param xmlSource
 * the xml source
 * @ param xsltSource
 * the xslt source
 * @ param outputStream
 * the output stream
 * @ throws TransformerConfigurationException
 * is thrown if there are errors when parsing the < code > Source < / code > or it is not
 * possible to create a < code > Transformer < / code > instance .
 * @ throws TransformerException
 * is thrown if an unrecoverable error occurs during the course of the
 * transformation . */
public static void transform ( final Source xmlSource , final Source xsltSource , final OutputStream outputStream ) throws TransformerConfigurationException , TransformerException { } }

implementation: final Transformer transformer = getTransformer ( xsltSource ) ; transformer . transform ( xmlSource , new StreamResult ( outputStream ) ) ;


signature:
public class XsltTransformerExtensions { /** * Transform .
 * @ param xmlInputFile
 * the xml input file
 * @ param xsltInputFile
 * the xslt input file
 * @ param outputStream
 * the output stream
 * @ throws TransformerConfigurationException
 * is thrown if there are errors when parsing the < code > Source < / code > or it is not
 * possible to create a < code > Transformer < / code > instance .
 * @ throws TransformerException
 * is thrown if an unrecoverable error occurs during the course of the
 * transformation . */
public static void transform ( final String xmlInputFile , final String xsltInputFile , final OutputStream outputStream ) throws TransformerConfigurationException , TransformerException { } }

implementation: final File xmlFile = new File ( xmlInputFile ) ; final File xsltFile = new File ( xsltInputFile ) ; transform ( xmlFile , xsltFile , outputStream ) ;


signature:
public class TagsPicker { /** * Set the change listener .
 * @ param listener */
public void setChangeListener ( OnChangeListener listener ) { } }

implementation:
changeListener = listener ; if ( changeListener != null ) { // add a listener to TagViewer for removed tags events
tv . setOnRemovedTagListener ( new TagsViewer . OnRemovedListener ( ) { @ Override public void onRemovedTag ( String tag ) { notifyChangeListener ( ) ; } } ) ; }


signature:
public class SPFTrigger { /** * ( non - Javadoc )
 * @ see android . os . Parcelable # writeToParcel ( android . os . Parcel , int ) */
@ Override public void writeToParcel ( Parcel dest , int flags ) { } }

implementation: dest . writeParcelable ( query , flags ) ; dest . writeParcelable ( action , flags ) ; dest . writeLong ( id ) ; dest . writeInt ( isOneShot ? 1 : 0 ) ; dest . writeLong ( sleepPeriod ) ; dest . writeString ( name ) ;


signature:
public class ValidatorExtensions { /** * Gets the document builder factory .
 * @ param schema
 * the schema
 * @ return the document builder factory */
public static DocumentBuilderFactory getDocumentBuilderFactory ( final String schema ) { } }

implementation: System . setProperty ( DOCUMENT_BUILDER_FACTORY_KEY , DOCUMENT_BUILDER_FACTORY_VALUE ) ; final DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; factory . setValidating ( true ) ; factory . setAttribute ( SCHEMA_LANGUAGE_KEY , HTTP_WWW_W3_ORG_2001_XML_SCHEMA ) ; factory . setAttribute ( SCHEMA_SOURCE_KEY , schema ) ; return factory ;


signature:
public class ValidatorExtensions { /** * Gets the dOM source .
 * @ param xml
 * the xml
 * @ param errorHandler
 * the error handler
 * @ return the dOM source
 * @ throws SAXException
 * If a SAX error occurs during parsing .
 * @ throws ParserConfigurationException
 * if a DocumentBuilder cannot be created which satisfies the configuration
 * requested .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static DOMSource getDOMSource ( final File xml , final ErrorHandler errorHandler ) throws SAXException , ParserConfigurationException , IOException { } }

implementation: return new DOMSource ( parse ( xml , errorHandler ) ) ;


signature:
public class ValidatorExtensions { /** * Gets the schema .
 * @ param xsd
 * the xsd
 * @ param errorHandler
 * the error handler
 * @ return the schema
 * @ throws SAXException
 * If a SAX error occurs during parsing . */
public static Schema getSchema ( final File xsd , final ErrorHandler errorHandler ) throws SAXException { } }

implementation:
// Create a new instance for an XSD - aware SchemaFactory
final SchemaFactory schemaFactory = SchemaFactory . newInstance ( HTTP_WWW_W3_ORG_2001_XML_SCHEMA ) ; // Set the ErrorHandler implementation .
schemaFactory . setErrorHandler ( errorHandler ) ; // get the custom xsd schema that describes
// the required format for my XML files .
return schemaFactory . newSchema ( xsd ) ;


signature:
public class ValidatorExtensions { /** * Parses the .
 * @ param xml
 * the xml
 * @ param errorHandler
 * the error handler
 * @ return the document
 * @ throws SAXException
 * If a SAX error occurs during parsing .
 * @ throws ParserConfigurationException
 * if a DocumentBuilder cannot be created which satisfies the configuration
 * requested .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static Document parse ( final File xml , final ErrorHandler errorHandler ) throws SAXException , ParserConfigurationException , IOException { } }

implementation: final DocumentBuilderFactory factory = getDocumentBuilderFactory ( xml . getName ( ) ) ; final DocumentBuilder builder = factory . newDocumentBuilder ( ) ; builder . setErrorHandler ( errorHandler ) ; return builder . parse ( xml ) ;


signature:
public class ValidatorExtensions { /** * Validate xml through xsd .
 * @ param xsd
 * the xsd
 * @ param xml
 * the xml
 * @ param errorHandler
 * the error handler
 * @ throws SAXException
 * If a SAX error occurs during parsing .
 * @ throws ParserConfigurationException
 * if a DocumentBuilder cannot be created which satisfies the configuration
 * requested .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static void validateSchema ( final File xsd , final File xml , final ErrorHandler errorHandler ) throws SAXException , ParserConfigurationException , IOException { } }

implementation:
final Schema schemaXSD = getSchema ( xsd , errorHandler ) ; // Create a Validator capable of validating XML files according to my custom schema .
final Validator validator = schemaXSD . newValidator ( ) ; // parse the XML DOM tree againts the stricter XSD schema
validator . validate ( getDOMSource ( xml , errorHandler ) ) ;


signature:
public class ValidatorExtensions { /** * Validate given xml schema .
 * @ param SchemaUrl
 * the schema url
 * @ param XmlDocumentUrl
 * the xml document url
 * @ return true if the given xml is valid otherwise false
 * @ throws SAXException
 * If a SAX error occurs during parsing .
 * @ throws ParserConfigurationException
 * if a DocumentBuilder cannot be created which satisfies the configuration
 * requested .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static boolean validateSchema ( final String SchemaUrl , final String XmlDocumentUrl ) throws SAXException , ParserConfigurationException , IOException { } }

implementation: System . setProperty ( DOCUMENT_BUILDER_FACTORY_KEY , DOCUMENT_BUILDER_FACTORY_VALUE ) ; final DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; factory . setNamespaceAware ( true ) ; factory . setValidating ( true ) ; factory . setAttribute ( SCHEMA_LANGUAGE_KEY , HTTP_WWW_W3_ORG_2001_XML_SCHEMA ) ; factory . setAttribute ( SCHEMA_SOURCE_KEY , SchemaUrl ) ; final DocumentBuilder builder = factory . newDocumentBuilder ( ) ; final ValidatorHandler handler = new ValidatorHandler ( ) ; builder . setErrorHandler ( handler ) ; builder . parse ( XmlDocumentUrl ) ; if ( handler . isValid ( ) ) { return false ; } return true ;


signature:
public class SPFActionIntent { /** * ( non - Javadoc )
 * @ see it . polimi . spf . framework . local . SPFAction # toJSON ( ) */
@ Override public String toJSON ( ) { } }

implementation: JSONObject o = new JSONObject ( ) ; try { o . put ( KEY_TYPE , mType ) ; o . put ( KEY_ACTION , mAction ) ; return o . toString ( ) ; } catch ( JSONException e ) { Log . e ( TAG , "Error marshalling action:" , e ) ; return "" ; }


signature:
public class TagExtensions { /** * Creates an { @ link Optional } of { @ link String } from the given attributes map
 * @ param attributes
 * the attributes map
 * @ return the { @ link Optional } of { @ link String } */
public static Optional < String > attributesToString ( Map < String , String > attributes ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; if ( attributes != null && ! attributes . isEmpty ( ) ) { builder . append ( " " ) ; for ( final Map . Entry < String , String > entry : attributes . entrySet ( ) ) { builder . append ( entry . getKey ( ) ) ; builder . append ( "=" ) ; builder . append ( "\"" ) . append ( entry . getValue ( ) ) . append ( "\"" ) ; builder . append ( " " ) ; } } else { return Optional . empty ( ) ; } return Optional . of ( builder . toString ( ) ) ;


signature:
public class SimpleTag { /** * Adds the given child .
 * @ param child
 * the child
 * @ return true , if successful */
public boolean addChild ( final SimpleTag child ) { } }

implementation: if ( getChildren ( ) == null ) { setChildren ( ListFactory . newArrayList ( ) ) ; } return getChildren ( ) . add ( child ) ;


signature:
public class SimpleTag { /** * Removes the attribute with the given name .
 * @ param name
 * the name
 * @ return the string */
public String removeAttribute ( final String name ) { } }

implementation: if ( getAttributes ( ) != null ) { getAttributes ( ) . remove ( name ) ; } return null ;


signature:
public class SimpleTag { /** * Creates from this Tag object an velocity template as String object . It puts children Tag
 * object in the template recursively .
 * @ return the string buffer */
public StringBuilder toVelocityTemplate ( ) { } }

implementation: final StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( "<" ) ; buffer . append ( "${" ) . append ( getName ( ) ) . append ( ".name}\n" ) ; if ( getAttributes ( ) != null && ! getAttributes ( ) . isEmpty ( ) ) { buffer . append ( " #foreach(" + "$attribute in $" ) . append ( getName ( ) ) . append ( ".attributes.keySet()" + ")\n" ) ; buffer . append ( "$attribute=\"$" ) . append ( getName ( ) ) . append ( ".getAttributes().get($attribute)\"\n" ) ; buffer . append ( " #end\n" ) ; } buffer . append ( "#if(${" ) . append ( getName ( ) ) . append ( ".endTag})>${" ) . append ( getName ( ) ) . append ( ".content}\n" ) ; if ( getChildren ( ) != null && ! getChildren ( ) . isEmpty ( ) ) { buffer . append ( "#foreach($" ) . append ( getChildren ( ) . get ( 0 ) . getName ( ) ) . append ( " in $" ) . append ( getName ( ) ) . append ( ".children)\n" ) ; for ( final SimpleTag child : getChildren ( ) ) { buffer . append ( child . toVelocityTemplate ( ) . toString ( ) ) ; } buffer . append ( "#end\n" ) ; } buffer . append ( "</${" ) . append ( getName ( ) ) . append ( ".name}>\n" ) ; buffer . append ( "#else />\n" + "#end\n" ) ; return buffer ;


signature:
public class SimpleTag { /** * Creates from this Tag object an xml string .
 * @ return the string */
public String toXmlString ( ) { } }

implementation: final StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( "<" ) ; buffer . append ( getName ( ) ) ; Optional < String > attr = TagExtensions . attributesToString ( getAttributes ( ) ) ; if ( attr . isPresent ( ) ) { buffer . append ( attr . get ( ) ) ; } if ( isEndTag ( ) ) { buffer . append ( ">" ) ; buffer . append ( getContent ( ) ) ; if ( getChildren ( ) != null && ! getChildren ( ) . isEmpty ( ) ) { for ( final SimpleTag child : getChildren ( ) ) { buffer . append ( child . toXmlString ( ) ) ; } } buffer . append ( "</" ) ; buffer . append ( getName ( ) ) ; buffer . append ( ">" ) ; } else { buffer . append ( "/>" ) ; } return buffer . toString ( ) ;


signature:
public class ProfileFieldConverter { /** * Returns a { @ link ProfileFieldConverter } that can handle the value of a
 * given { @ link ProfileField }
 * @ param field
 * - the field whose values should be handled
 * @ return - the { @ link ProfileFieldConverter } that can handle those values */
@ SuppressWarnings ( "unchecked" ) public static < E > ProfileFieldConverter < E > forField ( ProfileField < E > field ) { } }

implementation: Class < ? > fieldClass = field . getFieldClass ( ) ; if ( fieldClass == String . class ) { return ( ProfileFieldConverter < E > ) STRING_CONVERTER ; } else if ( fieldClass == Date . class ) { return ( ProfileFieldConverter < E > ) DATE_CONVERTER ; } else if ( fieldClass == String [ ] . class ) { return ( ProfileFieldConverter < E > ) STRING_ARRAY_CONVERTER ; } else if ( fieldClass == Bitmap . class ) { return ( ProfileFieldConverter < E > ) BITMAP_CONVERTER ; } throw new IllegalArgumentException ( "Field type " + fieldClass . getSimpleName ( ) + " not supported" ) ;


signature:
public class ServiceList { /** * Method to add a service inside the list in a secure way .
 * The service is added only if isn ' t already inside the list .
 * @ param service { @ link WiFiP2pService } to add . */
public void addServiceIfNotPresent ( WiFiP2pService service ) { } }

implementation:
WfdLog . d ( TAG , "addServiceIfNotPresent BEGIN, with size = " + serviceList . size ( ) ) ; if ( service == null ) { WfdLog . e ( TAG , "Service is null, returning..." ) ; return ; } boolean add = true ; for ( WiFiP2pService element : serviceList ) { if ( element != null && element . getDevice ( ) . equals ( service . getDevice ( ) ) && element . getInstanceName ( ) . equals ( service . getInstanceName ( ) ) ) { add = false ; // already in the list
} } if ( add ) { serviceList . add ( service ) ; } WfdLog . d ( TAG , "addServiceIfNotPresent END, with size = " + serviceList . size ( ) ) ;


signature:
public class ServiceList { /** * Method to get a service from the list , using only the device .
 * This method use only the deviceAddress , not the device name , because sometimes Android doesn ' t
 * get the name , but only the mac address .
 * @ param device WifiP2pDevice that you want to use to search the service .
 * @ return The WiFiP2pService associated to the device or null , if the device isn ' t in the list . */
public WiFiP2pService getServiceByDevice ( WifiP2pDevice device ) { } }

implementation: if ( device == null ) { return null ; } WfdLog . d ( TAG , "groupownerdevice passed to getServiceByDevice: " + device . deviceName + ", " + device . deviceAddress ) ; WfdLog . d ( TAG , "servicelist size: " + serviceList . size ( ) ) ; for ( WiFiP2pService element : serviceList ) { WfdLog . d ( TAG , "element in list: " + element . getDevice ( ) . deviceName + ", " + element . getDevice ( ) . deviceAddress ) ; WfdLog . d ( TAG , "element passed : " + device . deviceName + ", " + device . deviceAddress ) ; if ( element . getDevice ( ) . deviceAddress . equals ( device . deviceAddress ) ) { WfdLog . d ( TAG , "getServiceByDevice if satisfied : " + device . deviceAddress + ", " + element . getDevice ( ) . deviceAddress ) ; return element ; } } WfdLog . d ( TAG , "servicelist size: " + serviceList . size ( ) ) ; return null ;


signature:
public class SPFActivity { /** * Puts a detail in < code > this < / code > activity
 * @ param key
 * - the key of the detail
 * @ param value
 * - the value of the detail */
public void put ( String key , String value ) { } }

implementation: if ( key . equals ( VERB ) ) { return ; } mFields . put ( key , value ) ;


signature:
public class SPFService { /** * Sends an intent to SPFService , using the { @ link Context } provided , that
 * makes it start in foreground .
 * @ param c - the Context used to send the intent ;
 * @ see Service # startForeground ( int , Notification ) */
public static void startForeground ( Context c ) { } }

implementation: Intent i = new Intent ( c , SPFService . class ) ; i . setAction ( ACTION_START_FOREGROUND ) ; c . startService ( i ) ;


signature:
public class SPFService { /** * Sends an intent to SPFService , using the { @ link Context } provided , that
 * makes it stop foreground .
 * @ param c - the Context used to send the intent ;
 * @ see Service # stopForeground ( boolean ) */
public static void stopForeground ( Context c ) { } }

implementation: Intent i = new Intent ( c , SPFService . class ) ; i . setAction ( ACTION_STOP_FOREGROUND ) ; c . startService ( i ) ; c . stopService ( i ) ;


signature:
public class SPFService { /** * ( non - Javadoc )
 * @ see android . app . Service # onBind ( android . content . Intent ) */
@ Override public IBinder onBind ( Intent intent ) { } }

implementation:
String action = intent . getAction ( ) ; Log . d ( TAG , "External app bound with action " + intent . getAction ( ) ) ; if ( SPFInfo . ACTION_PROXIMITY_SERVER . equalsIgnoreCase ( action ) ) { SPF . get ( ) . connect ( ) ; // Request the binder that offers access to proximity
// functionalities
if ( mServerBinder == null ) { mServerBinder = new SPFProximityServiceImpl ( ) ; } return mServerBinder ; } else if ( SPFInfo . ACTION_PROFILE . equals ( action ) ) { // Requests the binder that offers the access to the local profile
if ( mProfileBinder == null ) { mProfileBinder = new SPFProfileServiceImpl ( this ) ; } return mProfileBinder ; } else if ( SPFInfo . ACTION_SERVICE . equalsIgnoreCase ( action ) ) { // Request the binder to manage local services
if ( mLocalServiceBinder == null ) { mLocalServiceBinder = new SPFServiceManagerImpl ( ) ; } return mLocalServiceBinder ; } else if ( SPFInfo . ACTION_NOTIFICATION . equalsIgnoreCase ( action ) ) { // request the binder to access notification services
if ( mNotificationBinder == null ) { mNotificationBinder = new SPFNotificationServiceImpl ( this ) ; } return mNotificationBinder ; } else if ( SPFInfo . ACTION_SECURITY . equals ( action ) ) { // request the binder to access security services
if ( mSecurityBinder == null ) { mSecurityBinder = new SPFSecurityServiceImpl ( this ) ; } return mSecurityBinder ; } Log . d ( TAG , "Unrecognized action: " + action ) ; return null ;


signature:
public class SPFService { /** * Triggered by the front end to keep spf service active in foreground */
@ Override public int onStartCommand ( Intent intent , int flags , int startId ) { } }

implementation:
if ( intent == null ) { return START_STICKY ; } String action = intent . getAction ( ) ; if ( ACTION_START_FOREGROUND . equals ( action ) ) { if ( ! SPF . get ( ) . isConnected ( ) ) { SPF . get ( ) . connect ( ) ; } SPF . get ( ) . notifyProximityStatus ( false ) ; // false because it ' s starting
startInForeground ( ) ; Log . d ( TAG , "Started in foreground" ) ; } else if ( ACTION_STOP_FOREGROUND . equals ( action ) ) { // notify to the middleware that i killed the proximity service
SPF . get ( ) . notifyProximityStatus ( true ) ; // true because it ' s killing
stopForeground ( true ) ; mIsStartedForeground = false ; Log . d ( TAG , "Foreground stopped" ) ; } return START_STICKY ;


signature:
public class SPFTriggerTable { /** * Save the trigger in the database . If the operation succeeds , return a
 * trigger with an updated id is returned , otherwise return null . The id is
 * updated only when a new trigger is created . ( e . g . its id is set to - 1)
 * @ param trigger
 * @ param appIdentifier
 * @ return a trigger , otherwise null */
SPFTrigger saveTrigger ( SPFTrigger trigger , String appIdentifier ) { } }

implementation: if ( appIdentifier == null || trigger == null ) { throw new NullPointerException ( ) ; } ContentValues cv = new ContentValues ( ) ; cv . put ( Contract . COLUMN_NAME , trigger . getName ( ) ) ; cv . put ( Contract . COLUMN_QUERY , trigger . getQuery ( ) . toQueryString ( ) ) ; cv . put ( Contract . COLUMN_ACTION , trigger . getAction ( ) . toJSON ( ) ) ; cv . put ( Contract . COLUMN_ONESHOT , trigger . isOneShot ( ) ? 1 : 0 ) ; cv . put ( Contract . COLUMN_EXPIRATION , trigger . getSleepPeriod ( ) ) ; cv . put ( Contract . COLUMN_APP_IDENTIFIER , appIdentifier ) ; SQLiteDatabase db = getWritableDatabase ( ) ; if ( trigger . getId ( ) >= 0 ) { String where = Contract . _ID + " = ?" ; String [ ] whereArgs = { String . valueOf ( trigger . getId ( ) ) } ; if ( db . update ( Contract . TABLE_NAME , cv , where , whereArgs ) > 0 ) { return trigger ; } return null ; } long id = db . insert ( Contract . TABLE_NAME , null , cv ) ; if ( id >= 0 ) { trigger . setId ( id ) ; return trigger ; } return null ;


signature:
public class SPFTriggerTable { /** * Return all the triggers of the specified application
 * @ param appIdentifier
 * - the identifier of the application
 * @ return a list of { @ link SPFTrigger } */
List < SPFTrigger > getAllTriggers ( String appIdentifier ) { } }

implementation: String where = Contract . COLUMN_APP_IDENTIFIER + " = ?" ; String [ ] whereArgs = { appIdentifier } ; Cursor c = getReadableDatabase ( ) . query ( Contract . TABLE_NAME , null , where , whereArgs , null , null , null ) ; List < SPFTrigger > triggers = new ArrayList < SPFTrigger > ( ) ; while ( c . moveToNext ( ) ) { triggers . add ( triggerFromCursor ( c ) ) ; } c . close ( ) ; return triggers ;


signature:
public class SPFTriggerTable { /** * Delete all the triggers registered with the given application identifier .
 * @ param appPackageName
 * @ return true if there is at least one row deleted */
boolean deleteAllTriggerOf ( String appPackageName ) { } }

implementation: String where = Contract . COLUMN_APP_IDENTIFIER + " = ?" ; String [ ] whereArgs = { appPackageName } ; int c = getReadableDatabase ( ) . delete ( Contract . TABLE_NAME , where , whereArgs ) ; return c > 0 ;


signature:
public class SPFTriggerTable { /** * Delete the trigger with the given id .
 * @ param id
 * @ param appPackageName
 * @ return true if there is a deletion */
boolean deleteTrigger ( long id , String appPackageName ) { } }

implementation: String where = Contract . COLUMN_APP_IDENTIFIER + " = ? AND " + Contract . _ID + " = ?" ; String [ ] whereArgs = { appPackageName , Long . toString ( id ) } ; int count = getReadableDatabase ( ) . delete ( Contract . TABLE_NAME , where , whereArgs ) ; return count > 0 ;


signature:
public class SPFTriggerTable { /** * Return the trigger with the specified id .
 * @ param triggerId
 * @ param appPackageName
 * @ return */
SPFTrigger getTrigger ( long triggerId , String appPackageName ) { } }

implementation: String where = Contract . _ID + " = ? AND " + Contract . COLUMN_APP_IDENTIFIER + " = ?" ; String [ ] whereArgs = { Long . toString ( triggerId ) , appPackageName } ; Cursor c = getReadableDatabase ( ) . query ( Contract . TABLE_NAME , null , where , whereArgs , null , null , null ) ; if ( ! c . moveToFirst ( ) ) { return null ; } SPFTrigger t = triggerFromCursor ( c ) ; c . close ( ) ; return t ;


signature:
public class SPFActionSendNotification { /** * ( non - Javadoc )
 * @ see android . os . Parcelable # writeToParcel ( android . os . Parcel , int ) */
@ Override public void writeToParcel ( Parcel dest , int flags ) { } }

implementation: dest . writeString ( mTitle ) ; dest . writeString ( mMessage ) ;


signature:
public class SPFActionSendNotification { /** * ( non - Javadoc )
 * @ see it . polimi . spf . framework . local . SPFAction # toJSON ( ) */
@ Override public String toJSON ( ) { } }

implementation: try { JSONObject o = new JSONObject ( ) ; o . put ( KEY_TYPE , mType ) ; o . put ( KEY_TITLE , mTitle ) ; o . put ( KEY_MESSAGE , mMessage ) ; return o . toString ( ) ; } catch ( JSONException e ) { Log . e ( TAG , "Error marshalling:" , e ) ; return "" ; }


signature:
public class SPFSearchDescriptor { /** * ( non - Javadoc )
 * @ see android . os . Parcelable # writeToParcel ( android . os . Parcel , int ) */
@ Override public void writeToParcel ( Parcel dest , int flags ) { } }

implementation: dest . writeLong ( mIntervalBtwSignals ) ; dest . writeInt ( mNumberOfSignals ) ; dest . writeParcelable ( mQuery , 0 ) ;


signature:
public class SPFSecurityMonitor { /** * Local app security */
public AppAuth validateAccess ( String accessToken , Permission permission ) throws TokenNotValidException , PermissionDeniedException { } }

implementation: AppAuth appAuth ; if ( accessToken == null ) { throw new TokenNotValidException ( ) ; } appAuth = mAppRegistry . getAppAuthorization ( accessToken ) ; if ( ( appAuth . getPermissionCode ( ) & permission . getCode ( ) ) == 0 ) { throw new PermissionDeniedException ( ) ; } return appAuth ;


signature:
public class ProfileField { /** * Converts an array of { @ link ProfileField } to an array of String ,
 * containing the identifier of the original fields , in the same order .
 * @ param fields
 * - the array to convert
 * @ return the array of identifiers */
public static String [ ] toIdentifierList ( ProfileField < ? > [ ] fields ) { } }

implementation: if ( fields == null ) { return null ; } String [ ] identifiers = new String [ fields . length ] ; for ( int i = 0 ; i < fields . length ; i ++ ) { identifiers [ i ] = fields [ i ] . getIdentifier ( ) ; } return identifiers ;


signature:
public class ProfileField { /** * Converts an array of profile field identifier to an array of
 * { @ link ProfileField }
 * @ param identifiers
 * the array of identifier
 * @ return the converted array of { @ link ProfileField } */
public static ProfileField < ? > [ ] fromIdentifierList ( String [ ] identifiers ) { } }

implementation: if ( identifiers == null ) { return null ; } ProfileField < ? > [ ] fields = new ProfileField < ? > [ identifiers . length ] ; for ( int i = 0 ; i < identifiers . length ; i ++ ) { fields [ i ] = lookup ( identifiers [ i ] ) ; if ( fields [ i ] == null ) { throw new IllegalArgumentException ( "Unknown field " + identifiers [ i ] ) ; } } return fields ;


signature:
public class ProfileField { /** * Lookups the { @ link ProfileField } identified by the given identifier
 * @ param identifier
 * - the identifier of the field to lookup
 * @ return the { @ link ProfileField } identified by the given identifier , or
 * null if none matches */
public static ProfileField < ? > lookup ( String identifier ) { } }

implementation: for ( ProfileField < ? > field : sFields ) { if ( field . getIdentifier ( ) . equals ( identifier ) ) { return field ; } } return null ;


signature:
public class XmlToObjectExtensions { /** * Creates from the given xml string an java object .
 * @ param < T >
 * the generic type
 * @ param xmlString
 * the xml string to transform to an java object .
 * @ return the xml string */
@ SuppressWarnings ( "unchecked" ) public static < T > T toObjectWithXMLDecoder ( final String xmlString ) { } }

implementation: XMLDecoder dec = null ; T obj = null ; try { final InputStream is = new ByteArrayInputStream ( xmlString . getBytes ( ) ) ; dec = new XMLDecoder ( is ) ; obj = ( T ) dec . readObject ( ) ; } finally { if ( dec != null ) { dec . close ( ) ; } } return obj ;


signature:
public class XmlToObjectExtensions { /** * Creates from the given xml string an Object . The given map hold the aliases . For more
 * information with aliasing see documation of xstream .
 * @ param < T >
 * the generic type of the return type
 * @ param xmlString
 * the xml as string object
 * @ param aliases
 * the aliases
 * @ return the created object from the given xml string . */
public static < T > T toObjectWithXStream ( final String xmlString , final Map < String , Class < ? > > aliases ) { } }

implementation: return toObjectWithXStream ( null , xmlString , aliases ) ;


signature:
public class XmlToObjectExtensions { /** * Creates from the given xml string an java object .
 * @ param < T >
 * the generic type of the return type
 * @ param xstream
 * the xstream object .
 * @ param xmlString
 * the xml as string object
 * @ return the object */
public static < T > T toObjectWithXStream ( final XStream xstream , final String xmlString ) { } }

implementation: return toObjectWithXStream ( xstream , xmlString , null ) ;


signature:
public class XmlToObjectExtensions { /** * Creates from the given xml string an java object . The given map hold the aliases . For more
 * information with aliasing see documation of xstream .
 * @ param < T >
 * the generic type of the return type
 * @ param xstream
 * the xstream object .
 * @ param xmlString
 * the xml
 * @ param aliases
 * the aliases
 * @ return the object */
@ SuppressWarnings ( "unchecked" ) public static < T > T toObjectWithXStream ( XStream xstream , final String xmlString , final Map < String , Class < ? > > aliases ) { } }

implementation: if ( xstream == null ) { xstream = new XStream ( ) ; } if ( aliases != null ) { for ( final Map . Entry < String , Class < ? > > alias : aliases . entrySet ( ) ) { xstream . alias ( alias . getKey ( ) , alias . getValue ( ) ) ; } } return ( T ) xstream . fromXML ( xmlString ) ;


signature:
public class MainActivity { /** * Method defined in
 * { @ link it . polimi . spf . app . permissiondisclaimer . PermissionDisclaimerDialogFragment . PermissionDisclaimerListener }
 * and called by
 * { @ link it . polimi . spf . app . permissiondisclaimer . PermissionDisclaimerDialogFragment } */
@ Override public void onClickConfirmButton ( ) { } }

implementation:
/* * Workaround to fix the crash :
 * android . view . WindowManager $ BadTokenException : Unable to add window
 * android . view . ViewRootImpl $ W @ 3d67307 - - permission denied for this window type
 * that appears only on Android 6.0 Marshmallow or greater .
 * See onActivityResult in this class ! ! ! */
if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . M && ! Settings . canDrawOverlays ( this ) ) { Intent intent = new Intent ( Settings . ACTION_MANAGE_OVERLAY_PERMISSION , Uri . parse ( "package:" + getPackageName ( ) ) ) ; Log . d ( TAG , "canDrawOverlay not enabled. Requesting... " ) ; startActivityForResult ( intent , OVERLAY_PERMISSION_REQ_CODE ) ; }


signature:
public class MainActivity { /** * Method defined in
 * { @ link it . polimi . spf . app . permissiondisclaimer . PermissionDisclaimerDialogFragment . PermissionDisclaimerListener }
 * and called by
 * { @ link it . polimi . spf . app . permissiondisclaimer . PermissionDisclaimerDialogFragment } */
@ Override public void onClickDenyButton ( ) { } }

implementation: Toast . makeText ( this , "You must confirm to activate SPF" , Toast . LENGTH_SHORT ) . show ( ) ; Log . d ( TAG , "User clicked on DenyButton in Permission Disclaimer Dialog Fragment" ) ; finish ( ) ;


signature:
public class SPFAction { /** * TODO comment
 * @ return */
public static SPFAction fromJSON ( String json ) { } }

implementation: try { JSONObject o = new JSONObject ( json ) ; int type = o . getInt ( KEY_TYPE ) ; switch ( type ) { case TYPE_INTENT : return new SPFActionIntent ( o ) ; case TYPE_NOTIFICATION : return new SPFActionSendNotification ( o ) ; default : throw new IllegalArgumentException ( "Unknown action type: " + type ) ; } } catch ( JSONException e ) { throw new IllegalArgumentException ( "JSON does not represent a valid SPFAction" ) ; }


signature:
public class InvocationResponse { /** * Creates a new { @ link InvocationResponse } to hold the result of an
 * invocation .
 * @ param result
 * - the result of the invocation , or null if the method returns
 * void .
 * @ return the invocation request . */
public static InvocationResponse result ( String payload ) { } }

implementation: InvocationResponse resp = new InvocationResponse ( RESULT ) ; resp . resultPayload = payload ; return resp ;


signature:
public class InvocationResponse { /** * Creates a new { @ link InvocationResponse } to hold the error that occurred
 * during the execution of the service .
 * @ param t
 * - the throwable that caused the error .
 * @ return the invocation request . */
public static InvocationResponse error ( Throwable t ) { } }

implementation: InvocationResponse resp = new InvocationResponse ( ERROR ) ; resp . errorMessage = t . getClass ( ) . getName ( ) + ":" + t . getLocalizedMessage ( ) ; return resp ;


signature:
public class InvocationResponse { /** * Creates a new { @ link InvocationResponse } to hold the error that occurred
 * during the execution of the service .
 * @ param errorMessage
 * - the error message that describes the occurred error .
 * @ return the invocation request . */
public static InvocationResponse error ( String errorMessage ) { } }

implementation: InvocationResponse resp = new InvocationResponse ( ERROR ) ; resp . errorMessage = errorMessage ; return resp ;


signature:
public class InboundProximityInterfaceImpl { /** * ( non - Javadoc )
 * @ see
 * it . polimi . spf . framework . proximity . ProximityResponder # getProfileBulk
 * ( java . lang . String , java . lang . String , java . lang . String [ ] ) */
@ Override public String getProfileBulk ( String token , String appIdentifier , String fields ) { } }

implementation: Utils . logCall ( TAG , "getProfileBulk" , token , appIdentifier , fields ) ; String [ ] fieldListArray = FieldContainerMarshaller . unmarshallIdentifierList ( fields ) ; SPFSecurityMonitor monitor = mSpf . getSecurityMonitor ( ) ; PersonAuth auth = monitor . getPersonRegistry ( ) . getPersonAuthFrom ( token ) ; SPFPersona persona = monitor . getPersonaOf ( appIdentifier ) ; ProfileFieldContainer container = mSpf . getProfileManager ( ) . getProfileFieldBulk ( auth , persona , fieldListArray ) ; return FieldContainerMarshaller . marshallContainer ( container ) ;


signature:
public class InboundProximityInterfaceImpl { /** * ( non - Javadoc )
 * @ see
 * it . polimi . spf . framework . proximity . ProximityResponder # executeService
 * ( it . polimi . spf . framework . local . InvocationRequest ) */
@ Override public InvocationResponse executeService ( InvocationRequest request ) { } }

implementation: Utils . logCall ( TAG , "executeService" ) ; try { return SPF . get ( ) . getServiceRegistry ( ) . dispatchInvocation ( request ) ; } catch ( Throwable t ) { return InvocationResponse . error ( "remote exception : " + t . toString ( ) ) ; }