signature:
public class InboundProximityInterfaceImpl { /** * ( non - Javadoc )
 * @ see
 * it . polimi . spf . framework . proximity . ProximityResponder # sendContactRequest
 * ( it . polimi . spf . framework . security . FriendshipMessage ) */
@ Override public void sendContactRequest ( ContactRequest request ) { } }

implementation: Utils . logCall ( TAG , "sendContactRequest" ) ; mSpf . getSecurityMonitor ( ) . getPersonRegistry ( ) . onFriendShipMessageReceived ( request ) ;


signature:
public class InboundProximityInterfaceImpl { /** * ( non - Javadoc )
 * @ see
 * it . polimi . spf . framework . proximity . ProximityResponder # sendNotification
 * ( java . lang . String , java . lang . String ) */
@ Override public void sendNotification ( String uniqueIdentifier , SPFActionSendNotification action ) { } }

implementation: Utils . logCall ( TAG , "sendNotification" , uniqueIdentifier , action ) ; NotificationMessage message = new NotificationMessage ( uniqueIdentifier , action . getTitle ( ) , action . getMessage ( ) ) ; mSpf . getNotificationManager ( ) . onNotificationMessageReceived ( message ) ;


signature:
public class InboundProximityInterfaceImpl { /** * ( non - Javadoc )
 * @ see
 * it . polimi . spf . framework . proximity . InboundProximityInterface # sendActivity
 * ( java . lang . String ) */
@ Override public InvocationResponse sendActivity ( SPFActivity activity ) { } }

implementation: Utils . logCall ( TAG , "sendActivity" , activity ) ; InvocationResponse response ; try { response = SPF . get ( ) . getServiceRegistry ( ) . sendActivity ( activity ) ; } catch ( Throwable t ) { response = InvocationResponse . error ( "remote exception : " + t . getMessage ( ) ) ; } return response ;


signature:
public class InboundProximityInterfaceImpl { /** * ( non - Javadoc )
 * @ see it . polimi . spf . framework . proximity . ProximityResponder #
 * onSearchSignalReceived ( java . lang . String , java . lang . String ) */
@ Override public boolean onSearchSignalReceived ( String queryId , String queryJson ) { } }

implementation:
Utils . logCall ( TAG , "onSearchSignalReceived" , queryId , queryJson ) ; if ( new SearchResponder ( mSpf . getContext ( ) ) . matches ( queryJson ) ) { // XXX # SearchRefactor
// - Merge with trigger query responder
// - Use the right persona to fetch baseinfo ( app name can be found in query json )
// - Move everything in search maager and search performer classes
BaseInfo info = mSpf . getProfileManager ( ) . getBaseInfo ( SPFPersona . getDefault ( ) ) ; mSpf . sendSearchResult ( queryId , info ) ; return true ; } return false ;


signature:
public class InboundProximityInterfaceImpl { /** * ( non - Javadoc )
 * @ see it . polimi . spf . framework . proximity . ProximityResponder #
 * onSearchResultReceived ( java . lang . String , java . lang . String ,
 * java . lang . String ) */
@ Override public void onSearchResultReceived ( String searchId , String uniqueIdentifier , String baseInfo ) { } }

implementation: Utils . logCall ( TAG , "onSearchResultReceived" , searchId , uniqueIdentifier , baseInfo ) ; BaseInfo info = new Gson ( ) . fromJson ( baseInfo , BaseInfo . class ) ; mSpf . getSearchManager ( ) . onSearchResultReceived ( new SearchResult ( searchId , uniqueIdentifier , info ) ) ;


signature:
public class InboundProximityInterfaceImpl { /** * ( non - Javadoc )
 * @ see it . polimi . spf . framework . proximity . ProximityResponder #
 * onAdvertisingSignalReceived ( java . lang . String ) */
@ Override public void onAdvertisingSignalReceived ( String profileInfo ) { } }

implementation: Utils . logCall ( TAG , "onAdvertisingSignalReceived" , profileInfo ) ; SPFAdvProfile advProfile = SPFAdvProfile . fromJSON ( profileInfo ) ; mSpf . getNotificationManager ( ) . onAdvertisementReceived ( advProfile ) ;


signature:
public class InboundProximityInterfaceImpl { /** * ( non - Javadoc )
 * @ see it . polimi . spf . framework . proximity . ProximityResponder #
 * onRemoteInstanceFound
 * ( it . polimi . spf . framework . interfaces . SPFRemoteInstance ) */
@ Override public void onRemoteInstanceFound ( SPFRemoteInstance instance ) { } }

implementation: Utils . logCall ( TAG , "onRemoteInstanceFound" , instance ) ; mSpf . getPeopleManager ( ) . newPerson ( instance ) ;


signature:
public class InboundProximityInterfaceImpl { /** * ( non - Javadoc )
 * @ see
 * it . polimi . spf . framework . proximity . ProximityResponder # onRemoteInstanceLost
 * ( java . lang . String ) */
@ Override public void onRemoteInstanceLost ( String uniqueIdentifier ) { } }

implementation: Utils . logCall ( TAG , "OnRemoteInstanceLost" , uniqueIdentifier ) ; mSpf . getPeopleManager ( ) . removePerson ( uniqueIdentifier ) ; mSpf . getSearchManager ( ) . onInstanceLost ( uniqueIdentifier ) ;


signature:
public class XmlToJsonExtensions { /** * Creates from the given xml string a json string .
 * @ param xmlString
 * the xml as string object
 * @ param aliases
 * the aliases
 * @ return the json string . */
public static String toJson ( final String xmlString , final Map < String , Class < ? > > aliases ) { } }

implementation: final Object object = XmlToObjectExtensions . toObjectWithXStream ( xmlString ) ; final XStream xstream = new XStream ( new JettisonMappedXmlDriver ( ) ) ; if ( aliases != null ) { for ( final Map . Entry < String , Class < ? > > alias : aliases . entrySet ( ) ) { xstream . alias ( alias . getKey ( ) , alias . getValue ( ) ) ; } } final String json = xstream . toXML ( object ) ; return json ;


signature:
public class InvocationStub { /** * Creates an invocation stub to send service invocation requests to a
 * target { @ link Target } performing method calls . The stub is created from a
 * provided service interface , which must be annotated with
 * { @ link ServiceInterface } describing the service . The method returns an
 * object implementing the aforementioned interface that can be used to
 * perform method invocation .
 * @ param target
 * - the target who the service invocation requests will be
 * dispatched to .
 * @ param serviceInterface
 * - the interface of the service .
 * @ param classLoader
 * - the ClassLoader to load classes .
 * @ return an invocation stub to perform method calls . */
static < E > E from ( Class < E > serviceInterface , ClassLoader classLoader , Target target ) { } }

implementation:
Utils . notNull ( target , "target must not be null" ) ; Utils . notNull ( serviceInterface , "descriptor must not be null" ) ; if ( classLoader == null ) { classLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; } // Validate service
ServiceValidator . validateInterface ( serviceInterface , ServiceValidator . TYPE_REMOTE ) ; ServiceInterface service = serviceInterface . getAnnotation ( ServiceInterface . class ) ; SPFServiceDescriptor desc = ServiceInterface . Convert . toServiceDescriptor ( service ) ; InvocationStub stub = InvocationStub . from ( desc , target ) ; InvocationHandler h = new InvocationHandlerAdapter ( stub ) ; Object proxy = Proxy . newProxyInstance ( classLoader , new Class [ ] { serviceInterface } , h ) ; return serviceInterface . cast ( proxy ) ;


signature:
public class InvocationStub { /** * Creates an invocation stub to send service invocation requests to a
 * target { @ link Target } providing the name and the parameter list . The
 * object is created from a { @ link ServiceDescriptor } containing the
 * required details .
 * @ param target
 * - the target who the service invocation requests will be
 * dispatched to .
 * @ param descriptor
 * - the { @ link ServiceDescriptor } of the service whose methods
 * to invoke .
 * @ return a { @ link InvocationStub } to perform invocations of remote
 * services . */
static InvocationStub from ( SPFServiceDescriptor descriptor , Target target ) { } }

implementation: Utils . notNull ( target , "target must not be null" ) ; Utils . notNull ( descriptor , "descriptor must not be null" ) ; return new InvocationStub ( descriptor , target ) ;


signature:
public class InvocationStub { /** * Invokes a remote service providing the name of the method to invoke name
 * and the list of parameters . The invocation is a blocking network request
 * and thus should not be performed on the main thread .
 * @ param methodName
 * - the name of the method to invoke .
 * @ param args
 * - the array of the parameters to pass to the method .
 * @ return the return value of the method , if any , or null if the method
 * returns void .
 * @ throws ServiceInvocationException
 * if an invocation is thrown during the execution of the
 * service . */
public Object invokeMethod ( String methodName , Object [ ] args , Type retType ) throws ServiceInvocationException { } }

implementation:
checkCurrentThread ( methodName ) ; Utils . notNull ( methodName ) ; Utils . notNull ( args ) ; // Let the target prepare the arguments if needed
mInvocationTarget . prepareArguments ( args ) ; // Serialize arguments
String payload = GsonHelper . gson . toJson ( args ) ; InvocationRequest request = new InvocationRequest ( mServiceDescriptor . getAppIdentifier ( ) , mServiceDescriptor . getServiceName ( ) , methodName , payload ) ; // Let the target perform the execution
InvocationResponse response = mInvocationTarget . executeService ( request ) ; // Analyze the response
if ( ! response . isResult ( ) ) { throw new ServiceInvocationException ( response . getErrorMessage ( ) ) ; } else if ( retType . equals ( void . class ) ) { return null ; } else { return GsonHelper . gson . fromJson ( response . getPayload ( ) , retType ) ; }


signature:
public class InvocationStub { /** * Checks if the current thread is the main thread , if so it logs a wrning . */
private void checkCurrentThread ( String methodName ) { } }

implementation: if ( Looper . myLooper ( ) == Looper . getMainLooper ( ) ) { Log . w ( TAG , String . format ( WRONG_THREAD_MSG , mServiceDescriptor . getServiceName ( ) , methodName ) ) ; }


signature:
public class Utils { /** * Helper to log a call to a method
 * @ param tag
 * - the tag
 * @ param methodName
 * - the name of the method
 * @ param args
 * - the method args */
public static void logCall ( String tag , String methodName , Object ... args ) { } }

implementation: if ( SPFConfig . DEBUG ) { Log . d ( tag , "method call: " + methodName + "(" + ( args != null ? TextUtils . join ( "," , args ) : "" ) + ")" ) ; }


signature:
public class XmlExtensions { /** * Load from the given file name that should represent an xml file and transform it to the
 * generic type object .
 * @ param < T >
 * the generic type
 * @ param xmlFile
 * the xml file
 * @ return the object from the given xml file .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static < T > T loadObject ( final File xmlFile ) throws IOException { } }

implementation: final InputStream is = FileUtils . openInputStream ( xmlFile ) ; return loadObject ( is ) ;


signature:
public class XmlExtensions { /** * Load from the given input stream that should represent an xml file and transform it to the
 * generic type object .
 * @ param < T >
 * the generic type
 * @ param is
 * the input stream
 * @ return the object from the given input stream .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
private static < T > T loadObject ( final InputStream is ) throws IOException { } }

implementation: final String xmlString = ReadFileExtensions . inputStream2String ( is ) ; final T object = XmlToObjectExtensions . toObjectWithXStream ( xmlString ) ; return object ;


signature:
public class XmlExtensions { /** * Load from the given file name that should represent an xml file and transform it to the
 * generic type object .
 * @ param < T >
 * the generic type
 * @ param xmlFileName
 * the xml file name
 * @ return the object from the given xml file .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static < T > T loadObject ( final String xmlFileName ) throws IOException { } }

implementation: final InputStream is = ClassExtensions . getResourceAsStream ( xmlFileName ) ; return loadObject ( is ) ;


signature:
public class XmlExtensions { /** * Creates a tag from the given string values . Can be used for creating html or xml tags .
 * @ param tagname
 * the tag name
 * @ param value
 * the value from the tag
 * @ param attributes
 * a map with the attributes
 * @ return the string */
public static String newTag ( final String tagname , final String value , final Map < String , String > attributes ) { } }

