signature:
public class XmlToXsdExtensions { /** * Returns a xsd String from the given XML file that can used for several purposes .
 * @ param xmlFile
 * the XML file .
 * @ param inst2XsdOptions
 * the inst2 xsd options
 * @ return the resulted xsd String
 * @ throws XmlException
 * occurs when a give xml file is invalid .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static String xmlToXsd ( final File xmlFile , final Inst2XsdOptions inst2XsdOptions ) throws XmlException , IOException { } }

implementation: return xmlToXsd ( xmlFile , inst2XsdOptions , new XmlOptions ( ) . setSavePrettyPrint ( ) ) ;


signature:
public class XmlToXsdExtensions { /** * Returns a xsd String from the given XML file that can used for several purposes .
 * @ param xmlFile
 * the xml file
 * @ param inst2XsdOptions
 * the inst2 xsd options
 * @ param xmlOptions
 * the xml options
 * @ return the resulted xsd String
 * @ throws XmlException
 * occurs when a give xml file is invalid .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static String xmlToXsd ( final File xmlFile , final Inst2XsdOptions inst2XsdOptions , final XmlOptions xmlOptions ) throws XmlException , IOException { } }

implementation: final XmlObject [ ] xmlInstances = new XmlObject [ 1 ] ; xmlInstances [ 0 ] = XmlObject . Factory . parse ( xmlFile ) ; final SchemaDocument [ ] schemaDocs = Inst2Xsd . inst2xsd ( xmlInstances , inst2XsdOptions ) ; final SchemaDocument schema = schemaDocs [ 0 ] ; return schema . xmlText ( xmlOptions ) ;


signature:
public class XmlToXsdExtensions { /** * Creates or update the given xsd output file from the given XML file .
 * @ param xmlFiles
 * the XML files
 * @ param inst2XsdOptions
 * the inst2 xsd options
 * @ param outDir
 * The directory path for output files . Default is ' . ' ( the current directory ) .
 * @ param outPrefix
 * The prefix for output file names . Default is " schema " .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static void xmlToXsd ( final File [ ] xmlFiles , final Inst2XsdOptions inst2XsdOptions , File outDir , String outPrefix ) throws IOException { } }

implementation: if ( xmlFiles == null || xmlFiles . length == 0 ) { throw new IllegalArgumentException ( "XML file array can not be null and not empty." ) ; } if ( outDir == null ) { outDir = new File ( "." ) ; } if ( outPrefix == null ) { outPrefix = "schema" ; } final XmlObject [ ] xmlInstances = new XmlObject [ xmlFiles . length ] ; int i = 0 ; try { for ( i = 0 ; i < xmlFiles . length ; i ++ ) { xmlInstances [ i ] = XmlObject . Factory . parse ( xmlFiles [ i ] ) ; } } catch ( final XmlException e ) { throw new IllegalArgumentException ( "Invalid xml file: '" + xmlFiles [ i ] . getName ( ) + "'. \n" + e . getMessage ( ) , e ) ; } catch ( final IOException e ) { throw new IllegalArgumentException ( "Could not read file: '" + xmlFiles [ i ] . getName ( ) + "'. " + e . getMessage ( ) , e ) ; } final SchemaDocument [ ] schemaDocs = Inst2Xsd . inst2xsd ( xmlInstances , inst2XsdOptions ) ; try { for ( i = 0 ; i < schemaDocs . length ; i ++ ) { final SchemaDocument schema = schemaDocs [ i ] ; schema . save ( new File ( outDir , outPrefix + i + ".xsd" ) , new XmlOptions ( ) . setSavePrettyPrint ( ) ) ; } } catch ( final IOException e ) { throw new IOException ( "Could not write file: '" + outDir + File . pathSeparator + outPrefix + i + ".xsd" + "'. " + e . getMessage ( ) , e ) ; }


signature:
public class ObjectToJsonQuietlyExtensions { /** * Creates from the given Object a json string . Note if an exception occurs null will be
 * returned .
 * @ param < T >
 * the generic type of the given argument
 * @ param object
 * the object .
 * @ return the json string or null if an error occured by parsing . */
public static < T > String toJsonQuietly ( final T object ) { } }

implementation: try { return ObjectToJsonExtensions . toJson ( object ) ; } catch ( final JsonProcessingException e ) { log . log ( Level . SEVERE , "An error occured when converting object to String.\nGiven object:" + object . toString ( ) + "\n" , e ) ; } return null ;


signature:
public class Component { /** * Loads a local component asynchronously .
 * @ param context
 * - the context to use to bind to the service
 * @ param descriptor
 * - a { @ link Descriptor } to handle the creation of the
 * component ;
 * @ param callback
 * - the callback to be notified when the service is available
 * @ param < C >
 * the type of the Component concrete implementation
 * @ param < I >
 * the type of the AIDL interface that is wrapped by the
 * component */
protected static < C extends Component < C , I > , I extends IInterface > void load ( final Context context , final Descriptor < C , I > descriptor , final ConnectionCallback < C > callback ) { } }

implementation: Utils . notNull ( context , "context must not be null" ) ; Utils . notNull ( descriptor , "context must not be null" ) ; if ( AccessTokenManager . get ( context ) . hasToken ( ) ) { bindToService ( context , descriptor , callback ) ; } else { AccessTokenManager . get ( context ) . requireAccessToken ( context , new AccessTokenManager . RegistrationCallback ( ) { @ Override public void onRegistrationSuccessful ( ) { Log . d ( "Component" , "Access Toekn: " + descriptor ) ; bindToService ( context , descriptor , callback ) ; } @ Override public void onRegistrationError ( SPFError errorMsg ) { callback . onError ( errorMsg ) ; } } ) ; }


signature:
public class Component { /** * Performs the binding to the remote service
 * @ param context
 * - the context used to bind to the service
 * @ param descriptor
 * - the { @ link Descriptor } to handle the service
 * @ param callback
 * - the callback to notify of the service availability */
private static < C extends Component < C , I > , I extends IInterface > void bindToService ( final Context context , final Descriptor < C , I > descriptor , final ConnectionCallback < C > callback ) { } }

implementation: Intent intent = new Intent ( ) ; intent . setComponent ( SPFInfo . getSPFServiceComponentName ( ) ) ; intent . setAction ( descriptor . getActionName ( ) ) ; ServiceConnection connection = new ServiceConnection ( ) { @ Override public void onServiceConnected ( ComponentName name , IBinder binder ) { I service = descriptor . castInterface ( binder ) ; C instance = descriptor . createInstance ( context , service , this , callback ) ; callback . onServiceReady ( instance ) ; } @ Override public void onServiceDisconnected ( ComponentName name ) { callback . onDisconnect ( ) ; } } ; if ( ! context . bindService ( intent , connection , Context . BIND_AUTO_CREATE ) ) { callback . onError ( new SPFError ( SPFError . SPF_NOT_INSTALLED_ERROR_CODE ) ) ; }


signature:
public class Component { /** * Disconnects the component from the remote service .
 * @ see Context # unbindService ( ServiceConnection ) */
public void disconnect ( ) { } }

implementation: try { mContext . unbindService ( mConnection ) ; } catch ( Exception e ) { Log . w ( getClass ( ) . getSimpleName ( ) , "Exception unbinding from service: " , e ) ; }


signature:
public class Component { /** * Performs common error handling operations . Subclasses may override it to
 * provide specific behavior .
 * @ param err */
protected void handleError ( SPFError err ) { } }

implementation: if ( err . codeEquals ( SPFError . TOKEN_NOT_VALID_ERROR_CODE ) ) { AccessTokenManager . get ( mContext ) . invalidateToken ( ) ; } mCallback . onError ( err ) ;


signature:
public class SPFTriggerEngine { /** * Update the current set of triggers with the given list .
 * @ param triggers2 */
public void refreshTriggers ( List < SPFTrigger > triggers2 ) { } }

implementation: triggers . clear ( ) ; for ( SPFTrigger trg : triggers2 ) { triggers . put ( trg . getId ( ) , trg ) ; }


signature:
public class ExceptionLogger { /** * Installs an instance of { @ link ExceptionLogger } as the default in the
 * Thread class
 * @ see Thread # setDefaultUncaughtExceptionHandler ( UncaughtExceptionHandler )
 * @ param c */
public static void installAsDefault ( Context c ) { } }

implementation: UncaughtExceptionHandler def = Thread . getDefaultUncaughtExceptionHandler ( ) ; UncaughtExceptionHandler newHandler = new ExceptionLogger ( c , def ) ; Thread . setDefaultUncaughtExceptionHandler ( newHandler ) ;


signature:
public class ExceptionLogger { /** * ( non - Javadoc )
 * @ see
 * java . lang . Thread . UncaughtExceptionHandler # uncaughtException ( java . lang
 * . Thread , java . lang . Throwable ) */
@ Override public void uncaughtException ( Thread thread , Throwable ex ) { } }

implementation:
Date now = new Date ( ) ; String name = FOLDER + now . getTime ( ) + ".txt" ; try { File folder = new File ( mContext . getExternalFilesDir ( null ) , FOLDER ) ; if ( ! folder . exists ( ) ) { folder . mkdir ( ) ; } File file = new File ( mContext . getExternalFilesDir ( null ) , name ) ; if ( ! file . exists ( ) ) { file . createNewFile ( ) ; } PrintWriter writer = new PrintWriter ( new FileWriter ( file , false ) ) ; writer . println ( "Exception in " + thread . getName ( ) + " @ " + DateFormat . getDateFormat ( mContext ) . format ( now ) ) ; ex . printStackTrace ( writer ) ; writer . flush ( ) ; writer . close ( ) ; } catch ( IOException e ) { Log . e ( getClass ( ) . getSimpleName ( ) , "Exception logging uncaught exception: " , e ) ; } // Dispatch to default handler to make app crash
mDefaultHandler . uncaughtException ( thread , ex ) ;


signature:
public class ProfileTable { /** * Insert a single profile field in the { @ link Contract # TABLE _ PROFILE }
 * @ param key
 * @ param value
 * @ param personaIdentifier
 * @ return true if the operation was successful */
private boolean setValue ( String key , String value , String personaIdentifier ) { } }

implementation:
SQLiteDatabase db = getWritableDatabase ( ) ; // Create a new map of values , where column names are the keys
ContentValues values = new ContentValues ( ) ; values . put ( Contract . COLUMN_KEY , key ) ; values . put ( Contract . COLUMN_VALUE , value ) ; values . put ( Contract . COLUMN_PERSONA , personaIdentifier ) ; // Insert the new row , returning the primary key value of the new row
long newRowId ; String nullHack = null ; newRowId = db . insert ( Contract . TABLE_PROFILE , nullHack , values ) ; if ( newRowId <= - 1 ) { Log . e ( TAG , "Failure on inserting key:" + key + " value:" + value ) ; return false ; } return true ;


signature:
public class ProfileTable { /** * / * * Check if the profile fields of a given SPFPersona contains the
 * specified tag . Returns true when the tag is contained in at least one
 * profile field value .
 * @ param tag
 * @ param persona
 * @ return true if the profile contains the tag */
public boolean hasTag ( String tag , SPFPersona persona ) { } }

implementation:
SQLiteDatabase db = getReadableDatabase ( ) ; String selection = Contract . COLUMN_VALUE + " LIKE ? AND " + Contract . COLUMN_PERSONA + " = ? " ; String [ ] selectionArgs = { "%" + tag + "%" , persona . getIdentifier ( ) } ; String [ ] columns = { Contract . COLUMN_KEY } ; String groupBy = null ; String having = null ; String orderBy = null ; String limit = null ; Cursor c = db . query ( true , // distinct
Contract . TABLE_PROFILE , // table name
columns , // projection
selection , // selection
selectionArgs , // selection arguments
groupBy , // don ' t group the rows
having , // don ' t filter by row groups
orderBy , // don ' t order by anything
limit ) ; boolean match = c . moveToNext ( ) ; c . close ( ) ; return match ;


signature:
public class ProfileTable { /** * Returns the list of all the existing { @ link SPFPersona } .
 * @ return the list of { @ link SPFPersona } */
List < SPFPersona > getAvailablePersonas ( ) { } }

