idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
5,600
public static boolean stringEquals ( @ Nullable final String pStr1 , @ Nullable final String pStr2 , final boolean pCaseSensitive ) { boolean result = false ; if ( pStr1 == null && pStr2 == null ) { result = true ; } else if ( pStr1 != null ) { if ( pCaseSensitive ) { result = pStr1 . equals ( pStr2 ) ; } else { result = pStr1 . equalsIgnoreCase ( pStr2 ) ; } } return result ; }
Determine the equality of two Strings optionally ignoring case .
114
13
5,601
@ Nonnull public static DetailAST findLeftMostTokenInLine ( @ Nonnull final DetailAST pAst ) { return findLeftMostTokenInLineInternal ( pAst , pAst . getLineNo ( ) , pAst . getColumnNo ( ) ) ; }
Find the left - most token in the given AST . The left - most token is the token with the smallest column number . Only tokens which are located on the same line as the given AST are considered .
56
41
5,602
public void setToolTipText ( String text ) { this . toolTipText = text ; if ( toolTipDialog != null ) { toolTipDialog . setText ( text ) ; } }
Sets the text for the tooltip to be used on this decoration .
40
14
5,603
private void updateToolTipDialogVisibility ( ) { // Determine whether tooltip should be/remain visible boolean shouldBeVisible = isOverDecorationPainter ( ) || isOverToolTipDialog ( ) ; // Create tooltip dialog if needed if ( shouldBeVisible ) { createToolTipDialogIfNeeded ( ) ; } // Update tooltip dialog visibility if changed if ( ( toolTipDialog != null ) && ( toolTipDialog . isVisible ( ) != shouldBeVisible ) ) { toolTipDialog . setVisible ( shouldBeVisible ) ; } }
Updates the visibility of the tooltip dialog according to the mouse pointer location the visibility of the decoration painter and the bounds of the decoration painter .
121
28
5,604
public void send ( Event event ) throws MetricsException { HttpPost request = new HttpPost ( MetricsUtils . GA_ENDPOINT_URL ) ; request . setEntity ( MetricsUtils . buildPostBody ( event , analyticsId , random ) ) ; try { client . execute ( request , RESPONSE_HANDLER ) ; } catch ( IOException e ) { // All errors in the request execution, including non-2XX HTTP codes, // will throw IOException or one of its subclasses. throw new MetricsCommunicationException ( "Problem sending request to server" , e ) ; } }
Translates an encapsulated event into a request to the Google Analytics API and sends the resulting request .
134
21
5,605
public synchronized boolean isRunning ( ) { if ( null == process ) return false ; try { process . exitValue ( ) ; return false ; } catch ( IllegalThreadStateException itse ) { return true ; } }
Check if Local BrowserMob Proxy is running .
45
9
5,606
private static String convertToRomaji ( String katakana ) throws EasyJaSubException { try { return Kurikosu . convertKatakanaToRomaji ( katakana ) ; } catch ( EasyJaSubException ex ) { try { return LuceneUtil . katakanaToRomaji ( katakana ) ; } catch ( Throwable luceneEx ) { throw ex ; } } }
Convert katakana to romaji with Lucene converter if Kurikosu throws errors
90
20
5,607
public DataProviderContext on ( final Trigger ... triggers ) { if ( triggers != null ) { Collections . addAll ( registeredTriggers , triggers ) ; } return this ; }
Adds more triggers to the validator .
37
8
5,608
public < D > RuleContext < D > read ( final DataProvider < D > ... dataProviders ) { final List < DataProvider < D > > registeredDataProviders = new ArrayList < DataProvider < D > > ( ) ; if ( dataProviders != null ) { Collections . addAll ( registeredDataProviders , dataProviders ) ; } return new RuleContext < D > ( registeredTriggers , registeredDataProviders ) ; }
Adds the first data providers to the validator .
95
10
5,609
public FileCollection buildClassPath ( @ Nonnull final DependencyConfig pDepConfig , @ Nullable final String pCsVersionOverride , final boolean pIsTestRun , @ Nonnull final SourceSet pSourceSet1 , @ Nullable final SourceSet ... pOtherSourceSets ) { FileCollection cp = getClassesDirs ( pSourceSet1 , pDepConfig ) . plus ( project . files ( pSourceSet1 . getOutput ( ) . getResourcesDir ( ) ) ) ; if ( pOtherSourceSets != null && pOtherSourceSets . length > 0 ) { for ( final SourceSet sourceSet : pOtherSourceSets ) { cp = cp . plus ( getClassesDirs ( sourceSet , pDepConfig ) ) . plus ( project . files ( sourceSet . getOutput ( ) . getResourcesDir ( ) ) ) ; } } cp = cp . plus ( project . files ( // calculateDependencies ( pDepConfig , pCsVersionOverride , getConfigName ( pSourceSet1 , pIsTestRun ) ) ) ) ; if ( pOtherSourceSets != null && pOtherSourceSets . length > 0 ) { for ( final SourceSet sourceSet : pOtherSourceSets ) { cp = cp . plus ( project . files ( // calculateDependencies ( pDepConfig , pCsVersionOverride , getConfigName ( sourceSet , pIsTestRun ) ) ) ) ; } } // final Logger logger = task.getLogger(); // logger.lifecycle("---------------------------------------------------------------------------"); // logger.lifecycle("Classpath of " + task.getName() + " (" + task.getClass().getSimpleName() + "):"); // for (File f : cp) { // logger.lifecycle("\t- " + f.getAbsolutePath()); // } // logger.lifecycle("- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"); return cp ; }
Run the classpath builder to produce a classpath for compilation running the Javadoc generation or running unit tests .
439
23
5,610
public static TriggerContext on ( Trigger trigger ) { List < Trigger > addedTriggers = new ArrayList < Trigger > ( ) ; if ( trigger != null ) { addedTriggers . add ( trigger ) ; } return new TriggerContext ( addedTriggers ) ; }
Adds the specified trigger to the validator under construction .
58
11
5,611
public static String getFileName ( final ConfigurationSourceKey source ) { //ensure an exception is thrown if we are not file. if ( source . getType ( ) != ConfigurationSourceKey . Type . FILE ) throw new AssertionError ( "Can only load configuration sources with type " + ConfigurationSourceKey . Type . FILE ) ; return source . getName ( ) + ' ' + source . getFormat ( ) . getExtension ( ) ; }
Returns the file name for the given source key .
95
10
5,612
public void setExtraFields ( Collection < String > fields ) { extraFields = new HashSet < String > ( ) ; if ( fields != null ) { extraFields . addAll ( fields ) ; } }
Sets the extra fields to request for the retrieved graph objects .
46
13
5,613
public Map < String , String > data ( ) { try { return event ( ) . get ( ) ; } catch ( InterruptedException e ) { // Can only happen if invoked before completion throw new IllegalStateException ( e ) ; } }
A shortcut to get the result of the completed query event .
50
12
5,614
@ Handler public void onRead ( Input < ByteBuffer > event ) throws InterruptedException { for ( IOSubchannel channel : event . channels ( IOSubchannel . class ) ) { ManagedBuffer < ByteBuffer > out = channel . byteBufferPool ( ) . acquire ( ) ; out . backingBuffer ( ) . put ( event . buffer ( ) . backingBuffer ( ) ) ; channel . respond ( Output . fromSink ( out , event . isEndOfRecord ( ) ) ) ; } }
Handle input data .
107
4
5,615
@ Handler public void onOutput ( Output < ByteBuffer > event , TcpChannelImpl channel ) throws InterruptedException { if ( channels . contains ( channel ) ) { channel . write ( event ) ; } }
Writes the data passed in the event .
44
9
5,616
public String replace ( CharSequence text ) { TextBuffer tb = wrap ( new StringBuilder ( text . length ( ) ) ) ; replace ( pattern . matcher ( text ) , substitution , tb ) ; return tb . toString ( ) ; }
Takes all instances in text of the Pattern this was constructed with and replaces them with substitution .
55
19
5,617
public int replace ( CharSequence text , StringBuilder sb ) { return replace ( pattern . matcher ( text ) , substitution , wrap ( sb ) ) ; }
Takes all occurrences of the pattern this was constructed with in text and replaces them with the substitution . Appends the replaced text into sb .
36
29
5,618
@ Handler ( priority = 1000 ) public void onProtocolSwitchAccepted ( ProtocolSwitchAccepted event , IOSubchannel channel ) { event . requestEvent ( ) . associated ( Selection . class ) . ifPresent ( selection -> channel . setAssociated ( Selection . class , selection ) ) ; }
Handles a procotol switch by associating the language selection with the channel .
62
17
5,619
public static Locale associatedLocale ( Associator assoc ) { return assoc . associated ( Selection . class ) . map ( sel -> sel . get ( ) [ 0 ] ) . orElse ( Locale . getDefault ( ) ) ; }
Convenience method to retrieve a locale from an associator .
54
13
5,620
private DataContainer fetch ( String tableAlias , IndexBooleanExpression condition , Map < String , String > tableAliases ) { String tableName = tableAliases . get ( tableAlias ) ; Set < String > ids = getIdsFromIndex ( tableName , tableAlias , condition ) ; return fetchContainer ( tableName , tableAlias , ids ) ; }
planner should guarantee that .
78
6
5,621
private static Set < Key > conditionToKeys ( int keyLength , Map < String , Set < Object > > condition ) { return crossProduct ( new ArrayList <> ( condition . values ( ) ) ) . stream ( ) . map ( v -> Keys . key ( keyLength , v . toArray ( ) ) ) . collect ( Collectors . toSet ( ) ) ; }
Set of objects is used for OR conditions . Otherwise set contains only one value .
80
16
5,622
public Value getValue ( final Environment in ) { log . debug ( "looking up value for " + name + " in " + in ) ; return attributeValue . get ( in ) ; }
Returns the value of the attribute in the given environment .
40
11
5,623
public KeyValueStoreUpdate update ( String key , String value ) { actions . add ( new Update ( key , value ) ) ; return this ; }
Adds a new update action to the event .
31
9
5,624
public KeyValueStoreUpdate storeAs ( String value , String ... segments ) { actions . add ( new Update ( "/" + String . join ( "/" , segments ) , value ) ) ; return this ; }
Adds a new update action to the event that stores the given value on the path formed by the path segments .
44
22
5,625
public KeyValueStoreUpdate clearAll ( String ... segments ) { actions . add ( new Deletion ( "/" + String . join ( "/" , segments ) ) ) ; return this ; }
Adds a new deletion action that clears all keys with the given path prefix .
41
15
5,626
public void set ( Value value , Environment in ) { values . put ( in . expandedStringForm ( ) , value ) ; }
Sets the value in a given environment .
27
9
5,627
@ SuppressWarnings ( { "PMD.DataflowAnomalyAnalysis" } ) /* default */ static ComponentVertex getComponentProxy ( ComponentType component , Channel componentChannel ) { ComponentProxy componentProxy = null ; try { Field field = getManagerField ( component . getClass ( ) ) ; synchronized ( component ) { if ( ! field . isAccessible ( ) ) { // NOPMD, handle problem first field . setAccessible ( true ) ; componentProxy = ( ComponentProxy ) field . get ( component ) ; if ( componentProxy == null ) { componentProxy = new ComponentProxy ( field , component , componentChannel ) ; } field . setAccessible ( false ) ; } else { componentProxy = ( ComponentProxy ) field . get ( component ) ; if ( componentProxy == null ) { componentProxy = new ComponentProxy ( field , component , componentChannel ) ; } } } } catch ( SecurityException | IllegalAccessException e ) { throw ( RuntimeException ) ( new IllegalArgumentException ( "Cannot access component's manager attribute" ) ) . initCause ( e ) ; } return componentProxy ; }
Return the component node for a component that is represented by a proxy in the tree .
236
17
5,628
public final < T extends GraphObject > T getGraphObjectAs ( Class < T > graphObjectClass ) { if ( graphObject == null ) { return null ; } if ( graphObjectClass == null ) { throw new NullPointerException ( "Must pass in a valid interface that extends GraphObject" ) ; } return graphObject . cast ( graphObjectClass ) ; }
The single graph object returned for this request if any cast into a particular type of GraphObject .
78
19
5,629
public final < T extends GraphObject > GraphObjectList < T > getGraphObjectListAs ( Class < T > graphObjectClass ) { if ( graphObjectList == null ) { return null ; } return graphObjectList . castToListOf ( graphObjectClass ) ; }
The list of graph objects returned for this request if any cast into a particular type of GraphObject .
58
20
5,630
public Request getRequestForPagedResults ( PagingDirection direction ) { String link = null ; if ( graphObject != null ) { PagedResults pagedResults = graphObject . cast ( PagedResults . class ) ; PagingInfo pagingInfo = pagedResults . getPaging ( ) ; if ( pagingInfo != null ) { if ( direction == PagingDirection . NEXT ) { link = pagingInfo . getNext ( ) ; } else { link = pagingInfo . getPrevious ( ) ; } } } if ( Utility . isNullOrEmpty ( link ) ) { return null ; } if ( link != null && link . equals ( request . getUrlForSingleRequest ( ) ) ) { // We got the same "next" link as we just tried to retrieve. This could happen if cached // data is invalid. All we can do in this case is pretend we have finished. return null ; } Request pagingRequest ; try { pagingRequest = new Request ( request . getSession ( ) , new URL ( link ) ) ; } catch ( MalformedURLException e ) { return null ; } return pagingRequest ; }
If a Response contains results that contain paging information returns a new Request that will retrieve the next page of results in whichever direction is desired . If no paging information is available returns null .
246
38
5,631
protected Configuration freemarkerConfig ( ) { if ( fmConfig == null ) { fmConfig = new Configuration ( Configuration . VERSION_2_3_26 ) ; fmConfig . setClassLoaderForTemplateLoading ( contentLoader , contentPath ) ; fmConfig . setDefaultEncoding ( "utf-8" ) ; fmConfig . setTemplateExceptionHandler ( TemplateExceptionHandler . RETHROW_HANDLER ) ; fmConfig . setLogTemplateExceptions ( false ) ; } return fmConfig ; }
Creates the configuration for freemarker template processing .
113
11
5,632
protected Map < String , Object > fmSessionModel ( Optional < Session > session ) { @ SuppressWarnings ( "PMD.UseConcurrentHashMap" ) final Map < String , Object > model = new HashMap <> ( ) ; Locale locale = session . map ( sess -> sess . locale ( ) ) . orElse ( Locale . getDefault ( ) ) ; model . put ( "locale" , locale ) ; final ResourceBundle resourceBundle = resourceBundle ( locale ) ; model . put ( "resourceBundle" , resourceBundle ) ; model . put ( "_" , new TemplateMethodModelEx ( ) { @ Override @ SuppressWarnings ( "PMD.EmptyCatchBlock" ) public Object exec ( @ SuppressWarnings ( "rawtypes" ) List arguments ) throws TemplateModelException { @ SuppressWarnings ( "unchecked" ) List < TemplateModel > args = ( List < TemplateModel > ) arguments ; if ( ! ( args . get ( 0 ) instanceof SimpleScalar ) ) { throw new TemplateModelException ( "Not a string." ) ; } String key = ( ( SimpleScalar ) args . get ( 0 ) ) . getAsString ( ) ; try { return resourceBundle . getString ( key ) ; } catch ( MissingResourceException e ) { // no luck } return key ; } } ) ; return model ; }
Build a freemarker model holding the information associated with the session .
308
14
5,633
protected ResourceBundle resourceBundle ( Locale locale ) { return ResourceBundle . getBundle ( contentPath . replace ( ' ' , ' ' ) + ".l10n" , locale , contentLoader , ResourceBundle . Control . getNoFallbackControl ( ResourceBundle . Control . FORMAT_DEFAULT ) ) ; }
Provides a resource bundle for localization . The default implementation looks up a bundle using the package name plus l10n as base name .
72
27
5,634
private void removeBuffer ( W buffer ) { createdBufs . decrementAndGet ( ) ; if ( bufferMonitor . remove ( buffer ) == null ) { if ( logger . isLoggable ( Level . FINE ) ) { logger . log ( Level . WARNING , "Attempt to remove unknown buffer from pool." , new Throwable ( ) ) ; } else { logger . warning ( "Attempt to remove unknown buffer from pool." ) ; } } }
Removes the buffer from the pool .
96
8
5,635
@ SuppressWarnings ( "PMD.GuardLogStatement" ) public W acquire ( ) throws InterruptedException { // Stop draining, because we obviously need this kind of buffers Optional . ofNullable ( idleTimer . getAndSet ( null ) ) . ifPresent ( timer -> timer . cancel ( ) ) ; if ( createdBufs . get ( ) < maximumBufs ) { // Haven't reached maximum, so if no buffer is queued, create one. W buffer = queue . poll ( ) ; if ( buffer != null ) { buffer . lockBuffer ( ) ; return buffer ; } return createBuffer ( ) ; } // Wait for buffer to become available. if ( logger . isLoggable ( Level . FINE ) ) { // If configured, log message after waiting some time. W buffer = queue . poll ( acquireWarningLimit , TimeUnit . MILLISECONDS ) ; if ( buffer != null ) { buffer . lockBuffer ( ) ; return buffer ; } logger . log ( Level . FINE , new Throwable ( ) , ( ) -> Thread . currentThread ( ) . getName ( ) + " waiting > " + acquireWarningLimit + "ms for buffer, while executing:" ) ; } W buffer = queue . take ( ) ; buffer . lockBuffer ( ) ; return buffer ; }
Acquires a managed buffer from the pool . If the pool is empty waits for a buffer to become available . The acquired buffer has a lock count of one .
279
33
5,636
@ Override public void recollect ( W buffer ) { if ( queue . size ( ) < preservedBufs ) { long effectiveDrainDelay = drainDelay > 0 ? drainDelay : defaultDrainDelay ; if ( effectiveDrainDelay > 0 ) { // Enqueue buffer . clear ( ) ; queue . add ( buffer ) ; Timer old = idleTimer . getAndSet ( Components . schedule ( this :: drain , Duration . ofMillis ( effectiveDrainDelay ) ) ) ; if ( old != null ) { old . cancel ( ) ; } return ; } } // Discard removeBuffer ( buffer ) ; }
Re - adds the buffer to the pool . The buffer is cleared .
138
14
5,637
public Value getIncludedValue ( Environment in ) { return ConfigurationManager . INSTANCE . getConfiguration ( configurationName , in ) . getAttribute ( attributeName ) ; }
Resolves included value dynamically from the linked config in the specified environment .
35
14
5,638
public ConfigurationSourceKey getConfigName ( ) { return new ConfigurationSourceKey ( ConfigurationSourceKey . Type . FILE , ConfigurationSourceKey . Format . JSON , configurationName ) ; }
Get configuration name of the linked config
37
7
5,639
Configuration copyWithIdentifier ( String identifier ) { return new Configuration ( details . builder ( ) . identifier ( identifier ) . build ( ) , new HashMap <> ( config ) ) ; }
Creates a configuration with the same content as this instance but with the specified identifier .
40
17
5,640
void write ( File f ) throws FileNotFoundException , IOException { try ( ObjectOutputStream os = new ObjectOutputStream ( new FileOutputStream ( f ) ) ) { os . writeObject ( this ) ; } }
Writes the configuration to file .
47
7
5,641
public void fireUpdateEvent ( final long timestamp ) { synchronized ( listeners ) { for ( final ConfigurationSourceListener listener : listeners ) { try { log . debug ( "Calling configurationSourceUpdated on " + listener ) ; listener . configurationSourceUpdated ( this ) ; } catch ( final Exception e ) { log . error ( "Error in notifying configuration source listener:" + listener , e ) ; } } } lastChangeTimestamp = timestamp ; }
Called by the ConfigurationSourceRegistry if a change in the underlying source is detected .
91
18
5,642
InventoryEntry remove ( String key ) { InventoryEntry ret = configs . remove ( key ) ; if ( ret != null ) { ret . getPath ( ) . delete ( ) ; } return ret ; }
Removes the entry with the specified key .
44
9
5,643
List < Configuration > removeMismatching ( ) { // List mismatching List < InventoryEntry > mismatching = configs . values ( ) . stream ( ) . filter ( v -> ( v . getConfiguration ( ) . isPresent ( ) && ! v . getIdentifier ( ) . equals ( v . getConfiguration ( ) . get ( ) . getDetails ( ) . getKey ( ) ) ) ) . collect ( Collectors . toList ( ) ) ; // Remove from inventory mismatching . forEach ( v -> configs . remove ( v . getIdentifier ( ) ) ) ; // Return the list of removed configurations return mismatching . stream ( ) . map ( v -> v . getConfiguration ( ) . get ( ) ) . collect ( Collectors . toList ( ) ) ; }
Removes configurations with mismatching identifiers .
167
8
5,644
List < File > removeUnreadable ( ) { // List unreadable List < InventoryEntry > unreadable = configs . values ( ) . stream ( ) . filter ( v -> ! v . getConfiguration ( ) . isPresent ( ) ) . collect ( Collectors . toList ( ) ) ; // Remove from inventory unreadable . forEach ( v -> configs . remove ( v . getIdentifier ( ) ) ) ; // Return the list of removed files return unreadable . stream ( ) . map ( v -> v . getPath ( ) ) . collect ( Collectors . toList ( ) ) ; }
Removes entries whose configurations are unreadable from the inventory .
128
12
5,645
@ RequestHandler ( patterns = "/form,/form/**" ) public void onGet ( Request . In . Get event , IOSubchannel channel ) throws ParseException { ResponseCreationSupport . sendStaticContent ( event , channel , path -> FormProcessor . class . getResource ( ResourcePattern . removeSegments ( path , 1 ) ) , null ) ; }
Handle a GET request .
78
5
5,646
@ RequestHandler ( patterns = "/form,/form/**" ) public void onPost ( Request . In . Post event , IOSubchannel channel ) { FormContext ctx = channel . associated ( this , FormContext :: new ) ; ctx . request = event . httpRequest ( ) ; ctx . session = event . associated ( Session . class ) . get ( ) ; event . setResult ( true ) ; event . stop ( ) ; }
Handle a POST request .
95
5
5,647
@ Handler public void onInput ( Input < ByteBuffer > event , IOSubchannel channel ) throws InterruptedException , UnsupportedEncodingException { Optional < FormContext > ctx = channel . associated ( this , FormContext . class ) ; if ( ! ctx . isPresent ( ) ) { return ; } ctx . get ( ) . fieldDecoder . addData ( event . data ( ) ) ; if ( ! event . isEndOfRecord ( ) ) { return ; } long invocations = ( Long ) ctx . get ( ) . session . computeIfAbsent ( "invocations" , key -> { return 0L ; } ) ; ctx . get ( ) . session . put ( "invocations" , invocations + 1 ) ; HttpResponse response = ctx . get ( ) . request . response ( ) . get ( ) ; response . setStatus ( HttpStatus . OK ) ; response . setHasPayload ( true ) ; response . setField ( HttpField . CONTENT_TYPE , MediaType . builder ( ) . setType ( "text" , "plain" ) . setParameter ( "charset" , "utf-8" ) . build ( ) ) ; String data = "First name: " + ctx . get ( ) . fieldDecoder . fields ( ) . get ( "firstname" ) + "\r\n" + "Last name: " + ctx . get ( ) . fieldDecoder . fields ( ) . get ( "lastname" ) + "\r\n" + "Previous invocations: " + invocations ; channel . respond ( new Response ( response ) ) ; ManagedBuffer < ByteBuffer > out = channel . byteBufferPool ( ) . acquire ( ) ; out . backingBuffer ( ) . put ( data . getBytes ( "utf-8" ) ) ; channel . respond ( Output . fromSink ( out , true ) ) ; }
Hanlde input .
413
4
5,648
@ Handler ( channels = NetworkChannel . class ) @ SuppressWarnings ( "PMD.DataflowAnomalyAnalysis" ) public void onConnected ( Connected event , TcpChannel netConnChannel ) throws InterruptedException , IOException { // Check if an app channel has been waiting for such a connection WebAppMsgChannel [ ] appChannel = { null } ; synchronized ( connecting ) { connecting . computeIfPresent ( event . remoteAddress ( ) , ( key , set ) -> { Iterator < WebAppMsgChannel > iter = set . iterator ( ) ; appChannel [ 0 ] = iter . next ( ) ; iter . remove ( ) ; return set . isEmpty ( ) ? null : set ; } ) ; } if ( appChannel [ 0 ] != null ) { appChannel [ 0 ] . connected ( netConnChannel ) ; } }
Called when the network connection is established . Triggers the frther processing of the initial request .
180
21
5,649
@ Handler ( channels = NetworkChannel . class ) public void onInput ( Input < ByteBuffer > event , TcpChannel netConnChannel ) throws InterruptedException , ProtocolException { Optional < WebAppMsgChannel > appChannel = netConnChannel . associated ( WebAppMsgChannel . class ) ; if ( appChannel . isPresent ( ) ) { appChannel . get ( ) . handleNetInput ( event , netConnChannel ) ; } }
Processes any input from the network layer .
92
9
5,650
@ Handler ( channels = NetworkChannel . class ) public void onClosed ( Closed event , TcpChannel netConnChannel ) { netConnChannel . associated ( WebAppMsgChannel . class ) . ifPresent ( appChannel -> appChannel . handleClosed ( event ) ) ; pooled . remove ( netConnChannel . remoteAddress ( ) , netConnChannel ) ; }
Called when the network connection is closed .
77
9
5,651
Map < String , Object > bindStrutsContext ( Object action ) { Map < String , Object > variables = new HashMap < String , Object > ( ) ; variables . put ( ACTION_VARIABLE_NAME , action ) ; if ( action instanceof ActionSupport ) { ActionSupport actSupport = ( ActionSupport ) action ; // Struts2 field errors.( Map<fieldname , fielderrors>) Map < String , List < String > > fieldErrors = actSupport . getFieldErrors ( ) ; variables . put ( FIELD_ERRORS_NAME , fieldErrors ) ; } return variables ; }
Binding Struts2 action and context and field - errors list binding field .
130
16
5,652
public static synchronized void sdkInitialize ( Context context ) { if ( sdkInitialized == true ) { return ; } BoltsMeasurementEventListener . getInstance ( context . getApplicationContext ( ) ) ; sdkInitialized = true ; }
Initialize SDK This function will be called once in the application it is tried to be called as early as possible ; This is the place to register broadcast listeners .
51
32
5,653
public static Executor getExecutor ( ) { synchronized ( LOCK ) { if ( Settings . executor == null ) { Executor executor = getAsyncTaskExecutor ( ) ; if ( executor == null ) { executor = new ThreadPoolExecutor ( DEFAULT_CORE_POOL_SIZE , DEFAULT_MAXIMUM_POOL_SIZE , DEFAULT_KEEP_ALIVE , TimeUnit . SECONDS , DEFAULT_WORK_QUEUE , DEFAULT_THREAD_FACTORY ) ; } Settings . executor = executor ; } } return Settings . executor ; }
Returns the Executor used by the SDK for non - AsyncTask background work .
133
17
5,654
public static void setExecutor ( Executor executor ) { Validate . notNull ( executor , "executor" ) ; synchronized ( LOCK ) { Settings . executor = executor ; } }
Sets the Executor used by the SDK for non - AsyncTask background work .
44
18
5,655
public static String getAttributionId ( ContentResolver contentResolver ) { try { String [ ] projection = { ATTRIBUTION_ID_COLUMN_NAME } ; Cursor c = contentResolver . query ( ATTRIBUTION_ID_CONTENT_URI , projection , null , null , null ) ; if ( c == null || ! c . moveToFirst ( ) ) { return null ; } String attributionId = c . getString ( c . getColumnIndex ( ATTRIBUTION_ID_COLUMN_NAME ) ) ; c . close ( ) ; return attributionId ; } catch ( Exception e ) { Log . d ( TAG , "Caught unexpected exception in getAttributionId(): " + e . toString ( ) ) ; return null ; } }
Acquire the current attribution id from the facebook app .
168
11
5,656
public static boolean getLimitEventAndDataUsage ( Context context ) { SharedPreferences preferences = context . getSharedPreferences ( APP_EVENT_PREFERENCES , Context . MODE_PRIVATE ) ; return preferences . getBoolean ( "limitEventUsage" , false ) ; }
Gets whether data such as that generated through AppEventsLogger and sent to Facebook should be restricted from being used for purposes other than analytics and conversions such as for targeting ads to this user . Defaults to false . This value is stored on the device and persists across app launches .
64
57
5,657
public static void setLimitEventAndDataUsage ( Context context , boolean limitEventUsage ) { SharedPreferences preferences = context . getSharedPreferences ( APP_EVENT_PREFERENCES , Context . MODE_PRIVATE ) ; SharedPreferences . Editor editor = preferences . edit ( ) ; editor . putBoolean ( "limitEventUsage" , limitEventUsage ) ; editor . commit ( ) ; }
Sets whether data such as that generated through AppEventsLogger and sent to Facebook should be restricted from being used for purposes other than analytics and conversions such as for targeting ads to this user . Defaults to false . This value is stored on the device and persists across app launches . Changes to this setting will apply to app events currently queued to be flushed .
89
73
5,658
public void show ( ) { if ( mAnchorViewRef . get ( ) != null ) { mPopupContent = new PopupContentView ( mContext ) ; TextView body = ( TextView ) mPopupContent . findViewById ( R . id . com_facebook_tooltip_bubble_view_text_body ) ; body . setText ( mText ) ; if ( mStyle == Style . BLUE ) { mPopupContent . bodyFrame . setBackgroundResource ( R . drawable . com_facebook_tooltip_blue_background ) ; mPopupContent . bottomArrow . setImageResource ( R . drawable . com_facebook_tooltip_blue_bottomnub ) ; mPopupContent . topArrow . setImageResource ( R . drawable . com_facebook_tooltip_blue_topnub ) ; mPopupContent . xOut . setImageResource ( R . drawable . com_facebook_tooltip_blue_xout ) ; } else { mPopupContent . bodyFrame . setBackgroundResource ( R . drawable . com_facebook_tooltip_black_background ) ; mPopupContent . bottomArrow . setImageResource ( R . drawable . com_facebook_tooltip_black_bottomnub ) ; mPopupContent . topArrow . setImageResource ( R . drawable . com_facebook_tooltip_black_topnub ) ; mPopupContent . xOut . setImageResource ( R . drawable . com_facebook_tooltip_black_xout ) ; } final Window window = ( ( Activity ) mContext ) . getWindow ( ) ; final View decorView = window . getDecorView ( ) ; final int decorWidth = decorView . getWidth ( ) ; final int decorHeight = decorView . getHeight ( ) ; registerObserver ( ) ; mPopupContent . onMeasure ( View . MeasureSpec . makeMeasureSpec ( decorWidth , View . MeasureSpec . AT_MOST ) , View . MeasureSpec . makeMeasureSpec ( decorHeight , View . MeasureSpec . AT_MOST ) ) ; mPopupWindow = new PopupWindow ( mPopupContent , mPopupContent . getMeasuredWidth ( ) , mPopupContent . getMeasuredHeight ( ) ) ; mPopupWindow . showAsDropDown ( mAnchorViewRef . get ( ) ) ; updateArrows ( ) ; if ( mNuxDisplayTime > 0 ) { mPopupContent . postDelayed ( new Runnable ( ) { @ Override public void run ( ) { dismiss ( ) ; } } , mNuxDisplayTime ) ; } mPopupWindow . setTouchable ( true ) ; mPopupContent . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { dismiss ( ) ; } } ) ; } }
Display this tool tip to the user
635
7
5,659
public void onCreate ( Bundle savedInstanceState ) { Session session = Session . getActiveSession ( ) ; if ( session == null ) { if ( savedInstanceState != null ) { session = Session . restoreSession ( activity , null , callback , savedInstanceState ) ; } if ( session == null ) { session = new Session ( activity ) ; } Session . setActiveSession ( session ) ; } if ( savedInstanceState != null ) { pendingFacebookDialogCall = savedInstanceState . getParcelable ( DIALOG_CALL_BUNDLE_SAVE_KEY ) ; } }
To be called from an Activity or Fragment s onCreate method .
126
14
5,660
public void onResume ( ) { Session session = Session . getActiveSession ( ) ; if ( session != null ) { if ( callback != null ) { session . addCallback ( callback ) ; } if ( SessionState . CREATED_TOKEN_LOADED . equals ( session . getState ( ) ) ) { session . openForRead ( null ) ; } } // add the broadcast receiver IntentFilter filter = new IntentFilter ( ) ; filter . addAction ( Session . ACTION_ACTIVE_SESSION_SET ) ; filter . addAction ( Session . ACTION_ACTIVE_SESSION_UNSET ) ; // Add a broadcast receiver to listen to when the active Session // is set or unset, and add/remove our callback as appropriate broadcastManager . registerReceiver ( receiver , filter ) ; }
To be called from an Activity or Fragment s onResume method .
170
15
5,661
public void onActivityResult ( int requestCode , int resultCode , Intent data ) { onActivityResult ( requestCode , resultCode , data , null ) ; }
To be called from an Activity or Fragment s onActivityResult method .
34
15
5,662
public void onActivityResult ( int requestCode , int resultCode , Intent data , FacebookDialog . Callback facebookDialogCallback ) { Session session = Session . getActiveSession ( ) ; if ( session != null ) { session . onActivityResult ( activity , requestCode , resultCode , data ) ; } handleFacebookDialogActivityResult ( requestCode , resultCode , data , facebookDialogCallback ) ; }
To be called from an Activity or Fragment s onActivityResult method when the results of a FacebookDialog call are expected .
83
25
5,663
public void onSaveInstanceState ( Bundle outState ) { Session . saveSession ( Session . getActiveSession ( ) , outState ) ; outState . putParcelable ( DIALOG_CALL_BUNDLE_SAVE_KEY , pendingFacebookDialogCall ) ; }
To be called from an Activity or Fragment s onSaveInstanceState method .
61
16
5,664
public void onPause ( ) { // remove the broadcast receiver broadcastManager . unregisterReceiver ( receiver ) ; if ( callback != null ) { Session session = Session . getActiveSession ( ) ; if ( session != null ) { session . removeCallback ( callback ) ; } } }
To be called from an Activity or Fragment s onPause method .
59
14
5,665
public static Evaluator definitionEvaluator ( HandlerDefinition hda ) { return definitionEvaluators . computeIfAbsent ( hda . evaluator ( ) , key -> { try { return hda . evaluator ( ) . getConstructor ( ) . newInstance ( ) ; } catch ( InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e ) { throw new IllegalStateException ( e ) ; } } ) ; }
Create a new definition evaluator .
109
8
5,666
public boolean matches ( TaskGroupInformation info ) { return getActivity ( ) . equals ( info . getActivity ( ) ) && getInputType ( ) . equals ( info . getInputType ( ) ) && getOutputType ( ) . equals ( info . getOutputType ( ) ) && info . matchesLocale ( getLocale ( ) ) ; }
Returns true if this specification matches the specified task group information .
74
12
5,667
public void logDomNodeList ( String msg , NodeList nodeList ) { StackTraceElement caller = StackTraceUtils . getCallerStackTraceElement ( ) ; String toLog = ( msg != null ? msg + "\n" : "DOM nodelist:\n" ) ; for ( int i = 0 ; i < nodeList . getLength ( ) ; i ++ ) { toLog += domNodeDescription ( nodeList . item ( i ) , 0 ) + "\n" ; } if ( caller != null ) { logger . logp ( Level . FINER , caller . getClassName ( ) , caller . getMethodName ( ) + "():" + caller . getLineNumber ( ) , toLog ) ; } else { logger . logp ( Level . FINER , "(UnknownSourceClass)" , "(unknownSourceMethod)" , toLog ) ; } }
Log a DOM node list at the FINER level
186
10
5,668
public void logDomNode ( String msg , Node node ) { StackTraceElement caller = StackTraceUtils . getCallerStackTraceElement ( ) ; logDomNode ( msg , node , Level . FINER , caller ) ; }
Log a DOM node at the FINER level
52
9
5,669
public void logDomNode ( String msg , Node node , Level level , StackTraceElement caller ) { String toLog = ( msg != null ? msg + "\n" : "DOM node:\n" ) + domNodeDescription ( node , 0 ) ; if ( caller != null ) { logger . logp ( level , caller . getClassName ( ) , caller . getMethodName ( ) + "():" + caller . getLineNumber ( ) , toLog ) ; } else { logger . logp ( level , "(UnknownSourceClass)" , "(unknownSourceMethod)" , toLog ) ; } }
Log a DOM node at a given logging level and a specified caller
128
13
5,670
private String domNodeDescription ( Node node , int tablevel ) { String domNodeDescription = null ; String nodeName = node . getNodeName ( ) ; String nodeValue = node . getNodeValue ( ) ; if ( ! ( nodeName . equals ( "#text" ) && nodeValue . replaceAll ( "\n" , "" ) . trim ( ) . equals ( "" ) ) ) { domNodeDescription = tabs ( tablevel ) + node . getNodeName ( ) + "\n" ; NamedNodeMap attributes = node . getAttributes ( ) ; if ( attributes != null ) { for ( int i = 0 ; i < attributes . getLength ( ) ; i ++ ) { Node attribute = attributes . item ( i ) ; domNodeDescription += tabs ( tablevel ) + "-" + attribute . getNodeName ( ) + "=" + attribute . getNodeValue ( ) + "\n" ; } } domNodeDescription += tabs ( tablevel ) + "=" + node . getNodeValue ( ) + "\n" ; NodeList children = node . getChildNodes ( ) ; if ( children != null ) { for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { String childDescription = domNodeDescription ( children . item ( i ) , tablevel + 1 ) ; if ( childDescription != null ) { domNodeDescription += childDescription ; } } } } return domNodeDescription ; }
Form a DOM node textual representation recursively
303
9
5,671
public void setLevel ( Level level ) { this . defaultLevel = level ; logger . setLevel ( level ) ; for ( Handler handler : logger . getHandlers ( ) ) { handler . setLevel ( level ) ; } }
Set this level for all configured loggers
48
8
5,672
@ Handler ( channels = Self . class ) public void onRegistered ( NioRegistration . Completed event ) throws InterruptedException , IOException { NioHandler handler = event . event ( ) . handler ( ) ; if ( handler == this ) { if ( event . event ( ) . get ( ) == null ) { fire ( new Error ( event , "Registration failed, no NioDispatcher?" ) ) ; return ; } registration = event . event ( ) . get ( ) ; purger = new Purger ( ) ; purger . start ( ) ; fire ( new Ready ( serverSocketChannel . getLocalAddress ( ) ) ) ; return ; } if ( handler instanceof TcpChannelImpl ) { TcpChannelImpl channel = ( TcpChannelImpl ) handler ; channel . downPipeline ( ) . fire ( new Accepted ( channel . nioChannel ( ) . getLocalAddress ( ) , channel . nioChannel ( ) . getRemoteAddress ( ) , false , Collections . emptyList ( ) ) , channel ) ; channel . registrationComplete ( event . event ( ) ) ; } }
Handles the successful channel registration .
233
7
5,673
@ Handler @ SuppressWarnings ( "PMD.DataflowAnomalyAnalysis" ) public void onClose ( Close event ) throws IOException , InterruptedException { boolean subOnly = true ; for ( Channel channel : event . channels ( ) ) { if ( channel instanceof TcpChannelImpl ) { if ( channels . contains ( channel ) ) { ( ( TcpChannelImpl ) channel ) . close ( ) ; } } else { subOnly = false ; } } if ( subOnly || ! serverSocketChannel . isOpen ( ) ) { // Closed already fire ( new Closed ( ) ) ; return ; } synchronized ( channels ) { closing = true ; // Copy to avoid concurrent modification exception Set < TcpChannelImpl > conns = new HashSet <> ( channels ) ; for ( TcpChannelImpl conn : conns ) { conn . close ( ) ; } while ( ! channels . isEmpty ( ) ) { channels . wait ( ) ; } } serverSocketChannel . close ( ) ; purger . interrupt ( ) ; closing = false ; fire ( new Closed ( ) ) ; }
Shuts down the server or one of the connections to the server .
231
14
5,674
public static Vector < String > tokenize2vector ( final String source , final char delimiter ) { final Vector < String > v = new Vector <> ( ) ; StringBuilder currentS = new StringBuilder ( ) ; char c ; for ( int i = 0 ; i < source . length ( ) ; i ++ ) { c = source . charAt ( i ) ; if ( c == delimiter ) { v . addElement ( currentS . length ( ) > 0 ? currentS . toString ( ) : "" ) ; currentS = new StringBuilder ( ) ; //TODO: should be use one SB and not create another one } else { currentS . append ( c ) ; } } if ( currentS . length ( ) > 0 ) v . addElement ( currentS . toString ( ) ) ; return v ; }
Return a Vector with tokens from the source string tokenized using the delimiter char .
177
17
5,675
public static String removeCComments ( final String src ) { final StringBuilder ret = new StringBuilder ( ) ; boolean inComments = false ; for ( int i = 0 ; i < src . length ( ) ; i ++ ) { char c = src . charAt ( i ) ; if ( inComments ) { if ( c == ' ' && src . charAt ( i + 1 ) == ' ' ) { inComments = false ; i ++ ; } } else { if ( c == ' ' ) { if ( src . charAt ( i + 1 ) == ' ' ) { inComments = true ; i ++ ; } else { ret . append ( c ) ; } } else ret . append ( c ) ; } } return ret . toString ( ) ; }
Remove C commentaries .
162
5
5,676
public void cleanupAttachmentsForCall ( Context context , UUID callId ) { File dir = getAttachmentsDirectoryForCall ( callId , false ) ; Utility . deleteDirectory ( dir ) ; }
Removes any temporary files associated with a particular native app call .
42
13
5,677
@ SuppressWarnings ( "unchecked" ) public final T duplicate ( ) { if ( backing instanceof ByteBuffer ) { return ( T ) ( ( ByteBuffer ) backing ) . duplicate ( ) ; } if ( backing instanceof CharBuffer ) { return ( T ) ( ( CharBuffer ) backing ) . duplicate ( ) ; } throw new IllegalArgumentException ( "Backing buffer of unknown type." ) ; }
Duplicate the buffer .
89
6
5,678
public void process ( EventPipeline eventPipeline , EventBase < ? > event ) { try { for ( HandlerReference hdlr : this ) { try { hdlr . invoke ( event ) ; if ( event . isStopped ( ) ) { break ; } } catch ( AssertionError t ) { // JUnit support CoreUtils . setAssertionError ( t ) ; event . handlingError ( eventPipeline , t ) ; } catch ( Error e ) { // NOPMD // Wouldn't have caught it, if it was possible. throw e ; } catch ( Throwable t ) { // NOPMD // Errors have been rethrown, so this should work. event . handlingError ( eventPipeline , t ) ; } } } finally { // NOPMD try { event . handled ( ) ; } catch ( AssertionError t ) { // JUnit support CoreUtils . setAssertionError ( t ) ; event . handlingError ( eventPipeline , t ) ; } catch ( Error e ) { // NOPMD // Wouldn't have caught it, if it was possible. throw e ; } catch ( Throwable t ) { // NOPMD // Errors have been rethrown, so this should work. event . handlingError ( eventPipeline , t ) ; } } }
Invoke all handlers with the given event as parameter .
287
11
5,679
public Session getOpenSession ( ) { Session openSession = getSession ( ) ; if ( openSession != null && openSession . isOpened ( ) ) { return openSession ; } return null ; }
Returns the current Session that s being tracked if it s open otherwise returns null .
43
16
5,680
public void setSession ( Session newSession ) { if ( newSession == null ) { if ( session != null ) { // We're current tracking a Session. Remove the callback // and start tracking the active Session. session . removeCallback ( callback ) ; session = null ; addBroadcastReceiver ( ) ; if ( getSession ( ) != null ) { getSession ( ) . addCallback ( callback ) ; } } } else { if ( session == null ) { // We're currently tracking the active Session, but will be // switching to tracking a different Session object. Session activeSession = Session . getActiveSession ( ) ; if ( activeSession != null ) { activeSession . removeCallback ( callback ) ; } broadcastManager . unregisterReceiver ( receiver ) ; } else { // We're currently tracking a Session, but are now switching // to a new Session, so we remove the callback from the old // Session, and add it to the new one. session . removeCallback ( callback ) ; } session = newSession ; session . addCallback ( callback ) ; } }
Set the Session object to track .
223
7
5,681
public void stopTracking ( ) { if ( ! isTracking ) { return ; } Session session = getSession ( ) ; if ( session != null ) { session . removeCallback ( callback ) ; } broadcastManager . unregisterReceiver ( receiver ) ; isTracking = false ; }
Stop tracking the Session and remove any callbacks attached to those sessions .
61
14
5,682
@ Override @ SuppressWarnings ( "PMD.ShortVariable" ) public < V > Optional < V > associated ( Object by , Class < V > type ) { Optional < V > result = super . associated ( by , type ) ; if ( ! result . isPresent ( ) ) { IOSubchannel upstream = upstreamChannel ( ) ; if ( upstream != null ) { return upstream . associated ( by , type ) ; } } return result ; }
Delegates the invocation to the upstream channel if no associated data is found for this channel .
98
18
5,683
public Task < AppLink > getAppLinkFromUrlInBackground ( final Uri uri ) { ArrayList < Uri > uris = new ArrayList < Uri > ( ) ; uris . add ( uri ) ; Task < Map < Uri , AppLink > > resolveTask = getAppLinkFromUrlsInBackground ( uris ) ; return resolveTask . onSuccess ( new Continuation < Map < Uri , AppLink > , AppLink > ( ) { @ Override public AppLink then ( Task < Map < Uri , AppLink > > resolveUrisTask ) throws Exception { return resolveUrisTask . getResult ( ) . get ( uri ) ; } } ) ; }
Asynchronously resolves App Link data for the passed in Uri
145
12
5,684
public void flush ( ) { if ( eventLoop . inEventLoop ( ) ) { pending ++ ; if ( pending >= maxPending ) { pending = 0 ; channel . flush ( ) ; } } if ( woken == 0 && WOKEN . compareAndSet ( this , 0 , 1 ) ) { woken = 1 ; eventLoop . execute ( wakeup ) ; } }
Schedule an asynchronous opportunistically batching flush .
81
10
5,685
@ Handler public void onStart ( Start event ) { synchronized ( this ) { if ( runner != null ) { return ; } buffers = new ManagedBufferPool <> ( ManagedBuffer :: new , ( ) -> { return ByteBuffer . allocateDirect ( bufferSize ) ; } , 2 ) ; runner = new Thread ( this , Components . simpleObjectName ( this ) ) ; // Because this cannot reliably be stopped, it doesn't prevent // shutdown. runner . setDaemon ( true ) ; runner . start ( ) ; } }
Starts a thread that continuously reads available data from the input stream .
111
14
5,686
@ Handler ( priority = - 10000 ) public void onStop ( Stop event ) throws InterruptedException { synchronized ( this ) { if ( runner == null ) { return ; } runner . interrupt ( ) ; synchronized ( this ) { if ( registered ) { unregisterAsGenerator ( ) ; registered = false ; } } runner = null ; } }
Stops the thread that reads data from the input stream . Note that the input stream is not closed .
72
21
5,687
public static ComponentVertex componentVertex ( ComponentType component , Channel componentChannel ) { if ( component instanceof ComponentVertex ) { return ( ComponentVertex ) component ; } return ComponentProxy . getComponentProxy ( component , componentChannel ) ; }
Return the component node for a given component .
52
9
5,688
private void setTree ( ComponentTree tree ) { synchronized ( this ) { this . tree = tree ; for ( ComponentVertex child : children ) { child . setTree ( tree ) ; } } }
Set the reference to the common properties of this component and all its children to the given value .
42
19
5,689
@ SuppressWarnings ( "PMD.UseVarargs" ) /* default */ void collectHandlers ( Collection < HandlerReference > hdlrs , EventBase < ? > event , Channel [ ] channels ) { for ( HandlerReference hdlr : handlers ) { if ( hdlr . handles ( event , channels ) ) { hdlrs . add ( hdlr ) ; } } for ( ComponentVertex child : children ) { child . collectHandlers ( hdlrs , event , channels ) ; } }
Collects all handlers . Iterates over the tree with this object as root and for all child components adds the matching handlers to the result set recursively .
111
32
5,690
public GraphPlace getSelection ( ) { Collection < GraphPlace > selection = getSelectedGraphObjects ( ) ; return ( selection != null && ! selection . isEmpty ( ) ) ? selection . iterator ( ) . next ( ) : null ; }
Gets the currently - selected place .
53
8
5,691
protected boolean hasFieldError ( String fieldname ) { if ( StringUtils . isEmpty ( fieldname ) ) { return false ; } Object action = ActionContext . getContext ( ) . getActionInvocation ( ) . getAction ( ) ; // check action instance 'ActionSupport'. if ( ! ( action instanceof ActionSupport ) ) { return false ; } ActionSupport asupport = ( ActionSupport ) action ; Map < String , List < String > > fieldErrors = asupport . getFieldErrors ( ) ; if ( CollectionUtils . isEmpty ( fieldErrors ) ) { return false ; } List < String > targetFieldErrors = fieldErrors . get ( fieldname ) ; if ( CollectionUtils . isEmpty ( targetFieldErrors ) ) { return false ; } return true ; }
If Struts2 has field - error for request parameter name return true .
174
15
5,692
protected Object getFieldValue ( String fieldname ) { ActionContext actionCtx = ActionContext . getContext ( ) ; ValueStack valueStack = actionCtx . getValueStack ( ) ; Object value = valueStack . findValue ( fieldname , false ) ; String overwriteValue = getOverwriteValue ( fieldname ) ; if ( overwriteValue != null ) { return overwriteValue ; } return value ; }
Return Strus2 field value .
85
7
5,693
protected String getOverwriteValue ( String fieldname ) { ActionContext ctx = ServletActionContext . getContext ( ) ; ValueStack stack = ctx . getValueStack ( ) ; Map < Object , Object > overrideMap = stack . getExprOverrides ( ) ; // If convertion error has not, do nothing. if ( overrideMap == null || overrideMap . isEmpty ( ) ) { return null ; } if ( ! overrideMap . containsKey ( fieldname ) ) { return null ; } String convertionValue = ( String ) overrideMap . get ( fieldname ) ; // Struts2-Conponent is wrapped String quote, which erase for output value. String altString = StringEscapeUtils . unescapeJava ( convertionValue ) ; altString = altString . substring ( 1 , altString . length ( ) - 1 ) ; return altString ; }
If Type - Convertion Error found at Struts2 overwrite request - parameter same name .
190
18
5,694
public final void setPresetSize ( int sizeType ) { switch ( sizeType ) { case SMALL : case NORMAL : case LARGE : case CUSTOM : this . presetSizeType = sizeType ; break ; default : throw new IllegalArgumentException ( "Must use a predefined preset size" ) ; } requestLayout ( ) ; }
Apply a preset size to this profile photo
74
8
5,695
public final void setProfileId ( String profileId ) { boolean force = false ; if ( Utility . isNullOrEmpty ( this . profileId ) || ! this . profileId . equalsIgnoreCase ( profileId ) ) { // Clear out the old profilePicture before requesting for the new one. setBlankProfilePicture ( ) ; force = true ; } this . profileId = profileId ; refreshImage ( force ) ; }
Sets the profile Id for this profile photo
90
9
5,696
@ Override protected Parcelable onSaveInstanceState ( ) { Parcelable superState = super . onSaveInstanceState ( ) ; Bundle instanceState = new Bundle ( ) ; instanceState . putParcelable ( SUPER_STATE_KEY , superState ) ; instanceState . putString ( PROFILE_ID_KEY , profileId ) ; instanceState . putInt ( PRESET_SIZE_KEY , presetSizeType ) ; instanceState . putBoolean ( IS_CROPPED_KEY , isCropped ) ; instanceState . putParcelable ( BITMAP_KEY , imageContents ) ; instanceState . putInt ( BITMAP_WIDTH_KEY , queryWidth ) ; instanceState . putInt ( BITMAP_HEIGHT_KEY , queryHeight ) ; instanceState . putBoolean ( PENDING_REFRESH_KEY , lastRequest != null ) ; return instanceState ; }
Some of the current state is returned as a Bundle to allow quick restoration of the ProfilePictureView object in scenarios like orientation changes .
194
26
5,697
@ Override protected void onRestoreInstanceState ( Parcelable state ) { if ( state . getClass ( ) != Bundle . class ) { super . onRestoreInstanceState ( state ) ; } else { Bundle instanceState = ( Bundle ) state ; super . onRestoreInstanceState ( instanceState . getParcelable ( SUPER_STATE_KEY ) ) ; profileId = instanceState . getString ( PROFILE_ID_KEY ) ; presetSizeType = instanceState . getInt ( PRESET_SIZE_KEY ) ; isCropped = instanceState . getBoolean ( IS_CROPPED_KEY ) ; queryWidth = instanceState . getInt ( BITMAP_WIDTH_KEY ) ; queryHeight = instanceState . getInt ( BITMAP_HEIGHT_KEY ) ; setImageBitmap ( ( Bitmap ) instanceState . getParcelable ( BITMAP_KEY ) ) ; if ( instanceState . getBoolean ( PENDING_REFRESH_KEY ) ) { refreshImage ( true ) ; } } }
If the passed in state is a Bundle an attempt is made to restore from it .
225
17
5,698
private void enhanceFAB ( final FloatingActionButton fab , int dx , int dy ) { if ( isEnhancedFAB ( ) && getFab ( ) != null ) { final FloatingActionButton mFloatingActionButton = this . fab ; if ( getLinearLayoutManager ( ) != null ) { if ( dy > 0 ) { if ( mFloatingActionButton . getVisibility ( ) == View . VISIBLE ) { mFloatingActionButton . hide ( ) ; } } else { if ( mFloatingActionButton . getVisibility ( ) != View . VISIBLE ) { mFloatingActionButton . show ( ) ; } } } } }
Enhanced FAB UX Logic Handle RecyclerView scrolling
139
11
5,699
private void enhanceFAB ( final FloatingActionButton fab , MotionEvent e ) { if ( hasAllItemsShown ( ) ) { if ( fab . getVisibility ( ) != View . VISIBLE ) { fab . show ( ) ; } } }
Enhanced FAB UX Logic Handle RecyclerView scrolled If all item visible within view port FAB will show
53
23