implementation: final StringBuilder xmlTag = new StringBuilder ( ) ; xmlTag . append ( "<" ) . append ( tagname ) ; if ( attributes != null && ! attributes . isEmpty ( ) ) { xmlTag . append ( " " ) ; int count = 1 ; for ( final Map . Entry < String , String > attributte : attributes . entrySet ( ) ) { xmlTag . append ( attributte . getKey ( ) ) ; xmlTag . append ( "=" ) ; xmlTag . append ( "\"" ) . append ( attributte . getValue ( ) ) . append ( "\"" ) ; if ( count != attributes . size ( ) ) { xmlTag . append ( " " ) ; } count ++ ; } } xmlTag . append ( ">" ) ; xmlTag . append ( value ) ; xmlTag . append ( "</" ) . append ( tagname ) . append ( ">" ) ; return xmlTag . toString ( ) ;


signature:
public class SearchResponder { /** * Verifies if the local profile matches the given query .
 * @ see Query
 * @ param q
 * @ return */
public boolean matches ( String queryJSON ) { } }

implementation: QueryContainer queryContainer ; try { queryContainer = QueryContainer . fromJSON ( queryJSON ) ; } catch ( JSONException e ) { return false ; } SPFQuery query = queryContainer . getQuery ( ) ; String callerApp = queryContainer . getCallerAppId ( ) ; String userUID = queryContainer . getUserUID ( ) ; return analyzeWith ( query , callerApp , userUID ) ;


signature:
public class SPFServiceManagerImpl { /** * ( non - Javadoc )
 * @ see it . polimi . spf . framework . local . LocalServiceManager # registerService
 * ( java . lang . String , it . polimi . spf . framework . local . ServiceDescriptor ) */
@ Override public boolean registerService ( String accessToken , SPFServiceDescriptor descriptor , SPFError error ) throws RemoteException { } }

implementation: Utils . logCall ( TAG , "registerService" , accessToken , descriptor , error ) ; try { mSecurityMonitor . validateAccess ( accessToken , Permission . REGISTER_SERVICES ) ; } catch ( TokenNotValidException e ) { error . setCode ( SPFError . TOKEN_NOT_VALID_ERROR_CODE ) ; return false ; } catch ( PermissionDeniedException e ) { error . setError ( SPFError . PERMISSION_DENIED_ERROR_CODE , "Missing permission: " + Permission . REGISTER_SERVICES ) ; return false ; } return SPF . get ( ) . getServiceRegistry ( ) . registerService ( descriptor ) ;


signature:
public class SPFServiceManagerImpl { /** * ( non - Javadoc )
 * @ see
 * it . polimi . spf . framework . local . LocalServiceManager # executeLocalService
 * ( java . lang . String , it . polimi . spf . framework . local . InvocationRequest ) */
@ Override public InvocationResponse executeLocalService ( String accessToken , InvocationRequest request , SPFError error ) throws RemoteException { } }

implementation: Utils . logCall ( TAG , "executeLocalService" , accessToken , request , error ) ; try { mSecurityMonitor . validateAccess ( accessToken , Permission . EXECUTE_LOCAL_SERVICES ) ; } catch ( TokenNotValidException e ) { error . setCode ( SPFError . TOKEN_NOT_VALID_ERROR_CODE ) ; return null ; } catch ( PermissionDeniedException e ) { error . setError ( SPFError . PERMISSION_DENIED_ERROR_CODE , "Missing capability: " + Permission . EXECUTE_LOCAL_SERVICES ) ; return null ; } try { return SPF . get ( ) . getServiceRegistry ( ) . dispatchInvocation ( request ) ; } catch ( Throwable t ) { error . setError ( SPFError . REMOTE_EXC_ERROR_CODE , t . getClass ( ) . getSimpleName ( ) ) ; return null ; }


signature:
public class SPFServiceManagerImpl { /** * ( non - Javadoc )
 * @ see
 * it . polimi . spf . shared . aidl . LocalServiceManager # unregisterService ( java .
 * lang . String , it . polimi . spf . shared . model . SPFServiceDescriptor ,
 * it . polimi . spf . shared . model . SPFError ) */
@ Override public boolean unregisterService ( String accessToken , SPFServiceDescriptor descriptor , SPFError error ) throws RemoteException { } }

implementation:
Utils . logCall ( TAG , "unregisterService" , accessToken , descriptor , error ) ; // try {
// mSecurityMonitor . validateAccess ( accessToken ,
// Permission . REGISTER _ SERVICES ) ;
// } catch ( TokenNotValidException e ) {
// error . setCode ( SPFError . TOKEN _ NOT _ VALID _ ERROR _ CODE ) ;
// return false ;
// } catch ( PermissionDeniedException e ) {
// error . setError ( SPFError . PERMISSION _ DENIED _ ERROR _ CODE ,
// " Missing capability : " + Permission . EXECUTE _ LOCAL _ SERVICES ) ;
// return false ;
// / / TODO check that the application removing the service is the one
// that
// / / registered it
// return SPF . get ( ) . getServiceRegistry ( ) . unregisterService ( descriptor ) ;
Log . w ( TAG , "Services cannot be unregistered by apps due to ActivityStream" ) ; return false ;


signature:
public class SPFServiceRegistry { /** * Dispatches an invocation request to the right application . If the
 * application is not found , an error response is returned .
 * @ param request
 * @ return */
public InvocationResponse dispatchInvocation ( InvocationRequest request ) { } }

implementation: String appName = request . getAppName ( ) ; String serviceName = request . getServiceName ( ) ; String componentName = mServiceTable . getComponentForService ( appName , serviceName ) ; if ( componentName == null ) { return InvocationResponse . error ( "Application " + appName + " doesn't have a service named " + serviceName ) ; } AppServiceProxy proxy = mCommunicationAgent . getProxy ( componentName ) ; if ( proxy == null ) { return InvocationResponse . error ( "Cannot bind to service" ) ; } try { return proxy . executeService ( request ) ; } catch ( Throwable t ) { Log . e ( "ServiceRegistry" , "Error dispatching invocation: " , t ) ; return InvocationResponse . error ( "Internal error: " + t . getMessage ( ) ) ; }


signature:
public class SPFServiceRegistry { /** * Dispatches an activity to the right application according to { @ link
 * ActivityConsumerRouteTable # }
 * @ param activity
 * @ return */
public InvocationResponse sendActivity ( SPFActivity activity ) { } }

implementation: ServiceIdentifier id = mActivityTable . getServiceFor ( activity ) ; String componentName = mServiceTable . getComponentForService ( id ) ; if ( componentName == null ) { String msg = "No service to handle " + activity ; Log . d ( TAG , msg ) ; return InvocationResponse . error ( msg ) ; } AppServiceProxy proxy = mCommunicationAgent . getProxy ( componentName ) ; if ( proxy == null ) { String msg = "Can't bind to service " + componentName ; Log . d ( TAG , msg ) ; return InvocationResponse . error ( msg ) ; } try { InvocationResponse r = proxy . sendActivity ( activity ) ; Log . v ( TAG , "Activity dispatched: " + r ) ; return r ; } catch ( Throwable t ) { Log . e ( TAG , "Error dispatching invocation: " , t ) ; return InvocationResponse . error ( "Internal error: " + t . getMessage ( ) ) ; }


signature:
public class SPFServiceRegistry { /** * Allows to register a service in the service index . Such service is made
 * available to remote apps .
 * @ param serviceInterface
 * @ param implementation */
@ Deprecated public < T > void registerService ( Class < ? super T > serviceInterface ) { } }

implementation: Utils . notNull ( serviceInterface , "serviceInterface must not be null" ) ; ServiceInterface annotation = serviceInterface . getAnnotation ( ServiceInterface . class ) ; if ( annotation == null ) { throw new IllegalServiceException ( "Missing annotation" ) ; } String flattenComponentName = annotation . componentName ( ) ; if ( flattenComponentName == null ) { throw new IllegalStateException ( "Missing componentName" ) ; } ComponentName cn = ComponentName . unflattenFromString ( flattenComponentName ) ; registerService ( serviceInterface , cn ) ;


signature:
public class SPFServiceRegistry { /** * Allows to register a service in the service index . Such service is made
 * available to remote apps .
 * @ param serviceInterface
 * @ param implementation */
public < T > void registerService ( Class < ? super T > serviceInterface , Class < T > implementationClass ) { } }

implementation: Utils . notNull ( serviceInterface , "serviceInterface must not be null" ) ; Utils . notNull ( implementationClass , "implementationClass must not be null" ) ; ComponentName cn = new ComponentName ( getContext ( ) , implementationClass ) ; registerService ( serviceInterface , cn ) ;


signature:
public class SPFServiceRegistry { /** * Allows to unregister a previously registered service .
 * @ param serviceInterface */
public < T > void unregisterService ( Class < ? super T > serviceInterface ) { } }

implementation: Utils . notNull ( serviceInterface , "serviceInterface must not be null" ) ; ServiceValidator . validateInterface ( serviceInterface , ServiceValidator . TYPE_PUBLISHED ) ; ServiceInterface svcInterface = serviceInterface . getAnnotation ( ServiceInterface . class ) ; SPFServiceDescriptor svcDesc = ServiceInterface . Convert . toServiceDescriptor ( svcInterface ) ; String token = getAccessToken ( ) ; try { SPFError error = new SPFError ( ) ; getService ( ) . unregisterService ( token , svcDesc , error ) ; if ( ! error . isOk ( ) ) { handleError ( error ) ; } } catch ( RemoteException e ) { catchRemoteException ( e ) ; }


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

implementation: try { getWriter ( ) . write ( s ) ; getWriter ( ) . flush ( ) ; } catch ( final IOException e ) { throw new SAXException ( "I/O error" , e ) ; }


signature:
public class WfdMessage { /** * Returns a { @ link WfdMessage } given its string representation . If the
 * string cannot be parsed returns null .
 * @ param str
 * @ return */
public static WfdMessage fromString ( String str ) throws MessageException { } }

implementation: if ( str == null ) { throw new MessageException ( MessageException . Reason . NULL_MESSAGE ) ; } JsonObject o = new JsonParser ( ) . parse ( str ) . getAsJsonObject ( ) ; WfdMessage msg = new WfdMessage ( ) ; msg . msgContent = o . getAsJsonObject ( KEY_MSG_CONTENT ) ; msg . type = o . get ( KEY_MSG_TYPE ) . getAsString ( ) ; if ( msg . type . equals ( TYPE_REQUEST ) || msg . type . equals ( TYPE_RESPONSE ) ) { msg . sequenceNumber = o . get ( KEY_TIMESTAMP ) . getAsLong ( ) ; } else { msg . sequenceNumber = - 1 ; } msg . receiverId = o . get ( KEY_RECEIVER_ID ) . getAsString ( ) ; msg . senderId = o . get ( KEY_SENDER_ID ) . getAsString ( ) ; return msg ;


signature:
public class ObjectToXmlExtensions { /** * Creates from the given Object an xml string .
 * @ param < T >
 * the generic type of the return type
 * @ param obj
 * the obj to transform to an xml string .
 * @ return the xml string */
public static < T > String toXmlWithXMLEncoder ( final T obj ) { } }

implementation: XMLEncoder enc = null ; final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; enc = new XMLEncoder ( baos ) ; enc . writeObject ( obj ) ; enc . close ( ) ; return baos . toString ( ) ;


signature:
public class ObjectToXmlExtensions { /** * Creates from the given Object an xml string . The given map hold the aliases . For more
 * information with aliasing see documation of xstream .
 * @ param < T >
 * the generic type of the object that will be transformed to xml
 * @ param objectToXML
 * the object to xml
 * @ param aliases
 * the aliases
 * @ return the xml string */
public static < T > String toXmlWithXStream ( final T objectToXML , final Map < String , Class < ? > > aliases ) { } }

implementation: return toXmlWithXStream ( null , objectToXML , aliases ) ;


signature:
public class ObjectToXmlExtensions { /** * Creates from the given Object an xml string .
 * @ param < T >
 * the generic type of the object that will be transformed to xml
 * @ param xstream
 * the xstream object .
 * @ param objectToXML
 * the object to xml
 * @ return the xml string */
public static < T > String toXmlWithXStream ( final XStream xstream , final T objectToXML ) { } }

implementation: return toXmlWithXStream ( xstream , objectToXML , null ) ;


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

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