implementation: SQLiteDatabase db = getReadableDatabase ( ) ; String table = Contract . TABLE_PERSONAS ; String [ ] columns = { Contract . COLUMN_PERSONA } ; String selection = null ; String [ ] selectionArgs = null ; String groupBy = null ; String having = null ; String orderBy = null ; Cursor c = db . query ( table , columns , selection , selectionArgs , groupBy , having , orderBy ) ; List < SPFPersona > availablePersonas = new ArrayList < SPFPersona > ( ) ; while ( c . moveToNext ( ) ) { String p = c . getString ( c . getColumnIndex ( Contract . COLUMN_PERSONA ) ) ; SPFPersona pers = new SPFPersona ( p ) ; availablePersonas . add ( pers ) ; } c . close ( ) ; return availablePersonas ;


signature:
public class ProfileTable { /** * Creates a new SPFPersona .
 * @ param persona
 * - the { @ link SPFPersona } to add . */
boolean addPersona ( SPFPersona persona ) { } }

implementation:
SQLiteDatabase db = getWritableDatabase ( ) ; String table = Contract . TABLE_PERSONAS ; String nullColumnHack = null ; ContentValues values = new ContentValues ( ) ; values . put ( Contract . COLUMN_PERSONA , persona . getIdentifier ( ) ) ; if ( db . insert ( table , nullColumnHack , values ) > 0 ) { // copy the unique identifier
ProfileFieldContainer pfc = getProfileFieldBulk ( SPFPersona . getDefault ( ) , ProfileField . IDENTIFIER ) ; String id = pfc . getFieldValue ( ProfileField . IDENTIFIER ) ; if ( setValue ( ProfileField . IDENTIFIER . getIdentifier ( ) , id , persona . getIdentifier ( ) ) ) { addCircleToFieldsInternal ( DefaultCircles . PUBLIC , ProfileField . IDENTIFIER , persona , db ) ; addCircleToFieldsInternal ( DefaultCircles . PUBLIC , ProfileField . DISPLAY_NAME , persona , db ) ; return true ; } else { removePersona ( persona ) ; return false ; } } return false ;


signature:
public class ProfileTable { /** * Delete a SPFPersona . All the information related to the specified persona
 * will be erased .
 * @ param persona
 * - the { @ link SPFPersona } to remove */
boolean removePersona ( SPFPersona persona ) { } }

implementation: SQLiteDatabase db = getWritableDatabase ( ) ; if ( persona . getIdentifier ( ) . equals ( "default" ) ) { return false ; } String table = Contract . TABLE_PERSONAS ; String selection = Contract . COLUMN_PERSONA + " = ?" ; String [ ] selectionArgs = { persona . getIdentifier ( ) } ; if ( db . delete ( table , selection , selectionArgs ) > 0 ) { deleteFieldsOf ( persona , db ) ; deleteVisibilityOf ( persona , db ) ; } return true ;


signature:
public class ProfileTable { /** * Remove a circle from a specified profile field .
 * @ param field
 * the { @ link ProfileField } to modify
 * @ param circle
 * - the circle to add
 * @ param p
 * - the { @ link SPFPersona } to modify
 * @ return true if the operation was successful */
boolean removeCircleFromField ( String circle , ProfileField < ? > field , SPFPersona p ) { } }

implementation: if ( field . getIdentifier ( ) . equals ( ProfileField . IDENTIFIER . getIdentifier ( ) ) || field . getIdentifier ( ) . equals ( ProfileField . DISPLAY_NAME . getIdentifier ( ) ) ) { return false ; } SQLiteDatabase db = getWritableDatabase ( ) ; return removeCircleFromField ( circle , field , p , db ) ;


signature:
public class ProfileTable { /** * Returns a { @ link Bundle } with profile fields identifiers as keys , and
 * { @ link ArrayList < String > } as circles .
 * @ param persona
 * @ return */
Bundle getCirclesOf ( SPFPersona persona ) { } }

implementation: SQLiteDatabase db = getReadableDatabase ( ) ; String table = Contract . TABLE_VISIBILITY ; String [ ] columns = { Contract . COLUMN_KEY , Contract . COLUMN_CIRCLE } ; String selection = Contract . COLUMN_PERSONA + " = ?" ; String [ ] selectionArgs = { persona . getIdentifier ( ) } ; String groupBy = null ; String having = null ; String orderBy = null ; Cursor c = db . query ( table , columns , selection , selectionArgs , groupBy , having , orderBy ) ; Bundle b = new Bundle ( ) ; while ( c . moveToNext ( ) ) { String key = c . getString ( c . getColumnIndex ( Contract . COLUMN_KEY ) ) ; String circle = c . getString ( c . getColumnIndex ( Contract . COLUMN_CIRCLE ) ) ; ArrayList < String > list = b . getStringArrayList ( key ) ; if ( list == null ) { list = new ArrayList < String > ( ) ; } list . add ( circle ) ; b . putStringArrayList ( key , list ) ; } c . close ( ) ; return b ;


signature:
public class ProfileTable { /** * Filters the parameter fields and retruns only the field that can be
 * accessed given the permission provided with the { @ link PersonAuth }
 * parameter .
 * @ param pAuth
 * - the permissions
 * @ param persona
 * - the { @ link SPFPersona } to read
 * @ param fields
 * - the fields ' identifiers to filter
 * @ return a list of accessible fields */
private List < String > visibleFields ( PersonAuth pAuth , SPFPersona persona , String [ ] fields ) { } }

implementation: SQLiteDatabase db = getReadableDatabase ( ) ; String table = Contract . TABLE_VISIBILITY ; String [ ] columns = { Contract . COLUMN_KEY , Contract . COLUMN_CIRCLE } ; String inClause = getInClause ( fields ) ; String selection = Contract . COLUMN_PERSONA + " = ? AND " + Contract . COLUMN_KEY + " IN " + inClause ; String [ ] selectionArgs = { persona . getIdentifier ( ) } ; String groupBy = null ; String having = null ; String orderBy = null ; Cursor c = db . query ( table , columns , selection , selectionArgs , groupBy , having , orderBy ) ; List < String > fieldKeys = new ArrayList < String > ( ) ; List < String > privateFields = new ArrayList < String > ( ) ; boolean allCircles = pAuth . getCircles ( ) . contains ( DefaultCircles . ALL_CIRCLE ) ; while ( c . moveToNext ( ) ) { String key = c . getString ( c . getColumnIndex ( Contract . COLUMN_KEY ) ) ; String circle = c . getString ( c . getColumnIndex ( Contract . COLUMN_CIRCLE ) ) ; if ( circle . equals ( DefaultCircles . PRIVATE ) ) { privateFields . add ( circle ) ; } else if ( allCircles || pAuth . getCircles ( ) . contains ( circle ) ) { fieldKeys . add ( key ) ; } } c . close ( ) ; fieldKeys . removeAll ( privateFields ) ; return fieldKeys ;


signature:
public class ProfileTable { /** * Return a SQL IN set parameter with the specified array of string e . g .
 * " ( ' arg1 ' , ' arg2 ' , ' arg3 ' ) "
 * @ param fields
 * @ return the IN clause */
private String getInClause ( String [ ] fields ) { } }

implementation: StringBuilder builder = new StringBuilder ( "( " ) ; if ( fields . length != 0 ) { for ( int i = 0 ; i < fields . length ; i ++ ) { builder . append ( "'" ) ; builder . append ( fields [ i ] ) ; builder . append ( "'" ) ; if ( i != fields . length - 1 ) { builder . append ( " , " ) ; } } } builder . append ( " )" ) ; return builder . toString ( ) ;


signature:
public class ActivityConsumerRouteTable { /** * Registers the capabilities of a service to consume activities . If the
 * descriptor doesn ' t declare the service as capable of handling activities ,
 * no action will be performed .
 * @ param descriptor
 * - the descriptor of the service to register
 * @ return true if the service was registered */
public boolean registerService ( SPFServiceDescriptor descriptor ) { } }

implementation: String appId = descriptor . getAppIdentifier ( ) ; String serviceName = descriptor . getServiceName ( ) ; for ( String verb : descriptor . getConsumedVerbs ( ) ) { if ( ! registerServiceInternal ( verb , serviceName , appId ) ) { return false ; } Log . v ( TAG , "Registered service as Activity consumer: " + descriptor . getServiceName ( ) ) ; } return true ;


signature:
public class ActivityConsumerRouteTable { /** * Returns a list containing the default service for each verb , as an
 * instance of { @ link ActivityVerb }
 * @ return - the list of { @ link ActivityVerb } */
public Collection < ActivityVerb > getVerbSupport ( ) { } }

implementation: Map < String , ActivityVerb > entries = new HashMap < String , ActivityVerb > ( ) ; String [ ] columns = { Contract . APP_ID , Contract . SERVICE_NAME , Contract . VERB } ; Cursor c = getReadableDatabase ( ) . query ( true , Contract . TABLE_SERVICES , columns , null , null , null , null , null , null ) ; int appIndex = c . getColumnIndexOrThrow ( Contract . APP_ID ) ; int verbIndex = c . getColumnIndexOrThrow ( Contract . VERB ) ; int svcIndex = c . getColumnIndexOrThrow ( Contract . SERVICE_NAME ) ; while ( c . moveToNext ( ) ) { String verb = c . getString ( verbIndex ) ; String appId = c . getString ( appIndex ) ; String svcName = c . getString ( svcIndex ) ; ActivityVerb d = entries . get ( verb ) ; if ( d == null ) { d = new ActivityVerb ( verb ) ; entries . put ( verb , d ) ; } d . addSupportingService ( new ServiceIdentifier ( appId , svcName ) ) ; } c . close ( ) ; for ( ActivityVerb d : entries . values ( ) ) { d . setDefaultApp ( getServiceForInternal ( d . getVerb ( ) ) ) ; } return entries . values ( ) ;


signature:
public class ApplicationRegistry { /** * Retrieves an appauth given the identifier of an application
 * @ param appId
 * - the Id of the application
 * @ return the appAuth of the application , or null if the app is not
 * installed */
AppAuth getAppAuthorizationByAppId ( String appId ) { } }

implementation: String where = Contract . COLUMN_APP_IDENTIFIER + " = ?" ; String args [ ] = { appId } ; Cursor c = mRegistryTable . getReadableDatabase ( ) . query ( Contract . TABLE_NAME , null , where , args , null , null , null ) ; AppAuth auth = null ; if ( c . moveToFirst ( ) ) { auth = appAuthFromCursor ( c ) ; } c . close ( ) ; return auth ;


signature:
public class ApplicationRegistry { /** * Low level method to register applications . It will not validate the
 * descriptor given as parameter .
 * @ param descriptor
 * @ param persona
 * @ return - the token to give back . */
public String registerApplication ( AppDescriptor descriptor , SPFPersona persona ) { } }

implementation:
String token = mTokenGenerator . generateAccessToken ( ) ; ContentValues cv = new ContentValues ( ) ; cv . put ( Contract . COLUMN_APP_NAME , descriptor . getAppName ( ) ) ; cv . put ( Contract . COLUMN_ACCESS_TOKEN , token ) ; cv . put ( Contract . COLUMN_APP_IDENTIFIER , descriptor . getAppIdentifier ( ) ) ; cv . put ( Contract . COLUMN_PERMISSION_CODE , descriptor . getPermissionCode ( ) ) ; cv . put ( Contract . COLUMN_PERSONA , persona . getIdentifier ( ) ) ; SQLiteDatabase db = mRegistryTable . getWritableDatabase ( ) ; if ( db . insert ( Contract . TABLE_NAME , null , cv ) == - 1 ) { return null ; // TODO handle insertion error
} return token ;


signature:
public class ApplicationRegistry { /** * To be called from application uninstall monitor
 * @ param appIdentifier */
public boolean unregisterApplication ( String appIdentifier ) { } }

implementation: String where = Contract . COLUMN_APP_IDENTIFIER + " = ?" ; String [ ] whereArgs = { appIdentifier } ; if ( mRegistryTable . getWritableDatabase ( ) . delete ( Contract . TABLE_NAME , where , whereArgs ) == 0 ) { return false ; } if ( SPF . get ( ) . getServiceRegistry ( ) . unregisterAllServicesOfApp ( appIdentifier ) ) { Intent i = new Intent ( DEREGISTRATION_INTENT ) ; i . putExtra ( DEREGISTERED_APP , appIdentifier ) ; mContext . sendBroadcast ( i ) ; return true ; } return false ;


signature:
public class ApplicationRegistry { /** * Returns the SPFPersona associated to the specified application . If the
 * application does not exist returns the default SPFPersona .
 * @ param appIdentifier
 * - the identifier of the application
 * @ return a SPFPersona */
public SPFPersona getPersonaOf ( String appIdentifier ) { } }

