idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
14,800 | public Binder varargs ( int index , Class < ? > type ) { return new Binder ( this , new Varargs ( type ( ) , index , type ) ) ; } | Box all incoming arguments from the given position onward into the given array type . This version accepts a variable number of incoming arguments . |
14,801 | public Binder foldVoid ( MethodHandle function ) { if ( type ( ) . returnType ( ) == void . class ) { return fold ( function ) ; } else { return fold ( function . asType ( function . type ( ) . changeReturnType ( void . class ) ) ) ; } } | Process the incoming arguments using the given handle leaving the argument list unmodified . |
14,802 | public Binder foldVirtual ( MethodHandles . Lookup lookup , String method ) { return fold ( Binder . from ( type ( ) ) . invokeVirtualQuiet ( lookup , method ) ) ; } | Process the incoming arguments by calling the given method on the first argument inserting the result as the first argument . |
14,803 | public Binder filterForward ( int index , MethodHandle ... functions ) { Binder filtered = this ; for ( int i = 0 ; i < functions . length ; i ++ ) { filtered = filtered . filter ( index + i , functions [ i ] ) ; } return filtered ; } | Filter incoming arguments from the given index replacing each with the result of calling the associated function in the given list . This version guarantees left - to - right evaluation of filter functions potentially at the cost of a more complex handle tree . |
14,804 | public Binder catchException ( Class < ? extends Throwable > throwable , MethodHandle function ) { return new Binder ( this , new Catch ( throwable , function ) ) ; } | Catch the given exception type from the downstream chain and handle it with the given function . |
14,805 | public MethodHandle nop ( ) { if ( type ( ) . returnType ( ) != void . class ) { throw new InvalidTransformException ( "must have void return type to nop: " + type ( ) ) ; } return invoke ( Binder . from ( type ( ) ) . drop ( 0 , type ( ) . parameterCount ( ) ) . cast ( Object . class ) . constant ( null ) ) ; } | Apply all transforms to an endpoint that does absolutely nothing . Useful for creating exception handlers in void methods that simply ignore the exception . |
14,806 | public MethodHandle throwException ( ) { if ( type ( ) . parameterCount ( ) != 1 || ! Throwable . class . isAssignableFrom ( type ( ) . parameterType ( 0 ) ) ) { throw new InvalidTransformException ( "incoming signature must have one Throwable type as its sole argument: " + type ( ) ) ; } return invoke ( MethodHandles . throwException ( type ( ) . returnType ( ) , type ( ) . parameterType ( 0 ) . asSubclass ( Throwable . class ) ) ) ; } | Throw the current signature s sole Throwable argument . Return type does not matter since it will never return . |
14,807 | public MethodHandle constant ( Object value ) { return invoke ( MethodHandles . constant ( type ( ) . returnType ( ) , value ) ) ; } | Apply the tranforms binding them to a constant value that will propagate back through the chain . The chain s expected return type at that point must be compatible with the given value s type . |
14,808 | public MethodHandle invoke ( MethodHandle target ) { MethodHandle current = target ; for ( Transform t : transforms ) { current = t . up ( current ) ; } current = MethodHandles . explicitCastArguments ( current , start ) ; return current ; } | Apply the chain of transforms with the target method handle as the final endpoint . Produces a handle that has the transforms in given sequence . |
14,809 | public MethodHandle arrayAccess ( VarHandle . AccessMode mode ) { return invoke ( MethodHandles . arrayElementVarHandle ( type ( ) . parameterType ( 0 ) ) . toMethodHandle ( mode ) ) ; } | Apply the chain of transforms and bind them to an array varhandle operation . The signature at the endpoint must match the VarHandle access type passed in . |
14,810 | public MethodHandle branch ( MethodHandle test , MethodHandle truePath , MethodHandle falsePath ) { return invoke ( MethodHandles . guardWithTest ( test , truePath , falsePath ) ) ; } | Apply the chain of transforms and bind them to a boolean branch as from java . lang . invoke . MethodHandles . guardWithTest . As with GWT the current endpoint signature must match the given target and fallback signatures . |
14,811 | public String toJava ( MethodType incoming ) { StringBuilder builder = new StringBuilder ( ) ; boolean second = false ; for ( Transform transform : transforms ) { if ( second ) builder . append ( '\n' ) ; second = true ; builder . append ( transform . toJava ( incoming ) ) ; } return builder . toString ( ) ; } | Produce Java code that would perform equivalent operations to this binder . |
14,812 | public HttpResponse execute ( ) throws IOException { if ( this . method == HttpMethod . GET ) { String url = this . toString ( ) ; if ( url . length ( ) > this . cutoff ) { if ( log . isLoggable ( Level . FINER ) ) log . finer ( "URL length " + url . length ( ) + " too long, converting GET to POST: " + url ) ; String rebase = this . baseURL + "?method=GET" ; return this . execute ( HttpMethod . POST , rebase ) ; } } return super . execute ( ) ; } | Replace excessively - long GET requests with a POST . |
14,813 | private < T > GraphRequest < T > graph ( String object , JavaType type , Param ... params ) { this . checkForBatchExecution ( ) ; GraphRequest < T > req = new GraphRequest < T > ( object , params , this . mapper , this . < T > createMappingChain ( type ) ) ; this . graphRequests . add ( req ) ; return req ; } | The actual implementation of this after we ve converted to proper Jackson JavaType |
14,814 | private < T > QueryRequest < T > query ( String fql , JavaType type ) { this . checkForBatchExecution ( ) ; if ( this . multiqueryRequest == null ) { this . multiqueryRequest = new MultiqueryRequest ( mapper , this . createUnmappedChain ( ) ) ; this . graphRequests . add ( this . multiqueryRequest ) ; } QueryNodeExtractor extractor = new QueryNodeExtractor ( this . multiqueryRequest ) ; String name = "__q" + this . generatedQueryNameIndex ++ ; QueryRequest < T > q = new QueryRequest < T > ( fql , name , new MapperWrapper < T > ( type , this . mapper , extractor ) ) ; extractor . setRequest ( q ) ; this . multiqueryRequest . addQuery ( q ) ; return q ; } | Implementation now that we have chosen a Jackson JavaType for the return value |
14,815 | private < T > MapperWrapper < T > createMappingChain ( JavaType type ) { return new MapperWrapper < T > ( type , this . mapper , this . createUnmappedChain ( ) ) ; } | Adds mapping to the basic unmapped chain . |
14,816 | private ErrorDetectingWrapper createUnmappedChain ( ) { int nextIndex = this . graphRequests . size ( ) ; return new ErrorDetectingWrapper ( new GraphNodeExtractor ( nextIndex , this . mapper , new ErrorDetectingWrapper ( this ) ) ) ; } | Creates the common chain of wrappers that will select out one graph request from the batch and error check it both at the batch level and at the individual request level . Result will be an unmapped JsonNode . |
14,817 | private Later < JsonNode > getRawBatchResult ( ) { if ( this . rawBatchResult == null ) { this . rawBatchResult = new LaterWrapper < JsonNode , JsonNode > ( this . createFetcher ( ) ) ; this . master . execute ( ) ; } return this . rawBatchResult ; } | Get the batch result firing it off if necessary |
14,818 | private Later < JsonNode > createFetcher ( ) { final RequestBuilder call = new GraphRequestBuilder ( getGraphEndpoint ( ) , HttpMethod . POST , this . timeout , this . retries ) ; String batchValue = JSONUtils . toJSON ( this . graphRequests , this . mapper ) ; if ( log . isLoggable ( Level . FINEST ) ) log . finest ( "Batch request is: " + batchValue ) ; this . addParams ( call , new Param [ ] { new Param ( "batch" , batchValue ) } ) ; final HttpResponse response ; try { response = call . execute ( ) ; } catch ( IOException ex ) { throw new IOFacebookException ( ex ) ; } return new Later < JsonNode > ( ) { public JsonNode get ( ) throws FacebookException { try { if ( response . getResponseCode ( ) == HttpURLConnection . HTTP_OK || response . getResponseCode ( ) == HttpURLConnection . HTTP_BAD_REQUEST || response . getResponseCode ( ) == HttpURLConnection . HTTP_UNAUTHORIZED ) { JsonNode result = mapper . readTree ( response . getContentStream ( ) ) ; if ( log . isLoggable ( Level . FINEST ) ) log . finest ( "Response is: " + result ) ; return result ; } else { throw new IOFacebookException ( "Unrecognized error " + response . getResponseCode ( ) + " from " + call + " :: " + StringUtils . read ( response . getContentStream ( ) ) ) ; } } catch ( IOException e ) { throw new IOFacebookException ( "Error calling " + call , e ) ; } } } ; } | Constructs the batch query and executes it possibly asynchronously . |
14,819 | private void throwPageMigratedException ( String msg , int code , int subcode , String userTitle , String userMsg ) { Matcher matcher = ID_PATTERN . matcher ( msg ) ; long oldId = this . extractNextId ( matcher , msg ) ; long newId = this . extractNextId ( matcher , msg ) ; throw new PageMigratedException ( msg , code , subcode , userTitle , userMsg , oldId , newId ) ; } | Builds the proper exception and throws it . |
14,820 | private long extractNextId ( Matcher matcher , String msg ) { if ( ! matcher . find ( ) ) throw new IllegalStateException ( "Facebook changed the error msg for page migration to something unfamiliar. The new msg is: " + msg ) ; String idStr = matcher . group ( ) . substring ( "ID " . length ( ) ) ; return Long . parseLong ( idStr ) ; } | Gets the next id out of the matcher |
14,821 | protected void throwCodeAndMessage ( int code , String msg ) { switch ( code ) { case 0 : case 101 : case 102 : case 190 : throw new OAuthException ( msg , "OAuthException" , code , null , null , null ) ; default : throw new ErrorFacebookException ( msg + " (code " + code + ")" , null , code , null , null , null ) ; } } | Throw the appropriate exception for the given legacy code and message . Always throws never returns . |
14,822 | protected ListSetItem < T > newItem ( IModel < T > itemModel ) { ListSetItem < T > item = new ListSetItem < T > ( Integer . toString ( counter ++ ) , itemModel ) ; populateItem ( item ) ; return item ; } | Create a new ListSetItem for list item . |
14,823 | public DateTextField getDateTextField ( ) { DateTextField component = visitChildren ( DateTextField . class , new IVisitor < DateTextField , DateTextField > ( ) { public void component ( DateTextField arg0 , IVisit < DateTextField > arg1 ) { arg1 . stop ( arg0 ) ; } } ) ; if ( component == null ) throw new WicketRuntimeException ( "BootstrapDatepicker didn't have any DateTextField child!" ) ; return component ; } | Gets the DateTextField inside this datepicker wrapper . |
14,824 | private boolean typesAreCompatible ( Class < ? > [ ] paramTypes , Class < ? > [ ] constructorParamTypes ) { boolean matches = true ; for ( int i = 0 ; i < paramTypes . length ; i ++ ) { Class < ? > paramType = paramTypes [ i ] ; if ( paramType != null ) { Class < ? > inputParamType = translateFromPrimitive ( paramType ) ; Class < ? > constructorParamType = translateFromPrimitive ( constructorParamTypes [ i ] ) ; if ( inputParamType . isArray ( ) && Collection . class . isAssignableFrom ( constructorParamType ) ) { continue ; } if ( ! constructorParamType . isAssignableFrom ( inputParamType ) ) { matches = false ; break ; } } } return matches ; } | Checks if a set of types are compatible with the given set of constructor parameter types . If an input type is null then it is considered as a wildcard for matching purposes and always matches . |
14,825 | public V action ( Callable < V > callable ) throws Exception { Exception re ; RetryState retryState = retryStrategy . getRetryState ( ) ; do { try { return callable . call ( ) ; } catch ( Exception e ) { re = e ; if ( Thread . interrupted ( ) || isInterruptTransitively ( e ) ) { re = new InterruptedException ( e . getMessage ( ) ) ; break ; } if ( ! transientExceptionDetector . isTransient ( e ) ) { break ; } } enqueueRetryEvent ( new RetryEvent ( this , retryState , re ) ) ; retryState . delayRetry ( ) ; } while ( retryState . hasRetries ( ) ) ; throw re ; } | Perform the specified action under the defined retry semantics . |
14,826 | private boolean isInterruptTransitively ( Throwable e ) { do { if ( e instanceof InterruptedException ) { return true ; } e = e . getCause ( ) ; } while ( e != null ) ; return false ; } | Special case during shutdown . |
14,827 | public Object getSet ( String key , Object value , Integer expiration ) throws Exception { Jedis jedis = null ; try { jedis = this . jedisPool . getResource ( ) ; long begin = System . currentTimeMillis ( ) ; byte [ ] val = jedis . getSet ( SafeEncoder . encode ( key ) , serialize ( value ) ) ; Object result = deserialize ( val ) ; boolean success = true ; if ( expiration > 0 ) { Long res = jedis . expire ( key , expiration ) ; if ( res == 0L ) { success = false ; } } long end = System . currentTimeMillis ( ) ; if ( success ) { logger . info ( "getset key:" + key + ", spends: " + ( end - begin ) + "ms" ) ; } else { logger . info ( "getset key: " + key + " failed, key has already exists! " ) ; } return result ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; this . jedisPool . returnBrokenResource ( jedis ) ; throw e ; } finally { if ( jedis != null ) { this . jedisPool . returnResource ( jedis ) ; } } } | get old value and set new value |
14,828 | public boolean add ( String key , Object value , Integer expiration ) throws Exception { Jedis jedis = null ; try { jedis = this . jedisPool . getResource ( ) ; long begin = System . currentTimeMillis ( ) ; Long result = jedis . setnx ( SafeEncoder . encode ( key ) , serialize ( value ) ) ; if ( expiration > 0 ) { result = result & jedis . expire ( key , expiration ) ; } long end = System . currentTimeMillis ( ) ; if ( result == 1L ) { logger . info ( "add key:" + key + ", spends: " + ( end - begin ) + "ms" ) ; } else { logger . info ( "add key: " + key + " failed, key has already exists! " ) ; } return result == 1L ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; this . jedisPool . returnBrokenResource ( jedis ) ; throw e ; } finally { if ( jedis != null ) { this . jedisPool . returnResource ( jedis ) ; } } } | add if not exists |
14,829 | public boolean exists ( String key ) throws Exception { boolean isExist = false ; Jedis jedis = null ; try { jedis = this . jedisPool . getResource ( ) ; isExist = jedis . exists ( SafeEncoder . encode ( key ) ) ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; this . jedisPool . returnBrokenResource ( jedis ) ; throw e ; } finally { if ( jedis != null ) { this . jedisPool . returnResource ( jedis ) ; } } return isExist ; } | Test if the specified key exists . |
14,830 | public boolean delete ( String key ) { Jedis jedis = null ; try { jedis = this . jedisPool . getResource ( ) ; jedis . del ( SafeEncoder . encode ( key ) ) ; logger . info ( "delete key:" + key ) ; return true ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; this . jedisPool . returnBrokenResource ( jedis ) ; } finally { if ( jedis != null ) { this . jedisPool . returnResource ( jedis ) ; } } return false ; } | Remove the specified keys . |
14,831 | public boolean flushall ( ) { String result = "" ; Jedis jedis = null ; try { jedis = this . jedisPool . getResource ( ) ; result = jedis . flushAll ( ) ; logger . info ( "redis client name: " + this . getCacheName ( ) + " flushall." ) ; } catch ( Exception e ) { logger . error ( e . getMessage ( ) , e ) ; this . jedisPool . returnBrokenResource ( jedis ) ; } finally { if ( jedis != null ) { this . jedisPool . returnResource ( jedis ) ; } } return "OK" . equalsIgnoreCase ( result ) ; } | Delete all the keys of all the existing databases not just the currently selected one . |
14,832 | public Object get ( Object obj ) throws ReflectionException { try { if ( isPublic ( readMethod ) ) { return readMethod . invoke ( obj ) ; } else { throw new ReflectionException ( "Cannot get the value of " + this + ", as it is write-only." ) ; } } catch ( Exception e ) { throw new ReflectionException ( "Cannot get the value of " + this + " in object " + obj , e ) ; } } | Returns the value of the representation of this property from the specified object . |
14,833 | public void set ( Object obj , Object value ) throws ReflectionException { try { if ( isPublic ( writeMethod ) ) { writeMethod . invoke ( obj , value ) ; } else { throw new ReflectionException ( "Cannot set the value of " + this + ", as it is read-only." ) ; } } catch ( Exception e ) { throw new ReflectionException ( "Cannot set the value of " + this + " to object " + obj , e ) ; } } | Sets a new value to the representation of this property on the specified object . |
14,834 | @ SuppressWarnings ( "unchecked" ) public < C > IConverter < C > getConverter ( final Class < C > type ) { if ( Temporal . class . isAssignableFrom ( type ) ) { return ( IConverter < C > ) converter ; } else { return super . getConverter ( type ) ; } } | Returns the default converter if created without pattern ; otherwise it returns a pattern - specific converter . |
14,835 | public static boolean isSqlStateDuplicateValueInUniqueIndex ( SQLException se ) { String sqlState = se . getSQLState ( ) ; return sqlState != null && ( sqlState . equals ( "23505" ) || se . getMessage ( ) . contains ( "duplicate value in unique index" ) ) ; } | Determines if the SQL exception a duplicate value in unique index . |
14,836 | public static boolean isSqlStateConnectionException ( SQLException se ) { String sqlState = se . getSQLState ( ) ; return sqlState != null && sqlState . startsWith ( "08" ) ; } | Determines if the SQL exception is a connection exception |
14,837 | public static boolean isSqlStateRollbackException ( SQLException se ) { String sqlState = se . getSQLState ( ) ; return sqlState != null && sqlState . startsWith ( "40" ) ; } | Determines if the SQL exception is a rollback exception |
14,838 | public static Date getPreviousDay ( Date dt ) { if ( dt == null ) { return dt ; } Calendar cal = Calendar . getInstance ( ) ; cal . setTime ( dt ) ; cal . add ( Calendar . DAY_OF_YEAR , - 1 ) ; return cal . getTime ( ) ; } | added by zhuqian 2009 - 03 - 25 |
14,839 | public static synchronized void cancel ( TimerTask task ) { if ( task == null ) { return ; } task . cancel ( ) ; usageCount . decrementAndGet ( ) ; if ( usageCount . get ( ) == 0 ) { timer . cancel ( ) ; timer = null ; } } | Remove the specified eviction task from the timer . |
14,840 | public void push ( AbstractDrawer drawer , AjaxRequestTarget target , String cssClass ) { ListItem item = new ListItem ( "next" , drawer , this , cssClass ) ; drawers . push ( item ) ; if ( first == null ) { first = item ; addOrReplace ( first ) ; } else { ListItem iter = first ; while ( iter . next != null ) { iter = iter . next ; } iter . add ( item ) ; } if ( target != null ) { target . add ( item ) ; target . appendJavaScript ( "$('#" + item . item . getMarkupId ( ) + "').modaldrawer('show');" ) ; if ( item . previous != null ) { target . appendJavaScript ( "$('#" + item . previous . item . getMarkupId ( ) + "').removeClass('shown-modal');" ) ; target . appendJavaScript ( "$('#" + item . previous . item . getMarkupId ( ) + "').addClass('hidden-modal');" ) ; } } drawer . setManager ( this ) ; } | Push and display a drawer on the page during an AJAX request and inject an optional CSS class onto the drawer s immediate container . |
14,841 | public void replaceLast ( AbstractDrawer newDrawer , AjaxRequestTarget target ) { if ( ! drawers . isEmpty ( ) ) { ListItem last = drawers . getFirst ( ) ; last . drawer . replaceWith ( newDrawer ) ; last . drawer = newDrawer ; newDrawer . setManager ( this ) ; target . add ( newDrawer ) ; } } | Replaces the topmost open drawer with a new one . If there is no open drawer this method does nothing . This method requires an AJAX request . DrawerManager does not support swapping drawers during page construction . |
14,842 | public void renderHead ( IHeaderResponse response ) { super . renderHead ( response ) ; response . render ( JavaScriptHeaderItem . forReference ( DRAWER_JAVASCRIPT ) ) ; response . render ( JavaScriptHeaderItem . forReference ( MANAGER_JAVASCRIPT ) ) ; response . render ( CssHeaderItem . forReference ( DRAWER_CSS ) ) ; Iterator < ListItem > iter = drawers . descendingIterator ( ) ; WebMarkupContainer drawer ; while ( iter . hasNext ( ) ) { drawer = iter . next ( ) . item ; response . render ( OnDomReadyHeaderItem . forScript ( "$('#" + drawer . getMarkupId ( ) + "').modaldrawer('show');" ) ) ; if ( drawers . getFirst ( ) . item . equals ( drawer ) ) { response . render ( OnDomReadyHeaderItem . forScript ( "$('#" + drawer . getMarkupId ( ) + "').addClass('shown-modal');" ) ) ; response . render ( OnDomReadyHeaderItem . forScript ( "$('#" + drawer . getMarkupId ( ) + "').removeClass('hidden-modal');" ) ) ; } else { response . render ( OnDomReadyHeaderItem . forScript ( "$('#" + drawer . getMarkupId ( ) + "').removeClass('shown-modal');" ) ) ; response . render ( OnDomReadyHeaderItem . forScript ( "$('#" + drawer . getMarkupId ( ) + "').addClass('hidden-modal');" ) ) ; } } } | pressing the Back button and landing on a page with open drawers . |
14,843 | public void setWrappedObject ( Object obj ) { if ( obj == null ) { throw new IllegalArgumentException ( "Cannot warp a 'null' object." ) ; } this . object = obj ; this . bean = Bean . forClass ( obj . getClass ( ) ) ; } | Changes at any time the wrapped object with a new object . |
14,844 | public Object getIndexedValue ( String propertyName , int index ) { return getIndexedValue ( object , getPropertyOrThrow ( bean , propertyName ) , index , this ) ; } | Returns the value of the specified indexed property from the wrapped object . |
14,845 | public void setSimpleValue ( String propertyName , Object value ) { setSimpleValue ( object , getPropertyOrThrow ( bean , propertyName ) , value ) ; } | Sets the value of the specified property in the wrapped object . |
14,846 | public static Class < ? > translateFromPrimitive ( Class < ? > paramType ) { if ( paramType == int . class ) { return Integer . class ; } else if ( paramType == char . class ) { return Character . class ; } else if ( paramType == byte . class ) { return Byte . class ; } else if ( paramType == long . class ) { return Long . class ; } else if ( paramType == short . class ) { return Short . class ; } else if ( paramType == boolean . class ) { return Boolean . class ; } else if ( paramType == double . class ) { return Double . class ; } else if ( paramType == float . class ) { return Float . class ; } else { return paramType ; } } | From a primitive type class tries to return the corresponding wrapper class . |
14,847 | protected final void onRender ( ) { Iterator < ? extends Component > it = renderIterator ( ) ; while ( it . hasNext ( ) ) { Component child = it . next ( ) ; if ( child == null ) { throw new IllegalStateException ( "The render iterator returned null for a child. Container: " + this . toString ( ) + "; Iterator=" + it . toString ( ) ) ; } renderChild ( child ) ; } } | Renders all child items in no specified order |
14,848 | private static int metadata_end_cmp_ ( MetaData x , MetaData y ) { return x . getEnd ( ) . compareTo ( y . getEnd ( ) ) ; } | Comparator in order to sort MetaData based on the end timestamp . |
14,849 | private static List < Path > file_listing_ ( Path dir ) throws IOException { try ( Stream < Path > files = Files . list ( dir ) ) { return files . collect ( Collectors . toList ( ) ) ; } } | Scan a directory for files . This method reads the entire stream and closes it immediately . |
14,850 | public TSDataScanDir filterUpgradable ( ) { return new TSDataScanDir ( getDir ( ) , getFiles ( ) . stream ( ) . filter ( MetaData :: isUpgradable ) . collect ( Collectors . toList ( ) ) ) ; } | Filter the list of files to contain only upgradable files . |
14,851 | protected void init ( ExplodeInfo info , int x , int y , int width , int height ) { _info = info ; _ox = x ; _oy = y ; _owid = width ; _ohei = height ; _info . rvel = ( float ) ( ( 2.0f * Math . PI ) * _info . rvel ) ; _chunkcount = ( _info . xchunk * _info . ychunk ) ; _cxpos = new int [ _chunkcount ] ; _cypos = new int [ _chunkcount ] ; _sxvel = new float [ _chunkcount ] ; _syvel = new float [ _chunkcount ] ; _cwid = _owid / _info . xchunk ; _chei = _ohei / _info . ychunk ; _hcwid = _cwid / 2 ; _hchei = _chei / 2 ; for ( int ii = 0 ; ii < _chunkcount ; ii ++ ) { int xpos = ii % _info . xchunk ; int ypos = ii / _info . xchunk ; _cxpos [ ii ] = _ox + ( xpos * _cwid ) ; _cypos [ ii ] = _oy + ( ypos * _chei ) ; _sxvel [ ii ] = RandomUtil . getFloat ( _info . xvel ) * ( ( xpos < ( _info . xchunk / 2 ) ) ? - 1.0f : 1.0f ) ; _syvel [ ii ] = - ( RandomUtil . getFloat ( _info . yvel ) ) ; } _angle = 0.0f ; } | Initializes the animation with the attributes of the given explode info object . |
14,852 | public static MetricValue fromNumberValue ( Number number ) { if ( number == null ) { return EMPTY ; } else if ( number instanceof Float || number instanceof Double ) { return fromDblValue ( number . doubleValue ( ) ) ; } else if ( number instanceof Byte || number instanceof Short || number instanceof Integer || number instanceof Long ) { return fromIntValue ( number . longValue ( ) ) ; } else { throw new IllegalArgumentException ( "Unrecognized number type: " + number . getClass ( ) ) ; } } | Construct a metric value from a Number implementation . |
14,853 | public void positionAvoidAnimation ( Animation anim , Rectangle viewBounds ) { Rectangle abounds = new Rectangle ( anim . getBounds ( ) ) ; @ SuppressWarnings ( "unchecked" ) ArrayList < Animation > avoidables = ( ArrayList < Animation > ) _avoidAnims . clone ( ) ; if ( SwingUtil . positionRect ( abounds , viewBounds , avoidables ) ) { anim . setLocation ( abounds . x , abounds . y ) ; } _avoidAnims . add ( anim ) ; anim . addAnimationObserver ( _avoidAnimObs ) ; } | Position the specified animation so that it is not overlapping any still - running animations previously passed to this method . |
14,854 | public void invalidateRegion ( int x , int y , int width , int height ) { if ( isValidSize ( width , height ) ) { addDirtyRegion ( new Rectangle ( x , y , width , height ) ) ; } } | Invalidates the specified region . |
14,855 | protected final boolean isValidSize ( int width , int height ) { if ( width < 0 || height < 0 ) { log . warning ( "Attempt to add invalid dirty region?!" , "size" , ( width + "x" + height ) , new Exception ( ) ) ; return false ; } else if ( width == 0 || height == 0 ) { return false ; } else { return true ; } } | Used to ensure our dirty regions are not invalid . |
14,856 | public Rectangle [ ] getDirtyRegions ( ) { List < Rectangle > merged = Lists . newArrayList ( ) ; for ( int ii = _dirty . size ( ) - 1 ; ii >= 0 ; ii -- ) { Rectangle mr = _dirty . remove ( ii ) ; for ( int jj = ii - 1 ; jj >= 0 ; jj -- ) { Rectangle r = _dirty . get ( jj ) ; if ( mr . intersects ( r ) ) { _dirty . remove ( jj ) ; ii -- ; mr . add ( r ) ; } } merged . add ( mr ) ; } return merged . toArray ( new Rectangle [ merged . size ( ) ] ) ; } | Merges all outstanding dirty regions into a single list of rectangles and returns that to the caller . Internally the list of accumulated dirty regions is cleared out and prepared for the next frame . |
14,857 | public List < Any2 < Integer , String > > getArguments ( ) { final List < Any2 < Integer , String > > result = new ArrayList < > ( ) ; elements_ . forEach ( elem -> elem . keys ( result :: add ) ) ; return result ; } | Retrieve the variables used to render this string . |
14,858 | public boolean hasConstraint ( int tileIdx , String constraint ) { return ( _bits == null || _bits [ tileIdx ] . constraints == null ) ? false : ListUtil . contains ( _bits [ tileIdx ] . constraints , constraint ) ; } | Checks whether the tile at the specified index has the given constraint . |
14,859 | public static TrimmedObjectTileSet trimObjectTileSet ( ObjectTileSet source , OutputStream destImage ) throws IOException { return trimObjectTileSet ( source , destImage , FastImageIO . FILE_SUFFIX ) ; } | Convenience function to trim the tile set to a file using FastImageIO . |
14,860 | public int renderCompareTo ( AbstractMedia other ) { int result = Ints . compare ( _renderOrder , other . _renderOrder ) ; return ( result != 0 ) ? result : naturalCompareTo ( other ) ; } | Compares this media to the specified media by render order . |
14,861 | public void queueNotification ( ObserverList . ObserverOp < Object > amop ) { if ( _observers != null ) { if ( _mgr != null ) { _mgr . queueNotification ( _observers , amop ) ; } else { log . warning ( "Have no manager, dropping notification" , "media" , this , "op" , amop ) ; } } } | Queues the supplied notification up to be dispatched to this abstract media s observers . |
14,862 | protected void addObserver ( Object obs ) { if ( _observers == null ) { _observers = ObserverList . newFastUnsafe ( ) ; } _observers . add ( obs ) ; } | Add the specified observer to this media element . |
14,863 | private void dispatchEvent ( XoaEvent event ) { LOG . entering ( CLASS_NAME , "dispatchEvent" , event ) ; try { Integer handlerId = event . getHandlerId ( ) ; XoaEventKind eventKind = event . getEvent ( ) ; if ( LOG . isLoggable ( Level . FINEST ) ) { LOG . finest ( "XOA + handlerId + " event: " + eventKind . name ( ) ) ; } BridgeDelegate handler = xoaObjectMap . get ( handlerId ) ; if ( handler == null ) { if ( LOG . isLoggable ( Level . FINEST ) ) { LOG . finest ( "No handler for handler id: " + handlerId ) ; } return ; } synchronized ( handler ) { Object [ ] args = { handlerId , eventKind . toString ( ) , event . getParams ( ) } ; firePropertyChange ( XOP_MESSAGE , null , args ) ; } } catch ( Exception e ) { LOG . log ( Level . FINE , "While dispatching event: " + e . getMessage ( ) , e ) ; throw new IllegalStateException ( "Unable to dispatch an event from the cross origin proxy" , e ) ; } } | Dispatch an event to Source Origin |
14,864 | public void setVariance ( int dx , int dy ) { if ( ( dx < 0 ) || ( dy < 0 ) || ( ( dx == 0 ) && ( dy == 0 ) ) ) { throw new IllegalArgumentException ( "Variance values must be positive, and at least one must be non-zero." ) ; } else { _dx = dx ; _dy = dy ; } } | Set the variance of bobblin in each direction . |
14,865 | protected boolean updatePositionTo ( Pathable pable , int x , int y ) { if ( ( pable . getX ( ) == x ) && ( pable . getY ( ) == y ) ) { return false ; } else { pable . setLocation ( x , y ) ; return true ; } } | Update the position of the pathable or return false if it s already there . |
14,866 | public static DisplayMode getDisplayMode ( GraphicsDevice gd , int width , int height , int desiredDepth , int minimumDepth ) { DisplayMode [ ] modes = gd . getDisplayModes ( ) ; final int ddepth = desiredDepth ; Comparator < DisplayMode > mcomp = new Comparator < DisplayMode > ( ) { public int compare ( DisplayMode m1 , DisplayMode m2 ) { int bd1 = m1 . getBitDepth ( ) , bd2 = m2 . getBitDepth ( ) ; int rr1 = m1 . getRefreshRate ( ) , rr2 = m2 . getRefreshRate ( ) ; if ( bd1 == ddepth && bd2 != ddepth ) { return - 1 ; } else if ( bd2 == ddepth && bd1 != ddepth ) { return 1 ; } if ( bd1 != bd2 ) { return bd2 - bd1 ; } return rr2 - rr1 ; } } ; TreeSet < DisplayMode > mset = new TreeSet < DisplayMode > ( mcomp ) ; for ( DisplayMode mode : modes ) { if ( mode . getWidth ( ) == width && mode . getHeight ( ) == height && mode . getBitDepth ( ) >= minimumDepth && mode . getRefreshRate ( ) <= 75 ) { mset . add ( mode ) ; } } return ( mset . size ( ) > 0 ) ? mset . first ( ) : null ; } | Gets a display mode that matches the specified parameters . The screen resolution must match the specified resolution exactly the specified desired depth will be used if it is available and if not the highest depth greater than or equal to the specified minimum depth is used . The highest refresh rate available for the desired mode is also used . |
14,867 | public static CharacterDescriptor getRandomDescriptor ( ComponentRepository crepo , String gender , String [ ] COMP_CLASSES , ColorPository cpos , String [ ] COLOR_CLASSES ) { ArrayList < ComponentClass > classes = Lists . newArrayList ( ) ; for ( String element : COMP_CLASSES ) { String cname = gender + "/" + element ; ComponentClass cclass = crepo . getComponentClass ( cname ) ; if ( cclass == null ) { log . warning ( "Missing definition for component class" , "class" , cname ) ; continue ; } Iterator < Integer > iter = crepo . enumerateComponentIds ( cclass ) ; if ( ! iter . hasNext ( ) ) { log . info ( "Skipping class for which we have no components" , "class" , cclass ) ; continue ; } classes . add ( cclass ) ; } int [ ] components = new int [ classes . size ( ) ] ; Colorization [ ] [ ] zations = new Colorization [ components . length ] [ ] ; for ( int ii = 0 ; ii < components . length ; ii ++ ) { ComponentClass cclass = classes . get ( ii ) ; ArrayList < Integer > choices = Lists . newArrayList ( ) ; Iterators . addAll ( choices , crepo . enumerateComponentIds ( cclass ) ) ; zations [ ii ] = new Colorization [ COLOR_CLASSES . length ] ; for ( int zz = 0 ; zz < COLOR_CLASSES . length ; zz ++ ) { zations [ ii ] [ zz ] = cpos . getRandomStartingColor ( COLOR_CLASSES [ zz ] ) . getColorization ( ) ; } if ( choices . size ( ) > 0 ) { int idx = RandomUtil . getInt ( choices . size ( ) ) ; components [ ii ] = choices . get ( idx ) . intValue ( ) ; } else { log . info ( "Have no components in class" , "class" , cclass ) ; } } return new CharacterDescriptor ( components , zations ) ; } | Returns a new character descriptor populated with a random set of components . |
14,868 | public CompletableFuture < NewFile > run ( ) { LOG . log ( Level . FINE , "starting optimized file creation for {0} files" , files . size ( ) ) ; CompletableFuture < NewFile > fileCreation = new CompletableFuture < > ( ) ; final List < TSData > fjpFiles = this . files ; TASK_POOL . execute ( ( ) -> createTmpFile ( fileCreation , destDir , fjpFiles , getCompression ( ) ) ) ; synchronized ( OUTSTANDING ) { OUTSTANDING . add ( fileCreation ) ; } this . files = new LinkedList < > ( ) ; return fileCreation ; } | Start creating the optimized file . This operation resets the state of the optimizer task so it can be re - used for subsequent invocations . |
14,869 | private static void createTmpFile ( CompletableFuture < NewFile > fileCreation , Path destDir , List < TSData > files , Compression compression ) { LOG . log ( Level . FINE , "starting temporary file creation..." ) ; try { Collections . sort ( files , Comparator . comparing ( TSData :: getBegin ) ) ; final FileChannel fd = FileUtil . createTempFile ( destDir , "monsoon-" , ".optimize-tmp" ) ; try { final DateTime begin ; try ( ToXdrTables output = new ToXdrTables ( ) ) { while ( ! files . isEmpty ( ) ) { TSData tsdata = files . remove ( 0 ) ; if ( fileCreation . isCancelled ( ) ) throw new IOException ( "aborted due to canceled execution" ) ; output . addAll ( tsdata ) ; } if ( fileCreation . isCancelled ( ) ) throw new IOException ( "aborted due to canceled execution" ) ; begin = output . build ( fd , compression ) ; } if ( fileCreation . isCancelled ( ) ) throw new IOException ( "aborted due to canceled execution" ) ; INSTALL_POOL . execute ( ( ) -> install ( fileCreation , destDir , fd , begin ) ) ; } catch ( Error | RuntimeException | IOException ex ) { try { fd . close ( ) ; } catch ( Error | RuntimeException | IOException ex1 ) { ex . addSuppressed ( ex1 ) ; } throw ex ; } } catch ( Error | RuntimeException | IOException ex ) { LOG . log ( Level . WARNING , "temporary file for optimization failure" , ex ) ; synchronized ( OUTSTANDING ) { OUTSTANDING . remove ( fileCreation ) ; } fileCreation . completeExceptionally ( ex ) ; } } | The fork - join task that creates a new file . This function creates a temporary file with the result contents then passes it on to the install thread which will put the final file in place . |
14,870 | private static void install ( CompletableFuture < NewFile > fileCreation , Path destDir , FileChannel tmpFile , DateTime begin ) { try { try { synchronized ( OUTSTANDING ) { OUTSTANDING . remove ( fileCreation ) ; } if ( fileCreation . isCancelled ( ) ) throw new IOException ( "Installation aborted, due to cancellation." ) ; final FileUtil . NamedFileChannel newFile = FileUtil . createNewFile ( destDir , prefixForTimestamp ( begin ) , ".optimized" ) ; try ( Releaseable < FileChannel > out = new Releaseable < > ( newFile . getFileChannel ( ) ) ) { final long fileSize = tmpFile . size ( ) ; LOG . log ( Level . INFO , "installing {0} ({1} MB)" , new Object [ ] { newFile . getFileName ( ) , fileSize / 1024.0 / 1024.0 } ) ; long offset = 0 ; while ( offset < fileSize ) offset += tmpFile . transferTo ( offset , fileSize - offset , out . get ( ) ) ; out . get ( ) . force ( true ) ; fileCreation . complete ( new NewFile ( newFile . getFileName ( ) , new ReadonlyTableFile ( new GCCloseable < > ( out . release ( ) ) ) ) ) ; } catch ( Error | RuntimeException | IOException | OncRpcException ex ) { try { Files . delete ( newFile . getFileName ( ) ) ; } catch ( Error | RuntimeException | IOException ex1 ) { ex . addSuppressed ( ex1 ) ; } throw ex ; } } finally { tmpFile . close ( ) ; } } catch ( Error | RuntimeException | IOException | OncRpcException ex ) { LOG . log ( Level . WARNING , "unable to install new file" , ex ) ; fileCreation . completeExceptionally ( ex ) ; } } | Installs the newly created file . This function runs on the install thread and essentially performs a copy - operation from the temporary file to the final file . |
14,871 | private static String prefixForTimestamp ( DateTime timestamp ) { return String . format ( "monsoon-%04d%02d%02d-%02d%02d" , timestamp . getYear ( ) , timestamp . getMonthOfYear ( ) , timestamp . getDayOfMonth ( ) , timestamp . getHourOfDay ( ) , timestamp . getMinuteOfHour ( ) ) ; } | Compute a prefix for a to - be - installed file . |
14,872 | public ErrorData getErrorData ( ) { return new ErrorData ( ( Throwable ) getRequest ( ) . getAttribute ( "javax.servlet.error.exception" ) , ( ( Integer ) getRequest ( ) . getAttribute ( "javax.servlet.error.status_code" ) ) . intValue ( ) , ( String ) getRequest ( ) . getAttribute ( "javax.servlet.error.request_uri" ) , ( String ) getRequest ( ) . getAttribute ( "javax.servlet.error.servlet_name" ) ) ; } | Provides convenient access to error information . |
14,873 | public static void storeLogs ( String sourceLogFileName , String destLogFileName ) throws Exception { String tmpdir = System . getProperty ( "java.io.tmpdir" ) ; if ( tmpdir == null || tmpdir == "null" ) { tmpdir = "/tmp" ; } File tmpLogFile = new File ( tmpdir + File . separator + sourceLogFileName ) ; File destFile = new File ( current_log_dir + File . separator + destLogFileName ) ; Files . copy ( tmpLogFile , destFile ) ; } | Stores the specified log for this test |
14,874 | protected void setSelectedComponent ( int idx ) { int cid = _components . get ( idx ) . intValue ( ) ; _model . setSelectedComponent ( _cclass , cid ) ; } | Sets the selected component in the builder model for the component class associated with this editor to the component at the given index in this editor s list of available components . |
14,875 | public boolean isFlowActive ( ) { Object val = this . getArgument ( "active" ) ; if ( val instanceof Integer ) { return ( ( Integer ) val ) . intValue ( ) == 1 ; } else { throw new IllegalStateException ( "ChannelEvent does not contain the 'active' argument" ) ; } } | Returns For flow events returns true if flow is active |
14,876 | static void writeTracker ( JSONWriter writer , Tracker tracker ) throws JSONException { writer . key ( "id" ) ; writer . value ( tracker . getId ( ) ) ; writer . key ( "name" ) ; writer . value ( tracker . getName ( ) ) ; } | Writes a tracker . |
14,877 | public static void addFull ( JSONWriter writer , String field , Date value ) throws JSONException { final SimpleDateFormat format = RedmineDateUtils . FULL_DATE_FORMAT . get ( ) ; JsonOutput . add ( writer , field , value , format ) ; } | Adds a value to a writer . |
14,878 | private Optional < Data < Input , Output > > match_ ( Input input ) { return Optional . ofNullable ( recent_ . get ( ) ) . filter ( ( Data < Input , Output > data ) -> equality_ . test ( data . getInput ( ) , input ) ) ; } | Try to match an input against the most recent calculation . |
14,879 | private Data < Input , Output > derive_ ( Input input ) { Data < Input , Output > result = new Data < > ( input , fn_ . apply ( input ) ) ; recent_ . set ( result ) ; return result ; } | Derive and remember a calculation . |
14,880 | public Output apply ( Input input ) { if ( input == null ) return fn_ . apply ( input ) ; return match_ ( input ) . orElseGet ( ( ) -> derive_ ( input ) ) . getOutput ( ) ; } | Functional implementation . |
14,881 | public void setWarning ( float warnPercent , ResultListener < TimerView > warner ) { _warned = false ; _warnPercent = warnPercent ; _warner = warner ; } | Setup a warning to trigger after the timer is warnPercent or more completed . If warner is non - null it will be called at that time . |
14,882 | public void start ( float startPercent , long duration , ResultListener < TimerView > finisher ) { if ( startPercent < 0.0f || startPercent >= 1.0f ) { throw new IllegalArgumentException ( "Invalid starting percent " + startPercent ) ; } if ( duration < 0 ) { throw new IllegalArgumentException ( "Invalid duration " + duration ) ; } stop ( ) ; _duration = duration ; changeComplete ( startPercent ) ; _start = Long . MIN_VALUE ; _finisher = finisher ; _warned = false ; _completed = false ; _running = true ; } | Start the timer running from the specified percentage complete to expire at the specified time . |
14,883 | public void unpause ( ) { if ( _lastUpdate == Long . MIN_VALUE || _start == Long . MIN_VALUE ) { return ; } _processUnpause = true ; _running = true ; } | Unpause the timer . |
14,884 | public void changeComplete ( float complete ) { _complete = complete ; _renderOffset = _renderComplete - _complete ; _renderOffsetTime = Long . MIN_VALUE ; } | Generate an unexpected change in the timer s completion and set up the necessary details to render interpolation from the old to new states |
14,885 | protected void invalidate ( ) { _invalidated = true ; _host . repaint ( _bounds . x , _bounds . y , _bounds . width , _bounds . height ) ; } | Invalidates this view s bounds via the host component . |
14,886 | public void checkFrameParticipation ( ) { boolean participate = _host . isShowing ( ) ; if ( participate && ! _participating ) { _fmgr . registerFrameParticipant ( this ) ; _participating = true ; } else if ( ! participate && _participating ) { _fmgr . removeFrameParticipant ( this ) ; _participating = false ; } } | Check that the frame knows about the timer . |
14,887 | public static int getTileHash ( int x , int y ) { long seed = ( ( ( x << 2 ) ^ y ) ^ MULTIPLIER ) & MASK ; long hash = ( seed * MULTIPLIER + ADDEND ) & MASK ; return ( int ) ( hash >>> 30 ) ; } | Compute some hash value for randomizing tileset picks based on x and y coordinates . |
14,888 | public static ObjectSequence < TimeSeriesCollection > fixSequence ( ObjectSequence < TimeSeriesCollection > seq ) { seq = seq . sort ( ) ; if ( ! seq . isDistinct ( ) && ! seq . isEmpty ( ) ) { List < ObjectSequence < TimeSeriesCollection > > toConcat = new ArrayList < > ( ) ; int lastGoodIdx = 0 ; int curIdx = 0 ; while ( curIdx < seq . size ( ) ) { final TimeSeriesCollection curElem = seq . get ( curIdx ) ; int nextIdx = curIdx + 1 ; while ( nextIdx < seq . size ( ) && curElem . getTimestamp ( ) . equals ( seq . get ( nextIdx ) . getTimestamp ( ) ) ) { ++ nextIdx ; } if ( curIdx + 1 < nextIdx ) { toConcat . add ( seq . limit ( curIdx ) . skip ( lastGoodIdx ) ) ; TimeSeriesCollection replacement = new LazyMergedTSC ( seq . limit ( nextIdx ) . skip ( curIdx ) ) ; toConcat . add ( ObjectSequence . of ( true , true , true , replacement ) ) ; lastGoodIdx = curIdx = nextIdx ; } else { ++ curIdx ; } } if ( lastGoodIdx < curIdx ) toConcat . add ( seq . skip ( lastGoodIdx ) ) ; seq = ObjectSequence . concat ( toConcat , true , true ) ; } return seq ; } | Fix a sequence to contain only distinct sorted elements . |
14,889 | public static ObjectSequence < TimeSeriesCollection > mergeSequences ( ObjectSequence < TimeSeriesCollection > ... tsSeq ) { if ( tsSeq . length == 0 ) return ObjectSequence . empty ( ) ; if ( tsSeq . length == 1 ) return tsSeq [ 0 ] ; final Queue < ObjectSequence < TimeSeriesCollection > > seq = new PriorityQueue < > ( Comparator . comparing ( ObjectSequence :: first ) ) ; seq . addAll ( Arrays . stream ( tsSeq ) . filter ( s -> ! s . isEmpty ( ) ) . collect ( Collectors . toList ( ) ) ) ; if ( seq . isEmpty ( ) ) return ObjectSequence . empty ( ) ; if ( seq . size ( ) == 1 ) return seq . element ( ) ; final List < ObjectSequence < TimeSeriesCollection > > output = new ArrayList < > ( tsSeq . length ) ; while ( ! seq . isEmpty ( ) ) { final ObjectSequence < TimeSeriesCollection > head = seq . remove ( ) ; if ( seq . isEmpty ( ) ) { output . add ( head ) ; continue ; } if ( head . last ( ) . compareTo ( seq . element ( ) . first ( ) ) < 0 ) { output . add ( head ) ; continue ; } final List < ObjectSequence < TimeSeriesCollection > > toMerge = new ArrayList < > ( ) ; final int headProblemStart = head . equalRange ( tsc -> tsc . compareTo ( seq . element ( ) . first ( ) ) ) . getBegin ( ) ; output . add ( head . limit ( headProblemStart ) ) ; toMerge . add ( head . skip ( headProblemStart ) ) ; final TimeSeriesCollection headLast = head . last ( ) ; while ( ! seq . isEmpty ( ) && seq . element ( ) . first ( ) . compareTo ( headLast ) <= 0 ) { final ObjectSequence < TimeSeriesCollection > succ = seq . remove ( ) ; TimeSeriesCollection succFirst = succ . first ( ) ; System . err . println ( "succ.first: " + succ . first ( ) + ", head.last: " + headLast ) ; final int succProblemEnd = succ . equalRange ( tsc -> tsc . compareTo ( headLast ) ) . getEnd ( ) ; assert succProblemEnd > 0 ; toMerge . add ( succ . limit ( succProblemEnd ) ) ; ObjectSequence < TimeSeriesCollection > succNoProblem = succ . skip ( succProblemEnd ) ; if ( ! succNoProblem . isEmpty ( ) ) seq . add ( succNoProblem ) ; } assert ( toMerge . size ( ) > 1 ) ; output . add ( fixSequence ( ObjectSequence . concat ( toMerge , false , false ) ) ) ; } return ObjectSequence . concat ( output , true , true ) ; } | Given zero or more sequences that are all sorted and distinct merge them together . |
14,890 | public void queueResource ( String bundle , String resource , boolean loop ) { try { queueURL ( new URL ( "resource://" + bundle + "/" + resource ) , loop ) ; } catch ( MalformedURLException e ) { log . warning ( "Invalid resource url." , "resource" , resource , e ) ; } } | Adds a resource to the queue of files to play . |
14,891 | public static boolean isMappedIPv4Address ( Inet6Address ip ) { byte bytes [ ] = ip . getAddress ( ) ; return ( ( bytes [ 0 ] == 0x00 ) && ( bytes [ 1 ] == 0x00 ) && ( bytes [ 2 ] == 0x00 ) && ( bytes [ 3 ] == 0x00 ) && ( bytes [ 4 ] == 0x00 ) && ( bytes [ 5 ] == 0x00 ) && ( bytes [ 6 ] == 0x00 ) && ( bytes [ 7 ] == 0x00 ) && ( bytes [ 8 ] == 0x00 ) && ( bytes [ 9 ] == 0x00 ) && ( bytes [ 10 ] == ( byte ) 0xff ) && ( bytes [ 11 ] == ( byte ) 0xff ) ) ; } | Evaluates whether the argument is an IPv6 mapped address . |
14,892 | public static Inet4Address getMappedIPv4Address ( Inet6Address ip ) { if ( ! isMappedIPv4Address ( ip ) ) throw new IllegalArgumentException ( String . format ( "Address '%s' is not IPv4-mapped." , toAddrString ( ip ) ) ) ; return getInet4Address ( copyOfRange ( ip . getAddress ( ) , 12 , 16 ) ) ; } | Returns the IPv4 address embedded in an IPv4 mapped address . |
14,893 | protected void checkIdle ( ) { long now = getTimeStamp ( ) ; switch ( _state ) { case ACTIVE : if ( now >= ( _lastEvent + _toIdleTime ) ) { log . info ( "User idle for " + ( now - _lastEvent ) + "ms." ) ; _state = IDLE ; idledOut ( ) ; } break ; case IDLE : if ( now >= ( _lastEvent + _toIdleTime + _toAbandonTime ) ) { log . info ( "User idle for " + ( now - _lastEvent ) + "ms. " + "Abandoning ship." ) ; _state = ABANDONED ; abandonedShip ( ) ; } break ; } } | Checks the last user event time and posts a command to idle them out if they ve been inactive for too long or log them out if they ve been idle for too long . |
14,894 | private void run_implementation_ ( PushProcessor p ) throws Exception { final Map < GroupName , Alert > alerts = registry_ . getCollectionAlerts ( ) ; final TimeSeriesCollection tsdata = registry_ . getCollectionData ( ) ; p . accept ( tsdata , unmodifiableMap ( alerts ) , registry_ . getFailedCollections ( ) ) ; } | Run the implementation of uploading the values and alerts . |
14,895 | public final void run ( ) { try { registry_ . updateCollection ( ) ; final long t0 = System . nanoTime ( ) ; processors_ . forEach ( p -> { try { run_implementation_ ( p ) ; } catch ( Exception ex ) { logger . log ( Level . SEVERE , p . getClass ( ) . getName ( ) + " failed to run properly, some or all metrics may be missed this cycle" , ex ) ; } } ) ; final long t_processor = System . nanoTime ( ) ; registry_ . updateProcessorDuration ( Duration . millis ( TimeUnit . NANOSECONDS . toMillis ( t_processor - t0 ) ) ) ; } catch ( Throwable t ) { logger . log ( Level . SEVERE , "failed to perform collection" , t ) ; } } | Run the collection cycle . |
14,896 | public void resolveBlock ( SceneBlock block , boolean hipri ) { log . debug ( "Queueing block for resolution" , "block" , block , "hipri" , hipri ) ; if ( hipri ) { _queue . prepend ( block ) ; } else { _queue . append ( block ) ; } } | Queues up a scene block for resolution . |
14,897 | public static boolean openNotification ( ) throws Exception { boolean success = false ; int apiLevel = Client . getInstance ( ) . mapField ( "android.os.Build$VERSION" , "SDK_INT" ) . getInt ( 0 ) ; if ( apiLevel >= 18 ) { success = Client . getInstance ( ) . map ( Constants . UIAUTOMATOR_UIDEVICE , "openNotification" ) . getBoolean ( 0 ) ; } else { int displayHeight = getDisplayHeight ( ) ; int pullTo = displayHeight - ( int ) ( ( double ) displayHeight * .1 ) ; Client . getInstance ( ) . map ( Constants . UIAUTOMATOR_UIDEVICE , "swipe" , 10 , 0 , 10 , pullTo , 100 ) ; success = true ; } return success ; } | Open notification shade |
14,898 | public static boolean click ( int x , int y ) throws Exception { return Client . getInstance ( ) . map ( Constants . UIAUTOMATOR_UIDEVICE , "click" , x , y ) . getBoolean ( 0 ) ; } | Click at x y position |
14,899 | public void moveAndFadeIn ( Path path , long pathDuration , float fadePortion ) { move ( path ) ; setAlpha ( 0.0f ) ; _fadeInDuration = ( long ) ( pathDuration * fadePortion ) ; } | Puts this sprite on the specified path and fades it in over the specified duration . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.