signature:
public class SearchScheduler { /** * Start a new search .
 * @ param appIdentifier
 * - the package name of the caller app
 * @ param searchDescriptor
 * - a descriptor specifying query and settings
 * @ return the identifier of the query */
void startSearch ( QueryInfo queryInfo ) { } }

implementation: Message msg = handler . obtainMessage ( SearchMessages . SEARCH_STARTED , queryInfo ) ; handler . sendMessage ( msg ) ;


signature:
public class SearchScheduler { /** * Registers and starts the search operation as specified in queryInfo .
 * @ param callback
 * @ param queryInfo
 * @ return the query id */
QueryInfo registerSearch ( String appIdentifier , SPFSearchDescriptor searchDescriptor , SPFSearchCallback callback ) { } }

implementation:
// convert SearchDescriptor to internal representation
// register the query and return the assigned id
QueryInfo queryInfo = QueryInfo . create ( appIdentifier , searchDescriptor ) ; String queryId = generateQueryId ( queryInfo ) ; queries . put ( queryId , queryInfo ) ; performer . registerSearchCallback ( callback , queryInfo ) ; log ( TAG , "registering query with queryId: " + queryId ) ; return queryInfo ;


signature:
public class SearchScheduler { /** * Generate a query id for the specified query . The query id is assigned to
 * the query descriptor .
 * @ param queryInfo
 * @ return the query id */
private String generateQueryId ( QueryInfo queryInfo ) { } }

implementation: String queryId = SPF . get ( ) . getUniqueIdentifier ( ) + ( ++ id ) ; queryInfo . setQueryId ( queryId ) ; return queryId ;


signature:
public class SearchScheduler { /** * Emits the search signal through the { @ link SearchPerformer } object .
 * @ param queryId
 * the query for which the search signal has to be emitted . */
private void sendSearchSignal ( String queryId ) { } }

implementation: log ( TAG , "handler is asking for a search signal" ) ; QueryInfo qd = queries . get ( queryId ) ; if ( qd != null ) { performer . sendSearchSignal ( qd ) ; }


signature:
public class SearchScheduler { /** * Schedules the next operation of the handler , according to the query
 * settings . It uses and updates the information contained in the QueryInfo
 * object . If the search operation is not terminated a message is sent to
 * the handler with the proper delay ; otherwise the query is eliminated and
 * the event is notified to the { @ link SearchPerformer } .
 * @ param queryId */
private void scheduleNextAction ( String queryId ) { } }

implementation: log ( TAG , "handler is scheduling next action" ) ; QueryInfo qd = queries . get ( queryId ) ; if ( qd == null ) { return ; } if ( qd . getRemainingSignals ( ) > 0 ) { Message msg = handler . obtainMessage ( SearchMessages . SEND_SIGNAL , queryId ) ; handler . sendMessageDelayed ( msg , qd . getSignalPeriod ( ) ) ; qd . decrementRemainingSignals ( ) ; } else { Message message = handler . obtainMessage ( SearchMessages . SEARCH_STOPPED , qd ) ; handler . sendMessageDelayed ( message , qd . getSignalPeriod ( ) ) ; }


signature:
public class SearchScheduler { /** * Call this method when the middleware notify that a spf instance is lost .
 * It will notify the event to all the active searches that have the lost
 * instance in their results .
 * @ param uniqueIdentifier
 * the identifier of the lost instance */
void onInstanceLost ( String uniqueIdentifier ) { } }

implementation: log ( TAG , "instance lost " + uniqueIdentifier ) ; List < String > queriesIds = results . get ( uniqueIdentifier ) ; if ( queriesIds == null ) { return ; } for ( String queryId : queriesIds ) { String [ ] args = new String [ 2 ] ; args [ 0 ] = queryId ; args [ 1 ] = uniqueIdentifier ; Message msg = handler . obtainMessage ( SearchMessages . RESULT_LOST , args ) ; log ( TAG , "sending message RESULT_LOST to handler for queryId: " + queryId ) ; handler . sendMessage ( msg ) ; }


signature:
public class SearchScheduler { /** * Call this method to stop the search and release the associated resources .
 * The application will not be notified about the event ;
 * @ param qd
 * @ return */
void stopSearch ( String queryId ) { } }

implementation: QueryInfo info = queries . get ( queryId ) ; if ( info != null ) { stopSearch ( info ) ; }


signature:
public class SearchScheduler { /** * Unregister all the active queries associated with the given
 * appIdentifier . Application will not be notified about the event . */
void stopAllSearches ( String appIdentifier ) { } }

implementation: List < QueryInfo > qinfos ; synchronized ( queries ) { qinfos = new ArrayList < QueryInfo > ( queries . values ( ) ) ; } for ( QueryInfo queryInfo : qinfos ) { if ( queryInfo . getAppName ( ) . equals ( appIdentifier ) ) { stopSearch ( queryInfo ) ; } }


signature:
public class SPF { /** * Creates a connection to SPF asynchronously .
 * @ param context
 * - the context used to bind to SPF service .
 * @ param listener
 * - the listener that is notified when the connection to SPF is
 * ready , when the connection is closed or when an error occurs . */
public static void connect ( final Context context , final ConnectionListener listener ) { } }

implementation: Component . load ( context , DESCRIPTOR , asBase ( listener ) ) ;


signature:
public class SPF { /** * FIXME ConnectionListener should extends ConnectionCallback < SPF > , but method names are different */
private static ConnectionCallback < SPF > asBase ( final ConnectionListener listener ) { } }

implementation: return new ConnectionCallback < SPF > ( ) { @ Override public void onServiceReady ( SPF serviceInterface ) { listener . onConnected ( serviceInterface ) ; } @ Override public void onError ( SPFError err ) { listener . onError ( err ) ; } @ Override public void onDisconnect ( ) { listener . onDisconnected ( ) ; } } ;


signature:
public class SPF { /** * Provides access to the different components of SPF . The components are
 * identified by static constants available in this class , and all share a
 * common superclass , { @ link SPFComponent } ; the instances returned vy this
 * method should be casted to the right class . Available services are :
 * < ul >
 * < li > { @ link # SEARCH } : Searching of people in proximity . Returned
 * instance should be casted to { @ link SPFSearch } < / li >
 * < li > { @ link # SERVICE _ EXECUTION } : Execution of remote methods .
 * Returned instance should be casted to { @ link SPFServiceExecutor } < / li >
 * < li > { @ link # REMOTE _ PROFILE } : Retrieval of information from
 * remote profiles . Returned instances should be casted to
 * { @ link SPFRemoteProfile } < / li >
 * < / ul >
 * @ param code
 * @ return */
@ SuppressWarnings ( "unchecked" ) public synchronized < E > E getComponent ( int code ) { } }

implementation: switch ( code ) { case REMOTE_PROFILE : if ( spfRemoteProfile == null ) { spfRemoteProfile = new SPFRemoteProfile ( getContext ( ) , this ) ; } return ( E ) spfRemoteProfile ; case SEARCH : if ( spfSearch == null ) { spfSearch = new SPFSearch ( getContext ( ) , this ) ; } return ( E ) spfSearch ; case SERVICE_EXECUTION : if ( spfServiceExecutor == null ) { spfServiceExecutor = new SPFServiceExecutor ( getContext ( ) , this ) ; } return ( E ) spfServiceExecutor ; default : throw new IllegalArgumentException ( "Component code " + code + " not found." ) ; }


signature:
public class SPF { /** * Implementation of SearchInterface ( non - Javadoc )
 * @ see it . polimi . spf . lib . async . search . SearchInterface # startSearch ( it . polimi
 * . dei . spf . framework . local . SearchDescriptor ,
 * it . polimi . spf . lib . async . search . SearchInterface . SearchStartedCallback ) */
public void startSearch ( SPFSearchDescriptor searchDescriptor , SPFSearchCallback callback ) { } }

implementation:
try { SPFError err = new SPFError ( ) ; getService ( ) . startNewSearch ( getAccessToken ( ) , searchDescriptor , callback , err ) ; if ( ! err . isOk ( ) ) { handleError ( err ) ; } } catch ( RemoteException e ) { // TODO Error management
e . printStackTrace ( ) ; }


signature:
public class SPF { /** * ( non - Javadoc )
 * @ see it . polimi . spf . lib . async . search . SearchInterface # stopSearch ( java . lang
 * . String ) */
public void stopSearch ( String queryId ) { } }

implementation:
try { SPFError err = new SPFError ( ) ; getService ( ) . stopSearch ( getAccessToken ( ) , queryId , err ) ; if ( ! err . isOk ( ) ) { handleError ( err ) ; } } catch ( RemoteException e ) { // TODO : error management
}


signature:
public class SPF { /** * ( non - Javadoc )
 * @ see
 * it . polimi . spf . lib . async . search . SearchInterface # lookup ( java . lang . String ) */
public boolean lookup ( String identifier ) { } }

implementation:
try { SPFError err = new SPFError ( ) ; boolean found = getService ( ) . lookup ( getAccessToken ( ) , identifier , err ) ; if ( err . isOk ( ) ) { return found ; } else { handleError ( err ) ; return false ; } } catch ( RemoteException e ) { // TODO Error Management
Log . d ( TAG , "Remote exception while executing lookup on " + identifier , e ) ; return false ; }


signature:
public class SPF { /** * ( non - Javadoc )
 * @ see
 * it . polimi . spf . lib . async . profile . RemoteProfileInterface # getProfileBulk
 * ( java . lang . String , java . lang . String [ ] ,
 * it . polimi . spf . framework . local . SPFError ) */
public ProfileFieldContainer getProfileBulk ( String identifier , String [ ] fields , SPFError err ) { } }

implementation: String accessToken = getAccessToken ( ) ; try { ProfileFieldContainer pfc = getService ( ) . getProfileBulk ( accessToken , identifier , fields , err ) ; if ( err . isOk ( ) ) { return pfc ; } } catch ( RemoteException e ) { Log . e ( TAG , "Error @ getProfileBulk" , e ) ; } handleError ( err ) ; return null ;


signature:
public class SPF { /** * ( non - Javadoc )
 * @ see it . polimi . spf . lib . async . services . execution . ServiceExecutionInterface
 * # sendActivity ( it . polimi . spf . framework . local . SPFActivity ) */
public InvocationResponse sendActivity ( String target , SPFActivity activity ) { } }

implementation: String token = getAccessToken ( ) ; SPFError err = new SPFError ( ) ; InvocationResponse resp ; try { getService ( ) . injectInformationIntoActivity ( token , target , activity , err ) ; if ( ! err . isOk ( ) ) { handleError ( err ) ; return InvocationResponse . error ( err . toString ( ) ) ; } resp = getService ( ) . sendActivity ( token , target , activity , err ) ; } catch ( RemoteException e ) { return InvocationResponse . error ( e ) ; } if ( ! err . isOk ( ) ) { handleError ( err ) ; resp = InvocationResponse . error ( err . toString ( ) ) ; } return resp ;


signature:
public class SPFSearchManager { /** * Start a new search .
 * @ param appIdentifier
 * - the package name of the caller app
 * @ param searchDescriptor
 * - a descriptor specifying query and settings
 * @ return the identifier of the query */
public String startSearch ( String appIdentifier , SPFSearchDescriptor searchDescriptor , SPFSearchCallback callback ) { } }

implementation: QueryInfo queryInfo = mSearchScheduler . registerSearch ( appIdentifier , searchDescriptor , callback ) ; mSearchScheduler . startSearch ( queryInfo ) ; return queryInfo . getQueryId ( ) ;


signature:
public class PackageChangeReceiver { /** * ( non - Javadoc )
 * @ see android . content . BroadcastReceiver # onReceive ( android . content . Context ,
 * android . content . Intent ) */
@ Override public void onReceive ( Context context , Intent intent ) { } }

implementation:
String action = intent . getAction ( ) ; SPFSecurityMonitor securityMonitor = SPF . get ( ) . getSecurityMonitor ( ) ; String packageIdentifier = intent . getData ( ) . getSchemeSpecificPart ( ) ; if ( action . equals ( Intent . ACTION_PACKAGE_ADDED ) ) { // TODO Maybe we can check if the app wants to use SPF ?
} else if ( action . equals ( Intent . ACTION_PACKAGE_REMOVED ) ) { if ( intent . getBooleanExtra ( Intent . EXTRA_REPLACING , false ) ) { Log . d ( TAG , "App " + packageIdentifier + " is being updated - do not remove" ) ; return ; } if ( securityMonitor . isAppRegistered ( packageIdentifier ) ) { securityMonitor . unregisterApplication ( packageIdentifier ) ; Log . d ( TAG , "App " + packageIdentifier + " uninstalled from SPF" ) ; } else { Log . d ( TAG , "App " + packageIdentifier + " was not installed in SPF" ) ; } }