implementation: SQLiteDatabase db = mRegistryTable . getReadableDatabase ( ) ; String table = Contract . TABLE_NAME ; String [ ] columns = { Contract . COLUMN_PERSONA } ; String selection = Contract . COLUMN_APP_IDENTIFIER + " = ? " ; String [ ] selectionArgs = { appIdentifier } ; String groupBy = null ; String having = null ; String orderBy = null ; Cursor c = db . query ( table , columns , selection , selectionArgs , groupBy , having , orderBy ) ; if ( c . moveToNext ( ) ) { String persona = c . getString ( c . getColumnIndex ( Contract . COLUMN_PERSONA ) ) ; return new SPFPersona ( persona ) ; } c . close ( ) ; return SPFPersona . DEFAULT ;


signature:
public class GroupOwnerActor { /** * called from GoInternalClient */
void onClientConnected ( String identifier , GOInternalClient gOInternalClient ) throws InterruptedException { } }

implementation: WfdLog . d ( TAG , "New client connected id : " + identifier ) ; NineBus . get ( ) . post ( new GOConnectionEvent ( GOConnectionEvent . CONNECTED , identifier ) ) ; connectionSemaphore . acquire ( ) ; Set < String > clients = new HashSet < > ( goInternalClients . keySet ( ) ) ; clients . add ( super . myIdentifier ) ; GOInternalClient c = goInternalClients . put ( identifier , gOInternalClient ) ; signalNewInstanceToGroup ( identifier ) ; signalGroupToNewClient ( gOInternalClient , clients ) ; connectionSemaphore . release ( ) ; if ( c != null ) { c . recycle ( ) ; }


signature:
public class GroupOwnerActor { /** * called from GoInternalClient */
void onClientDisconnected ( String identifier ) throws InterruptedException { } }

implementation: connectionSemaphore . acquire ( ) ; NineBus . get ( ) . post ( new GOConnectionEvent ( GOConnectionEvent . DISCONNECTED , identifier ) ) ; WfdLog . d ( TAG , "Client lost id : " + identifier ) ; GOInternalClient c = null ; if ( identifier != null ) { c = goInternalClients . remove ( identifier ) ; if ( c != null ) { signalInstanceLossToGroup ( identifier ) ; } } connectionSemaphore . release ( ) ; if ( c != null ) { c . recycle ( ) ; }


signature:
public class GroupOwnerActor { /** * called from the GOInternalClient */
void onMessageReceived ( final WfdMessage msg ) { } }

implementation: threadPool . execute ( new Runnable ( ) { @ Override public void run ( ) { if ( msg . getReceiverId ( ) . equals ( myIdentifier ) ) { handle ( msg ) ; } else { route ( msg ) ; } } } ) ;


signature:
public class ClientsGuiList { /** * Method to add a client inside the list in a secure way .
 * The client is added only if isn ' t already inside the list .
 * @ param device { @ link DeviceGuiElement } to add . */
public void addClientIfNotPresent ( DeviceGuiElement device ) { } }

implementation:
boolean add = true ; for ( DeviceGuiElement element : clients ) { if ( element != null && element . getName ( ) . equals ( device . getName ( ) ) && element . getAddress ( ) . equals ( device . getAddress ( ) ) ) { add = false ; // already in the list
} } if ( add ) { clients . add ( device ) ; }


signature:
public class SPF { /** * Initializes SPF with a { @ link Context } reference . Called by
 * { @ link SPFContext # initialize ( int , Context , ProximityMiddleware . Factory ) } .
 * @ param context - the context that will be used by SPF */
synchronized static void initialize ( Context context , int goIntent , boolean isAutonomous , ProximityMiddleware . Factory factory ) { } }

implementation: if ( singleton == null ) { singleton = new SPF ( context , goIntent , isAutonomous , factory ) ; }


signature:
public class SPF { /** * Life - cycle methods */
public void connect ( ) { } }

implementation: if ( ! mMiddleware . isConnected ( ) ) { mMiddleware . connect ( ) ; } if ( ! mNotificationManager . isRunning ( ) ) { mNotificationManager . start ( ) ; } if ( mAdvertiseManager . isAdvertisingEnabled ( ) ) { mMiddleware . registerAdvertisement ( mAdvertiseManager . generateAdvProfile ( ) . toJSON ( ) , 10000 ) ; }


signature:
public class SPF { /** * TODO this class should handle only components life - cycle move search primitives elsewhere */
public void sendSearchSignal ( String queryId , String query ) { } }

implementation: mMiddleware . sendSearchSignal ( getUniqueIdentifier ( ) , queryId , query ) ;


signature:
public class ProfileFieldContainer { /** * Gets the value of a field from the container
 * @ param field - the field whose value to retrieve
 * @ return the value of the field , or null if the container doesn ' t have a value for such field */
public < E > E getFieldValue ( ProfileField < E > field ) { } }

implementation: if ( field == null ) { throw new NullPointerException ( ) ; } String val = mFields . getString ( field . getIdentifier ( ) ) ; return val == null ? null : ProfileFieldConverter . forField ( field ) . fromStorageString ( val ) ;


signature:
public class ProfileFieldContainer { /** * Sets the value of a field in the container . After the first set of a field , calling { @ link
 * ProfileFieldContainer # isModified ( ProfileField ) ) } with it as parameter will return true .
 * @ param field - the fiel whose value to set
 * @ param value - the new value of the field . */
public < E > void setFieldValue ( ProfileField < E > field , E value ) { } }

implementation: if ( field == null || value == null ) { throw new NullPointerException ( ) ; } if ( getStatus ( field ) == FieldStatus . UNACCESSIBLE ) { throw new IllegalStateException ( "Cannot write an unaccessible field" ) ; } String newVal = ProfileFieldConverter . forField ( field ) . toStorageString ( value ) ; String currentVal = mFields . getString ( field . getIdentifier ( ) ) ; if ( newVal . equals ( currentVal ) ) { return ; } if ( getStatus ( field ) == FieldStatus . ORIGINAL ) { setStatus ( field . getIdentifier ( ) , FieldStatus . MODIFIED ) ; } mFields . putString ( field . getIdentifier ( ) , newVal ) ;


signature:
public class ProfileFieldContainer { /** * Returns whether at least one field in the container has been modified
 * @ return true if at least the value of one field in the container has been modified , false
 * otherwise */
public boolean isModified ( ) { } }

implementation: for ( String key : mStatus . keySet ( ) ) { FieldStatus status = getStatus ( key ) ; if ( status == FieldStatus . DELETED || status == FieldStatus . MODIFIED ) { return true ; } } return false ;


signature:
public class ProfileFieldContainer { /** * Clears the modified state of fields . After this call and before any call to { @ link
 * ProfileFieldContainer # setFieldValue ( ProfileField , Object ) } , { @ link
 * ProfileFieldContainer # isModified ( ) } and { @ link ProfileFieldContainer # isModified ( ProfileField ) }
 * return false . */
public void clearModified ( ) { } }

implementation: for ( String field : mStatus . keySet ( ) ) { switch ( getStatus ( field ) ) { case DELETED : mStatus . remove ( field ) ; break ; case MODIFIED : setStatus ( field , FieldStatus . ORIGINAL ) ; break ; default : continue ; } }


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

implementation: dest . writeBundle ( mFields ) ; dest . writeBundle ( mStatus ) ;


signature:
public class FlowLayout { /** * from http : / / adilatwork . blogspot . it / 2012/12 / android - horizontal - flow - layout . html */
@ Override protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { } }

implementation:
super . onMeasure ( widthMeasureSpec , heightMeasureSpec ) ; final int width = MeasureSpec . getSize ( widthMeasureSpec ) ; int height = MeasureSpec . getSize ( heightMeasureSpec ) ; // increment the x position as we progress through a line
int xpos = getPaddingLeft ( ) ; // increment the y position as we progress through the lines
int ypos = getPaddingTop ( ) ; // the height of the current line
int line_height = 0 ; // go through children
// to work out the height required for this view
measureChildren ( widthMeasureSpec , heightMeasureSpec ) ; View child ; MarginLayoutParams childMarginLayoutParams ; int childWidth , childHeight , childMarginLeft , childMarginRight , childMarginTop , childMarginBottom ; for ( int i = 0 ; i < getChildCount ( ) ; i ++ ) { child = getChildAt ( i ) ; if ( child . getVisibility ( ) != GONE ) { childWidth = child . getMeasuredWidth ( ) ; childHeight = child . getMeasuredHeight ( ) ; if ( child . getLayoutParams ( ) != null && child . getLayoutParams ( ) instanceof MarginLayoutParams ) { childMarginLayoutParams = ( MarginLayoutParams ) child . getLayoutParams ( ) ; childMarginLeft = childMarginLayoutParams . leftMargin ; childMarginRight = childMarginLayoutParams . rightMargin ; childMarginTop = childMarginLayoutParams . topMargin ; childMarginBottom = childMarginLayoutParams . bottomMargin ; } else { childMarginLeft = 0 ; childMarginRight = 0 ; childMarginTop = 0 ; childMarginBottom = 0 ; } if ( xpos + childMarginLeft + childWidth + childMarginRight + getPaddingRight ( ) > width ) { // this child will need to go on a new line
xpos = getPaddingLeft ( ) ; ypos += line_height ; line_height = childMarginTop + childHeight + childMarginBottom ; } else // enough space for this child on the current line
line_height = Math . max ( line_height , childMarginTop + childHeight + childMarginBottom ) ; xpos += childMarginLeft + childWidth + childMarginRight ; } } ypos += line_height + getPaddingBottom ( ) ; if ( MeasureSpec . getMode ( heightMeasureSpec ) == MeasureSpec . UNSPECIFIED ) // set height as measured since there ' s no height restrictions
height = ypos ; else if ( MeasureSpec . getMode ( heightMeasureSpec ) == MeasureSpec . AT_MOST && ypos < height ) // set height as measured since it ' s less than the maximum allowed
height = ypos ; setMeasuredDimension ( width , height ) ;


signature:
public class SPFSearch { /** * Starts a search for remote people . The application must provide a tag ,
 * used to replace equivalent queries , a { @ link SearchDescriptor } containing
 * the configuration of the search , and a { @ link SearchCallback } to be
 * notified of found results .
 * @ param tag
 * - the tag identifying this query
 * @ param searchDescriptor
 * - the descriptor of the search
 * @ param callback
 * - the callback to be notified of results . */
public void startSearch ( final int tag , SPFSearchDescriptor searchDescriptor , final SearchCallback callback ) { } }

implementation:
// replace equivalent query ( equivalent = = same tag )
if ( mTagToId . get ( tag ) != null ) { Log . d ( "start search" , "mTagToId.get(tag) != null" ) ; String queryId = mTagToId . get ( tag ) ; Log . d ( "start search" , "mTagToId.get(tag)= " + mTagToId . get ( tag ) ) ; mTagToId . delete ( tag ) ; SearchCallback state = mCallbacks . remove ( queryId ) ; if ( queryId != null && state != null ) { Log . d ( "start search" , "queryId: " + queryId + ", state: " + state ) ; mSearchInterface . stopSearch ( queryId ) ; Log . d ( "start search" , "stopSearch" ) ; } } Log . d ( "start search" , "startSearch" ) ; mSearchInterface . startSearch ( searchDescriptor , new SPFSearchCallbackImpl ( callback , tag ) ) ;


signature:
public class SPFSearch { /** * Stops a previously registered search request performed by the
 * application . The application must provide the tag it registered the
 * search with . The callback associated to the search does not receive any
 * further notification .
 * @ param tag
 * - the tag used to register the search . */
public void stopSearch ( int tag ) { } }

implementation: String queryId = mTagToId . get ( tag ) ; mTagToId . delete ( tag ) ; if ( queryId != null && mCallbacks . remove ( queryId ) != null ) { mSearchInterface . stopSearch ( queryId ) ; }


signature:
public class SPFSearch { /** * Stops all searches registered by the application .
 * @ see SPFSearch # stopSearch ( int ) */
public void stopAllSearches ( ) { } }

implementation: mTagToId . clear ( ) ; String [ ] queryIds = mCallbacks . keySet ( ) . toArray ( new String [ ] { } ) ; mCallbacks . clear ( ) ; for ( String queryId : queryIds ) { mSearchInterface . stopSearch ( queryId ) ; }


signature:
public class SPFSearch { /** * Allows to retrieve a reference to a remote person given its identifier .
 * This reference is valid until the given person is reachable from the
 * proximity middleware .
 * @ param identifier
 * @ return */
public SPFPerson lookup ( String identifier ) { } }

