idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
5,700 | 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 Strus2 field value . |
5,701 | protected String getOverwriteValue ( String fieldname ) { ActionContext ctx = ServletActionContext . getContext ( ) ; ValueStack stack = ctx . getValueStack ( ) ; Map < Object , Object > overrideMap = stack . getExprOverrides ( ) ; if ( overrideMap == null || overrideMap . isEmpty ( ) ) { return null ; } if ( ! overrid... | If Type - Convertion Error found at Struts2 overwrite request - parameter same name . |
5,702 | 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 |
5,703 | public final void setProfileId ( String profileId ) { boolean force = false ; if ( Utility . isNullOrEmpty ( this . profileId ) || ! this . profileId . equalsIgnoreCase ( profileId ) ) { setBlankProfilePicture ( ) ; force = true ; } this . profileId = profileId ; refreshImage ( force ) ; } | Sets the profile Id for this profile photo |
5,704 | 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 , presetSi... | Some of the current state is returned as a Bundle to allow quick restoration of the ProfilePictureView object in scenarios like orientation changes . |
5,705 | 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 . ge... | If the passed in state is a Bundle an attempt is made to restore from it . |
5,706 | 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 ) {... | Enhanced FAB UX Logic Handle RecyclerView scrolling |
5,707 | 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 |
5,708 | private int getHeaderViewType ( int position ) { if ( headerContent != null ) { if ( headerContent . getData ( ) == getItem ( position ) && ( position == 0 ) ) { return headerContent . getViewtype ( ) ; } } return PeasyHeaderViewHolder . VIEWTYPE_NOTHING ; } | To identify content as Header |
5,709 | public int getFooterViewType ( int position ) { if ( footerContent != null ) { if ( footerContent . getData ( ) == getItem ( position ) && ( position == getLastItemIndex ( ) ) ) { return footerContent . getViewtype ( ) ; } } return PeasyHeaderViewHolder . VIEWTYPE_NOTHING ; } | To identify content as Footer |
5,710 | public boolean onItemLongClick ( final View view , final int viewType , final int position , final T item , final PeasyViewHolder viewHolder ) { return true ; } | Indicate content is clicked with long tap |
5,711 | @ SuppressWarnings ( { "PMD.NcssCount" , "PMD.UseStringBufferForStringAppends" } ) public static boolean sendStaticContent ( HttpRequest request , IOSubchannel channel , Function < String , URL > resolver , MaxAgeCalculator maxAgeCalculator ) { String path = request . requestUri ( ) . getPath ( ) ; URL resourceUrl = re... | Creates and sends a response with static content . The content is looked up by invoking the resolver with the path from the request . |
5,712 | @ SuppressWarnings ( "PMD.EmptyCatchBlock" ) public static ResourceInfo resourceInfo ( URL resource ) { try { Path path = Paths . get ( resource . toURI ( ) ) ; return new ResourceInfo ( Files . isDirectory ( path ) , Files . getLastModifiedTime ( path ) . toInstant ( ) . with ( ChronoField . NANO_OF_SECOND , 0 ) ) ; }... | Attempts to lookup the additional resource information for the given URL . |
5,713 | public static long setMaxAge ( HttpResponse response , int maxAge ) { List < Directive > directives = new ArrayList < > ( ) ; directives . add ( new Directive ( "max-age" , maxAge ) ) ; response . setField ( HttpField . CACHE_CONTROL , directives ) ; return maxAge ; } | Sets the cache control header in the given response . |
5,714 | public void setSelection ( List < GraphUser > graphUsers ) { List < String > userIds = new ArrayList < String > ( ) ; for ( GraphUser graphUser : graphUsers ) { userIds . add ( graphUser . getId ( ) ) ; } setSelectionByIds ( userIds ) ; } | Sets the list of friends for pre selection . These friends will be selected by default . |
5,715 | private void authorize ( Activity activity , String [ ] permissions , int activityCode , SessionLoginBehavior behavior , final DialogListener listener ) { checkUserSession ( "authorize" ) ; pendingOpeningSession = new Session . Builder ( activity ) . setApplicationId ( mAppId ) . setTokenCachingStrategy ( getTokenCache... | Full authorize method . |
5,716 | private boolean validateServiceIntent ( Context context , Intent intent ) { ResolveInfo resolveInfo = context . getPackageManager ( ) . resolveService ( intent , 0 ) ; if ( resolveInfo == null ) { return false ; } return validateAppSignatureForPackage ( context , resolveInfo . serviceInfo . packageName ) ; } | Helper to validate a service intent by resolving and checking the provider s package signature . |
5,717 | private boolean validateAppSignatureForPackage ( Context context , String packageName ) { PackageInfo packageInfo ; try { packageInfo = context . getPackageManager ( ) . getPackageInfo ( packageName , PackageManager . GET_SIGNATURES ) ; } catch ( NameNotFoundException e ) { return false ; } for ( Signature signature : ... | Query the signature for the application that would be invoked by the given intent and verify that it matches the FB application s signature . |
5,718 | @ SuppressWarnings ( "deprecation" ) String requestImpl ( String graphPath , Bundle params , String httpMethod ) throws FileNotFoundException , MalformedURLException , IOException { params . putString ( "format" , "json" ) ; if ( isSessionValid ( ) ) { params . putString ( TOKEN , getAccessToken ( ) ) ; } String url = ... | Internal call to avoid deprecated warnings . |
5,719 | public void setSession ( Session session ) { if ( session == null ) { throw new IllegalArgumentException ( "session cannot be null" ) ; } synchronized ( this . lock ) { this . userSetSession = session ; } } | Allows the user to set a Session for the Facebook class to use . If a Session is set here then one should not use the authorize logout or extendAccessToken methods which alter the Session object since that may result in undefined behavior . Using those methods after setting the session here will result in exceptions be... |
5,720 | public final Session getSession ( ) { while ( true ) { String cachedToken = null ; Session oldSession = null ; synchronized ( this . lock ) { if ( userSetSession != null ) { return userSetSession ; } if ( ( session != null ) || ! sessionInvalidated ) { return session ; } cachedToken = accessToken ; oldSession = session... | Get the underlying Session object to use with 3 . 0 api . |
5,721 | public void onStart ( Start event ) { synchronized ( this ) { if ( runner != null && ! runner . isInterrupted ( ) ) { return ; } runner = new Thread ( this , Components . simpleObjectName ( this ) ) ; runner . start ( ) ; } } | Starts this dispatcher . A dispatcher has an associated thread that keeps it running . |
5,722 | @ Handler ( priority = - 10000 ) public void onStop ( Stop event ) throws InterruptedException { synchronized ( this ) { if ( runner == null ) { return ; } while ( runner . isAlive ( ) ) { runner . interrupt ( ) ; selector . wakeup ( ) ; runner . join ( 10 ) ; } runner = null ; } } | Stops the thread that is associated with this dispatcher . |
5,723 | public void onNioRegistration ( NioRegistration event ) throws IOException { SelectableChannel channel = event . ioChannel ( ) ; channel . configureBlocking ( false ) ; SelectionKey key ; synchronized ( selectorGate ) { selector . wakeup ( ) ; key = channel . register ( selector , event . ops ( ) , event . handler ( ) ... | Handle the NIO registration . |
5,724 | private DataContainer innerJoin ( DataContainer left , DataContainer right , Optional < BooleanExpression > joinCondition ) { return crossJoin ( left , right , joinCondition , JoinType . INNER ) ; } | A naive implementation filtering cross join by condition |
5,725 | @ SuppressWarnings ( "PMD.DataflowAnomalyAnalysis" ) protected static String derivePattern ( String path ) { String pattern ; if ( "/" . equals ( path ) ) { pattern = "/**" ; } else { String patternBase = path ; if ( patternBase . endsWith ( "/" ) ) { patternBase = path . substring ( 0 , path . length ( ) - 1 ) ; } pat... | Derives the resource pattern from the path . |
5,726 | protected String createSessionId ( HttpResponse response ) { StringBuilder sessionIdBuilder = new StringBuilder ( ) ; byte [ ] bytes = new byte [ 16 ] ; secureRandom . nextBytes ( bytes ) ; for ( byte b : bytes ) { sessionIdBuilder . append ( Integer . toHexString ( b & 0xff ) ) ; } String sessionId = sessionIdBuilder ... | Creates a session id and adds the corresponding cookie to the response . |
5,727 | @ Handler ( channels = Channel . class ) public void discard ( DiscardSession event ) { removeSession ( event . session ( ) . id ( ) ) ; } | Discards the given session . |
5,728 | @ Handler ( priority = 1000 ) public void onProtocolSwitchAccepted ( ProtocolSwitchAccepted event , IOSubchannel channel ) { event . requestEvent ( ) . associated ( Session . class ) . ifPresent ( session -> { channel . setAssociated ( Session . class , session ) ; } ) ; } | Associates the channel with the session from the upgrade request . |
5,729 | public void onOpenConnection ( OpenTcpConnection event ) { try { SocketChannel socketChannel = SocketChannel . open ( event . address ( ) ) ; channels . add ( new TcpChannelImpl ( socketChannel ) ) ; } catch ( ConnectException e ) { fire ( new ConnectError ( event , "Connection refused." , e ) ) ; } catch ( IOException... | Opens a connection to the end point specified in the event . |
5,730 | @ Handler ( channels = Self . class ) public void onRegistered ( NioRegistration . Completed event ) throws InterruptedException , IOException { NioHandler handler = event . event ( ) . handler ( ) ; if ( ! ( handler instanceof TcpChannelImpl ) ) { return ; } if ( event . event ( ) . get ( ) == null ) { fire ( new Erro... | Called when the new socket channel has successfully been registered with the nio dispatcher . |
5,731 | @ SuppressWarnings ( "PMD.DataflowAnomalyAnalysis" ) public void onClose ( Close event ) throws IOException , InterruptedException { for ( Channel channel : event . channels ( ) ) { if ( channel instanceof TcpChannelImpl && channels . contains ( channel ) ) { ( ( TcpChannelImpl ) channel ) . close ( ) ; } } } | Shuts down the one of the connections . |
5,732 | public Validator newValidator ( String identifier ) { if ( identifier == null ) { return null ; } ValidatorFactory template ; synchronized ( map ) { verifyMapIntegrity ( ) ; template = map . get ( identifier ) ; } if ( template != null ) { try { return template . newValidator ( identifier ) ; } catch ( ValidatorFactory... | Obtains a new instance of a Validator with the given identifier |
5,733 | @ SuppressWarnings ( { "PMD.CyclomaticComplexity" , "PMD.NPathComplexity" , "PMD.CollapsibleIfStatements" , "PMD.DataflowAnomalyAnalysis" } ) public int matches ( URI resource ) { if ( protocol != null && ! protocol . equals ( "*" ) ) { if ( resource . getScheme ( ) == null ) { return - 1 ; } if ( Arrays . stream ( pro... | Matches the given resource URI against the pattern . |
5,734 | public static boolean matches ( String pattern , URI resource ) throws ParseException { return ( new ResourcePattern ( pattern ) ) . matches ( resource ) >= 0 ; } | Matches the given pattern against the given resource URI . |
5,735 | @ RequestHandler ( dynamic = true ) public void onGet ( Request . In . Get event , IOSubchannel channel ) throws ParseException , IOException { int prefixSegs = resourcePattern . matches ( event . requestUri ( ) ) ; if ( prefixSegs < 0 ) { return ; } if ( contentDirectory == null ) { getFromUri ( event , channel , pref... | Handles a GET request . |
5,736 | @ SuppressWarnings ( "PMD.SystemPrintln" ) public void onInput ( Input < ByteBuffer > event ) { String data = Charset . defaultCharset ( ) . decode ( event . data ( ) ) . toString ( ) ; System . out . print ( data ) ; if ( data . trim ( ) . equals ( "QUIT" ) ) { fire ( new Stop ( ) ) ; } } | Handle input . |
5,737 | public ConfigurationUpdate removePath ( String path ) { if ( path == null || ! path . startsWith ( "/" ) ) { throw new IllegalArgumentException ( "Path must start with \"/\"." ) ; } paths . put ( path , null ) ; return this ; } | Remove a path from the configuration . |
5,738 | public Optional < Map < String , String > > values ( String path ) { Map < String , String > result = paths . get ( path ) ; if ( result == null ) { return Optional . empty ( ) ; } return Optional . of ( Collections . unmodifiableMap ( result ) ) ; } | Return the values for a given path if they exists . |
5,739 | public Optional < String > value ( String path , String key ) { return Optional . ofNullable ( paths . get ( path ) ) . flatMap ( map -> Optional . ofNullable ( map . get ( key ) ) ) ; } | Return the value with the given path and key if it exists . |
5,740 | public static boolean isRange ( String value ) { if ( value == null ) { return false ; } try { Set < Integer > values = parseRange ( value ) ; return values . size ( ) > 0 ; } catch ( Exception e ) { return false ; } } | Returns whether passed value is a range |
5,741 | public static void disableSSLValidation ( ) { try { SSLContext context = SSLContext . getInstance ( "SSL" ) ; context . init ( null , new TrustManager [ ] { new UnsafeTrustManager ( ) } , null ) ; HttpsURLConnection . setDefaultSSLSocketFactory ( context . getSocketFactory ( ) ) ; } catch ( Exception e ) { throw new Ru... | Disabling SSL validation is strongly discouraged . This is generally only intended for use during testing or perhaps when used in a private network with a self signed certificate . |
5,742 | public static void enableSSLValidation ( ) { try { SSLContext . getInstance ( "SSL" ) . init ( null , null , null ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } } | Enable SSL Validation . |
5,743 | public static boolean validCertificateString ( String certificateString ) { try { byte [ ] certBytes = parseDERFromPEM ( certificateString , CERT_START , CERT_END ) ; generateCertificateFromDER ( certBytes ) ; } catch ( Exception e ) { return false ; } return true ; } | Checks the given certificate String to ensure it is a PEM formatted certificate . |
5,744 | public RESTClient < RS , ERS > urlParameter ( String name , Object value ) { if ( value == null ) { return this ; } List < Object > values = this . parameters . get ( name ) ; if ( values == null ) { values = new ArrayList < > ( ) ; this . parameters . put ( name , values ) ; } if ( value instanceof ZonedDateTime ) { v... | Add a URL parameter as a key value pair . |
5,745 | protected Enumeration < URL > findResources ( String name ) { URL url = findResource ( name ) ; Vector < URL > urls = new Vector < > ( ) ; if ( url != null ) { urls . add ( url ) ; } return urls . elements ( ) ; } | Returns an enumeration of URL objects representing all the resources with th given name . |
5,746 | public void unsetUserConfigurations ( UserConfigurationsProvider provider ) { if ( userConfigurations . isPresent ( ) && userConfigurations . get ( ) . equals ( provider ) ) { this . userConfigurations = Optional . empty ( ) ; } } | Unset reference added automatically from setUserConfigurations annotation |
5,747 | public Attribute getAttribute ( final String attributeName ) { final Attribute a = attributes . get ( attributeName ) ; if ( a == null ) throw new IllegalArgumentException ( "Attribute " + attributeName + " doesn't exists" ) ; return a ; } | Returns the attribute with the given name . Throws an IllegalArgumentException if there is no such attribute . |
5,748 | public void addAttributeValue ( final String attributeName , final Value attributeValue , Environment in ) { if ( in == null ) in = GlobalEnvironment . INSTANCE ; Attribute attr = attributes . get ( attributeName ) ; if ( attr == null ) { attr = new Attribute ( attributeName ) ; attributes . put ( attr . getName ( ) , ... | Adds an attribute value . If the attribute doesn t exist it will be created . |
5,749 | public void onClose ( Close event , WebAppMsgChannel appChannel ) throws InterruptedException { appChannel . handleClose ( event ) ; } | Handles a close event from downstream by closing the upstream connections . |
5,750 | @ Handler ( priority = Integer . MIN_VALUE ) public void onOptions ( Request . In . Options event , IOSubchannel appChannel ) { if ( event . requestUri ( ) == HttpRequest . ASTERISK_REQUEST ) { HttpResponse response = event . httpRequest ( ) . response ( ) . get ( ) ; response . setStatus ( HttpStatus . OK ) ; appChann... | Provides a fallback handler for an OPTIONS request with asterisk . Simply responds with OK . |
5,751 | public Matcher matcher ( CharSequence s ) { Matcher m = new Matcher ( this ) ; m . setTarget ( s ) ; return m ; } | Returns a matcher for a specified string . |
5,752 | public Matcher matcher ( char [ ] data , int start , int end ) { Matcher m = new Matcher ( this ) ; m . setTarget ( data , start , end ) ; return m ; } | Returns a matcher for a specified region . |
5,753 | public Matcher matcher ( MatchResult res , String groupName ) { Integer id = res . pattern ( ) . groupId ( groupName ) ; if ( id == null ) throw new IllegalArgumentException ( "group not found:" + groupName ) ; int group = id ; return matcher ( res , group ) ; } | Just as above yet with symbolic group name . |
5,754 | public List < ColumnRelation > toList ( ) { List < ColumnRelation > ret = new ArrayList < > ( ) ; ret . add ( this ) ; if ( getNextRelation ( ) . isPresent ( ) ) { ret . addAll ( getNextRelation ( ) . get ( ) . toList ( ) ) ; } return ret ; } | Returns a chain of column relations as list |
5,755 | public static void addToDataSource ( DataSource parent , DataSource child ) { if ( ! parent . getLeftDataSource ( ) . isPresent ( ) ) { parent . setLeftDataSource ( child ) ; } else if ( ! parent . getRightDataSource ( ) . isPresent ( ) ) { parent . setRightDataSource ( child ) ; } else { DataSource newLeftDataSource =... | Builds optimized data source as a tree |
5,756 | public String format ( LogRecord logRecord ) { StringBuilder resultBuilder = new StringBuilder ( ) ; String prefix = logRecord . getLevel ( ) . getName ( ) + "\t" ; resultBuilder . append ( prefix ) ; resultBuilder . append ( Thread . currentThread ( ) . getName ( ) ) . append ( " " ) . append ( sdf . format ( new java... | Format a logging message |
5,757 | public boolean acceptsValue ( String value ) { if ( value == null ) { return false ; } else if ( hasValues ( ) ) { return getValuesList ( ) . contains ( value ) ; } else { return true ; } } | Returns true if this option accepts the specified value |
5,758 | private static String getUrl ( int method , String baseUrl , String endpoint , Map < String , String > params ) { if ( params != null ) { for ( Map . Entry < String , String > entry : params . entrySet ( ) ) { if ( entry . getValue ( ) == null || entry . getValue ( ) . equals ( "null" ) ) { entry . setValue ( "" ) ; } ... | Converts a base URL endpoint and parameters into a full URL |
5,759 | public static boolean configure ( File configFile ) { boolean goOn = true ; if ( ! configFile . exists ( ) ) { LogHelperDebug . printError ( "File " + configFile . getAbsolutePath ( ) + " does not exist" , false ) ; goOn = false ; } DocumentBuilderFactory documentBuilderFactory = null ; DocumentBuilder documentBuilder ... | Configure the log - helper library to the values in the given XML config file |
5,760 | private static void configureLoggerWrapper ( Node configNode ) { Node lwNameNode = configNode . getAttributes ( ) . getNamedItem ( "name" ) ; String lwName ; if ( lwNameNode != null ) { lwName = lwNameNode . getTextContent ( ) ; } else { lwName = "LoggerWrapper_" + String . valueOf ( ( new Date ( ) ) . getTime ( ) ) ; ... | Configure a LoggerWrapper to the values of a DOM node . It MUST have an attribute named name storing the LoggerWrapper s name . It may have subnodes named configurator keeping the properties for |
5,761 | public PermitsPool removeListener ( AvailabilityListener listener ) { synchronized ( listeners ) { for ( Iterator < WeakReference < AvailabilityListener > > iter = listeners . iterator ( ) ; iter . hasNext ( ) ; ) { WeakReference < AvailabilityListener > item = iter . next ( ) ; if ( item . get ( ) == null || item . ge... | Removes the listener . |
5,762 | public static String className ( Class < ? > clazz ) { if ( CoreUtils . classNames . isLoggable ( Level . FINER ) ) { return clazz . getName ( ) ; } else { return simpleClassName ( clazz ) ; } } | Returns the full name or simple name of the class depending on the log level . |
5,763 | public static Timer schedule ( TimeoutHandler timeoutHandler , Instant scheduledFor ) { return scheduler . schedule ( timeoutHandler , scheduledFor ) ; } | Schedules the given timeout handler for the given instance . |
5,764 | public static Timer schedule ( TimeoutHandler timeoutHandler , Duration scheduledFor ) { return scheduler . schedule ( timeoutHandler , Instant . now ( ) . plus ( scheduledFor ) ) ; } | Schedules the given timeout handler for the given offset from now . |
5,765 | public static String encodePostBody ( Bundle parameters , String boundary ) { if ( parameters == null ) return "" ; StringBuilder sb = new StringBuilder ( ) ; for ( String key : parameters . keySet ( ) ) { Object parameter = parameters . get ( key ) ; if ( ! ( parameter instanceof String ) ) { continue ; } sb . append ... | Generate the multi - part post body providing the parameters and boundary string |
5,766 | public static Bundle parseUrl ( String url ) { url = url . replace ( "fbconnect" , "http" ) ; try { URL u = new URL ( url ) ; Bundle b = decodeUrl ( u . getQuery ( ) ) ; b . putAll ( decodeUrl ( u . getRef ( ) ) ) ; return b ; } catch ( MalformedURLException e ) { return new Bundle ( ) ; } } | Parse a URL query and fragment parameters into a key - value bundle . |
5,767 | public static String openUrl ( String url , String method , Bundle params ) throws MalformedURLException , IOException { String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f" ; String endLine = "\r\n" ; OutputStream os ; if ( method . equals ( "GET" ) ) { url = url + "?" + encodeUrl ( params ) ; } Utility . l... | Connect to an HTTP URL and return the response as a string . |
5,768 | public static String getAttachmentUrl ( String applicationId , UUID callId , String attachmentName ) { return String . format ( "%s%s/%s/%s" , ATTACHMENT_URL_BASE , applicationId , callId . toString ( ) , attachmentName ) ; } | Returns the name of the content provider formatted correctly for constructing URLs . |
5,769 | public Character set ( final int index , final Character ok ) { return set ( index , ok . charValue ( ) ) ; } | Delegates to the corresponding type - specific method . |
5,770 | private void getElements ( final int from , final char [ ] a , final int offset , final int length ) { CharArrays . ensureOffsetLength ( a , offset , length ) ; System . arraycopy ( this . a , from , a , offset , length ) ; } | Copies element of this type - specific list into the given array using optimized system calls . |
5,771 | public void removeElements ( final int from , final int to ) { CharArrays . ensureFromTo ( size , from , to ) ; System . arraycopy ( a , to , a , from , size - to ) ; size -= ( to - from ) ; } | Removes elements of this type - specific list using optimized system calls . |
5,772 | public void addElements ( final int index , final char a [ ] , final int offset , final int length ) { ensureIndex ( index ) ; CharArrays . ensureOffsetLength ( a , offset , length ) ; grow ( size + length ) ; System . arraycopy ( this . a , index , this . a , index + length , size - index ) ; System . arraycopy ( a , ... | Adds elements to this type - specific list using optimized system calls . |
5,773 | private void ensureIndex ( final int index ) { if ( index < 0 ) throw new IndexOutOfBoundsException ( "Index (" + index + ") is negative" ) ; if ( index > size ( ) ) throw new IndexOutOfBoundsException ( "Index (" + index + ") is greater than list size (" + ( size ( ) ) + ")" ) ; } | Ensures that the given index is non - negative and not greater than the list size . |
5,774 | protected void ensureRestrictedIndex ( final int index ) { if ( index < 0 ) throw new IndexOutOfBoundsException ( "Index (" + index + ") is negative" ) ; if ( index >= size ( ) ) throw new IndexOutOfBoundsException ( "Index (" + index + ") is greater than or equal to list size (" + ( size ( ) ) + ")" ) ; } | Ensures that the given index is non - negative and smaller than the list size . |
5,775 | public boolean containsAll ( Collection < ? > c ) { int n = c . size ( ) ; final Iterator < ? > i = c . iterator ( ) ; while ( n -- != 0 ) if ( ! contains ( i . next ( ) ) ) return false ; return true ; } | Checks whether this collection contains all elements from the given collection . |
5,776 | public boolean addAll ( Collection < ? extends Character > c ) { boolean retVal = false ; final Iterator < ? extends Character > i = c . iterator ( ) ; int n = c . size ( ) ; while ( n -- != 0 ) if ( add ( i . next ( ) ) ) retVal = true ; return retVal ; } | Adds all elements of the given collection to this collection . |
5,777 | public synchronized Set < ConfigurationDetails > getConfigurationDetails ( ) { return inventory . entries ( ) . stream ( ) . map ( c -> c . getConfiguration ( ) . orElse ( null ) ) . filter ( v -> v != null ) . map ( v -> v . getDetails ( ) ) . collect ( Collectors . toSet ( ) ) ; } | Gets configuration details . |
5,778 | public synchronized Map < String , Object > getConfiguration ( String key ) { return Optional . ofNullable ( inventory . get ( key ) ) . flatMap ( v -> v . getConfiguration ( ) ) . map ( v -> v . getMap ( ) ) . orElse ( null ) ; } | Gets a configuration . |
5,779 | public synchronized Optional < String > addConfiguration ( String niceName , String description , Map < String , Object > config ) { try { if ( catalog == null ) { throw new FileNotFoundException ( ) ; } return sync ( ( ) -> { ConfigurationDetails p = new ConfigurationDetails . Builder ( inventory . nextIdentifier ( ) ... | Adds a configuration to this catalog . |
5,780 | public synchronized boolean removeConfiguration ( String key ) { try { if ( catalog == null ) { throw new FileNotFoundException ( ) ; } return sync ( ( ) -> inventory . remove ( key ) != null ) ; } catch ( IOException e ) { logger . log ( Level . WARNING , "Failed to remove configuration." , e ) ; return false ; } } | Removes the configuration with the specified identifier . |
5,781 | private boolean cleanupInventory ( ) { boolean modified = false ; modified |= removeUnreadable ( ) ; modified |= recreateMismatching ( ) ; modified |= importConfigurations ( ) ; return modified ; } | Cleans up the inventory . |
5,782 | private boolean removeUnreadable ( ) { List < File > unreadable = inventory . removeUnreadable ( ) ; unreadable . forEach ( v -> v . delete ( ) ) ; return ! unreadable . isEmpty ( ) ; } | Removes unreadable configurations from the file system . |
5,783 | private boolean recreateMismatching ( ) { List < Configuration > mismatching = inventory . removeMismatching ( ) ; mismatching . forEach ( entry -> { try { inventory . add ( InventoryEntry . create ( entry . copyWithIdentifier ( inventory . nextIdentifier ( ) ) , newConfigurationFile ( ) ) ) ; } catch ( IOException e1 ... | Recreates mismatching configurations . |
5,784 | private boolean importConfigurations ( ) { Set < File > files = inventory . entries ( ) . stream ( ) . map ( v -> v . getPath ( ) ) . collect ( Collectors . toSet ( ) ) ; List < File > entriesToImport = Arrays . asList ( baseDir . listFiles ( f -> f . isFile ( ) && ! f . equals ( catalog ) && f . getName ( ) . endsWith... | Imports new configurations from the file system . |
5,785 | @ SuppressWarnings ( { "unchecked" , "PMD.ShortVariable" , "PMD.AvoidDuplicateLiterals" } ) public < C > C [ ] channels ( Class < C > type ) { return Arrays . stream ( channels ) . filter ( c -> type . isAssignableFrom ( c . getClass ( ) ) ) . toArray ( size -> ( C [ ] ) Array . newInstance ( type , size ) ) ; } | Returns the subset of channels that are assignable to the given type . |
5,786 | @ SuppressWarnings ( { "unchecked" , "PMD.ShortVariable" } ) public < E extends EventBase < ? > , C extends Channel > void forChannels ( Class < C > type , BiConsumer < E , C > handler ) { Arrays . stream ( channels ) . filter ( c -> type . isAssignableFrom ( c . getClass ( ) ) ) . forEach ( c -> handler . accept ( ( E... | Execute the given handler for all channels of the given type . |
5,787 | public Event < T > setResult ( T result ) { synchronized ( this ) { if ( results == null ) { results = new ArrayList < T > ( ) ; results . add ( result ) ; firstResultAssigned ( ) ; return this ; } results . add ( result ) ; return this ; } } | Sets the result of handling this event . If this method is invoked more then once the various results are collected in a list . This can happen if the event is handled by several components . |
5,788 | protected List < T > currentResults ( ) { return results == null ? Collections . emptyList ( ) : Collections . unmodifiableList ( results ) ; } | Allows access to the intermediate result before the completion of the event . |
5,789 | public static View inflateView ( LayoutInflater inflater , ViewGroup parent , int layoutId ) { return inflater . inflate ( layoutId , parent , false ) ; } | Static method to help inflate parent view with layoutId |
5,790 | public static < VH extends PeasyViewHolder > VH GetViewHolder ( PeasyViewHolder vh , Class < VH > cls ) { return cls . cast ( vh ) ; } | Help to cast provided PeasyViewHolder to its child class instance |
5,791 | < T > void bindWith ( final PeasyRecyclerView < T > binder , final int viewType ) { this . itemView . setOnClickListener ( new View . OnClickListener ( ) { public void onClick ( View v ) { int position = getLayoutPosition ( ) ; position = ( position <= binder . getLastItemIndex ( ) ) ? position : getAdapterPosition ( )... | Will bind onClick and setOnLongClickListener here |
5,792 | @ SuppressWarnings ( "PMD.UseVarargs" ) public void fire ( Event < ? > event , Channel [ ] channels ) { eventPipeline . add ( event , channels ) ; } | Forward to the thread s event manager . |
5,793 | @ SuppressWarnings ( "PMD.UseVarargs" ) void dispatch ( EventPipeline pipeline , EventBase < ? > event , Channel [ ] channels ) { HandlerList handlers = getEventHandlers ( event , channels ) ; handlers . process ( pipeline , event ) ; } | Send the event to all matching handlers . |
5,794 | public static String readlineFromStdIn ( ) throws IOException { StringBuilder ret = new StringBuilder ( ) ; int c ; while ( ( c = System . in . read ( ) ) != '\n' && c != - 1 ) { if ( c != '\r' ) ret . append ( ( char ) c ) ; } return ret . toString ( ) ; } | Reads a line from standard input . |
5,795 | protected final SessionState getSessionState ( ) { if ( sessionTracker != null ) { Session currentSession = sessionTracker . getSession ( ) ; return ( currentSession != null ) ? currentSession . getState ( ) : null ; } return null ; } | Gets the current state of the session or null if no session has been created . |
5,796 | protected final String getAccessToken ( ) { if ( sessionTracker != null ) { Session currentSession = sessionTracker . getOpenSession ( ) ; return ( currentSession != null ) ? currentSession . getAccessToken ( ) : null ; } return null ; } | Gets the access token associated with the current session or null if no session has been created . |
5,797 | protected final Date getExpirationDate ( ) { if ( sessionTracker != null ) { Session currentSession = sessionTracker . getOpenSession ( ) ; return ( currentSession != null ) ? currentSession . getExpirationDate ( ) : null ; } return null ; } | Gets the date at which the current session will expire or null if no session has been created . |
5,798 | protected final void closeSessionAndClearTokenInformation ( ) { if ( sessionTracker != null ) { Session currentSession = sessionTracker . getOpenSession ( ) ; if ( currentSession != null ) { currentSession . closeAndClearTokenInformation ( ) ; } } } | Closes the current session as well as clearing the token cache . |
5,799 | protected final List < String > getSessionPermissions ( ) { if ( sessionTracker != null ) { Session currentSession = sessionTracker . getSession ( ) ; return ( currentSession != null ) ? currentSession . getPermissions ( ) : null ; } return null ; } | Gets the permissions associated with the current session or null if no session has been created . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.