signature:
public class ProfileFieldViewFactory { /** * Creates a new view to visualize the value and the clearance of the given
 * profile field . If the { @ link Mode } of visualization is { @ link Mode # EDIT } ,
 * the view will support modifications . Such modifications will trigger the
 * appropriate call to a { @ link FieldValueListener } , if provided .
 * @ param field
 * - the field to visualize
 * @ param container
 * - the { @ link ViewGroup } to which the view is intended to be
 * attached , as in { @ link LayoutInflater # inflate ( int , ViewGroup ) }
 * @ param listener
 * - the listener that will be notified of value or clearance
 * changes in { @ link Mode # EDIT } mode .
 * @ return - the view that visualizes the profile field . Please note that
 * the view is < strong > NOT < / strong > attached to the container ; */
@ SuppressWarnings ( "unchecked" ) public < E > View createViewForField ( ProfileField < E > field , ViewGroup container , FieldValueListener < E > listener ) { } }

implementation: E currentValue = mContainer . getFieldValue ( field ) ; if ( field instanceof TagProfileField ) { return createTagView ( ( TagProfileField ) field , ( String [ ] ) currentValue , listener , container , mMode == Mode . EDIT ) ; } switch ( mMode ) { case SELF : case REMOTE : return createStandardDisplayView ( field , currentValue , container ) ; case EDIT : if ( field instanceof MultipleChoicheProfileField ) { return createSpinner ( ( MultipleChoicheProfileField < E > ) field , currentValue , listener , container ) ; } else if ( field instanceof DateProfileField ) { return createDateView ( ( DateProfileField ) field , ( Date ) currentValue , ( FieldValueListener < Date > ) listener , container ) ; } else { return createStandardEditView ( field , currentValue , listener , container ) ; } default : return null ; }


signature:
public class ProfileFieldViewFactory { /** * Standard display view for all profile fields except tags */
private < E > View createStandardDisplayView ( ProfileField < E > field , E currentValue , ViewGroup viewContainer ) { } }

implementation: View result = mInflater . inflate ( R . layout . profileview_field_listelement , viewContainer , false ) ; String friendlyFieldName = mHelper . getFriendlyNameOfField ( field ) ; ( ( TextView ) result . findViewById ( R . id . profile_field_key ) ) . setText ( friendlyFieldName ) ; String fieldValue = mHelper . convertToFriendlyString ( field , currentValue ) ; ( ( TextView ) result . findViewById ( R . id . profile_field_value ) ) . setText ( fieldValue ) ; setUpCircleView ( result , field , null ) ; return result ;


signature:
public class ProfileFieldViewFactory { /** * Edit view for multiple choiche fields */
private < E > View createSpinner ( MultipleChoicheProfileField < E > field , E currentValue , FieldValueListener < E > listener , ViewGroup container ) { } }

implementation: View result = mInflater . inflate ( R . layout . profileedit_field_multiplechoiche , container , false ) ; String friendlyName = mHelper . getFriendlyNameOfField ( field ) ; ( ( TextView ) result . findViewById ( R . id . profileedit_field_identifier ) ) . setText ( friendlyName ) ; Spinner spinner = ( Spinner ) result . findViewById ( R . id . profileedit_field_multiple_value ) ; ArrayAdapter < E > adapter = new ArrayAdapter < E > ( mContext , android . R . layout . simple_list_item_1 , field . getChoiches ( ) ) ; spinner . setAdapter ( adapter ) ; int index = indexOf ( field . getChoiches ( ) , currentValue ) ; if ( index >= 0 ) { spinner . setSelection ( index , false ) ; } spinner . setOnItemSelectedListener ( new OnItemSelectedAdapter < E > ( field , listener , adapter ) ) ; setUpCircleView ( result , field , listener ) ; return result ;


signature:
public class ProfileFieldViewFactory { /** * Edit view for date fields */
@ SuppressWarnings ( "unchecked" ) private < E > View createDateView ( final DateProfileField field , Date currentValue , final FieldValueListener < Date > listener , ViewGroup container ) { } }

implementation: View result = mInflater . inflate ( R . layout . profileedit_field_date , container , false ) ; String friendlyName = mHelper . getFriendlyNameOfField ( field ) ; ( ( TextView ) result . findViewById ( R . id . profileedit_field_identifier ) ) . setText ( friendlyName ) ; String dateToShow ; if ( currentValue == null ) { dateToShow = "Click to edit" ; } else { dateToShow = mHelper . convertToFriendlyString ( field , currentValue ) ; } final TextView dateTextView = ( TextView ) result . findViewById ( R . id . profileedit_field_date_text ) ; dateTextView . setText ( dateToShow ) ; dateTextView . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { Calendar today = GregorianCalendar . getInstance ( ) ; int year = today . get ( Calendar . YEAR ) ; int monthOfYear = today . get ( Calendar . MONTH ) ; int dayOfMonth = today . get ( Calendar . DAY_OF_MONTH ) ; OnDateSetListener callBack = new OnDateSetListener ( ) { @ Override public void onDateSet ( DatePicker view , int year , int monthOfYear , int dayOfMonth ) { GregorianCalendar cal = new GregorianCalendar ( year , monthOfYear , dayOfMonth ) ; Date newDate = new Date ( cal . getTimeInMillis ( ) ) ; String newDateString = mHelper . convertToFriendlyString ( field , newDate ) ; dateTextView . setText ( newDateString ) ; listener . onFieldValueChanged ( field , newDate ) ; } } ; DatePickerDialog dialog = new DatePickerDialog ( mContext , callBack , year , monthOfYear , dayOfMonth ) ; dialog . show ( ) ; } } ) ; setUpCircleView ( result , ( ProfileField < E > ) field , ( FieldValueListener < E > ) listener ) ; return result ;


signature:
public class ProfileFieldViewFactory { /** * Edit and display view for tags */
@ SuppressWarnings ( "unchecked" ) private < E > View createTagView ( TagProfileField field , String [ ] currentValue , FieldValueListener < E > listener , ViewGroup container , boolean editable ) { } }

implementation: View result = mInflater . inflate ( editable ? R . layout . profileedit_field_tag : R . layout . profileview_tag_field , container , false ) ; String friendlyName = mHelper . getFriendlyNameOfField ( field ) ; ( ( TextView ) result . findViewById ( R . id . profileedit_field_identifier ) ) . setText ( friendlyName ) ; TagsPicker picker = ( TagsPicker ) result . findViewById ( R . id . profileedit_tags_picker ) ; picker . setEditable ( editable ) ; if ( currentValue != null ) { picker . setInitialTags ( Arrays . asList ( currentValue ) ) ; } if ( editable ) { picker . setChangeListener ( new OnChangeListenerAdapter ( field , ( FieldValueListener < String [ ] > ) listener ) ) ; } setUpCircleView ( result , ( ProfileField < E > ) field , listener ) ; return result ;


signature:
public class ProfileFieldViewFactory { /** * Edit view for all other fields */
private < E > View createStandardEditView ( ProfileField < E > field , E currentValue , FieldValueListener < E > listener , ViewGroup container ) { } }

implementation: View result = mInflater . inflate ( R . layout . profileedit_field_standard , container , false ) ; String friendlyName = mHelper . getFriendlyNameOfField ( field ) ; ( ( TextView ) result . findViewById ( R . id . profileedit_field_identifier ) ) . setText ( friendlyName ) ; EditText editText = ( EditText ) result . findViewById ( R . id . profileedit_field_value ) ; editText . addTextChangedListener ( new OnEditorActionAdapter < > ( listener , field ) ) ; if ( currentValue != null ) { editText . setText ( mHelper . convertToFriendlyString ( field , currentValue ) ) ; } setUpCircleView ( result , field , listener ) ; return result ;


signature:
public class SPFRemoteInstance { /** * Retrieves the values of a defined set of { @ link ProfileField } from the
 * profile of the remote instance . The value of a field will be returned
 * only if visible to the current instance .
 * @ param fieldIdentifiers - the list of identifiers of the profile fields to retrieve
 * @ param appIdentifier - the identifier of the app that created the request .
 * @ return a { @ link ProfileFieldContainer } with all the retrieved values . */
public final ProfileFieldContainer getProfileBulk ( String [ ] fieldIdentifiers , String appIdentifier ) { } }

implementation: if ( fieldIdentifiers == null || appIdentifier == null ) { throw new NullPointerException ( ) ; } String identifierList = FieldContainerMarshaller . marshallIdentifierList ( fieldIdentifiers ) ; String token = SPF . get ( ) . getSecurityMonitor ( ) . getPersonRegistry ( ) . getTokenFor ( getUniqueIdentifier ( ) ) ; String containerString = getProfileBulk ( token , identifierList , appIdentifier ) ; return FieldContainerMarshaller . unmarshallContainer ( containerString ) ;


signature:
public class SPFRemoteInstance { /** * Sends a notification to the remote SPF instance .
 * @ param uniqueIdentifier - the identifier of the sender .
 * @ param action - the notification action . */
public final void sendNotification ( String uniqueIdentifier , SPFActionSendNotification action ) { } }

implementation: if ( uniqueIdentifier == null || action == null ) { throw new NullPointerException ( ) ; } String actionJSON = action . toJSON ( ) ; sendNotification ( uniqueIdentifier , actionJSON ) ;


signature:
public class XmlTransformation { /** * To xml .
 * @ return the string */
public String toXml ( ) { } }

implementation: final String lqSimpleName = this . getClass ( ) . getSimpleName ( ) . toLowerCase ( ) ; final Map < String , Class < ? > > aliases = new HashMap < > ( ) ; aliases . put ( lqSimpleName , this . getClass ( ) ) ; return ObjectToXmlExtensions . toXmlWithXStream ( this , aliases ) ;


signature:
public class SPFApp { /** * Method to set the contentview with Title , Text and Image . */
private void setContentViewWithMinimalElements ( ) { } }

implementation:
// Set data in the RemoteViews programmatically
contentView . setImageViewResource ( R . id . imageView , R . drawable . ic_launcher ) ; contentView . setTextViewText ( R . id . title_text_notification , getResources ( ) . getString ( R . string . notification_title ) ) ; contentView . setTextViewText ( R . id . message_notification , getResources ( ) . getString ( R . string . notification_text ) ) ;


signature:
public class Helper { /** * Provides the localized friendly name of a field .
 * @ param field - the field whose name to retrieve
 * @ return the friendly name of the field */
public String getFriendlyNameOfField ( ProfileField < ? > field ) { } }

implementation: String name = getStringFromResource ( PROFILE_FIELD_PREFIX + field . getIdentifier ( ) ) ; if ( name == null ) { return field . getIdentifier ( ) ; } return name ;


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

implementation: final DeviceGuiElement device = ServicesGuiList . get ( ) . getServices ( ) . get ( position ) ; if ( device . getName ( ) == null || device . getName ( ) . equals ( "" ) ) { viewHolder . nameTextView . setText ( "Name not found, please wait..." ) ; } else { viewHolder . nameTextView . setText ( device . getName ( ) ) ; } viewHolder . addressTextView . setText ( device . getAddress ( ) ) ; 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 . serviceItemClicked ( device ) ; } } ) ;


signature:
public class EternalConnect { /** * Kill the scheduler to stop the Eternal Connect in any case . */
private void killScheduler ( ) { } }

implementation: if ( scheduler != null ) { WfdLog . d ( TAG , "scheduler killed" ) ; scheduler . shutdown ( ) ; scheduler = null ; }


signature:
public class SPFContext { /** * Initializes SPFContext . After this method has been called , you can get
 * references to SPFContext and SPF .
 * @ param context */
public static synchronized void initialize ( Context context , int goIntent , boolean isAutonomous , ProximityMiddleware . Factory factory ) { } }

implementation: if ( context == null || factory == null ) { throw new NullPointerException ( "Arguments cannot be null" ) ; } SPF . initialize ( context , goIntent , isAutonomous , factory ) ; sInstance = new SPFContext ( ) ;