implementation: boolean isReachable = mSearchInterface . lookup ( identifier ) ; if ( isReachable ) { return new SPFPerson ( identifier ) ; } else { return null ; }


signature:
public class ServiceValidator { /** * Validates the interface of a service . In case of failed validation , an
 * unchecked { @ link IllegalServiceException } is thrown .
 * To be valid , a service interface must comply with a series of
 * constraints :
 * < ul >
 * < li > Being annotated with a complete { @ link ServiceInterface } annotation ; < / li >
 * < li > Having all methods with supported return type ; < / li >
 * < li > Having all methods with parameters whose type is supported < / li >
 * < li > Having all methods throwing { @ link ServiceInvocationException } < / li >
 * < / ul >
 * Supported types includes only native Java types .
 * @ param serviceInterface
 * - the interface to be validated ;
 * @ param validationType
 * - the validation to be performed , either
 * < code > TYPE _ PUBLISHED < / code > or < code > TYPE _ REMOTE < / code > */
static void validateInterface ( Class < ? > serviceInterface , int validationType ) { } }

implementation:
// Verify serviceInterface is an interface .
assertThat ( serviceInterface . isInterface ( ) , ErrorMsg . INTERFACE_REQUIRED ) ; // Verify serviceInterface has the right annotation .
ServiceInterface service = serviceInterface . getAnnotation ( ServiceInterface . class ) ; assertThat ( service != null , ErrorMsg . MISSING_ANNOTATION ) ; // Verify service name is not empty
assertThat ( ! isStringEmpty ( service . name ( ) ) , ErrorMsg . MISSING_SERVICE_NAME ) ; // Verify service app name is not empty for remote services
assertThat ( ! ( validationType == TYPE_REMOTE && isStringEmpty ( service . app ( ) ) ) , ErrorMsg . MISSING_APP_NAME ) ; // Analyze methods
for ( Method m : serviceInterface . getMethods ( ) ) { if ( m . isAnnotationPresent ( ActivityConsumer . class ) ) { validateActivityConsumer ( service . name ( ) , m ) ; } else { validateStandardMethod ( service . name ( ) , m ) ; } }


signature:
public class SPFProfileManager { /** * Returns a { @ link ProfileFieldContainer } filled with the values specified
 * in the request .
 * @ param persona
 * - not null
 * @ param fields
 * - an array of { @ link ProfileField } to retrieve .
 * @ return a { @ link ProfileFieldContainer } */
public ProfileFieldContainer getProfileFieldBulk ( SPFPersona persona , ProfileField < ? > ... fields ) { } }

implementation: return mProfileTable . getProfileFieldBulk ( persona , fields ) ;


signature:
public class SPFProfileManager { /** * Method for proximity interface to provide access to local profile to
 * remote spf instances
 * @ param auth
 * - the { @ link PersonAuth } of the sender of the request
 * @ param persona
 * @ param fields
 * - the identifiers of the list of fields to read
 * @ return a { @ link ProfileFieldContainer } with the value of read fields , if
 * accessible . */
public ProfileFieldContainer getProfileFieldBulk ( PersonAuth auth , SPFPersona persona , String [ ] fields ) { } }

implementation: return mProfileTable . getProfileFieldBulk ( persona , fields , auth ) ;


signature:
public class SPFProfileManager { /** * Returns a { @ link ProfileFieldContainer } filled with the values specified
 * in the request .
 * @ param fields
 * - an array of { @ link ProfileField } to retrieve .
 * @ param persona
 * - the { @ link SPFPersona } to read , not null
 * @ return a { @ link ProfileFieldContainer } */
public ProfileFieldContainer getProfileFieldBulk ( String [ ] fields , SPFPersona persona ) { } }


signature:
public class SPFProfileManager { /** * Returns the display _ name of the user . If there is no display _ name , the
 * method returns its identifier .
 * @ param persona
 * - the { @ link SPFPersona } to read .
 * @ return the { @ link BaseInfo } of the given persona */
public BaseInfo getBaseInfo ( SPFPersona persona ) { } }

implementation: ProfileFieldContainer pfc = getProfileFieldBulk ( persona , ProfileField . IDENTIFIER , ProfileField . DISPLAY_NAME ) ; return new BaseInfo ( pfc . getFieldValue ( ProfileField . IDENTIFIER ) , pfc . getFieldValue ( ProfileField . DISPLAY_NAME ) ) ;


signature:
public class SPFProfileManager { /** * Adds a circle to a specified { @ link ProfileField } .
 * @ param field
 * - the { @ link ProfileField } to modify
 * @ param group
 * - the circle to add
 * @ param persona
 * - the { @ link SPFPersona } to modify
 * @ return true if the operation was successful */
public boolean addGroupToField ( ProfileField < ? > field , String group , SPFPersona persona ) { } }

implementation: return mProfileTable . addCircleToFields ( group , field , persona ) ;


signature:
public class SPFProfileManager { /** * Remove a circle from a specified profile field .
 * @ param field
 * the { @ link ProfileField } to modify
 * @ param group
 * - the circle to add
 * @ param persona
 * - the { @ link SPFPersona } to modify
 * @ return true if the operation was successful */
public boolean removeGroupFromField ( ProfileField < ? > field , String group , SPFPersona persona ) { } }

implementation: return mProfileTable . removeCircleFromField ( group , field , persona ) ;


signature:
public class SPFProfileManager { /** * Adds a circle to a specified { @ link ProfileField } .
 * @ param field
 * - the { @ link ProfileField } to modify
 * @ param circle
 * - the circle to add
 * @ param persona
 * - the { @ link SPFPersona } to modify
 * @ return true if the operation was successful */
@ Deprecated public boolean addCircleToField ( ProfileField < ? > field , String circle , SPFPersona persona ) { } }

implementation: return mProfileTable . addCircleToFields ( circle , field , persona ) ;


signature:
public class SPFProfileManager { /** * Remove a circle from a specified profile field .
 * @ param field
 * the { @ link ProfileField } to modify
 * @ param circle
 * - the circle to add
 * @ param persona
 * - the { @ link SPFPersona } to modify
 * @ return true if the operation was successful */
@ Deprecated public boolean removeCircleFromField ( ProfileField < ? > field , String circle , SPFPersona persona ) { } }

implementation: return mProfileTable . removeCircleFromField ( circle , field , persona ) ;


signature:
public class ClientsRecyclerViewAdapter { /** * Create new views ( invoked by the layout manager ) */
@ Override public ViewHolder onCreateViewHolder ( ViewGroup viewGroup , int viewType ) { } }

implementation:
// Create a new view .
View v = LayoutInflater . from ( viewGroup . getContext ( ) ) . inflate ( R . layout . device_card_view , viewGroup , false ) ; return new ViewHolder ( v ) ;


signature:
public class ClientsRecyclerViewAdapter { /** * Replace the contents of a view ( invoked by the layout manager ) */
@ Override public void onBindViewHolder ( ViewHolder viewHolder , final int position ) { } }

implementation: final DeviceGuiElement device = ClientsGuiList . get ( ) . getClients ( ) . get ( position ) ; viewHolder . identifierTextView . setText ( device . getIdentifier ( ) ) ; viewHolder . logo . setImageDrawable ( new IconicsDrawable ( context ) . icon ( FontAwesome . Icon . faw_android ) . color ( context . getResources ( ) . getColor ( R . color . red ) ) . sizeDp ( 30 ) ) ; viewHolder . setOnClickListener ( new OnClickListener ( ) { @ Override public void onClick ( View v ) { itemClickListener . clientItemClicked ( device ) ; } } ) ;


signature:
public class XPathExtensions { /** * Gets the node list from the given xml file and the given xpath expression .
 * @ param xml
 * the xml file as string .
 * @ param xpathExpression
 * the xpath expression as string .
 * @ return the node list
 * @ throws XPathExpressionException
 * the x path expression exception
 * @ throws ParserConfigurationException
 * the parser configuration exception
 * @ throws SAXException
 * the sAX exception
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static NodeList getNodeList ( final String xml , final String xpathExpression ) throws XPathExpressionException , ParserConfigurationException , SAXException , IOException { } }

implementation: final DocumentBuilderFactory domFactory = DocumentBuilderFactory . newInstance ( ) ; domFactory . setNamespaceAware ( true ) ; final DocumentBuilder builder = domFactory . newDocumentBuilder ( ) ; final Document doc = builder . parse ( xml ) ; final XPath xpath = XPathFactory . newInstance ( ) . newXPath ( ) ; final XPathExpression expr = xpath . compile ( xpathExpression ) ; final Object result = expr . evaluate ( doc , XPathConstants . NODESET ) ; final NodeList nodes = ( NodeList ) result ; return nodes ;


signature:
public class LooperUtils { /** * Wraps a callback into a proxy that executes its methods on the main
 * thread . Return types are not supported , a method with return type other
 * than void always returns null when called on the proxy .
 * @ param callbackInterface
 * - the interface of the callback .
 * @ param callback
 * - the callback implementation
 * @ return the proxy to execute methods on the main thread . */
public static < E > E onMainThread ( Class < E > callbackInterface , final E callback ) { } }

implementation: Utils . notNull ( callbackInterface , "callbackInterface must not be null" ) ; Utils . notNull ( callback , "callback must not be null" ) ; final Handler handler = new Handler ( Looper . getMainLooper ( ) ) ; final String tag = callback . getClass ( ) . getSimpleName ( ) ; Object proxy = Proxy . newProxyInstance ( callbackInterface . getClassLoader ( ) , new Class < ? > [ ] { callbackInterface } , new InvocationHandler ( ) { @ Override public Object invoke ( Object proxy , final Method method , final Object [ ] args ) throws Throwable { handler . post ( new Runnable ( ) { @ Override public void run ( ) { try { method . invoke ( callback , args ) ; } catch ( IllegalAccessException e ) { Log . e ( tag , "Error executing method " + method . getName ( ) + " on main thread." , e ) ; } catch ( IllegalArgumentException e ) { Log . e ( tag , "Error executing method " + method . getName ( ) + " on main thread." , e ) ; } catch ( InvocationTargetException e ) { Log . e ( tag , "Error executing method " + method . getName ( ) + " on main thread." , e ) ; } } } ) ; return null ; } } ) ; return callbackInterface . cast ( proxy ) ;


signature:
public class PersonPermissionTable { /** * Call this method every time you receive a remote request .
 * @ param receivedTkn
 * - may be null
 * @ return */
public PersonAuth getPersonAuthFrom ( String receivedTkn ) { } }

implementation:
if ( receivedTkn . equals ( "" ) ) { return PersonAuth . getPublicAuth ( ) ; } String selection = RelationshipEntry . COLUMN_TKN + " = ? AND " + RelationshipEntry . COLUMN_REQUEST_STATUS + " = ?" ; String [ ] selectionArgs = { receivedTkn , Integer . toString ( REQUEST_ACCEPTED ) } ; String [ ] columns = { RelationshipEntry . COLUMN_USER_UUID } ; SQLiteDatabase db = getReadableDatabase ( ) ; Cursor cursor = db . query ( RelationshipEntry . TABLE_PERSON_AUTH , columns , selection , selectionArgs , /* groupBy */
null , /* having */
null , /* orderBy */
null ) ; PersonAuth auth ; if ( cursor . moveToNext ( ) ) { String uniqueIdentifier = cursor . getString ( cursor . getColumnIndex ( RelationshipEntry . COLUMN_USER_UUID ) ) ; auth = generatePermissionFor ( uniqueIdentifier , db ) ; } else { auth = PersonAuth . getPublicAuth ( ) ; } cursor . close ( ) ; return auth ;


signature:
public class PersonPermissionTable { /** * Creates a pending request associated to the target id .
 * @ param targetUid
 * @ return */
public String createEntryForSentRequest ( String targetUid , String password ) throws GeneralSecurityException { } }

implementation:
// TODO Add it back later
// if ( entryExistsFor ( targetUid ) ! = REQUEST _ NOT _ EXIST ) {
// return ;
String user_uuid = targetUid ; String token = new IdentifierGenerator ( ) . generateAccessToken ( ) ; int request_status = REQUEST_ACCEPTED ; insertNewEntry ( user_uuid , token , request_status ) ; return TokenCipher . encryptToken ( token , password ) ;


signature:
public class PersonPermissionTable { /** * Creates a pending request with the information contained in the message .
 * @ param fr
 * @ return */
public boolean createEntryForReceivedRequest ( ContactRequest fr ) { } }

implementation: String user_uuid = fr . getUserIdentifier ( ) ; String receive_token = fr . getAccessToken ( ) ; int request_status = REQUEST_PENDING ; if ( insertNewEntry ( user_uuid , receive_token , request_status ) ) { return true ; } return false ;


