idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
5,800
protected final void openSessionForRead ( String applicationId , List < String > permissions , SessionLoginBehavior behavior , int activityCode ) { openSession ( applicationId , permissions , behavior , activityCode , SessionAuthorizationType . READ ) ; }
Opens a new session with read permissions . If either applicationID or permissions is null this method will default to using the values from the associated meta - data value and an empty list respectively .
5,801
public static void fetchDeferredAppLinkData ( Context context , String applicationId , final CompletionHandler completionHandler ) { Validate . notNull ( context , "context" ) ; Validate . notNull ( completionHandler , "completionHandler" ) ; if ( applicationId == null ) { applicationId = Utility . getMetadataApplicationId ( context ) ; } Validate . notNull ( applicationId , "applicationId" ) ; final Context applicationContext = context . getApplicationContext ( ) ; final String applicationIdCopy = applicationId ; Settings . getExecutor ( ) . execute ( new Runnable ( ) { public void run ( ) { fetchDeferredAppLinkFromServer ( applicationContext , applicationIdCopy , completionHandler ) ; } } ) ; }
Asynchronously fetches app link information that might have been stored for use after installation of the app
5,802
public static AppLinkData createFromActivity ( Activity activity ) { Validate . notNull ( activity , "activity" ) ; Intent intent = activity . getIntent ( ) ; if ( intent == null ) { return null ; } AppLinkData appLinkData = createFromAlApplinkData ( intent ) ; if ( appLinkData == null ) { String appLinkArgsJsonString = intent . getStringExtra ( BUNDLE_APPLINK_ARGS_KEY ) ; appLinkData = createFromJson ( appLinkArgsJsonString ) ; } if ( appLinkData == null ) { appLinkData = createFromUri ( intent . getData ( ) ) ; } return appLinkData ; }
Parses out any app link data from the Intent of the Activity passed in .
5,803
public void setPattern ( Pattern regex ) { this . re = regex ; int memregCount , counterCount , lookaheadCount ; if ( ( memregCount = regex . memregs ) > 0 ) { MemReg [ ] memregs = new MemReg [ memregCount ] ; for ( int i = 0 ; i < memregCount ; i ++ ) { memregs [ i ] = new MemReg ( - 1 ) ; } this . memregs = memregs ; } if ( ( counterCount = regex . counters ) > 0 ) counters = new int [ counterCount ] ; if ( ( lookaheadCount = regex . lookaheads ) > 0 ) { LAEntry [ ] lookaheads = new LAEntry [ lookaheadCount ] ; for ( int i = 0 ; i < lookaheadCount ; i ++ ) { lookaheads [ i ] = new LAEntry ( ) ; } this . lookaheads = lookaheads ; } this . memregCount = memregCount ; this . counterCount = counterCount ; this . lookaheadCount = lookaheadCount ; first = new SearchEntry ( ) ; defaultEntry = new SearchEntry ( ) ; minQueueLength = regex . stringRepr . length ( ) / 2 ; }
Sets the regex Pattern this tries to match . Won t do anything until the target is set as well .
5,804
public void skip ( ) { int we = wEnd ; if ( wOffset == we ) { if ( top == null ) { wOffset ++ ; flush ( ) ; } return ; } else { if ( we < 0 ) wOffset = 0 ; else wOffset = we ; } flush ( ) ; }
Sets the current search position just after the end of last match .
5,805
public void flush ( ) { top = null ; defaultEntry . reset ( 0 ) ; first . reset ( minQueueLength ) ; for ( int i = memregs . length - 1 ; i > 0 ; i -- ) { MemReg mr = memregs [ i ] ; mr . in = mr . out = - 1 ; } called = false ; }
Resets the internal state .
5,806
public int start ( String name ) { Integer id = re . groupId ( name ) ; if ( id == null ) throw new IllegalArgumentException ( "<" + name + "> isn't defined" ) ; return start ( id ) ; }
Returns the start index of the subsequence captured by the given named - capturing group during the previous match operation .
5,807
private static int repeat ( char [ ] data , int off , int out , Term term ) { switch ( term . type ) { case Term . CHAR : { char c = term . c ; int i = off ; while ( i < out ) { if ( data [ i ] != c ) break ; i ++ ; } return i - off ; } case Term . ANY_CHAR : { return out - off ; } case Term . ANY_CHAR_NE : { int i = off ; char c ; while ( i < out ) { if ( ( c = data [ i ] ) == '\r' || c == '\n' ) break ; i ++ ; } return i - off ; } case Term . BITSET : { IntBitSet arr = term . bitset ; int i = off ; char c ; if ( term . inverse ) while ( i < out ) { if ( ( c = data [ i ] ) <= 255 && arr . get ( c ) ) break ; else i ++ ; } else while ( i < out ) { if ( ( c = data [ i ] ) <= 255 && arr . get ( c ) ) i ++ ; else break ; } return i - off ; } case Term . BITSET2 : { int i = off ; IntBitSet [ ] bitset2 = term . bitset2 ; char c ; if ( term . inverse ) while ( i < out ) { IntBitSet arr = bitset2 [ ( c = data [ i ] ) >> 8 ] ; if ( arr != null && arr . get ( c & 0xff ) ) break ; else i ++ ; } else while ( i < out ) { IntBitSet arr = bitset2 [ ( c = data [ i ] ) >> 8 ] ; if ( arr != null && arr . get ( c & 0xff ) ) i ++ ; else break ; } return i - off ; } } throw new Error ( "this kind of term can't be quantified:" + term . type ) ; }
repeat while matches
5,808
private static int find ( char [ ] data , int off , int out , Term term ) { if ( off >= out ) return - 1 ; switch ( term . type ) { case Term . CHAR : { char c = term . c ; int i = off ; while ( i < out ) { if ( data [ i ] == c ) break ; i ++ ; } return i - off ; } case Term . BITSET : { IntBitSet arr = term . bitset ; int i = off ; char c ; if ( ! term . inverse ) while ( i < out ) { if ( ( c = data [ i ] ) <= 255 && arr . get ( c ) ) break ; else i ++ ; } else while ( i < out ) { if ( ( c = data [ i ] ) <= 255 && arr . get ( c ) ) i ++ ; else break ; } return i - off ; } case Term . BITSET2 : { int i = off ; IntBitSet [ ] bitset2 = term . bitset2 ; char c ; if ( ! term . inverse ) while ( i < out ) { IntBitSet arr = bitset2 [ ( c = data [ i ] ) >> 8 ] ; if ( arr != null && arr . get ( c & 0xff ) ) break ; else i ++ ; } else while ( i < out ) { IntBitSet arr = bitset2 [ ( c = data [ i ] ) >> 8 ] ; if ( arr != null && arr . get ( c & 0xff ) ) i ++ ; else break ; } return i - off ; } } throw new IllegalArgumentException ( "can't seek this kind of term:" + term . type ) ; }
repeat while doesn t match
5,809
public PendingCall present ( ) { logDialogActivity ( activity , fragment , getEventName ( appCall . getRequestIntent ( ) ) , AnalyticsEvents . PARAMETER_DIALOG_OUTCOME_VALUE_COMPLETED ) ; if ( onPresentCallback != null ) { try { onPresentCallback . onPresent ( activity ) ; } catch ( Exception e ) { throw new FacebookException ( e ) ; } } if ( fragment != null ) { fragment . startActivityForResult ( appCall . getRequestIntent ( ) , appCall . getRequestCode ( ) ) ; } else { activity . startActivityForResult ( appCall . getRequestIntent ( ) , appCall . getRequestCode ( ) ) ; } return appCall ; }
Launches an activity in the Facebook application to present the desired dialog . This method returns a PendingCall that contains a unique ID associated with this call to the Facebook application . In general a calling Activity should use UiLifecycleHelper to handle incoming activity results in order to ensure proper processing of the results from this dialog .
5,810
public static boolean handleActivityResult ( Context context , PendingCall appCall , int requestCode , Intent data , Callback callback ) { if ( requestCode != appCall . getRequestCode ( ) ) { return false ; } if ( attachmentStore != null ) { attachmentStore . cleanupAttachmentsForCall ( context , appCall . getCallId ( ) ) ; } if ( callback != null ) { if ( NativeProtocol . isErrorResult ( data ) ) { Exception error = NativeProtocol . getErrorFromResult ( data ) ; callback . onError ( appCall , error , data . getExtras ( ) ) ; } else { callback . onComplete ( appCall , NativeProtocol . getSuccessResultsFromIntent ( data ) ) ; } } return true ; }
Parses the results of a dialog activity and calls the appropriate method on the provided Callback .
5,811
public static boolean canPresentShareDialog ( Context context , ShareDialogFeature ... features ) { return handleCanPresent ( context , EnumSet . of ( ShareDialogFeature . SHARE_DIALOG , features ) ) ; }
Determines whether the version of the Facebook application installed on the user s device is recent enough to support specific features of the native Share dialog which in turn may be used to determine which UI etc . to present to the user .
5,812
public static boolean canPresentMessageDialog ( Context context , MessageDialogFeature ... features ) { return handleCanPresent ( context , EnumSet . of ( MessageDialogFeature . MESSAGE_DIALOG , features ) ) ; }
Determines whether the version of the Facebook application installed on the user s device is recent enough to support specific features of the native Message dialog which in turn may be used to determine which UI etc . to present to the user .
5,813
public static boolean canPresentOpenGraphActionDialog ( Context context , OpenGraphActionDialogFeature ... features ) { return handleCanPresent ( context , EnumSet . of ( OpenGraphActionDialogFeature . OG_ACTION_DIALOG , features ) ) ; }
Determines whether the version of the Facebook application installed on the user s device is recent enough to support specific features of the native Open Graph action dialog which in turn may be used to determine which UI etc . to present to the user .
5,814
public static boolean canPresentOpenGraphMessageDialog ( Context context , OpenGraphMessageDialogFeature ... features ) { return handleCanPresent ( context , EnumSet . of ( OpenGraphMessageDialogFeature . OG_MESSAGE_DIALOG , features ) ) ; }
Determines whether the version of the Facebook application installed on the user s device is recent enough to support specific features of the native Open Graph Message dialog which in turn may be used to determine which UI etc . to present to the user .
5,815
private static String reduceVariant ( final String variant ) { if ( isEmpty ( variant ) ) throw new AssertionError ( "Shouldn't happen, can't reduce non existent variant" ) ; int indexOfUnderscore = variant . lastIndexOf ( '_' ) ; if ( indexOfUnderscore == - 1 ) return "" ; return variant . substring ( 0 , indexOfUnderscore ) ; }
This function is used internally to reduce the variant - > a_b_c - > a_b .
5,816
@ SuppressWarnings ( { "unchecked" } ) public static < V > V associate ( Associator associator , Serializable id , V value ) { associator . setAssociated ( new TypedIdKey < V > ( ( Class < V > ) value . getClass ( ) , id ) , value ) ; return value ; }
Associates the given value s type and the id with the given value using the given associator .
5,817
@ SuppressWarnings ( { "unchecked" } ) public static < V > V put ( Map < ? super TypedIdKey < V > , ? super V > map , Serializable id , V value ) { map . put ( new TypedIdKey < V > ( ( Class < V > ) value . getClass ( ) , id ) , value ) ; return value ; }
Associates the given value s type and the id with the given value using the given map .
5,818
public static < V > Optional < V > associated ( Associator associator , Class < V > type , Serializable id ) { return associator . associated ( new TypedIdKey < > ( type , id ) , type ) ; }
Retrieves a value with the given type and id from the given associator .
5,819
@ SuppressWarnings ( { "unchecked" } ) public static < V > Optional < V > get ( Map < ? , ? > map , Class < V > type , Serializable id ) { return Optional . ofNullable ( ( V ) map . get ( new TypedIdKey < > ( type , id ) ) ) ; }
Retrieves a value with the given type and id from the given map .
5,820
public static BaseFolder with ( String first , String ... more ) { return new BaseFolder ( Paths . get ( first , more ) ) ; }
Creates a new base folder at the specified location .
5,821
@ SuppressWarnings ( { "PMD.GuardLogStatement" , "PMD.AvoidDuplicateLiterals" } ) public void add ( Object obj ) { synchronized ( this ) { running += 1 ; if ( generators != null ) { generators . put ( obj , null ) ; generatorTracking . finest ( ( ) -> "Added generator " + obj + ", " + generators . size ( ) + " generators registered: " + generators . keySet ( ) ) ; } if ( running == 1 ) { keepAlive = new Thread ( "GeneratorRegistry" ) { public void run ( ) { try { while ( true ) { Thread . sleep ( Long . MAX_VALUE ) ; } } catch ( InterruptedException e ) { } } } ; keepAlive . start ( ) ; } } }
Adds a generator .
5,822
@ SuppressWarnings ( "PMD.GuardLogStatement" ) public void remove ( Object obj ) { synchronized ( this ) { running -= 1 ; if ( generators != null ) { generators . remove ( obj ) ; generatorTracking . finest ( ( ) -> "Removed generator " + obj + ", " + generators . size ( ) + " generators registered: " + generators . keySet ( ) ) ; } if ( running == 0 ) { generatorTracking . finest ( ( ) -> "Zero generators, notifying all." ) ; keepAlive . interrupt ( ) ; notifyAll ( ) ; } } }
Removes the generator .
5,823
@ SuppressWarnings ( { "PMD.CollapsibleIfStatements" , "PMD.GuardLogStatement" } ) public void awaitExhaustion ( ) throws InterruptedException { synchronized ( this ) { if ( generators != null ) { if ( running != generators . size ( ) ) { generatorTracking . severe ( ( ) -> "Generator count doesn't match tracked." ) ; } } while ( running > 0 ) { if ( generators != null ) { generatorTracking . fine ( ( ) -> "Thread " + Thread . currentThread ( ) . getName ( ) + " is waiting, " + generators . size ( ) + " generators registered: " + generators . keySet ( ) ) ; } wait ( ) ; } generatorTracking . finest ( "Thread " + Thread . currentThread ( ) . getName ( ) + " continues." ) ; } }
Await exhaustion .
5,824
@ SuppressWarnings ( { "PMD.CollapsibleIfStatements" , "PMD.GuardLogStatement" } ) public boolean awaitExhaustion ( long timeout ) throws InterruptedException { synchronized ( this ) { if ( generators != null ) { if ( running != generators . size ( ) ) { generatorTracking . severe ( "Generator count doesn't match tracked." ) ; } } if ( isExhausted ( ) ) { return true ; } if ( generators != null ) { generatorTracking . fine ( ( ) -> "Waiting, generators: " + generators . keySet ( ) ) ; } wait ( timeout ) ; if ( generators != null ) { generatorTracking . fine ( ( ) -> "Waited, generators: " + generators . keySet ( ) ) ; } return isExhausted ( ) ; } }
Await exhaustion with a timeout .
5,825
public boolean matchesLocale ( String loc ) { return getLocale ( ) == null || ( getLocale ( ) . isPresent ( ) && getLocale ( ) . get ( ) . startsWith ( loc ) ) ; }
Returns true if the information matches the specified locale .
5,826
public static Request newPostRequest ( Session session , String graphPath , GraphObject graphObject , Callback callback ) { Request request = new Request ( session , graphPath , null , HttpMethod . POST , callback ) ; request . setGraphObject ( graphObject ) ; return request ; }
Creates a new Request configured to post a GraphObject to a particular graph path to either create or update the object at that path .
5,827
public static Request newMeRequest ( Session session , final GraphUserCallback callback ) { Callback wrapper = new Callback ( ) { public void onCompleted ( Response response ) { if ( callback != null ) { callback . onCompleted ( response . getGraphObjectAs ( GraphUser . class ) , response ) ; } } } ; return new Request ( session , ME , null , null , wrapper ) ; }
Creates a new Request configured to retrieve a user s own profile .
5,828
public static Request newMyFriendsRequest ( Session session , final GraphUserListCallback callback ) { Callback wrapper = new Callback ( ) { public void onCompleted ( Response response ) { if ( callback != null ) { callback . onCompleted ( typedListFromResponse ( response , GraphUser . class ) , response ) ; } } } ; return new Request ( session , MY_FRIENDS , null , null , wrapper ) ; }
Creates a new Request configured to retrieve a user s friend list .
5,829
public static Request newUploadPhotoRequest ( Session session , Bitmap image , Callback callback ) { Bundle parameters = new Bundle ( 1 ) ; parameters . putParcelable ( PICTURE_PARAM , image ) ; return new Request ( session , MY_PHOTOS , parameters , HttpMethod . POST , callback ) ; }
Creates a new Request configured to upload a photo to the user s default photo album .
5,830
public static Request newUploadPhotoRequest ( Session session , File file , Callback callback ) throws FileNotFoundException { ParcelFileDescriptor descriptor = ParcelFileDescriptor . open ( file , ParcelFileDescriptor . MODE_READ_ONLY ) ; Bundle parameters = new Bundle ( 1 ) ; parameters . putParcelable ( PICTURE_PARAM , descriptor ) ; return new Request ( session , MY_PHOTOS , parameters , HttpMethod . POST , callback ) ; }
Creates a new Request configured to upload a photo to the user s default photo album . The photo will be read from the specified stream .
5,831
public static Request newUploadVideoRequest ( Session session , File file , Callback callback ) throws FileNotFoundException { ParcelFileDescriptor descriptor = ParcelFileDescriptor . open ( file , ParcelFileDescriptor . MODE_READ_ONLY ) ; Bundle parameters = new Bundle ( 1 ) ; parameters . putParcelable ( file . getName ( ) , descriptor ) ; return new Request ( session , MY_VIDEOS , parameters , HttpMethod . POST , callback ) ; }
Creates a new Request configured to upload a photo to the user s default photo album . The photo will be read from the specified file descriptor .
5,832
public static Request newGraphPathRequest ( Session session , String graphPath , Callback callback ) { return new Request ( session , graphPath , null , null , callback ) ; }
Creates a new Request configured to retrieve a particular graph path .
5,833
public static Request newPlacesSearchRequest ( Session session , Location location , int radiusInMeters , int resultsLimit , String searchText , final GraphPlaceListCallback callback ) { if ( location == null && Utility . isNullOrEmpty ( searchText ) ) { throw new FacebookException ( "Either location or searchText must be specified." ) ; } Bundle parameters = new Bundle ( 5 ) ; parameters . putString ( "type" , "place" ) ; parameters . putInt ( "limit" , resultsLimit ) ; if ( location != null ) { parameters . putString ( "center" , String . format ( Locale . US , "%f,%f" , location . getLatitude ( ) , location . getLongitude ( ) ) ) ; parameters . putInt ( "distance" , radiusInMeters ) ; } if ( ! Utility . isNullOrEmpty ( searchText ) ) { parameters . putString ( "q" , searchText ) ; } Callback wrapper = new Callback ( ) { public void onCompleted ( Response response ) { if ( callback != null ) { callback . onCompleted ( typedListFromResponse ( response , GraphPlace . class ) , response ) ; } } } ; return new Request ( session , SEARCH , parameters , HttpMethod . GET , wrapper ) ; }
Creates a new Request that is configured to perform a search for places near a specified location via the Graph API . At least one of location or searchText must be specified .
5,834
public static Request newPostOpenGraphActionRequest ( Session session , OpenGraphAction openGraphAction , Callback callback ) { if ( openGraphAction == null ) { throw new FacebookException ( "openGraphAction cannot be null" ) ; } if ( Utility . isNullOrEmpty ( openGraphAction . getType ( ) ) ) { throw new FacebookException ( "openGraphAction must have non-null 'type' property" ) ; } String path = String . format ( MY_ACTION_FORMAT , openGraphAction . getType ( ) ) ; return newPostRequest ( session , path , openGraphAction , callback ) ; }
Creates a new Request configured to publish an Open Graph action .
5,835
public static Request newDeleteObjectRequest ( Session session , String id , Callback callback ) { return new Request ( session , id , null , HttpMethod . DELETE , callback ) ; }
Creates a new Request configured to delete a resource through the Graph API .
5,836
public static final ConfigurationSourceKey propertyFile ( final String name ) { return new ConfigurationSourceKey ( Type . FILE , Format . PROPERTIES , name ) ; }
Creates a new configuration source key for property files .
5,837
public static final ConfigurationSourceKey xmlFile ( final String name ) { return new ConfigurationSourceKey ( Type . FILE , Format . XML , name ) ; }
Creates a new configuration source key for xml files .
5,838
public static final ConfigurationSourceKey jsonFile ( final String name ) { return new ConfigurationSourceKey ( Type . FILE , Format . JSON , name ) ; }
Creates a new configuration source key for json files .
5,839
public static < T > boolean isSubset ( Collection < T > subset , Collection < T > superset ) { if ( ( superset == null ) || ( superset . size ( ) == 0 ) ) { return ( ( subset == null ) || ( subset . size ( ) == 0 ) ) ; } HashSet < T > hash = new HashSet < T > ( superset ) ; for ( T t : subset ) { if ( ! hash . contains ( t ) ) { return false ; } } return true ; }
the same .
5,840
static InputStream getCachedImageStream ( URI url , Context context ) { InputStream imageStream = null ; if ( url != null ) { if ( isCDNURL ( url ) ) { try { FileLruCache cache = getCache ( context ) ; imageStream = cache . get ( url . toString ( ) ) ; } catch ( IOException e ) { Logger . log ( LoggingBehavior . CACHE , Log . WARN , TAG , e . toString ( ) ) ; } } } return imageStream ; }
Does not throw if there was an error .
5,841
public void reduceThis ( ) { if ( elements == null || elements . isEmpty ( ) ) throw new AssertionError ( "Can't reduce this environment" ) ; elements . remove ( elements . size ( ) - 1 ) ; }
Reduces current environment . Modifies current object hence NOT THREADSAFE .
5,842
public static Environment parse ( final String s ) { if ( s == null || s . isEmpty ( ) || s . trim ( ) . isEmpty ( ) ) return GlobalEnvironment . INSTANCE ; final String [ ] tokens = StringUtils . tokenize ( s , '_' ) ; final DynamicEnvironment env = new DynamicEnvironment ( ) ; for ( final String t : tokens ) { env . add ( t ) ; } return env ; }
Parses a string and creates a new Environment which corresponds the string .
5,843
public static void downloadAsync ( ImageRequest request ) { if ( request == null ) { return ; } RequestKey key = new RequestKey ( request . getImageUri ( ) , request . getCallerTag ( ) ) ; synchronized ( pendingRequests ) { DownloaderContext downloaderContext = pendingRequests . get ( key ) ; if ( downloaderContext != null ) { downloaderContext . request = request ; downloaderContext . isCancelled = false ; downloaderContext . workItem . moveToFront ( ) ; } else { enqueueCacheRead ( request , key , request . isCachedRedirectAllowed ( ) ) ; } } }
Downloads the image specified in the passed in request . If a callback is specified it is guaranteed to be invoked on the calling thread .
5,844
public static AppEventsLogger newLogger ( Context context , String applicationId ) { return new AppEventsLogger ( context , applicationId , null ) ; }
Build an AppEventsLogger instance to log events that are attributed to the application but not to any particular Session .
5,845
public void logEvent ( String eventName , Bundle parameters ) { logEvent ( eventName , null , parameters , false ) ; }
Log an app event with the specified name and set of parameters .
5,846
public void logEvent ( String eventName , double valueToSum , Bundle parameters ) { logEvent ( eventName , valueToSum , parameters , false ) ; }
Log an app event with the specified name supplied value and set of parameters .
5,847
public void logPurchase ( BigDecimal purchaseAmount , Currency currency , Bundle parameters ) { if ( purchaseAmount == null ) { notifyDeveloperError ( "purchaseAmount cannot be null" ) ; return ; } else if ( currency == null ) { notifyDeveloperError ( "currency cannot be null" ) ; return ; } if ( parameters == null ) { parameters = new Bundle ( ) ; } parameters . putString ( AppEventsConstants . EVENT_PARAM_CURRENCY , currency . getCurrencyCode ( ) ) ; logEvent ( AppEventsConstants . EVENT_NAME_PURCHASED , purchaseAmount . doubleValue ( ) , parameters ) ; eagerFlush ( ) ; }
Logs a purchase event with Facebook in the specified amount and with the specified currency . Additional detail about the purchase can be passed in through the parameters bundle .
5,848
public void logSdkEvent ( String eventName , Double valueToSum , Bundle parameters ) { logEvent ( eventName , valueToSum , parameters , true ) ; }
This method is intended only for internal use by the Facebook SDK and other use is unsupported .
5,849
private static SessionEventsState getSessionEventsState ( Context context , AccessTokenAppIdPair accessTokenAppId ) { SessionEventsState state = stateMap . get ( accessTokenAppId ) ; AttributionIdentifiers attributionIdentifiers = null ; if ( state == null ) { attributionIdentifiers = AttributionIdentifiers . getAttributionIdentifiers ( context ) ; } synchronized ( staticLock ) { state = stateMap . get ( accessTokenAppId ) ; if ( state == null ) { state = new SessionEventsState ( attributionIdentifiers , context . getPackageName ( ) , hashedDeviceAndAppId ) ; stateMap . put ( accessTokenAppId , state ) ; } return state ; } }
Creates a new SessionEventsState if not already in the map .
5,850
private static void setSourceApplication ( Activity activity ) { ComponentName callingApplication = activity . getCallingActivity ( ) ; if ( callingApplication != null ) { String callingApplicationPackage = callingApplication . getPackageName ( ) ; if ( callingApplicationPackage . equals ( activity . getPackageName ( ) ) ) { resetSourceApplication ( ) ; return ; } sourceApplication = callingApplicationPackage ; } Intent openIntent = activity . getIntent ( ) ; if ( openIntent == null || openIntent . getBooleanExtra ( SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT , false ) ) { resetSourceApplication ( ) ; return ; } Bundle applinkData = AppLinks . getAppLinkData ( openIntent ) ; if ( applinkData == null ) { resetSourceApplication ( ) ; return ; } isOpenedByApplink = true ; Bundle applinkReferrerData = applinkData . getBundle ( "referer_app_link" ) ; if ( applinkReferrerData == null ) { sourceApplication = null ; return ; } String applinkReferrerPackage = applinkReferrerData . getString ( "package" ) ; sourceApplication = applinkReferrerPackage ; openIntent . putExtra ( SOURCE_APPLICATION_HAS_BEEN_SET_BY_THIS_INTENT , true ) ; return ; }
Source Application setters and getters
5,851
private Pair < List < BooleanExpression > , Optional < BooleanExpression > > extractWhereConditions ( SelectQueryAware selectQueryAware ) { List < BooleanExpression > whereConditions = new ArrayList < > ( ) ; Optional < BooleanExpression > whereExpressionCandidate = selectQueryAware . getWhereExpression ( ) ; if ( whereExpressionCandidate . isPresent ( ) ) { whereConditions . add ( whereExpressionCandidate . get ( ) ) ; } boolean noGroupByTaskExists = selectQueryAware . getGroupByExpressions ( ) . isEmpty ( ) ; Optional < BooleanExpression > havingExpressionCandidate = selectQueryAware . getHavingExpression ( ) ; if ( havingExpressionCandidate . isPresent ( ) && noGroupByTaskExists ) { whereConditions . add ( havingExpressionCandidate . get ( ) ) ; return new Pair < > ( whereConditions , Optional . empty ( ) ) ; } else { return new Pair < > ( whereConditions , havingExpressionCandidate ) ; } }
Deciding whether having clause can be moved to where clause
5,852
private Pair < DataSource , Optional < BooleanExpression > > optimizeDataSource ( DataSource originalDataSource , List < BooleanExpression > originalWhereConditions , Map < String , Object > selectionMap , Map < String , String > tableAliases ) { OptimizationContext optimizationContext = analyzeOriginalData ( originalDataSource , originalWhereConditions , tableAliases ) ; DataSource optimizedDataSource = createOptimizedDataSource ( originalDataSource , optimizationContext , selectionMap , tableAliases ) ; Optional < BooleanExpression > optimizedWhereCondition = createOptimizedWhereCondition ( optimizationContext ) ; return new Pair < > ( optimizedDataSource , optimizedWhereCondition ) ; }
Deciding whether parts of where clause can be moved to data sources
5,853
public static ReplyObject success ( final String name , final Object result ) { final ReplyObject ret = new ReplyObject ( name , result ) ; ret . success = true ; return ret ; }
Factory method that creates a new reply object for successful request .
5,854
public final void close ( ) { synchronized ( this . lock ) { final SessionState oldState = this . state ; switch ( this . state ) { case CREATED : case OPENING : this . state = SessionState . CLOSED_LOGIN_FAILED ; postStateChange ( oldState , this . state , new FacebookException ( "Log in attempt aborted." ) ) ; break ; case CREATED_TOKEN_LOADED : case OPENED : case OPENED_TOKEN_UPDATED : this . state = SessionState . CLOSED ; postStateChange ( oldState , this . state , null ) ; break ; case CLOSED : case CLOSED_LOGIN_FAILED : break ; } } }
Closes the local in - memory Session object but does not clear the persisted token cache .
5,855
public final void closeAndClearTokenInformation ( ) { if ( this . tokenCachingStrategy != null ) { this . tokenCachingStrategy . clear ( ) ; } Utility . clearFacebookCookies ( staticContext ) ; Utility . clearCaches ( staticContext ) ; close ( ) ; }
Closes the local in - memory Session object and clears any persisted token cache related to the Session .
5,856
public final void addCallback ( StatusCallback callback ) { synchronized ( callbacks ) { if ( callback != null && ! callbacks . contains ( callback ) ) { callbacks . add ( callback ) ; } } }
Adds a callback that will be called when the state of this Session changes .
5,857
public static final void saveSession ( Session session , Bundle bundle ) { if ( bundle != null && session != null && ! bundle . containsKey ( SESSION_BUNDLE_SAVE_KEY ) ) { ByteArrayOutputStream outputStream = new ByteArrayOutputStream ( ) ; try { new ObjectOutputStream ( outputStream ) . writeObject ( session ) ; } catch ( IOException e ) { throw new FacebookException ( "Unable to save session." , e ) ; } bundle . putByteArray ( SESSION_BUNDLE_SAVE_KEY , outputStream . toByteArray ( ) ) ; bundle . putBundle ( AUTH_BUNDLE_SAVE_KEY , session . authorizationBundle ) ; } }
Save the Session object into the supplied Bundle . This method is intended to be called from an Activity or Fragment s onSaveInstanceState method in order to preserve Sessions across Activity lifecycle events .
5,858
public static final Session restoreSession ( Context context , TokenCachingStrategy cachingStrategy , StatusCallback callback , Bundle bundle ) { if ( bundle == null ) { return null ; } byte [ ] data = bundle . getByteArray ( SESSION_BUNDLE_SAVE_KEY ) ; if ( data != null ) { ByteArrayInputStream is = new ByteArrayInputStream ( data ) ; try { Session session = ( Session ) ( new ObjectInputStream ( is ) ) . readObject ( ) ; initializeStaticContext ( context ) ; if ( cachingStrategy != null ) { session . tokenCachingStrategy = cachingStrategy ; } else { session . tokenCachingStrategy = new SharedPreferencesTokenCachingStrategy ( context ) ; } if ( callback != null ) { session . addCallback ( callback ) ; } session . authorizationBundle = bundle . getBundle ( AUTH_BUNDLE_SAVE_KEY ) ; return session ; } catch ( ClassNotFoundException e ) { Log . w ( TAG , "Unable to restore session" , e ) ; } catch ( IOException e ) { Log . w ( TAG , "Unable to restore session." , e ) ; } } return null ; }
Restores the saved session from a Bundle if any . Returns the restored Session or null if it could not be restored . This method is intended to be called from an Activity or Fragment s onCreate method when a Session has previously been saved into a Bundle via saveState to preserve a Session across Activity lifecycle events .
5,859
public Node getConfigurationOption ( String optionName ) { NodeList children = configuration . getChildNodes ( ) ; Node configurationOption = null ; for ( int childIndex = 0 ; childIndex < children . getLength ( ) ; childIndex ++ ) { if ( children . item ( childIndex ) . getNodeName ( ) . equals ( optionName ) ) { configurationOption = children . item ( childIndex ) ; break ; } } return configurationOption ; }
Get a configuration option of this configurator .
5,860
public String getConfigurationOptionValue ( String optionName , String defaultValue ) { String optionValue ; Node configurationOption = this . getConfigurationOption ( optionName ) ; if ( configurationOption != null ) { optionValue = configurationOption . getTextContent ( ) ; } else { optionValue = defaultValue ; } return optionValue ; }
Get a configuration option value as String .
5,861
public InputStream interceptAndPut ( String key , InputStream input ) throws IOException { OutputStream output = openPutStream ( key ) ; return new CopyingInputStream ( input , output ) ; }
copy of input and associate that data with key .
5,862
public void configure ( ) { ServletContext servletContext = ServletActionContext . getServletContext ( ) ; ServletContextTemplateResolver templateResolver = new ServletContextTemplateResolver ( servletContext ) ; templateResolver . setTemplateMode ( templateMode ) ; templateResolver . setCharacterEncoding ( characterEncoding ) ; templateResolver . setPrefix ( prefix ) ; templateResolver . setSuffix ( suffix ) ; templateResolver . setCacheable ( cacheable ) ; templateResolver . setCacheTTLMs ( cacheTtlMillis ) ; templateEngine . setTemplateResolver ( templateResolver ) ; StrutsMessageResolver messageResolver = new StrutsMessageResolver ( ) ; templateEngine . setMessageResolver ( new StrutsMessageResolver ( ) ) ; if ( templateEngine instanceof SpringTemplateEngine ) { ( ( SpringTemplateEngine ) templateEngine ) . setMessageSource ( messageResolver . getMessageSource ( ) ) ; } FieldDialect fieldDialect = new FieldDialect ( TemplateMode . HTML , "sth" ) ; templateEngine . addDialect ( fieldDialect ) ; }
Configure settings from the struts . xml or struts . properties using sensible defaults if values are not provided .
5,863
public void setContainer ( Container container ) { this . container = container ; Map < String , TemplateEngine > map = new HashMap < String , TemplateEngine > ( ) ; Set < String > prefixes = container . getInstanceNames ( TemplateEngine . class ) ; for ( String prefix : prefixes ) { TemplateEngine engine = ( TemplateEngine ) container . getInstance ( TemplateEngine . class , prefix ) ; map . put ( prefix , engine ) ; } this . templateEngines = Collections . unmodifiableMap ( map ) ; }
loading di container configulation from struts - plugin . xml choise thymeleaf template engine .
5,864
public static boolean hasTokenInformation ( Bundle bundle ) { if ( bundle == null ) { return false ; } String token = bundle . getString ( TOKEN_KEY ) ; if ( ( token == null ) || ( token . length ( ) == 0 ) ) { return false ; } long expiresMilliseconds = bundle . getLong ( EXPIRATION_DATE_KEY , 0L ) ; if ( expiresMilliseconds == 0L ) { return false ; } return true ; }
Returns a boolean indicating whether a Bundle contains properties that could be a valid saved token .
5,865
public static String getToken ( Bundle bundle ) { Validate . notNull ( bundle , "bundle" ) ; return bundle . getString ( TOKEN_KEY ) ; }
Gets the cached token value from a Bundle .
5,866
public static void putToken ( Bundle bundle , String value ) { Validate . notNull ( bundle , "bundle" ) ; Validate . notNull ( value , "value" ) ; bundle . putString ( TOKEN_KEY , value ) ; }
Puts the token value into a Bundle .
5,867
public static Date getExpirationDate ( Bundle bundle ) { Validate . notNull ( bundle , "bundle" ) ; return getDate ( bundle , EXPIRATION_DATE_KEY ) ; }
Gets the cached expiration date from a Bundle .
5,868
public static List < String > getPermissions ( Bundle bundle ) { Validate . notNull ( bundle , "bundle" ) ; return bundle . getStringArrayList ( PERMISSIONS_KEY ) ; }
Gets the cached list of permissions from a Bundle .
5,869
public static void putPermissions ( Bundle bundle , List < String > value ) { Validate . notNull ( bundle , "bundle" ) ; Validate . notNull ( value , "value" ) ; ArrayList < String > arrayList ; if ( value instanceof ArrayList < ? > ) { arrayList = ( ArrayList < String > ) value ; } else { arrayList = new ArrayList < String > ( value ) ; } bundle . putStringArrayList ( PERMISSIONS_KEY , arrayList ) ; }
Puts the list of permissions into a Bundle .
5,870
public static void putDeclinedPermissions ( Bundle bundle , List < String > value ) { Validate . notNull ( bundle , "bundle" ) ; Validate . notNull ( value , "value" ) ; ArrayList < String > arrayList ; if ( value instanceof ArrayList < ? > ) { arrayList = ( ArrayList < String > ) value ; } else { arrayList = new ArrayList < String > ( value ) ; } bundle . putStringArrayList ( DECLINED_PERMISSIONS_KEY , arrayList ) ; }
Puts the list of declined permissions into a Bundle .
5,871
public static AccessTokenSource getSource ( Bundle bundle ) { Validate . notNull ( bundle , "bundle" ) ; if ( bundle . containsKey ( TokenCachingStrategy . TOKEN_SOURCE_KEY ) ) { return ( AccessTokenSource ) bundle . getSerializable ( TokenCachingStrategy . TOKEN_SOURCE_KEY ) ; } else { boolean isSSO = bundle . getBoolean ( TokenCachingStrategy . IS_SSO_KEY ) ; return isSSO ? AccessTokenSource . FACEBOOK_APPLICATION_WEB : AccessTokenSource . WEB_VIEW ; } }
Gets the cached enum indicating the source of the token from the Bundle .
5,872
public static void putSource ( Bundle bundle , AccessTokenSource value ) { Validate . notNull ( bundle , "bundle" ) ; bundle . putSerializable ( TOKEN_SOURCE_KEY , value ) ; }
Puts the enum indicating the source of the token into a Bundle .
5,873
public static Date getLastRefreshDate ( Bundle bundle ) { Validate . notNull ( bundle , "bundle" ) ; return getDate ( bundle , LAST_REFRESH_DATE_KEY ) ; }
Gets the cached last refresh date from a Bundle .
5,874
public Builder newCopyBuilder ( ) { return new Builder ( getInputFormat ( ) , getOutputFormat ( ) , getActivity ( ) ) . locale ( getLocale ( ) ) . setRequiredOptions ( keys ) ; }
Creates a new builder with the same settings as this information .
5,875
public static Builder newConvertBuilder ( String input , String output ) { return new Builder ( input , output , TaskGroupActivity . CONVERT ) ; }
Creates a new builder of convert type with the specified parameters .
5,876
@ SuppressWarnings ( { "PMD.DataflowAnomalyAnalysis" , "PMD.AvoidCatchingGenericException" , "PMD.UseStringBufferForStringAppends" , "PMD.SystemPrintln" } ) public void printError ( Error event ) { String msg = "Unhandled " + event ; System . err . println ( msg ) ; if ( event . throwable ( ) == null ) { System . err . println ( "No stack trace available." ) ; } else { event . throwable ( ) . printStackTrace ( ) ; } }
Prints the error .
5,877
protected List < Segment > segment ( ) { List < Segment > segments = new ArrayList < > ( ) ; List < Recipe > recipeStack = new ArrayList < > ( ) ; recipeStack . add ( this ) ; _segment ( new Recipe ( ) , recipeStack , null , segments ) ; return segments ; }
original recipe but more efficient for sending payloads of ingredients to different services .
5,878
@ RequestHandler ( patterns = "/ws/echo" , priority = 100 ) public void onGet ( Request . In . Get event , IOSubchannel channel ) throws InterruptedException { final HttpRequest request = event . httpRequest ( ) ; if ( ! request . findField ( HttpField . UPGRADE , Converters . STRING_LIST ) . map ( f -> f . value ( ) . containsIgnoreCase ( "websocket" ) ) . orElse ( false ) ) { return ; } openChannels . add ( channel ) ; channel . respond ( new ProtocolSwitchAccepted ( event , "websocket" ) ) ; event . stop ( ) ; }
Handle GET requests .
5,879
public void onUpgraded ( Upgraded event , IOSubchannel channel ) { if ( ! openChannels . contains ( channel ) ) { return ; } channel . respond ( Output . from ( "/Greetings!" , true ) ) ; }
Handle upgrade confirmation .
5,880
public void onOutput ( Output < ByteBuffer > event , PlainChannel plainChannel ) throws InterruptedException , SSLException , ExecutionException { if ( plainChannel . hub ( ) != this ) { return ; } plainChannel . sendUpstream ( event ) ; }
Sends decrypted data through the engine and then upstream .
5,881
public void onClose ( Close event , PlainChannel plainChannel ) throws InterruptedException , SSLException { if ( plainChannel . hub ( ) != this ) { return ; } plainChannel . close ( event ) ; }
Forwards a close event upstream .
5,882
public void onInput ( Input < ByteBuffer > event , Channel channel ) { Writer writer = inputWriters . get ( channel ) ; if ( writer != null ) { writer . write ( event . buffer ( ) ) ; } }
Handle input by writing it to the file if a channel exists .
5,883
public void onClose ( Close event , Channel channel ) throws InterruptedException { Writer writer = inputWriters . get ( channel ) ; if ( writer != null ) { writer . close ( event ) ; } writer = outputWriters . get ( channel ) ; if ( writer != null ) { writer . close ( event ) ; } }
Handle close by closing the file associated with the channel .
5,884
@ Handler ( priority = - 1000 ) public void onStop ( Stop event ) throws InterruptedException { while ( ! inputWriters . isEmpty ( ) ) { Writer handler = inputWriters . entrySet ( ) . iterator ( ) . next ( ) . getValue ( ) ; handler . close ( event ) ; } while ( ! outputWriters . isEmpty ( ) ) { Writer handler = outputWriters . entrySet ( ) . iterator ( ) . next ( ) . getValue ( ) ; handler . close ( event ) ; } }
Handle stop by closing all files .
5,885
private String data ( ) { if ( datasets . isEmpty ( ) ) { return "" ; } else { final StringBuilder ret = new StringBuilder ( ) ; int biggestSize = 0 ; for ( final Dataset dataset : datasets ) { biggestSize = Math . max ( biggestSize , dataset . numPoints ( ) ) ; } for ( int row = 0 ; row < biggestSize ; ++ row ) { ret . append ( valueOrBlank ( datasets . get ( 0 ) , row ) ) ; for ( final Dataset dataset : Iterables . skip ( datasets , 1 ) ) { ret . append ( "\t" ) ; ret . append ( valueOrBlank ( dataset , row ) ) ; } ret . append ( "\n" ) ; } return ret . toString ( ) ; } }
gnuplot annoyingly requires data to be written in columns
5,886
private String valueOrBlank ( Dataset dataset , int idx ) { if ( idx < dataset . numPoints ( ) ) { return Double . toString ( dataset . get ( idx ) ) ; } else { return "" ; } }
used by writeData
5,887
public static void main ( String [ ] argv ) throws IOException { final File outputDir = new File ( argv [ 0 ] ) ; final Random rand = new Random ( ) ; final double mean1 = 5.0 ; final double mean2 = 7.0 ; final double dev1 = 2.0 ; final double dev2 = 4.0 ; final double [ ] data1 = new double [ 100 ] ; final double [ ] data2 = new double [ 100 ] ; for ( int i = 0 ; i < 100 ; ++ i ) { data1 [ i ] = rand . nextGaussian ( ) * dev1 + mean1 ; data2 [ i ] = rand . nextGaussian ( ) * dev2 + mean2 ; } BoxPlot . builder ( ) . addDataset ( Dataset . createAdoptingData ( "A" , data1 ) ) . addDataset ( Dataset . createAdoptingData ( "B" , data2 ) ) . setTitle ( "A vs B" ) . setXAxis ( Axis . xAxis ( ) . setLabel ( "FooCategory" ) . build ( ) ) . setYAxis ( Axis . yAxis ( ) . setLabel ( "FooValue" ) . setRange ( Range . closed ( 0.0 , 15.0 ) ) . build ( ) ) . hideKey ( ) . build ( ) . renderToEmptyDirectory ( outputDir ) ; }
Little test program
5,888
public void setFirstAxis ( double x , double y , double z , double extent , CoordinateSystem3D system ) { this . axis1 . set ( x , y , z ) ; assert ( this . axis1 . isUnitVector ( ) ) ; if ( system . isLeftHanded ( ) ) { this . axis3 . set ( this . axis1 . crossLeftHand ( this . axis2 ) ) ; } else { this . axis3 . set ( this . axis3 . crossRightHand ( this . axis2 ) ) ; } this . extent1 = extent ; }
Set the first axis of the second . The third axis is updated to be perpendicular to the two other axis .
5,889
public ObjectProperty < PathWindingRule > windingRuleProperty ( ) { if ( this . windingRule == null ) { this . windingRule = new SimpleObjectProperty < > ( this , MathFXAttributeNames . WINDING_RULE , DEFAULT_WINDING_RULE ) ; } return this . windingRule ; }
Replies the windingRule property .
5,890
public BooleanProperty isPolylineProperty ( ) { if ( this . isPolyline == null ) { this . isPolyline = new ReadOnlyBooleanWrapper ( this , MathFXAttributeNames . IS_POLYLINE , false ) ; this . isPolyline . bind ( Bindings . createBooleanBinding ( ( ) -> { boolean first = true ; boolean hasOneLine = false ; for ( final PathElementType type : innerTypesProperty ( ) ) { if ( first ) { if ( type != PathElementType . MOVE_TO ) { return false ; } first = false ; } else if ( type != PathElementType . LINE_TO ) { return false ; } else { hasOneLine = true ; } } return hasOneLine ; } , innerTypesProperty ( ) ) ) ; } return this . isPolyline ; }
Replies the isPolyline property .
5,891
public BooleanProperty isCurvedProperty ( ) { if ( this . isCurved == null ) { this . isCurved = new ReadOnlyBooleanWrapper ( this , MathFXAttributeNames . IS_CURVED , false ) ; this . isCurved . bind ( Bindings . createBooleanBinding ( ( ) -> { for ( final PathElementType type : innerTypesProperty ( ) ) { if ( type == PathElementType . CURVE_TO || type == PathElementType . QUAD_TO ) { return true ; } } return false ; } , innerTypesProperty ( ) ) ) ; } return this . isCurved ; }
Replies the isCurved property .
5,892
public BooleanProperty isPolygonProperty ( ) { if ( this . isPolygon == null ) { this . isPolygon = new ReadOnlyBooleanWrapper ( this , MathFXAttributeNames . IS_POLYGON , false ) ; this . isPolygon . bind ( Bindings . createBooleanBinding ( ( ) -> { boolean first = true ; boolean lastIsClose = false ; for ( final PathElementType type : innerTypesProperty ( ) ) { lastIsClose = false ; if ( first ) { if ( type != PathElementType . MOVE_TO ) { return false ; } first = false ; } else if ( type == PathElementType . MOVE_TO ) { return false ; } else if ( type == PathElementType . CLOSE ) { lastIsClose = true ; } } return lastIsClose ; } , innerTypesProperty ( ) ) ) ; } return this . isPolygon ; }
Replies the isPolygon property .
5,893
protected ReadOnlyListWrapper < PathElementType > innerTypesProperty ( ) { if ( this . types == null ) { this . types = new ReadOnlyListWrapper < > ( this , MathFXAttributeNames . TYPES , FXCollections . observableList ( new ArrayList < > ( ) ) ) ; } return this . types ; }
Replies the private types property .
5,894
protected void setMapLayerAt ( int index , L layer ) { this . subLayers . set ( index , layer ) ; layer . setContainer ( this ) ; resetBoundingBox ( ) ; }
Put the given layer at the given index but do not fire any event .
5,895
protected void fireLayerAddedEvent ( MapLayer layer , int index ) { fireLayerHierarchyChangedEvent ( new MapLayerHierarchyEvent ( this , layer , Type . ADD_CHILD , index , layer . isTemporaryLayer ( ) ) ) ; }
Fire the event that indicates a layer was added .
5,896
protected void fireLayerRemovedEvent ( MapLayer layer , int oldChildIndex ) { fireLayerHierarchyChangedEvent ( new MapLayerHierarchyEvent ( this , layer , Type . REMOVE_CHILD , oldChildIndex , layer . isTemporaryLayer ( ) ) ) ; }
Fire the event that indicates a layer was removed .
5,897
protected void fireLayerMovedUpEvent ( MapLayer layer , int newIndex ) { fireLayerHierarchyChangedEvent ( new MapLayerHierarchyEvent ( this , layer , Type . MOVE_CHILD_UP , newIndex , layer . isTemporaryLayer ( ) ) ) ; }
Fire the event that indicates a layer was moved up .
5,898
protected void fireLayerMovedDownEvent ( MapLayer layer , int newIndex ) { fireLayerHierarchyChangedEvent ( new MapLayerHierarchyEvent ( this , layer , Type . MOVE_CHILD_DOWN , newIndex , layer . isTemporaryLayer ( ) ) ) ; }
Fire the event that indicates a layer was moved down .
5,899
protected void fireLayerRemoveAllEvent ( List < ? extends L > removedObjects ) { fireLayerHierarchyChangedEvent ( new MapLayerHierarchyEvent ( this , removedObjects , Type . REMOVE_ALL_CHILDREN , - 1 , isTemporaryLayer ( ) ) ) ; }
Fire the event that indicates all the layers were removed .