signature:
public class SPFContext { /** * Broadcasts an event to all registered listeners . Each listener will
 * receive a reference to the given bundle .
 * @ param code - the event code
 * @ param payload - the event payload */
public void broadcastEvent ( final int code , final Bundle payload ) { } }

implementation:
if ( SPFConfig . DEBUG ) { Log . d ( TAG , "Broadcasting event " + code + " with payload " + payload ) ; } for ( final OnEventListener listener : mEventListeners ) { // TODO is it thread safe ?
mHandler . post ( new Runnable ( ) { @ Override public void run ( ) { listener . onEvent ( code , payload ) ; } } ) ; }


signature:
public class ProfileFragment { /** * Creates a new instance of { @ link ProfileFragment } to show the profile of
 * a remote user . The fragment will allow only to view the fields and not to
 * modify them .
 * @ param personIdentifer - the identifier of the person whose profile to show
 * @ return an instance of ProfileFragment */
public static ProfileFragment createRemoteProfileFragment ( String personIdentifer ) { } }

implementation: Bundle b = new Bundle ( ) ; b . putInt ( EXTRA_VIEW_MODE , Mode . REMOTE . ordinal ( ) ) ; b . putString ( EXTRA_PERSON_IDENTIFIER , personIdentifer ) ; ProfileFragment fragment = new ProfileFragment ( ) ; fragment . setArguments ( b ) ; return fragment ;


signature:
public class ProfileFragment { /** * Creates a new instance of ProfileFragment to show the local profile .
 * @ return an instance of ProfileFragment */
public static ProfileFragment createViewSelfProfileFragment ( ) { } }

implementation: Bundle b = new Bundle ( ) ; b . putInt ( EXTRA_VIEW_MODE , Mode . SELF . ordinal ( ) ) ; ProfileFragment fragment = new ProfileFragment ( ) ; fragment . setArguments ( b ) ; return fragment ;


signature:
public class ProfileFragment { /** * LOADERS - Used to load and save profile data . */
@ Override public Loader < ProfileFieldContainer > onCreateLoader ( int id , Bundle args ) { } }

implementation: switch ( id ) { case LoadersConfig . LOAD_PROFILE_LOADER_ID : return new AsyncTaskLoader < ProfileFieldContainer > ( getActivity ( ) ) { @ Override public ProfileFieldContainer loadInBackground ( ) { if ( mMode == Mode . SELF || mMode == Mode . EDIT ) { return SPF . get ( ) . getProfileManager ( ) . getProfileFieldBulk ( mCurrentPersona , ProfilePagerAdapter . DEFAULT_FIELDS ) ; } else { SPFRemoteInstance instance = SPF . get ( ) . getPeopleManager ( ) . getPerson ( mPersonIdentifier ) ; if ( instance == null ) { throw new IllegalStateException ( "Person " + mPersonIdentifier + " not found in proximity" ) ; } else { String app = getActivity ( ) . getCallingPackage ( ) ; app = app == null ? "it.polimi.spf.app" : app ; return instance . getProfileBulk ( ProfileField . toIdentifierList ( ProfilePagerAdapter . DEFAULT_FIELDS ) , app ) ; } } } } ; case LoadersConfig . SAVE_PROFILE_LOADER_ID : if ( mMode != Mode . EDIT ) { Log . e ( TAG , "SAVE_PROFILE_LOADER initialized in mode " + mMode ) ; } return new AsyncTaskLoader < ProfileFieldContainer > ( getActivity ( ) ) { @ Override public ProfileFieldContainer loadInBackground ( ) { SPF . get ( ) . getProfileManager ( ) . setProfileFieldBulk ( mContainer , mCurrentPersona ) ; return null ; } } ; default : throw new IllegalArgumentException ( "No loader for id " + id ) ; }


signature:
public class ProfileFragment { /** * Called when the profile data is available , thus we can set up the view */
private void onProfileDataAvailable ( ) { } }

implementation:
Log . d ( TAG , "onProfileDataAvailable" ) ; mFactory = new ProfileFieldViewFactory ( getActivity ( ) , mMode , mCurrentPersona , mContainer ) ; String [ ] mPageTitles = this . getResources ( ) . getStringArray ( R . array . profileedit_fragments_titles ) ; tabLayout . removeAllTabs ( ) ; tabLayout . addTab ( tabLayout . newTab ( ) . setText ( mPageTitles [ 0 ] . toUpperCase ( Locale . getDefault ( ) ) ) ) ; tabLayout . addTab ( tabLayout . newTab ( ) . setText ( mPageTitles [ 1 ] . toUpperCase ( Locale . getDefault ( ) ) ) ) ; tabLayout . addTab ( tabLayout . newTab ( ) . setText ( mPageTitles [ 2 ] . toUpperCase ( Locale . getDefault ( ) ) ) ) ; tabLayout . setTabGravity ( TabLayout . GRAVITY_FILL ) ; ProfilePagerAdapter mPagerAdapter = new ProfilePagerAdapter ( getChildFragmentManager ( ) , mMode , tabLayout . getTabCount ( ) ) ; mViewPager . setAdapter ( mPagerAdapter ) ; mViewPager . addOnPageChangeListener ( new TabLayout . TabLayoutOnPageChangeListener ( tabLayout ) ) ; tabLayout . setOnTabSelectedListener ( new TabLayout . OnTabSelectedListener ( ) { @ Override public void onTabSelected ( TabLayout . Tab tab ) { mViewPager . setCurrentItem ( tab . getPosition ( ) ) ; } @ Override public void onTabUnselected ( TabLayout . Tab tab ) { } @ Override public void onTabReselected ( TabLayout . Tab tab ) { } } ) ; if ( mMode != Mode . SELF ) { showPicture ( mContainer . getFieldValue ( ProfileField . PHOTO ) ) ; } else { if ( getActivity ( ) instanceof MainActivity ) { ( ( MainActivity ) getActivity ( ) ) . onPhotoReady ( mContainer . getFieldValue ( ProfileField . PHOTO ) ) ; } else if ( getActivity ( ) instanceof ProfileViewActivity ) { // TODO implement this
// ( ( ProfileViewActivity ) getActivity ( ) ) . onPhotoReady ( mContainer . getFieldValue ( ProfileField . PHOTO ) ) ;
} } // Refresh field fragments
mPagerAdapter . onRefresh ( ) ;


signature:
public class ProfileFragment { /** * Creates a view for the given profile field . Depending on the { @ link Mode }
 * of visualization , the view may allow the modification of the value . This
 * method will not attach the view to the provided { @ link ViewGroup }
 * @ param field - the field for which to create the view .
 * @ param container - the container to which the view will be attached , needed by
 * { @ link LayoutInflater # inflate ( int , ViewGroup , boolean ) } to
 * evaluate layout params .
 * @ return */
public < E > View createViewFor ( ProfileField < E > field , ViewGroup container ) { } }

implementation: switch ( mMode ) { case SELF : case REMOTE : return mFactory . createViewForField ( field , container , null ) ; case EDIT : return mFactory . createViewForField ( field , container , new ProfileFieldViewFactory . FieldValueListener < E > ( ) { @ Override public void onFieldValueChanged ( ProfileField < E > field , E value ) { mContainer . setFieldValue ( field , value ) ; } @ Override public void onInvalidFieldValue ( ProfileField < E > field , String fieldFriendlyName ) { Toast . makeText ( getActivity ( ) , "Invalid value for field " + fieldFriendlyName , Toast . LENGTH_SHORT ) . show ( ) ; } @ Override public void onCircleAdded ( ProfileField < E > field , String circle ) { Log . d ( TAG , "Circle " + circle + " added to field " + field + " of persona " + mCurrentPersona ) ; SPF . get ( ) . getProfileManager ( ) . addGroupToField ( field , circle , mCurrentPersona ) ; } @ Override public void onCircleRemoved ( ProfileField < E > field , String circle ) { Log . d ( TAG , "Circle " + circle + " removed from field " + field + " of persona " + mCurrentPersona ) ; SPF . get ( ) . getProfileManager ( ) . removeGroupFromField ( field , circle , mCurrentPersona ) ; } } ) ; default : return null ; }


signature:
public class ProfileFragment { /** * Method to start the activity to crop an image .
 * @ param source */
public void beginCrop ( Uri source ) { } }

implementation: Uri destination = Uri . fromFile ( new File ( this . getActivity ( ) . getCacheDir ( ) , "cropped" ) ) ; Crop . of ( source , destination ) . asSquare ( ) . start ( this . getActivity ( ) ) ;


signature:
public class ProfileFragment { /** * Method to set an show a cropped imaged .
 * @ param resultCode
 * @ param result */
public void handleCrop ( int resultCode , Intent result ) { } }

implementation: if ( resultCode == Activity . RESULT_OK ) { Uri uri = Crop . getOutput ( result ) ; resultView . setImageURI ( uri ) ; InputStream inputStream = null ; try { inputStream = new FileInputStream ( uri . getPath ( ) ) ; Bitmap myBitmap = BitmapFactory . decodeStream ( inputStream ) ; myBitmap = Bitmap . createScaledBitmap ( myBitmap , 130 , 130 , false ) ; mContainer . setFieldValue ( ProfileField . PHOTO , myBitmap ) ; showPicture ( myBitmap ) ; } catch ( FileNotFoundException e ) { Log . e ( TAG , "handleCrop FileInputStream-file not found from uri.getpath" , e ) ; } finally { if ( inputStream != null ) { try { inputStream . close ( ) ; } catch ( IOException e ) { Log . e ( TAG , "handleCrop closing input stream error" , e ) ; } } } } else if ( resultCode == Crop . RESULT_ERROR ) { Toast . makeText ( this . getActivity ( ) , Crop . getError ( result ) . getMessage ( ) , Toast . LENGTH_SHORT ) . show ( ) ; }


signature:
public class ProfileFragment { /** * ItemSelectListener for Persona spinner in actionbar */
@ Override public void onItemSelected ( AdapterView < ? > parent , View view , int position , long id ) { } }

implementation: SPFPersona persona = ( SPFPersona ) parent . getItemAtPosition ( position ) ; if ( mCurrentPersona . equals ( persona ) ) { return ; } mCurrentPersona = persona ; startLoader ( LoadersConfig . LOAD_PROFILE_LOADER_ID ) ;


signature:
public class JsonToObjectExtensions { /** * Transforms the given json string into a java object .
 * @ param < T >
 * the generic type of the return type
 * @ param jsonString
 * the json string
 * @ param clazz
 * the clazz of the generic type
 * @ return the object
 * @ throws JsonParseException
 * If an error occurs when parsing the string into Object
 * @ throws JsonMappingException
 * the If an error occurs when mapping the string into Object
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static < T > T toObject ( final String jsonString , final Class < T > clazz ) throws JsonParseException , JsonMappingException , IOException { } }

implementation: return toObject ( jsonString , clazz , false ) ;


signature:
public class JsonToObjectExtensions { /** * Transforms the given json string into a java object .
 * @ param < T >
 * the generic type of the return type
 * @ param jsonString
 * the json string
 * @ param clazz
 * the clazz of the generic type
 * @ param newMapper
 * flag that indicates if a new ObjectMapper should be created . if true a new
 * ObjectMapper will be created otherwise the ObjectMapper from this class will be
 * returned .
 * @ return the object
 * @ throws JsonParseException
 * If an error occurs when parsing the string into Object
 * @ throws JsonMappingException
 * the If an error occurs when mapping the string into Object
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static < T > T toObject ( final String jsonString , final Class < T > clazz , final boolean newMapper ) throws JsonParseException , JsonMappingException , IOException { } }

implementation: final ObjectMapper mapper = ObjectMapperFactory . getObjectMapper ( newMapper ) ; final T object = mapper . readValue ( jsonString , clazz ) ; return object ;


signature:
public class JsonToObjectExtensions { /** * Transforms the given json string into a java object .
 * @ param < T >
 * the generic type of the return type
 * @ param jsonString
 * the json string
 * @ param clazz
 * the clazz of the generic type
 * @ param modules
 * The modules to register for the mapper
 * @ return the object
 * @ throws JsonParseException
 * If an error occurs when parsing the string into Object
 * @ throws JsonMappingException
 * the If an error occurs when mapping the string into Object
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static < T > T toObject ( final String jsonString , final Class < T > clazz , final Module ... modules ) throws JsonParseException , JsonMappingException , IOException { } }

implementation: ObjectMapper mapper = ObjectMapperFactory . getObjectMapper ( true ) ; mapper = mapper . registerModules ( modules ) ; final T object = mapper . readValue ( jsonString , clazz ) ; return object ;


signature:
public class JsonToObjectExtensions { /** * Transforms the given json string into a java object { @ link List }
 * @ param < T >
 * the generic type of the return type
 * @ param jsonString
 * the json string
 * @ param elementClass
 * the element class of the generic type
 * @ return the list with the java objects .
 * @ throws JsonParseException
 * If an error occurs when parsing the string into Object
 * @ throws JsonMappingException
 * the If an error occurs when mapping the string into Object
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static < T > List < T > toObjectList ( final String jsonString , final Class < T > elementClass ) throws JsonParseException , JsonMappingException , IOException { } }

implementation: return ( List < T > ) toObjectCollection ( jsonString , List . class , elementClass ) ;


signature:
public class JsonToObjectExtensions { /** * Transforms the given json string into a java object { @ link Collection }
 * @ param < T >
 * the generic type of the return type
 * @ param jsonString
 * the json string
 * @ param collectionClass
 * the collection class
 * @ param elementClass
 * the element class
 * @ return the list with the java objects .
 * @ throws JsonParseException
 * If an error occurs when parsing the string into Object
 * @ throws JsonMappingException
 * the If an error occurs when mapping the string into Object
 * @ throws IOException
 * Signals that an I / O exception has occurred */
public static < T > Collection < T > toObjectCollection ( final String jsonString , @ SuppressWarnings ( "rawtypes" ) Class < ? extends Collection > collectionClass , Class < T > elementClass ) throws JsonParseException , JsonMappingException , IOException { } }