signature:
public class PersonPermissionTable { /** * check if an entry for the specified user id exists . Returns the entry
 * state .
 * @ param userUID
 * @ return */
public int entryExistsFor ( String userUID ) { } }

implementation:
String selection = RelationshipEntry . COLUMN_USER_UUID + " = ?" ; String [ ] selectionArgs = { userUID } ; String [ ] columns = { RelationshipEntry . COLUMN_REQUEST_STATUS } ; SQLiteDatabase db = getReadableDatabase ( ) ; Cursor cursor = db . query ( RelationshipEntry . TABLE_PERSON_AUTH , columns , selection , selectionArgs , /* groupBy */
null , /* having */
null , /* orderBy */
null ) ; if ( cursor . moveToNext ( ) ) { return cursor . getInt ( cursor . getColumnIndex ( RelationshipEntry . COLUMN_REQUEST_STATUS ) ) ; } cursor . close ( ) ; return REQUEST_NOT_EXIST ;


signature:
public class PersonPermissionTable { /** * Confirm a friendship request . the status of the entry associated with the
 * specified person , will be REQUEST _ ACCEPTED
 * @ param targetUID
 * - the unique identifier of the person
 * @ throws WrongPassphraseException
 * @ throws GeneralSecurityException */
public boolean confirmRequest ( String targetUID , String password ) throws GeneralSecurityException , WrongPassphraseException { } }

implementation: SQLiteDatabase db = getWritableDatabase ( ) ; String table = RelationshipEntry . TABLE_PERSON_AUTH ; String [ ] columns = { RelationshipEntry . COLUMN_TKN , RelationshipEntry . COLUMN_REQUEST_STATUS , RelationshipEntry . COLUMN_PASSWORD } ; String selection = RelationshipEntry . COLUMN_USER_UUID + " = ? " ; String [ ] selectionArgs = { targetUID } ; String groupBy = null ; String having = null ; String orderBy = null ; String limit = null ; Cursor c = db . query ( table , columns , selection , selectionArgs , groupBy , having , orderBy , limit ) ; if ( c . moveToNext ( ) ) { String token = c . getString ( c . getColumnIndex ( RelationshipEntry . COLUMN_TKN ) ) ; String decryptedTkn = TokenCipher . decryptToken ( token , password ) ; if ( decryptedTkn != null ) { return commitConfirmation ( targetUID , password , decryptedTkn ) ; } else { return false ; } } return false ;


signature:
public class SPFNotification { /** * FIXME callback should run in the main thread after the method
 * execution . . . . . . concurrency problem in the client apps */
public List < SPFTrigger > listTrigger ( ) { } }

implementation: try { SPFError err = new SPFError ( SPFError . NONE_ERROR_CODE ) ; List < SPFTrigger > trgs = getService ( ) . listTrigger ( getAccessToken ( ) , err ) ; if ( ! err . codeEquals ( SPFError . NONE_ERROR_CODE ) ) { handleError ( err ) ; } return trgs ; } catch ( RemoteException e ) { catchRemoteException ( e ) ; return new ArrayList < SPFTrigger > ( 0 ) ; }


signature:
public class TemplateHandler { /** * { @ inheritDoc } */
@ Override protected void write ( final String s ) throws SAXException { } }

implementation: try { if ( s . startsWith ( "$" ) ) { final String newValue = data . get ( s . substring ( 1 , s . length ( ) ) ) ; getWriter ( ) . append ( newValue ) ; } else { getWriter ( ) . append ( s ) ; } } catch ( final IOException e ) { throw new SAXException ( "I/O error" , e ) ; }


signature:
public class GuiceJustInTimeResolver { /** * Returns a { @ link Guice } { @ link Binding } for the given HK2 { @ link Injectee }
 * or { @ code null } if there is no such binding ( i . e . Guice doesn ' t have it and
 * doesn ' t know how to build it ) . */
private Binding < ? > findBinding ( Injectee injectee ) { } }

implementation:
Key < ? > key = BindingUtils . toKey ( injectee ) ; if ( key == null ) { return null ; } // We can ' t do anything about HK2 @ Contracts
if ( BindingUtils . isHk2Contract ( injectee ) ) { return null ; } // Classes with a @ Contract annotation are SPIs . They either exist or
// not . They must be explicit bindings in the world of Guice .
if ( BindingUtils . isJerseyContract ( injectee ) ) { return injector . getExistingBinding ( key ) ; } // We ' ve to use Injector # getBinding ( ) to cover Just - In - Time bindings
// which may fail with an Exception because Guice doesn ' t know how to
// construct the requested object .
return injector . getBinding ( key ) ;


signature:
public class JerseyGuiceUtils { /** * Installs the given { @ link Injector } .
 * @ see JerseyGuiceModule */
public static void install ( Injector injector ) { } }

implementation:
// This binding is provided by JerseyGuiceModule
ServiceLocator locator = injector . getInstance ( ServiceLocator . class ) ; GuiceServiceLocatorGenerator generator = getOrCreateGuiceServiceLocatorGenerator ( ) ; generator . add ( locator ) ;


signature:
public class JerseyGuiceUtils { /** * Returns { @ code true } if jersey2 - guice SPI is present . */
private static synchronized boolean isProviderPresent ( ) { } }

implementation: if ( ! SPI_CHECKED ) { SPI_CHECKED = true ; ServiceLocatorGenerator generator = lookupSPI ( ) ; if ( generator instanceof GuiceServiceLocatorGeneratorStub ) { SPI_PRESENT = true ; } if ( ! SPI_PRESENT ) { LOG . warn ( "It appears jersey2-guice-spi is either not present or in conflict with some other Jar: {}" , generator ) ; } } return SPI_PRESENT ;


signature:
public class JerseyGuiceUtils { /** * Creates and returns a { @ link ServiceLocator } .
 * NOTE : This code should be very similar to HK2 ' s own { @ link ServiceLocatorGeneratorImpl } . */
public static ServiceLocator newServiceLocator ( String name , ServiceLocator parent ) { } }

implementation: if ( parent != null && ! ( parent instanceof ServiceLocatorImpl ) ) { throw new IllegalArgumentException ( "name=" + name + ", parent=" + parent ) ; } if ( name == null ) { name = PREFIX ; } if ( name . endsWith ( "-" ) ) { name += NTH . incrementAndGet ( ) ; } GuiceServiceLocator locator = new GuiceServiceLocator ( name , parent ) ; DynamicConfigurationImpl config = new DynamicConfigurationImpl ( locator ) ; config . bind ( Utilities . getLocatorDescriptor ( locator ) ) ; ActiveDescriptor < InjectionResolver < javax . inject . Inject > > threeThirtyResolver = newThreeThirtyInjectionResolverDescriptor ( locator ) ; config . addActiveDescriptor ( threeThirtyResolver ) ; config . addActiveDescriptor ( newGuiceInjectionResolverDescriptor ( locator , threeThirtyResolver ) ) ; config . bind ( BuilderHelper . link ( DynamicConfigurationServiceImpl . class , false ) . to ( DynamicConfigurationService . class ) . in ( Singleton . class . getName ( ) ) . localOnly ( ) . build ( ) ) ; config . bind ( BuilderHelper . createConstantDescriptor ( new DefaultClassAnalyzer ( locator ) ) ) ; config . bind ( BuilderHelper . createDescriptorFromClass ( ServiceLocatorRuntimeImpl . class ) ) ; config . bind ( BuilderHelper . createConstantDescriptor ( new InstantiationServiceImpl ( ) ) ) ; config . commit ( ) ; return locator ;


signature:
public class JerseyGuiceUtils { /** * This method links the { @ link Injector } to the { @ link ServiceLocator } . */
public static ServiceLocator link ( ServiceLocator locator , Injector injector ) { } }

implementation: Map < Key < ? > , Binding < ? > > bindings = gatherBindings ( injector ) ; Set < Binder > binders = toBinders ( bindings ) ; return link ( locator , injector , binders ) ;


signature:
public class JerseyGuiceUtils { /** * Gathers Guice { @ link Injector } bindings over the hierarchy . */
private static Map < Key < ? > , Binding < ? > > gatherBindings ( Injector injector ) { } }

implementation: Map < Key < ? > , Binding < ? > > dst = new HashMap < Key < ? > , Binding < ? > > ( ) ; Injector current = injector ; while ( current != null ) { dst . putAll ( current . getBindings ( ) ) ; current = current . getParent ( ) ; } return dst ;


signature:
public class JerseyGuiceUtils { /** * Turns the given Guice { @ link Binding } s into HK2 { @ link Binder } s . */
@ SuppressWarnings ( { } }

implementation:
"unchecked" , "rawtypes" } ) private static Set < Binder > toBinders ( Map < Key < ? > , Binding < ? > > bindings ) { Set < Binder > binders = new HashSet < > ( ) ; for ( Map . Entry < Key < ? > , Binding < ? > > entry : bindings . entrySet ( ) ) { Key < ? > key = entry . getKey ( ) ; Binding < ? > binding = entry . getValue ( ) ; Object source = binding . getSource ( ) ; if ( ! ( source instanceof ElementSource ) ) { // Things like the Injector itself don ' t have an ElementSource .
if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "Adding binding: key={}, source={}" , key , source ) ; } binders . add ( new GuiceBinder ( key , binding ) ) ; continue ; } ElementSource element = ( ElementSource ) source ; List < String > names = element . getModuleClassNames ( ) ; String name = names . get ( 0 ) ; // Skip everything that is declared in a JerseyModule
try { Class < ? > module ; // Attempt to load the classes via the context class loader first , in order to support
// environments that enforce tighter constraints on class loading ( such as in an OSGi container )
ClassLoader classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( classLoader != null ) { module = classLoader . loadClass ( name ) ; } else { module = Class . forName ( name ) ; } if ( JerseyModule . class . isAssignableFrom ( module ) ) { if ( LOG . isTraceEnabled ( ) ) { LOG . trace ( "Ignoring binding {} in {}" , key , module ) ; } continue ; } } catch ( ClassNotFoundException err ) { // Some modules may not be able to be instantiated directly here as a class if we ' re running
// in a container that enforcer tighter class loader constraints ( such as the
// org . ops4j . peaberry . osgi . OSGiModule Guice module when running in an OSGi container ) ,
// so we ' re only logging a warning here instead of throwing a hard exception
if ( LOG . isWarnEnabled ( ) ) { LOG . warn ( "Unavailable to load class in order to validate module: name={}" , name ) ; } } binders . add ( new GuiceBinder ( key , binding ) ) ; } return binders ;


signature:
public class BindingUtils { /** * Creates and returns a { @ link InjectionResolver } for { @ link javax . inject . Inject } .
 * @ see javax . inject . Inject
 * @ see InjectionResolver */
public static ActiveDescriptor < InjectionResolver < javax . inject . Inject > > newThreeThirtyInjectionResolverDescriptor ( ServiceLocator locator ) { } }

implementation: GuiceThreeThirtyResolver resolver = new GuiceThreeThirtyResolver ( locator ) ; Set < Annotation > qualifiers = Collections . < Annotation > singleton ( new NamedImpl ( SYSTEM_RESOLVER_NAME ) ) ; return newActiveDescriptor ( locator , resolver , qualifiers , SYSTEM_RESOLVER_NAME , javax . inject . Inject . class ) ;


signature:
public class BindingUtils { /** * Creates and returns a { @ link InjectionResolver } for { @ link com . google . inject . Inject }
 * @ see # newThreeThirtyInjectionResolverDescriptor ( ServiceLocator )
 * @ see com . google . inject . Inject
 * @ see InjectionResolver */
public static ActiveDescriptor < InjectionResolver < com . google . inject . Inject > > newGuiceInjectionResolverDescriptor ( ServiceLocator locator , ActiveDescriptor < ? extends InjectionResolver < ? > > threeThirtyResolver ) { } }

implementation: GuiceInjectionResolver resolver = new GuiceInjectionResolver ( threeThirtyResolver ) ; Set < Annotation > qualifiers = Collections . emptySet ( ) ; return newActiveDescriptor ( locator , resolver , qualifiers , GUICE_RESOLVER_NAME , com . google . inject . Inject . class ) ;


signature:
public class BindingUtils { /** * Returns { @ code true } if the given { @ link Injectee } can be { @ code null } .
 * @ see Optional
 * @ see Injectee # isOptional ( )
 * @ see Nullable
 * @ see com . google . inject . Inject # optional ( )
 * @ see Nullability # allowsNull ( Annotation [ ] ) */
public static boolean isNullable ( Injectee injectee ) { } }

implementation:
// HK2 ' s optional
if ( injectee . isOptional ( ) ) { return true ; } // Guice ' s optional
AnnotatedElement element = injectee . getParent ( ) ; if ( isGuiceOptional ( element ) ) { return true ; } // Any @ Nullable ?
int position = injectee . getPosition ( ) ; if ( element instanceof Field ) { return Nullability . allowsNull ( ( ( Field ) element ) . getAnnotations ( ) ) ; } else if ( element instanceof Method ) { Annotation annotations [ ] [ ] = ( ( Method ) element ) . getParameterAnnotations ( ) ; return Nullability . allowsNull ( annotations [ position ] ) ; } else if ( element instanceof Constructor < ? > ) { Annotation annotations [ ] [ ] = ( ( Constructor < ? > ) element ) . getParameterAnnotations ( ) ; return Nullability . allowsNull ( annotations [ position ] ) ; } return false ;


signature:
public class BindingUtils { /** * Returns { @ code true } if the given { @ link AnnotatedElement } has a
 * { @ link com . google . inject . Inject } { @ link Annotation } and it ' s marked
 * as being optional .
 * @ see com . google . inject . Inject # optional ( ) */
private static boolean isGuiceOptional ( AnnotatedElement element ) { } }

implementation: com . google . inject . Inject inject = element . getAnnotation ( com . google . inject . Inject . class ) ; if ( inject != null ) { return inject . optional ( ) ; } return false ;


signature:
public class BindingUtils { /** * Returns { @ code true } if the { @ link Injectee } has a HK2 SPI
 * { @ link org . jvnet . hk2 . annotations . Contract } annotation .
 * @ see org . jvnet . hk2 . annotations . Contract */
public static boolean isHk2Contract ( Injectee injectee ) { } }

implementation: Type type = injectee . getRequiredType ( ) ; return isContact ( type , org . jvnet . hk2 . annotations . Contract . class ) ;


signature:
public class BindingUtils { /** * Returns { @ code true } if the { @ link Injectee } has a Jersey SPI
 * { @ link org . glassfish . jersey . spi . Contract } annotation .
 * @ see org . glassfish . jersey . spi . Contract */
public static boolean isJerseyContract ( Injectee injectee ) { } }

implementation: Type type = injectee . getRequiredType ( ) ; return isContact ( type , org . glassfish . jersey . spi . Contract . class ) ;


signature:
public class BindingUtils { /** * Turns a { @ link Guice } { @ link com . google . inject . name . Named } into a
 * JSR - 330 ' s { @ link javax . inject . Named } instance . */
public static javax . inject . Named toThreeThirtyNamed ( com . google . inject . name . Named qualifier ) { } }

implementation: return new NamedImpl ( qualifier . value ( ) ) ;


signature:
public class BindingUtils { /** * Creates and returns a { @ link Key } from the given { @ link Injectee } . */
public static Key < ? > toKey ( Injectee injectee ) { } }

implementation: Type type = injectee . getRequiredType ( ) ; Set < Annotation > qualifiers = getQualifiers ( injectee ) ; return newKey ( type , qualifiers ) ;


signature:
public class BindingUtils { /** * Returns a { @ link Set } of qualifier { @ link Annotation } s for
 * the given { @ link Key } .
 * NOTE : The { @ link Set } will be either empty or will have
 * at most one { @ link Annotation } in it . */
public static < T > Set < Annotation > getQualifiers ( Key < T > key ) { } }

implementation:
Annotation annotation = key . getAnnotation ( ) ; if ( annotation != null ) { // Replace ' com . google . inject . name . Named ' with ' javax . inject . Named '
if ( annotation instanceof com . google . inject . name . Named ) { annotation = toThreeThirtyNamed ( ( com . google . inject . name . Named ) annotation ) ; } Class < ? extends Annotation > type = annotation . annotationType ( ) ; if ( type . isAnnotationPresent ( Qualifier . class ) ) { return Collections . singleton ( annotation ) ; } return Collections . < Annotation > singleton ( new GuiceQualifier < > ( key ) ) ; } Class < ? extends Annotation > annotationType = key . getAnnotationType ( ) ; if ( annotationType != null ) { return Collections . < Annotation > singleton ( new GuiceQualifier < > ( key ) ) ; } return Collections . emptySet ( ) ;


signature:
public class BindingUtils { /** * Creates and returns a { @ link Key } for the given { @ link Type } and { @ link Set } of { @ link Annotation } s . */
private static Key < ? > newKey ( Type type , Set < ? extends Annotation > qualifiers ) { } }

implementation:
if ( qualifiers . isEmpty ( ) ) { return Key . get ( type ) ; } // There can be only one qualifier .
if ( qualifiers . size ( ) == 1 ) { for ( Annotation first : qualifiers ) { return Key . get ( type , first ) ; } } return null ;


signature:
public class BindingUtils { /** * NOTE : There can be only one { @ link Annotation } that is a { @ link Qualifier } or { @ link BindingAnnotation } .
 * They ' re the same but HK2 does not know about { @ link BindingAnnotation } .
 * @ see Qualifier
 * @ see BindingAnnotation
 * @ see javax . inject . Named
 * @ see com . google . inject . name . Named */
private static Set < Annotation > getQualifiers ( Injectee injectee ) { } }

implementation:
// JSR 330 ' s @ Qualifier
Set < Annotation > qualifiers = injectee . getRequiredQualifiers ( ) ; if ( ! qualifiers . isEmpty ( ) ) { return qualifiers ; } AnnotatedElement element = injectee . getParent ( ) ; int position = injectee . getPosition ( ) ; // Guice ' s @ BindingAnnotation is the same as @ Qualifier
Annotation annotation = getBindingAnnotation ( element , position ) ; if ( annotation != null ) { return Collections . singleton ( annotation ) ; } return Collections . emptySet ( ) ;


signature:
public class BindingUtils { /** * Returns a { @ link BindingAnnotation } for the given { @ link AnnotatedElement } and position . */
private static Annotation getBindingAnnotation ( AnnotatedElement element , int position ) { } }

implementation: if ( element instanceof Field ) { return getBindingAnnotation ( ( ( Field ) element ) . getAnnotations ( ) ) ; } if ( element instanceof Method ) { Annotation annotations [ ] [ ] = ( ( Method ) element ) . getParameterAnnotations ( ) ; return getBindingAnnotation ( annotations [ position ] ) ; } if ( element instanceof Constructor < ? > ) { Annotation annotations [ ] [ ] = ( ( Constructor < ? > ) element ) . getParameterAnnotations ( ) ; return getBindingAnnotation ( annotations [ position ] ) ; } return null ;


signature:
public class BindingUtils { /** * Returns the first { @ link Annotation } from the given array that
 * is a { @ link BindingAnnotation } .
 * @ see BindingAnnotation */
private static Annotation getBindingAnnotation ( Annotation [ ] annotations ) { } }

implementation: for ( Annotation annotation : annotations ) { Class < ? extends Annotation > type = annotation . annotationType ( ) ; if ( type . isAnnotationPresent ( BindingAnnotation . class ) ) { return annotation ; } } return null ;


signature:
public class JarURIResourceFactory { /** * Method that needs to be implemented by children . .
 * @ param uri
 * @ param parent the parent resource factory
 * @ return the resource
 * @ throws IOException if there is a problem creating the resource */
@ Override protected Resource doCreateResource ( URI uri , URIResourceFactory parent ) { } }

implementation: try { return JarResource . create ( uri , parent ) ; } catch ( URISyntaxException e ) { throw new IllegalArgumentException ( uri . toString ( ) , e ) ; }


signature:
public class ThreadControl { /** * This method is usually called from within a mock object to execute the call associated
 * to the given key . It will block until another thread calls one of the < code > unblock < / code >
 * method with the object to return .
 * @ param key same key as used in < code > unblock < / code >
 * @ return the object provided to < code > unblock < / code > */
public Object block ( Object key ) { } }