implementation: final ObjectMapper mapper = ObjectMapperFactory . getObjectMapper ( true ) ; return mapper . readValue ( jsonString , mapper . getTypeFactory ( ) . constructCollectionType ( collectionClass , elementClass ) ) ;


signature:
public class PopupAppRegistrationHandler { /** * ( non - Javadoc )
 * @ see it . polimi . spf . framework . security . AppRegistrationHandler #
 * handleRegistrationRequest ( android . content . Context ,
 * it . polimi . spf . shared . model . AppDescriptor ,
 * it . polimi . spf . framework . security . AppRegistrationHandler . Callback ) */
@ Override public void handleRegistrationRequest ( Context context , AppDescriptor descriptor , final Callback callback ) { } }

implementation:
final DialogView dialogView = new DialogView ( context , descriptor ) ; Dialog dialog = new AlertDialog . Builder ( context ) . setPositiveButton ( R . string . app_permission_dialog_allow , new AlertDialog . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { callback . onRequestAccepted ( dialogView . getSelectedPersona ( ) ) ; } } ) . setNegativeButton ( R . string . app_permission_dialog_deny , new AlertDialog . OnClickListener ( ) { @ Override public void onClick ( DialogInterface dialog , int which ) { callback . onRequestRefused ( ) ; } } ) . setView ( dialogView . getView ( ) ) . create ( ) ; /* * Workaround to fix the crash :
 * android . view . WindowManager $ BadTokenException : Unable to add window
 * android . view . ViewRootImpl $ W @ 3d67307 - - permission denied for this window type
 * that appears only on Android 6.0 Marshmallow or greater .
 * Start a dialog fragment to explain the procedure to the user .
 * When the user accepts , onClickOnUnderstoodButton ( ) will be called . */
if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . M ) { // if android MarshMallow or greater
if ( Settings . canDrawOverlays ( context ) ) { dialog . getWindow ( ) . setType ( WindowManager . LayoutParams . TYPE_SYSTEM_ALERT ) ; dialog . show ( ) ; } else { // to prevent a crash
Toast . makeText ( context , "You must activate SPF!" , Toast . LENGTH_SHORT ) . show ( ) ; } } else { // other older Android ' s versions
dialog . getWindow ( ) . setType ( WindowManager . LayoutParams . TYPE_SYSTEM_ALERT ) ; dialog . show ( ) ; }


signature:
public class ObjectToJsonExtensions { /** * Creates from the given { @ link List } to a json string .
 * @ param < T >
 * the generic type
 * @ param list
 * the list
 * @ return the json string .
 * @ throws JsonGenerationException
 * If an error occurs by writing json string
 * @ throws JsonMappingException
 * the If an error occurs when mapping the string into Object
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static < T > String toJson ( final List < T > list ) throws JsonGenerationException , JsonMappingException , IOException { } }

implementation: final ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; final ObjectMapper mapper = new ObjectMapper ( ) ; mapper . writeValue ( out , list ) ; final byte [ ] bytes = out . toByteArray ( ) ; out . close ( ) ; return new String ( bytes ) ;


signature:
public class ObjectToJsonExtensions { /** * To json .
 * @ param < T >
 * the generic type
 * @ param object
 * the object
 * @ param newMapper
 * flag that indicates if a new ObjectMapper should be created . if true a new
 * ObjectMapper will be created otherwise the ObjectMapper from this class will be
 * returned .
 * @ return the string
 * @ throws JsonProcessingException
 * If an error occurs when converting object to String */
public static < T > String toJson ( final T object , final boolean newMapper ) throws JsonProcessingException { } }

implementation: final ObjectMapper mapper = ObjectMapperFactory . getObjectMapper ( newMapper ) ; final String json = mapper . writeValueAsString ( object ) ; return json ;


signature:
public class SPFServiceExecutor { /** * Creates an invocation stub to send service invocation requests to a
 * target { @ link SPFPerson } performing method calls . The stub is created
 * from a provided service interface , which must be annotated with
 * { @ link ServiceInterface } describing the service . The method returns an
 * object implementing the aforementioned interface that can be used to
 * perform method invocation .
 * @ param target
 * - the person who the service invocation requests will be
 * dispatched to .
 * @ param serviceInterface
 * - the interface of the service .
 * @ param classLoader
 * - the ClassLoader to load classes .
 * @ return an invocation stub to perform method calls . */
public < E > E createStub ( final SPFPerson target , Class < E > serviceInterface , ClassLoader classLoader ) { } }

implementation: return InvocationStub . from ( serviceInterface , classLoader , new InvocationStub . Target ( ) { @ Override public void prepareArguments ( Object [ ] arguments ) throws ServiceInvocationException { mExecutionInterface . injectActivities ( target . getIdentifier ( ) , arguments ) ; } @ Override public InvocationResponse executeService ( InvocationRequest request ) throws ServiceInvocationException { return mExecutionInterface . executeService ( target . getIdentifier ( ) , request ) ; } } ) ;


signature:
public class SPFServiceExecutor { /** * Creates an invocation stub to send service invocation requests to a
 * target { @ link SPFPerson } providing the name and the parameter list . The
 * object is created from a { @ link ServiceDescriptor } containing the
 * required details .
 * @ param target
 * - the person who the service invocation requests will be
 * dispatched to .
 * @ param descriptor
 * - the { @ link ServiceDescriptor } of the service whose methods
 * to invoke .
 * @ return a { @ link InvocationStub } to perform invocations of remote
 * services . */
public InvocationStub createStub ( final SPFPerson target , SPFServiceDescriptor descriptor ) { } }

implementation: return InvocationStub . from ( descriptor , new InvocationStub . Target ( ) { @ Override public void prepareArguments ( Object [ ] arguments ) throws ServiceInvocationException { mExecutionInterface . injectActivities ( target . getIdentifier ( ) , arguments ) ; } @ Override public InvocationResponse executeService ( InvocationRequest request ) { return mExecutionInterface . executeService ( target . getIdentifier ( ) , request ) ; } } ) ;


signature:
public class SPFServiceExecutor { /** * Dispatches an activity to the SPF instances matching the given
 * identifier . The framework will perform information injection into the
 * activity : such information will be available to the caller once the
 * method ends .
 * @ param target
 * - the target of the activity .
 * @ param activity
 * - the activity to dispatch .
 * @ return - true if the activity has been correctly consumed by the
 * recipient . */
public boolean sendActivity ( String target , SPFActivity activity ) { } }

implementation: InvocationResponse resp = mExecutionInterface . sendActivity ( target , activity ) ; if ( resp . isResult ( ) ) { return GsonHelper . gson . fromJson ( resp . getPayload ( ) , Boolean . class ) ; } else { return false ; }


signature:
public class TagsViewer { /** * Adds and shows a new tag .
 * @ param tag */
public void addTag ( String tag ) { } }

implementation: TagBubble tb = new TagBubble ( getContext ( ) ) ; tb . setText ( tag ) ; tb . setEditable ( editable ) ; tb . setOnRemoveTagListener ( bubbleClickListener ) ; tags . add ( tag . toString ( ) ) ; addView ( tb ) ;


signature:
public class TagsViewer { /** * Set the list of tags to be displayed .
 * @ param tags */
public void setTags ( List < String > tags ) { } }

implementation: this . tags . clear ( ) ; removeAllViews ( ) ; for ( String tag : tags ) { addTag ( tag ) ; }


signature:
public class JsonToXmlExtensions { /** * Transform the given json as { @ link String } object to an xml as { @ link String } object .
 * @ param jsonString
 * the json as { @ link String } object
 * @ return the transformed xml as { @ link String } object
 * @ throws JSONException
 * if there is a syntax error in the source string or a duplicated key . */
public static String toXml ( final String jsonString ) throws JSONException { } }

implementation: final JSONObject json = new JSONObject ( jsonString ) ; final String xmlString = XML . toString ( json ) ; return xmlString ;


signature:
public class JsonToXmlExtensions { /** * Transform the given json as { @ link String } object to an xml as { @ link String } object .
 * @ param < T >
 * the generic type
 * @ param jsonString
 * the json as { @ link String } object
 * @ param clazz
 * the clazz of the generic type
 * @ return the transformed xml as { @ link String } object
 * @ throws JsonParseException
 * If an error occurs when parsing the string into Object
 * @ throws JsonMappingException
 * the If an error occurs when mapping the string into Object
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static < T > String toXml ( final String jsonString , final Class < T > clazz ) throws JsonParseException , JsonMappingException , IOException { } }

implementation: final T object = JsonToObjectExtensions . toObject ( jsonString , clazz ) ; final String xmlString = ObjectToXmlExtensions . toXmlWithXStream ( object ) ; return xmlString ;


signature:
public class SPFNotificationManager { /** * Saves the trigger on the database .
 * @ param t */
public long saveTrigger ( SPFTrigger trigger , String appPackageName ) { } }

implementation: trigger = mTriggerTable . saveTrigger ( trigger , appPackageName ) ; if ( trigger != null ) { if ( mHandler != null ) mHandler . postAddTrigger ( trigger ) ; return trigger . getId ( ) ; } else { return - 1 ; }


signature:
public class SPFNotificationManager { /** * Deletes the trigger specified by its id .
 * @ param id
 * @ return true if the trigger has been deleted */
public boolean deleteTrigger ( long id , String appPackageName ) { } }

implementation: boolean success = mTriggerTable . deleteTrigger ( id , appPackageName ) ; if ( success ) { if ( mHandler != null ) mHandler . postRemoveTrigger ( id ) ; } return success ;


signature:
public class SPFNotificationManager { /** * Initialize and start all the threads and resources used by
 * SPFNotification service . Call this method to initialize the logic that
 * handles triggers processing . */
public void start ( ) { } }

implementation: this . mHandlerThread = new HandlerThread ( "notification-handler-thread" ) ; this . mHandlerThread . start ( ) ; this . mHandler = new SPFNotificationHandler ( mHandlerThread . getLooper ( ) ) ; mHandler . postSetup ( this ) ; isRunning = true ;


signature:
public class SPFNotificationManager { /** * to be called after on start : initializes the triggers ' logic */
private void setup ( ) { } }

implementation: List < SPFTrigger > triggers = mTriggerTable . getAllTriggers ( ) ; mTriggerCache = new SPFActionCache ( mContext ) ; mTriggerEngine . refreshTriggers ( triggers ) ; mTriggerCache . refresh ( triggers ) ;