implementation: if ( log . isDebugEnabled ( ) ) log . debug ( LangUtils . shortIdentityString ( this ) + ".block(" + key + ")" ) ; _lock . lock ( ) ; try { _waitingForBlock . add ( key ) ; _blockCondition . signalAll ( ) ; long endTime = System . currentTimeMillis ( ) + _timeout . getDurationInMilliseconds ( ) ; while ( ! _waitingForUnblock . containsKey ( key ) ) { try { ConcurrentUtils . awaitUntil ( _unblockCondition , endTime ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } catch ( TimeoutException e ) { throw new RuntimeException ( e ) ; } } return _waitingForUnblock . remove ( key ) ; } finally { _lock . unlock ( ) ; }


signature:
public class ThreadControl { /** * This method is usually called from within a mock object to execute the call associated
 * to the given key . It will block until another thread calls one of the < code > unblock < / code >
 * method with the object to return . If the object to return is an exception it will throw
 * it instead !
 * @ param key same key as used in < code > unblock < / code >
 * @ return the object provided to < code > unblock < / code > */
public Object blockWithException ( Object key ) throws Exception { } }

implementation: Object value = block ( key ) ; if ( value instanceof Exception ) { Exception exception = ( Exception ) value ; throw exception ; } return value ;


signature:
public class ThreadControl { /** * This method is called from one thread while another is going to call < code > block < / code > . It
 * is basically a synchronization point as this method will block until
 * < code > block < / code > is called and will then release the thread who called < code > block < / code >
 * in the first place .
 * @ param key the same key used in < code > block < / code >
 * @ param value the value that will be returned by < code > block < / code > */
public void unblock ( Object key , Object value ) { } }

implementation: if ( log . isDebugEnabled ( ) ) log . debug ( LangUtils . shortIdentityString ( this ) + ".unblock(" + key + ", " + value + ")" ) ; _lock . lock ( ) ; try { try { waitForBlock ( key ) ; } catch ( InterruptedException e ) { throw new RuntimeException ( e ) ; } catch ( TimeoutException e ) { throw new RuntimeException ( e ) ; } _waitingForBlock . remove ( key ) ; _waitingForUnblock . put ( key , value ) ; _unblockCondition . signalAll ( ) ; } finally { _lock . unlock ( ) ; }


signature:
public class ThreadControl { /** * Blocking call to wait for a thread to call < code > block < / code > .
 * @ param key the key we are waiting for
 * @ throws TimeOutException
 * @ throws InterruptedException */
public void waitForBlock ( Object key , Timespan timeout ) throws TimeoutException , InterruptedException { } }

implementation: _lock . lock ( ) ; try { long endTime = System . currentTimeMillis ( ) + timeout . getDurationInMilliseconds ( ) ; while ( ! _waitingForBlock . contains ( key ) ) { ConcurrentUtils . awaitUntil ( _blockCondition , endTime ) ; } } finally { _lock . unlock ( ) ; }


signature:
public class URLCodec { /** * Encapsulates the call to encoding a URL
 * @ param original the string to encode
 * @ return the encoded url */
public String urlEncode ( String original ) { } }

implementation:
// see http : / / www . w3 . org / TR / html40 / appendix / notes . html # non - ascii - chars
// for an explanation of the character encoding
String s = null ; try { s = URLEncoder . encode ( original , _characterEncoding ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } if ( _encodeDot ) { // we encode . as well because it can cause problems in url in emails .
s = TextUtils . searchAndReplace ( s , "." , "%2E" ) ; } return s ;


signature:
public class URLCodec { /** * Encapsulates the call to decoding a URL so that we don ' t have to deal
 * with the encoding .
 * @ param original the string to decode
 * @ return the encoded url */
public String urlDecode ( String original ) { } }

implementation: try { return URLDecoder . decode ( original , _characterEncoding ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; }


signature:
public class XMLIndent { /** * Adds the XML declaration ( < code > & lt ; ? xml version = " 1.0 " encoding = " UTF - 8"
 * standalone = " yes " ? & gt ; < / code > )
 * @ param versionInfo the version info
 * @ param encoding the encoding ( eg : UTF - 8)
 * @ param standalone < code > true < / code > for standalone */
@ Override public void addXMLDecl ( String versionInfo , String encoding , boolean standalone ) { } }

implementation: _xml . addXMLDecl ( versionInfo , encoding , standalone ) ;


signature:
public class XMLIndent { /** * Adds a closing tag
 * @ param tagName the name of the closing tag to add */
@ Override public void addClosingTag ( String tagName ) { } }

implementation: _indent . dec ( ) ; _xml . addXML ( _indent . toString ( ) ) ; _xml . addClosingTag ( tagName ) ; _xml . addXML ( "\n" ) ;


signature:
public class XMLIndent { /** * Adds an empty tag
 * @ param tagName the name of the empty tag to add */
@ Override public void addEmptyTag ( String tagName ) { } }

implementation: _xml . addXML ( _indent . toString ( ) ) ; _xml . addEmptyTag ( tagName ) ; _xml . addXML ( "\n" ) ;


signature:
public class XMLIndent { /** * Adds a tag
 * @ param tagName the name of the tag to add
 * @ param tagValue the value of the tag to add */
@ Override public void addTag ( String tagName , String tagValue ) { } }

implementation: _xml . addXML ( _indent . toString ( ) ) ; _xml . addTag ( tagName , tagValue ) ; _xml . addXML ( "\n" ) ;


signature:
public class XMLIndent { /** * Adds an empty tag which contains an attribute
 * @ param tagName the name of the empty tag to add
 * @ param attrName the name of the attribute
 * @ param attrValue the value of the attribute */
@ Override public void addEmptyTag ( String tagName , String attrName , String attrValue ) { } }

implementation: _xml . addXML ( _indent . toString ( ) ) ; _xml . addEmptyTag ( tagName , attrName , attrValue ) ; _xml . addXML ( "\n" ) ;


signature:
public class XMLIndent { /** * Adds an opening tag which contains the attributes specified . All the
 * properties will be turned into attributes .
 * @ param tagName the name of the opening tag to add
 * @ param attributes the attributes */
@ Override public void addOpeningTag ( String tagName , Map attributes ) { } }

implementation: _xml . addXML ( _indent . toString ( ) ) ; _xml . addOpeningTag ( tagName , attributes ) ; _xml . addXML ( "\n" ) ; _indent . inc ( ) ;


signature:
public class IOUtils { /** * Deletes the file provided . If it is a directory , recursively deletes a directory and its content .
 * @ param file
 * @ return < code > true < / code > if the file was deleted , < code > false < / code >
 * if didn ' t exist
 * @ throws IOException */
public static boolean deleteFile ( File file ) throws IOException { } }

implementation: if ( ! file . exists ( ) ) return false ; File [ ] files = file . listFiles ( ) ; if ( files != null ) { for ( int i = 0 ; i < files . length ; i ++ ) { File childFile = files [ i ] ; if ( childFile . equals ( file ) ) continue ; if ( childFile . isDirectory ( ) ) deleteFile ( childFile ) ; else childFile . delete ( ) ; } } return file . delete ( ) ;


signature:
public class IOUtils { /** * Creates a new directory . This method creates automatically all the parent
 * directories if necesary . Contrary to < code > File . mkdirs < / code > , this method
 * will fail if the directory cannot be created . The returned value is also
 * different in meaning : < code > false < / code > means that the directory was not
 * created because it already existed as opposed to it was not created because
 * we don ' t know .
 * @ param directory the directory to create
 * @ return < code > true < / code > if the directory was created , < code > false < / code >
 * if it existed already .
 * @ throws IOException when there is a problem creating the directory */
public static boolean createNewDirectory ( File directory ) throws IOException { } }

implementation: if ( directory . exists ( ) ) return false ; if ( ! directory . mkdirs ( ) ) throw new IOException ( "cannot create the directory: " + directory ) ; return true ;


signature:
public class IOUtils { /** * Creates a temporary directory .
 * @ param namespace
 * @ param name root name of the temporary directory
 * @ return the temp dir
 * @ throws IOException if there is a problem */
public static File createTempDirectory ( String namespace , String name ) throws IOException { } }

implementation: File dir = File . createTempFile ( namespace , "" ) ; if ( dir . exists ( ) ) deleteFile ( dir ) ; createNewDirectory ( dir ) ; File tempDir = new File ( dir , name ) ; createNewDirectory ( tempDir ) ; return tempDir . getCanonicalFile ( ) ;


signature:
public class IOUtils { /** * Turns the object into a < code > byte [ ] < / code > by serializing it in memory .
 * @ param ser the serializable object
 * @ exception IOException if there is a problem in the serialization step */
public static < T extends Serializable > byte [ ] serialize ( T ser ) throws IOException { } }

implementation: ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; try { oos . writeObject ( ser ) ; } finally { oos . close ( ) ; } return baos . toByteArray ( ) ;


signature:
public class IOUtils { /** * This is the opposite of { @ link # serialize ( Serializable ) } .
 * @ param array the previously serialized object
 * @ exception IOException if there is a problem in the deserialization step
 * @ exception ClassNotFoundException if problem with the serialized object */
@ SuppressWarnings ( "unchecked" ) public static < T extends Serializable > T deserialize ( byte [ ] array ) throws IOException , ClassNotFoundException { } }

implementation: return ( T ) ( deserialize ( array , false ) ) ;


signature:
public class IOUtils { /** * This is the opposite of { @ link # serialize ( Serializable ) } .
 * @ param array the previously serialized object
 * @ param useContextClassLoader true to use the context classLoader , false
 * to use the current classLoader
 * @ exception IOException if there is a problem in the deserialization step
 * @ exception ClassNotFoundException if problem with the serialized object */
@ SuppressWarnings ( "unchecked" ) public static < T extends Serializable > T deserialize ( byte [ ] array , boolean useContextClassLoader ) throws IOException , ClassNotFoundException { } }

implementation: ByteArrayInputStream bais = new ByteArrayInputStream ( array ) ; ObjectInputStream ois ; if ( useContextClassLoader ) { ois = new ObjectInputStreamWithClassLoader ( bais , null ) ; } else { ois = new ObjectInputStream ( bais ) ; } try { return ( T ) ois . readObject ( ) ; } finally { ois . close ( ) ; }


signature:
public class IOUtils { /** * Copies the input stream into the output stream ( num _ bytes )
 * @ param in the input stream to read data
 * @ param out the output stream to write data
 * @ param num _ bytes the number of bytes to copy */
public static void copy ( InputStream in , OutputStream out , int num_bytes ) throws IOException { } }

implementation: if ( num_bytes == 0 ) return ; int n ; if ( num_bytes < 0 ) { byte [ ] b = new byte [ 2048 ] ; while ( ( n = in . read ( b , 0 , b . length ) ) > 0 ) out . write ( b , 0 , n ) ; } else { int offset = 0 ; byte [ ] b = new byte [ num_bytes ] ; while ( num_bytes > 0 && ( n = in . read ( b , offset , num_bytes ) ) > 0 ) { offset += n ; num_bytes -= n ; } out . write ( b ) ; }


signature:
public class IOUtils { /** * Copies the reader into the writer ( num _ bytes )
 * @ param in the reader to read data
 * @ param out the writer to write data
 * @ param num _ bytes the number of chars to copy */
public static void copy ( Reader in , Writer out , int num_bytes ) throws IOException { } }

implementation: if ( num_bytes == 0 ) return ; int n ; if ( num_bytes < 0 ) { char [ ] b = new char [ 2048 ] ; while ( ( n = in . read ( b , 0 , b . length ) ) > 0 ) out . write ( b , 0 , n ) ; } else { int offset = 0 ; char [ ] b = new char [ num_bytes ] ; while ( num_bytes > 0 && ( n = in . read ( b , offset , num_bytes ) ) > 0 ) { offset += n ; num_bytes -= n ; } out . write ( b ) ; }


signature:
public class FileResourceProvider { /** * Builds a resource given a path . Only subclasses know how to do that .
 * @ param path the path to the new resource ( always starts with / )
 * @ return the resource */
@ Override public InternalResource doBuildResource ( String path ) { } }

implementation: return new FileResource ( this , path , new File ( _root , path ) ) ;


signature:
public class FileResourceProvider { /** * Creates a new resource provider given the new path .
 * @ param rootPath
 * @ return the new resource provider */
@ Override public InternalResourceProvider doCreateResourceProvider ( String rootPath ) { } }

implementation: try { return new FileResourceProvider ( new File ( _root , rootPath ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; }


signature:
public class FileResourceProvider { /** * If the path denotes a directory , then it will return all resources that are contained in the
 * directory .
 * @ param path the path to the resource
 * @ param filter the filter to include only some resources in the result
 * @ return < code > true < / code > if it was a directory , < code > false < / code > otherwise */
@ Override public boolean doList ( String path , ResourceFilter filter ) { } }

implementation: File file = null ; try { file = new File ( _root , path ) . getCanonicalFile ( ) ; } catch ( IOException e ) { if ( log . isDebugEnabled ( ) ) log . debug ( "exception (ignored) while converting canonical file " + new File ( _root , path ) , e ) ; return false ; } if ( ! file . isDirectory ( ) ) return false ; File [ ] files = file . listFiles ( ) ; for ( File f : files ) { filter . accept ( new FileResource ( this , path + f . getName ( ) , f ) ) ; } return true ;


signature:
public class HexaCodec { /** * Decodes the < code > String < / code > into a byte array
 * @ param s the string to decode
 * @ return the byte array decoded
 * @ throws CannotDecodeException if the string has not been encoded with this codec */
@ Override public byte [ ] decode ( String s ) throws CannotDecodeException { } }

implementation: if ( s == null || s . length ( ) <= 0 ) { throw new CannotDecodeException ( "Cannot decode null or empty String" ) ; } else { return new BigInteger ( s , 16 ) . toByteArray ( ) ; }


signature:
public class HexaCodec { /** * Encode the array into a < code > String < / code >
 * @ param byteArray the array to encode
 * @ return the encoded < code > String < / code > */
@ Override public String encode ( byte [ ] byteArray ) { } }

implementation: int len = byteArray . length ; char [ ] encoded = new char [ len * 2 ] ; int j = 0 ; for ( int i = 0 ; i < byteArray . length ; i ++ ) { int b = byteArray [ i ] & 0xFF ; String hexa = HEXA_VALUES [ b ] ; encoded [ j ++ ] = hexa . charAt ( 0 ) ; encoded [ j ++ ] = hexa . charAt ( 1 ) ; } return new String ( encoded ) ;


signature:
public class ReflectUtils { /** * Given a proxy returns the object proxied . If the object is not a proxy , then return the object
 * itself .
 * @ param proxy
 * @ return the proxied object ( or proxy if not an object proxy ) */
@ SuppressWarnings ( "unchecked" ) public static Object getProxiedObject ( Object proxy ) { } }

implementation:
if ( Proxy . isProxyClass ( proxy . getClass ( ) ) ) { InvocationHandler invocationHandler = Proxy . getInvocationHandler ( proxy ) ; if ( invocationHandler instanceof ObjectProxy ) { ObjectProxy objectProxy = ( ObjectProxy ) invocationHandler ; // recursively fetch the proxy
return getProxiedObject ( objectProxy . getProxiedObject ( ) ) ; } else return proxy ; } else return proxy ;


signature:
public class ReflectUtils { /** * Return a the default class loader ( the one associated to the current thread or the one from
 * this class )
 * @ return the default ClassLoader ( never < code > null < / code > )
 * @ see java . lang . Thread # getContextClassLoader ( ) */
public static ClassLoader getDefaultClassLoader ( ) { } }

implementation:
ClassLoader cl = null ; try { cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; } catch ( Throwable ex ) { if ( log . isDebugEnabled ( ) ) log . debug ( "Cannot access thread context ClassLoader - falling back to system class loader" , ex ) ; } if ( cl == null ) { // No thread context class loader - > use class loader of this class .
cl = ReflectUtils . class . getClassLoader ( ) ; } return cl ;


signature:
public class ReflectUtils { /** * Wraps < code > Class . forName < / code > to be context class loader aware .
 * @ param name the name of the Class
 * @ param classLoader the class loader to use ( may be < code > null < / code > , which indicates the
 * default class loader )
 * @ return Class instance for the supplied name
 * @ throws ClassNotFoundException if the class was not found
 * @ throws LinkageError if the class file could not be loaded
 * @ see Class # forName ( String , boolean , ClassLoader ) */
public static Class forName ( String name , ClassLoader classLoader ) throws ClassNotFoundException , LinkageError { } }

implementation: if ( classLoader == null ) { classLoader = getDefaultClassLoader ( ) ; } return Class . forName ( name , true , classLoader ) ;


signature:
public class ReflectUtils { /** * Convenient call to return a class in a different class loader . . . note that it will handle
 * correctly a class in the same class loader
 * @ param clazz the clazz you want in a different class loader
 * @ param classLoader the class loader to use ( may be < code > null < / code > , which indicates the
 * default class loader )
 * @ return Class instance for the supplied name
 * @ throws ClassNotFoundException if the class was not found
 * @ throws LinkageError if the class file could not be loaded
 * @ see Class # forName ( String , boolean , ClassLoader ) */
public static Class forName ( Class clazz , ClassLoader classLoader ) throws ClassNotFoundException , LinkageError { } }

implementation: if ( clazz == null ) return null ; if ( classLoader == null ) { classLoader = getDefaultClassLoader ( ) ; } if ( clazz . getClassLoader ( ) == null || clazz . getClassLoader ( ) . equals ( classLoader ) ) return clazz ; else return forName ( clazz . getName ( ) , classLoader ) ;


signature:
public class ReflectUtils { /** * Execute the call within the given class loader . . . handle setting / reverting to
 * previous class loader in a safe manner .
 * @ param classLoader the class loader to set for the duration of the call
 * @ param callable the callable to execute within the context of the provided class loader
 * @ return the result of the call
 * @ throws Exception whatever callable throws */
public static < T > T executeWithClassLoader ( ClassLoader classLoader , Callable < T > callable ) throws Exception { } }

implementation: ClassLoader previousClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { Thread . currentThread ( ) . setContextClassLoader ( classLoader ) ; return callable . call ( ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( previousClassLoader ) ; }


signature:
public class ReflectUtils { /** * Computes the signature of a method . Note that if 2 methods are declared
 * in different classes or interfaces then I1 . m and I2 . m are different but
 * they can still have the same signature . . .
 * @ param m method
 * @ return the signature ( unique per method definition ) */
@ SuppressWarnings ( "unchecked" ) public static String computeSignature ( Method m ) { } }

implementation: StringBuilder sb = new StringBuilder ( ) ; sb . append ( m . getName ( ) ) . append ( '(' ) ; Class [ ] parameterTypes = m . getParameterTypes ( ) ; for ( int i = 0 ; i < parameterTypes . length ; i ++ ) { if ( i > 0 ) sb . append ( ',' ) ; Class parameterType = parameterTypes [ i ] ; sb . append ( parameterType . getName ( ) ) ; } sb . append ( ')' ) ; return sb . toString ( ) ;


signature:
public class ReflectUtils { /** * Utility which extract the interfaces implemented by o : it goes up the chain of inheritance
 * to find all the interfaces .
 * @ param o
 * @ return all the interfaces implemented by o */
public static Class [ ] extractAllInterfaces ( Object o ) { } }

implementation: Set < Class > interfaces = new LinkedHashSet < Class > ( ) ; Class c = o . getClass ( ) ; do { interfaces . addAll ( Arrays . asList ( c . getInterfaces ( ) ) ) ; c = c . getSuperclass ( ) ; } while ( c != null ) ; return interfaces . toArray ( new Class [ interfaces . size ( ) ] ) ;


signature:
public class ObjectProxyBuilder { /** * Convenient call which creates a proxy using the handler and the interface . It will also
 * check that the object bien proxied ( if implements < code > ObjectProxy < / code > ) properly
 * implement the interface . . .
 * @ return the proxy ( which implement all the interface ) */
@ SuppressWarnings ( "unchecked" ) public static < T > T createProxy ( InvocationHandler handler , Class < T > itface ) { } }

implementation: if ( handler instanceof ObjectProxy ) { ObjectProxy proxy = ( ObjectProxy ) handler ; if ( ! ReflectUtils . isSubClassOrInterfaceOf ( proxy . getProxiedObject ( ) . getClass ( ) , itface ) ) throw new IllegalArgumentException ( proxy . getProxiedObject ( ) . getClass ( ) + " does not extend " + itface ) ; } return ( T ) Proxy . newProxyInstance ( itface . getClassLoader ( ) , new Class < ? > [ ] { itface } , handler ) ;


signature:
public class ObjectProxyBuilder { /** * Convenient call which creates a proxy using the handler and the interfaces . It will also
 * check that the object bien proxied ( if implements < code > ObjectProxy < / code > ) properly
 * implement the right interfaces . . .
 * @ return the proxy ( which implement all the provided interfaces ) */
public static Object createProxy ( InvocationHandler handler , Class < ? > ... itfaces ) { } }

implementation: if ( handler instanceof ObjectProxy ) { ObjectProxy proxy = ( ObjectProxy ) handler ; Class < ? > proxyClass = proxy . getProxiedObject ( ) . getClass ( ) ; for ( Class < ? > itface : itfaces ) { if ( ! ReflectUtils . isSubClassOrInterfaceOf ( proxyClass , itface ) ) throw new IllegalArgumentException ( proxyClass + " does not extend " + itface ) ; } } List < ClassLoader > classLoaders = new ArrayList < ClassLoader > ( ) ; for ( Class < ? > itface : itfaces ) { classLoaders . add ( itface . getClassLoader ( ) ) ; } ClassLoader classLoader = ClassLoaderChain . createChain ( classLoaders ) ; return Proxy . newProxyInstance ( classLoader , itfaces , handler ) ;


signature:
public class ConcurrentUtils { /** * Waits on the condition but if end time is expired then throws an
 * exception . On purpose this method does not synchronize on the lock
 * because it must be called from a block which synchronizes on it
 * @ param condition the condition to wait on
 * @ param endTime the time after which an exception is thrown ( compared
 * to { @ link java . lang . System # currentTimeMillis ( ) } . If & lt ; 0 then wait
 * indefinitely ( so < code > TimeOutException < / code > will not be thrown ! )
 * @ throws InterruptedException if the thread is interrupted while waiting
 * @ throws TimeoutException if the time has been reached */
public static void awaitUntil ( Condition condition , long endTime ) throws InterruptedException , TimeoutException { } }

implementation: awaitUntil ( SystemClock . INSTANCE , condition , endTime ) ;


signature:
public class ConcurrentUtils { /** * Waits on the condition but if end time is expired then throws an
 * exception . On purpose this method does not synchronize on the lock
 * because it must be called from a block which synchronizes on it
 * @ param condition the condition to wait on
 * @ param endTime the time after which an exception is thrown ( compared
 * to { @ link java . lang . System # currentTimeMillis ( ) } . If & lt ; 0 then wait
 * indefinitely ( so < code > TimeOutException < / code > will not be thrown ! )
 * @ throws InterruptedException if the thread is interrupted while waiting
 * @ throws TimeoutException if the time has been reached */
public static void awaitUntil ( Clock clock , Condition condition , long endTime ) throws InterruptedException , TimeoutException { } }

implementation: if ( endTime <= 0 ) condition . await ( ) ; else { long now = clock . currentTimeMillis ( ) ; if ( now >= endTime ) throw new TimeoutException ( "timeout reached while waiting on the lock: " + condition ) ; if ( ! condition . await ( endTime - now , TimeUnit . MILLISECONDS ) ) throw new TimeoutException ( "timeout reached while waiting on the lock: " + condition ) ; }


signature:
public class ConcurrentUtils { /** * Waits on the lock but if end time is expired then throws an
 * exception . On purpose this method does not synchronize on the lock
 * because it must be called from a block which synchronizes on it
 * @ param lock the lock to wait on
 * @ param endTime the time after which an exception is thrown ( compared
 * to { @ link java . lang . System # currentTimeMillis ( ) } . If & lt ; 0 then wait
 * indefinitely ( so < code > TimeOutException < / code > will not be thrown ! )
 * @ throws InterruptedException if the thread is interrupted while waiting
 * @ throws TimeoutException if the time has been reached */
public static void awaitUntil ( Object lock , long endTime ) throws InterruptedException , TimeoutException { } }

implementation: awaitUntil ( SystemClock . INSTANCE , lock , endTime ) ;


signature:
public class ConcurrentUtils { /** * Waits on the lock but if end time is expired then throws an
 * exception . On purpose this method does not synchronize on the lock
 * because it must be called from a block which synchronizes on it
 * @ param lock the lock to wait on
 * @ param endTime the time after which an exception is thrown ( compared
 * to { @ link java . lang . System # currentTimeMillis ( ) } . If & lt ; 0 then wait
 * indefinitely ( so < code > TimeOutException < / code > will not be thrown ! )
 * @ throws InterruptedException if the thread is interrupted while waiting
 * @ throws TimeoutException if the time has been reached */
public static void awaitUntil ( Clock clock , Object lock , long endTime ) throws InterruptedException , TimeoutException { } }

implementation: if ( endTime <= 0 ) lock . wait ( ) ; else { long now = clock . currentTimeMillis ( ) ; if ( now >= endTime ) throw new TimeoutException ( "timeout reached while waiting on the lock: " + lock ) ; lock . wait ( endTime - now ) ; }


signature:
public class ConcurrentUtils { /** * Joins on the thread but if end time is expired then throws an exception .
 * @ param thread the thread to join on
 * @ param endTime the time after which an exception is thrown ( compared
 * to { @ link java . lang . System # currentTimeMillis ( ) } . If & lt ; = 0 then wait
 * indefinitely ( so < code > TimeOutException < / code > will not be thrown ! )
 * @ throws InterruptedException if the thread is interrupted while waiting
 * @ throws TimeoutException if the time has been reached */
public static void joinUntil ( Clock clock , Thread thread , long endTime ) throws InterruptedException , TimeoutException { } }

implementation: if ( endTime <= 0 ) thread . join ( ) ; else { while ( thread . isAlive ( ) ) { long now = clock . currentTimeMillis ( ) ; if ( now >= endTime ) throw new TimeoutException ( "timeout reached while joining on: " + thread ) ; thread . join ( endTime - now ) ; } }


signature:
public class ConcurrentUtils { /** * Joins on the thread but if end time is expired then throws an exception .
 * @ param thread the thread to join on
 * @ param timeout how long to join for ( < code > null < / code > or < = 0 means forever )
 * @ throws InterruptedException if the thread is interrupted while waiting
 * @ throws TimeoutException if the time has been reached */
public static void joinFor ( Clock clock , Thread thread , Object timeout ) throws InterruptedException , TimeoutException { } }

implementation: joinUntil ( clock , thread , ClockUtils . toEndTime ( timeout ) ) ;


signature:
public class ObjectProxyInvocationHandler { /** * This is a convenient call when you want to proxy an object with the unique given
 * interface . Note that you can use the more general call { @ link Proxy # newProxyInstance ( ClassLoader , Class [ ] , InvocationHandler ) }
 * if you want to do something different .
 * @ param interfaceToProxy the interface to proxy
 * @ param objectToProxy the object to proxy ( note that it must implement interfaceToProxy ! )
 * @ return the proxied object */
@ SuppressWarnings ( "unchecked" ) public static < T > T createProxy ( Class < T > interfaceToProxy , T objectToProxy ) { } }

implementation:
// since there is only one interface in the array , we know that the proxy must implement it !
return ( T ) Proxy . newProxyInstance ( interfaceToProxy . getClassLoader ( ) , new Class < ? > [ ] { interfaceToProxy } , new ObjectProxyInvocationHandler ( objectToProxy ) ) ;


signature:
public class ResourceChain { /** * Convenient method to create a chain from a list of resources . All the resources are turned into
 * roots before chaining ( otherwise it does not make a lot of sense . . . )
 * @ param resources the list of resources .
 * @ return the resource */
public static Resource create ( List < Resource > resources ) { } }

implementation: if ( resources . size ( ) == 1 ) return resources . get ( 0 ) . chroot ( "." ) ; List < InternalResourceProvider > providers = new ArrayList < InternalResourceProvider > ( resources . size ( ) ) ; for ( Resource resource : resources ) { resource = resource . chroot ( "." ) ; InternalResourceProvider provider = ( InternalResourceProvider ) ( ( InternalResource ) resource ) . getResourceProvider ( ) ; if ( provider instanceof ResourceProviderChain ) { ResourceProviderChain resourceProviderChain = ( ResourceProviderChain ) provider ; providers . addAll ( resourceProviderChain . getResourceProviders ( ) ) ; } else { providers . add ( provider ) ; } } return new ResourceProviderChain ( providers ) . getRootResource ( ) ;


signature:
public class OneWayMessageDigestCodec { /** * Encode the array into a < code > String < / code >
 * @ param byteArray the array to encode
 * @ return the encoded < code > String < / code > */
@ Override public String encode ( byte [ ] byteArray ) { } }

implementation:
MessageDigest md = null ; try { md = ( MessageDigest ) _md . clone ( ) ; } catch ( CloneNotSupportedException e ) { // should not happen . . . already tested in constructor ! !
throw new RuntimeException ( e ) ; } return _codec . encode ( md . digest ( byteArray ) ) ;