signature:
public class SPFNotificationManager { /** * Notification messages */
public List < NotificationMessage > getAvailableNotifications ( ) { } }

implementation: Log . d ( "TAG" , "notification available: " + mMessageTable . getAvailableNotifications ( ) . size ( ) ) ; return mMessageTable . getAvailableNotifications ( ) ;


signature:
public class WifiDirectMiddleware { /** * Method called by { @ link WFDMiddlewareAdapter # connect ( ) } */
public void init ( ) { } }

implementation: WfdLog . d ( TAG , "Called init()" ) ; initAndStartHandler ( ) ; try { mPort = this . requestAvailablePortFromOs ( ) ; } catch ( IOException e ) { mListener . onError ( ) ; return ; } mManager = ( WifiP2pManager ) mContext . getSystemService ( Context . WIFI_P2P_SERVICE ) ; mChannel = mManager . initialize ( mContext , Looper . getMainLooper ( ) , new WifiP2pManager . ChannelListener ( ) { @ Override public void onChannelDisconnected ( ) { WfdLog . d ( TAG , "Channel disconnected" ) ; } } ) ; mReceiver . register ( mContext ) ; NineBus . get ( ) . register ( this ) ;


signature:
public class WifiDirectMiddleware { /** * Method to connect . Called by { @ link it . polimi . spf . wfdadapter . WFDMiddlewareAdapter # connect ( ) } . */
public void connect ( ) { } }

implementation: if ( isConnected ( ) ) { Log . w ( TAG , "Connect called but isConnected() == true" ) ; return ; } this . startRegistration ( ) ; this . discoverService ( ) ; WfdLog . d ( TAG , "-----> " + isAutonomous + " , " + goIntent ) ; if ( this . isAutonomous ( ) && this . goIntent == 15 ) { this . createGroup ( ) ; } this . connected = true ;


signature:
public class WifiDirectMiddleware { /** * Registers a local service . */
private void startRegistration ( ) { } }

implementation:
// Create a string map containing information about your service .
Map < String , String > mRecordMap = new HashMap < > ( ) ; mRecordMap . put ( Configuration . PORT , Integer . toString ( mPort ) ) ; mRecordMap . put ( Configuration . IDENTIFIER , myIdentifier ) ; // Service information . Pass it an instance name , service type
// Configuration . SERVICE _ REG _ TYPE , and the map containing
// information other devices will want once they connect to this one .
WifiP2pDnsSdServiceInfo mInfo = WifiP2pDnsSdServiceInfo . newInstance ( Configuration . SERVICE_INSTANCE + myIdentifier , Configuration . SERVICE_REG_TYPE , mRecordMap ) ; // Add the local service , sending the service info , network channel ,
// and listener that will be used to indicate success or failure of
// the request .
mManager . addLocalService ( mChannel , mInfo , new CustomizableActionListener ( this . mContext , TAG , "Added Local Service" , null , "Failed to add a service" , "Failed to add a service" , true ) ) ; // important : sets true to get detailed message when this method fails


signature:
public class WifiDirectMiddleware { /** * Method to discover services and put the results
 * in { @ link it . polimi . spf . wfd . ServiceList } .
 * This method updates also the discovery menu item . */
private void discoverService ( ) { } }

implementation:
/* * Register listeners for DNS - SD services . These are callbacks invoked
 * by the system when a service is actually discovered . */
mManager . setDnsSdResponseListeners ( mChannel , new CustomDnsServiceResponseListener ( this ) , new CustomDnsSdTxtRecordListener ( ) ) ; // After attaching listeners , create a service request and initiate
// discovery .
WifiP2pDnsSdServiceRequest mServiceRequest = WifiP2pDnsSdServiceRequest . newInstance ( ) ; // initiates discovery
mManager . addServiceRequest ( mChannel , mServiceRequest , new CustomizableActionListener ( this . mContext , TAG , "Added service discovery request" , null , "Failed adding service discovery request" , "Failed adding service discovery request" , true ) ) ; // important : sets true to get detailed message when this method fails
// starts services discovery
mManager . discoverServices ( mChannel , new CustomizableActionListener ( this . mContext , TAG , "Service discovery initiated" , null , "Failed starting service discovery" , "Failed starting service discovery" , true ) ) ; // important : sets true to get detailed message when this method fails


signature:
public class WifiDirectMiddleware { /** * Method to send in broadcast a new discovered service to the UI . */
public void notifyServiceToGui ( @ NonNull String notificationType , @ Nullable WiFiP2pService service ) { } }

implementation: Intent intent = new Intent ( ) ; if ( service != null ) { intent . putExtra ( SERVICE_NAME , service . getDevice ( ) . deviceName ) ; intent . putExtra ( SERVICE_ADDRESS , service . getDevice ( ) . deviceAddress ) ; intent . putExtra ( SERVICE_IDENTIFIER , service . getIdentifier ( ) ) ; } intent . setAction ( notificationType ) ; mContext . sendBroadcast ( intent ) ;


signature:
public class WifiDirectMiddleware { /** * Method to send in broadcast a new connected device to the UI */
public void notifyConnectedDeviceToGui ( @ NonNull String notificationType , @ Nullable String id ) { } }

implementation: Intent intent = new Intent ( ) ; if ( id != null ) { intent . putExtra ( CLIENT_IDENTIFIER , id ) ; } intent . setAction ( notificationType ) ; mContext . sendBroadcast ( intent ) ;


signature:
public class WifiDirectMiddleware { /** * subscribe to catch events posted by { @ link EternalConnect } . */
@ Subscribe public void onEternalConnectUpdate ( EternalConnectEvent e ) { } }

implementation:
if ( e == null || e . getType ( ) == null ) { return ; } WfdLog . d ( TAG , "onEternalConnectUpdate received event: " + e . getType ( ) ) ; // if you want , in the future , you can change the behaviour of either a
// simple eternal connect reconnection ( autonomous go ) or a cycle of the eternal connect ( clients )
switch ( e . getType ( ) ) { case EternalConnectEvent . NEW_EC_CYCLE : case EternalConnectEvent . SIMPLE_EC_RECONNECTION : disconnect ( ) ; init ( ) ; connect ( ) ; break ; }


signature:
public class WifiDirectMiddleware { /** * subscribe to catch events posted by { @ link WfdHandler } . */
@ Subscribe public void onSendBroadcastMessage ( HandlerSendBroadcastEvent e ) { } }

implementation: try { this . sendMessageBroadcast ( e . getMessage ( ) ) ; } catch ( GroupException e1 ) { WfdLog . e ( TAG , "GroupException " + e . getMessage ( ) ) ; } catch ( IOException e1 ) { WfdLog . e ( TAG , "handleMessage IOException" , e1 ) ; }


signature:
public class SPFPerson { /** * Shorthand method to retrieve the RemoteProfile of { @ code this } person .
 * @ param spf
 * @ return */
public RemoteProfile getProfile ( SPF spf ) { } }

implementation: SPFRemoteProfile rp = ( SPFRemoteProfile ) spf . getComponent ( SPF . REMOTE_PROFILE ) ; return rp . getProfileOf ( this ) ;


signature:
public class SPFPerson { /** * Shorthand method to create an invocation interface for { @ code this } person .
 * @ param serviceInterface
 * @ param spf
 * @ return */
public < E > E getServiceInterface ( Class < E > serviceInterface , SPF spf ) { } }

implementation: if ( spf == null || serviceInterface == null ) { throw new NullPointerException ( ) ; } return spf . < SPFServiceExecutor > getComponent ( SPF . SERVICE_EXECUTION ) . createStub ( this , serviceInterface , getClass ( ) . getClassLoader ( ) ) ;


signature:
public class Tag { /** * Adds the attribute with the given name and value .
 * @ param name
 * the name
 * @ param value
 * the value
 * @ return the string */
public String addAttribute ( final String name , final String value ) { } }

implementation: if ( getAttributes ( ) == null ) { this . attributes = MapFactory . newLinkedHashMap ( ) ; } return getAttributes ( ) . put ( name , value ) ;


signature:
public class Tag { /** * Adds the given { @ link Tag } child to the given position .
 * @ param child
 * the { @ link Tag } child
 * @ param position
 * the position to add
 * @ return true , if the given { @ link Tag } child was added successfully to the given position
 * otherwise false */
public boolean addChild ( final Tag child , final Integer position ) { } }

implementation: if ( getChildren ( ) == null ) { this . childTagPositions = ListFactory . newArrayList ( ) ; } final ChildTagPosition childTagPosition = ChildTagPosition . builder ( ) . child ( child ) . position ( position ) . build ( ) ; return getChildren ( ) . add ( childTagPosition ) ;


signature:
public class Tag { /** * Removes the given { @ link Tag } child
 * @ param child
 * the { @ link Tag } child
 * @ return true , if the given { @ link Tag } child was removed successfully otherwise false */
public boolean removeChild ( final Tag child ) { } }

implementation: if ( getChildren ( ) != null ) { ChildTagPosition found = null ; for ( final ChildTagPosition childTagPosition : getChildren ( ) ) { if ( childTagPosition . getChild ( ) . equals ( child ) ) { found = childTagPosition ; break ; } } if ( found != null ) { return getChildren ( ) . remove ( found ) ; } } return false ;


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

implementation: final StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( "<" ) ; buffer . append ( getName ( ) ) ; Optional < String > attr = TagExtensions . attributesToString ( getAttributes ( ) ) ; if ( attr . isPresent ( ) ) { buffer . append ( attr . get ( ) ) ; } if ( isEndTag ( ) ) { buffer . append ( ">" ) ; if ( getChildren ( ) != null && ! getChildren ( ) . isEmpty ( ) ) { String processingContent = getContent ( ) ; Integer lastPosition = 0 ; for ( final ChildTagPosition child : getChildren ( ) ) { final String subContent = getContent ( ) . substring ( lastPosition , child . getPosition ( ) ) ; lastPosition = child . getPosition ( ) ; processingContent = processingContent . substring ( lastPosition , processingContent . length ( ) ) ; buffer . append ( subContent ) ; buffer . append ( child . getChild ( ) . toXmlString ( ) ) ; } buffer . append ( processingContent ) ; } else { buffer . append ( getContent ( ) ) ; } buffer . append ( "</" ) ; buffer . append ( getName ( ) ) ; buffer . append ( ">" ) ; } else { buffer . append ( "/>" ) ; } return buffer . toString ( ) ;


signature:
public class XmlResourceBundleControl { /** * { @ inheritDoc } */
@ Override public List < String > getFormats ( final String baseName ) { } }

implementation: if ( baseName == null ) { throw new NullPointerException ( "baseName is null" ) ; } return Collections . unmodifiableList ( Arrays . asList ( XML ) ) ;


signature:
public class SPFServiceLocalExecutor { /** * Creates an invocation stub to send service invocation requests to the
 * local person performing method calls . The stub is created from a provided
 * service interface , which must be annotated with { @ link ServiceInterface }
 * describing the service . The method returns an object implementing the
 * aforementioned interface that can be used to perform method invocation .
 * @ param serviceInterface
 * - the interface of the service .
 * @ param classLoader
 * - the ClassLoader to load classes .
 * @ return an invocation stub to perform method calls . */
public < E > E createStub ( Class < E > serviceInterface , ClassLoader classLoader ) { } }

implementation: return InvocationStub . from ( serviceInterface , classLoader , mLocalInvocationTarget ) ;


signature:
public class SPFServiceLocalExecutor { /** * Dispatches an activity to the local SPF instance . The framework will
 * perform information injection into the activity : such information will be
 * available to the caller once the method ends .
 * @ param activity
 * - the activity to dispatch .
 * @ return - true if the activity has been correctly consumed . */
public boolean sendActivityLocally ( SPFActivity activity ) { } }

implementation:
String token = getAccessToken ( ) ; SPFError err = new SPFError ( ) ; InvocationResponse resp ; try { getService ( ) . injectInformationIntoActivity ( token , activity , err ) ; if ( ! err . isOk ( ) ) { handleError ( err ) ; return false ; } resp = getService ( ) . sendActivityLocally ( token , activity , err ) ; } catch ( RemoteException e ) { // TODO Error Management
return false ; } if ( ! err . isOk ( ) ) { handleError ( err ) ; return false ; } if ( ! resp . isResult ( ) ) { return false ; } return GsonHelper . gson . fromJson ( resp . getPayload ( ) , Boolean . class ) ;


signature:
public class ServiceWrapper { /** * Invokes a method of the service .
 * @ param request
 * - The invocation request
 * @ return the return value
 * @ throws IllegalInvocationException
 * if the request does not match the service
 * @ throws InvocationTargetException
 * if an Exception is thrown during execution */
public InvocationResponse invokeMethod ( InvocationRequest request ) { } }

implementation: String methodName = request . getMethodName ( ) ; if ( ! mMethodIndex . containsKey ( methodName ) ) { String msg = String . format ( ErrorMsg . METHOD_NOT_FOUND , methodName , mServiceDescriptor . getServiceName ( ) ) ; return InvocationResponse . error ( msg ) ; } Method m = mMethodIndex . get ( methodName ) ; Object [ ] params ; try { params = deserializeParameters ( request . getPayload ( ) , m . getGenericParameterTypes ( ) ) ; } catch ( ServiceInvocationException e ) { return InvocationResponse . error ( "Error deserializing parameters:" + e . getMessage ( ) ) ; } try { Object result = m . invoke ( mImplementation , params ) ; String json = GsonHelper . gson . toJson ( result ) ; return InvocationResponse . result ( json ) ; } catch ( IllegalAccessException e ) { return InvocationResponse . error ( e ) ; } catch ( IllegalArgumentException e ) { return InvocationResponse . error ( ErrorMsg . ILLEGAL_ARGUMENT ) ; } catch ( InvocationTargetException e ) { return InvocationResponse . error ( e . getCause ( ) ) ; }


signature:
public class CircleSelectSpinner { /** * { @ inheritDoc } */
@ Override public void onClick ( DialogInterface dialog , int which , boolean isChecked ) { } }

implementation: if ( mSelection != null && which < mSelection . length ) { mSelection [ which ] = isChecked ; List < String > selected = getSelectedStrings ( ) ; mProxyAdapter . clear ( ) ; mProxyAdapter . add ( mHelper . sumUpCircles ( selected ) ) ; setSelection ( 0 ) ; if ( mListener != null ) { String item = mItems [ which ] ; if ( isChecked ) { mListener . onItemAdded ( item ) ; } else { mListener . onItemRemoved ( item ) ; } } } else { throw new IllegalArgumentException ( "Argument 'which' is out of bounds." ) ; }


signature:
public class CircleSelectSpinner { /** * { @ inheritDoc } */
@ SuppressLint ( "ClickableViewAccessibility" ) @ Override public boolean performClick ( ) { } }

implementation: AlertDialog . Builder builder = new AlertDialog . Builder ( getContext ( ) ) ; builder . setMultiChoiceItems ( mItems , mSelection , this ) ; builder . show ( ) ; return true ;


signature:
public class CircleSelectSpinner { /** * Sets the options for this spinner .
 * @ param items */
public void setItems ( String [ ] items ) { } }

implementation: mItems = items ; mSelection = new boolean [ mItems . length ] ; Arrays . fill ( mSelection , false ) ; refreshDisplayValue ( ) ;


signature:
public class CircleSelectSpinner { /** * Sets the options for this spinner .
 * @ param items */
public void setItems ( List < String > items ) { } }

implementation: mItems = items . toArray ( new String [ items . size ( ) ] ) ; mSelection = new boolean [ mItems . length ] ; Arrays . fill ( mSelection , false ) ; refreshDisplayValue ( ) ;


signature:
public class CircleSelectSpinner { /** * Sets the selected options based on an array of string .
 * @ param selection */
public void setSelection ( String [ ] selection ) { } }

implementation: for ( String sel : selection ) { for ( int j = 0 ; j < mItems . length ; ++ j ) { if ( mItems [ j ] . equals ( sel ) ) { mSelection [ j ] = true ; } } } refreshDisplayValue ( ) ;


signature:
public class CircleSelectSpinner { /** * Sets the selected options based on an array of positions .
 * @ param selectedIndicies */
public void setSelection ( int [ ] selectedIndicies ) { } }

implementation: for ( int index : selectedIndicies ) { if ( index >= 0 && index < mSelection . length ) { mSelection [ index ] = true ; } else { throw new IllegalArgumentException ( "Index " + index + " is out of bounds." ) ; } } refreshDisplayValue ( ) ;


signature:
public class CircleSelectSpinner { /** * Returns a list of strings , one for each selected item .
 * @ return */
public List < String > getSelectedStrings ( ) { } }

implementation: List < String > selection = new LinkedList < String > ( ) ; for ( int i = 0 ; i < mItems . length ; ++ i ) { if ( mSelection [ i ] ) { selection . add ( mItems [ i ] ) ; } } return selection ;


signature:
public class CircleSelectSpinner { /** * Returns a list of positions , one for each selected item .
 * @ return */
public List < Integer > getSelectedIndicies ( ) { } }

implementation: List < Integer > selection = new LinkedList < Integer > ( ) ; for ( int i = 0 ; i < mItems . length ; ++ i ) { if ( mSelection [ i ] ) { selection . add ( i ) ; } } return selection ;


signature:
public class ProfileFieldsFragment { /** * Creates a new instance of { @ link ProfileFieldsFragment } to show the given
 * list of profile fields .
 * @ param fieldsToShow - the fields to show ;
 * @ return an instance of { @ link ProfileFieldsFragment } ; */
public static ProfileFieldsFragment newInstance ( ProfileField < ? > [ ] fieldsToShow ) { } }

implementation: if ( fieldsToShow == null ) { throw new NullPointerException ( ) ; } Bundle b = new Bundle ( ) ; b . putStringArray ( EXTRA_FIELDS_TO_SHOW , ProfileField . toIdentifierList ( fieldsToShow ) ) ; ProfileFieldsFragment instance = new ProfileFieldsFragment ( ) ; instance . setArguments ( b ) ; return instance ;


signature:
public class ProfileFieldsFragment { /** * Refreshes the values of displayed fields . */
public void onRefresh ( ) { } }

implementation: mViewContainer . removeAllViews ( ) ; for ( ProfileField < ? > field : mFieldsToShow ) { View child = mParent . createViewFor ( field , mViewContainer ) ; mViewContainer . addView ( child ) ; }


signature:
public class AppCommunicationAgent { /** * Returns an { @ link AppServiceProxy } that can be used to communicate with
 * the remote service identified by the given component name . If an alive
 * proxy for the given component name is found in cache , it i returned .
 * Otherwise , a new proxy is created , stored in the cache and returned .
 * @ param componentName
 * - the component name of the remote service
 * @ return a proxy to communicate with the remote service */
public AppServiceProxy getProxy ( String componentName ) { } }

implementation:
synchronized ( this ) { if ( mShutdown ) { throw new IllegalStateException ( "Communication agent is shutdown" ) ; } long start = System . nanoTime ( ) ; if ( mProxies . containsKey ( componentName ) ) { AppServiceProxy proxy = mProxies . get ( componentName ) ; unscheduleHousekeeper ( proxy ) ; if ( proxy . isConnected ( ) ) { long st = ( System . nanoTime ( ) - start ) / 1000 ; Log . d ( TAG , "HIT for " + componentName + " in " + st + "us" ) ; scheduleHousekeeper ( proxy ) ; return proxy ; } else { Log . d ( TAG , "Removed dead proxy (" + componentName + ")" ) ; mProxies . remove ( proxy ) ; // Go on with the creation of new proxy
} } AppServiceProxy proxy = new AppServiceProxy ( componentName ) ; mProxies . put ( componentName , proxy ) ; Intent serviceIntent = new Intent ( ) ; serviceIntent . setComponent ( ComponentName . unflattenFromString ( componentName ) ) ; boolean bound = mContext . bindService ( serviceIntent , proxy , Context . BIND_AUTO_CREATE ) ; if ( ! bound ) { Log . e ( TAG , "Cannot bound to app service with intent " + componentName ) ; return null ; } long st = ( System . nanoTime ( ) - start ) / 1000 ; Log . d ( TAG , "MISS for " + componentName + " in " + st + "us" ) ; scheduleHousekeeper ( proxy ) ; return proxy ; }


signature:
public class AppCommunicationAgent { /** * Unbinds all proxies available in caches and prevents the creation of new
 * ones . */
public void shutdown ( ) { } }

implementation: synchronized ( this ) { if ( mShutdown ) { return ; } for ( AppServiceProxy p : mProxies . values ( ) ) { if ( p . isConnected ( ) ) { mContext . unbindService ( p ) ; mProxies . remove ( p ) ; } } mShutdown = true ; }


signature:
public class WriterHandler { /** * { @ inheritDoc } */
@ Override public void characters ( final char [ ] buf , final int offset , final int len ) throws SAXException { } }

implementation: final String string = new String ( buf , offset , len ) ; if ( stringBuilder == null ) { stringBuilder = new StringBuilder ( string ) ; } else { stringBuilder . append ( string ) ; }


signature:
public class WriterHandler { /** * { @ inheritDoc } */
@ Override public void endDocument ( ) throws SAXException { } }

implementation: insertNewLine ( ) ; try { insertNewLine ( ) ; writer . flush ( ) ; } catch ( final IOException e ) { throw new SAXException ( "I/O error" , e ) ; }


signature:
public class WriterHandler { /** * { @ inheritDoc } */
@ Override public void endElement ( final String namespaceURI , final String simpleName , final String qualifiedName ) throws SAXException { } }

implementation: writeToBuffer ( ) ; String elementName = simpleName ; if ( "" . equals ( elementName ) ) { elementName = qualifiedName ; } write ( "</" + elementName + ">" ) ;


signature:
public class WriterHandler { /** * Insert a new line to the writer
 * @ throws SAXException
 * any SAX exception , possibly wrapping another exception */
private void insertNewLine ( ) throws SAXException { } }

implementation: try { writer . write ( System . getProperty ( "line.separator" ) ) ; } catch ( final IOException e ) { throw new SAXException ( "I/O error" , e ) ; }


signature:
public class WriterHandler { /** * { @ inheritDoc } */
@ Override public void startElement ( final String namespaceURI , final String simpleName , final String qualifiedName , final Attributes attributes ) throws SAXException { } }

implementation: writeToBuffer ( ) ; String elementName = simpleName ; if ( "" . equals ( elementName ) ) { elementName = qualifiedName ; } write ( "<" + elementName ) ; if ( attributes != null ) { for ( int i = 0 ; i < attributes . getLength ( ) ; i ++ ) { String attributeName = attributes . getLocalName ( i ) ; if ( "" . equals ( attributeName ) ) { attributeName = attributes . getQName ( i ) ; } write ( " " ) ; write ( attributeName + "=\"" + attributes . getValue ( i ) + "\"" ) ; } } write ( ">" ) ;


signature:
public class WriterHandler { /** * Write to buffer .
 * @ throws SAXException
 * any SAX exception , possibly wrapping another exception */
private void writeToBuffer ( ) throws SAXException { } }

implementation: if ( stringBuilder == null ) { return ; } final String string = stringBuilder . toString ( ) . trim ( ) ; write ( string ) ; stringBuilder = null ;


signature:
public class XmlToXsdExtensions { /** * Creates or update the given xsd output file from the given XML file .
 * @ param xmlInputFile
 * the xml input file
 * @ param xsdOutFile
 * the xsd out file
 * @ throws XmlException
 * the xml exception
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static void xmlToXsd ( final File xmlInputFile , final File xsdOutFile ) throws XmlException , IOException { } }

implementation: xmlToXsd ( xmlInputFile , xsdOutFile , new Inst2XsdOptions ( ) ) ;


signature:
public class XmlToXsdExtensions { /** * Creates or update the given xsd output file from the given XML file .
 * @ param xmlInputFile
 * the xml input file
 * @ param xsdOutFile
 * the xsd out file
 * @ param inst2XsdOptions
 * the inst2 xsd options
 * @ throws XmlException
 * occurs when a give xml file is invalid .
 * @ throws IOException
 * Signals that an I / O exception has occurred . */
public static void xmlToXsd ( final File xmlInputFile , final File xsdOutFile , final Inst2XsdOptions inst2XsdOptions ) throws XmlException , IOException { } }

implementation: xmlToXsd ( xmlInputFile , xsdOutFile , inst2XsdOptions , new XmlOptions ( ) . setSavePrettyPrint ( ) ) ;