idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
24,000 | private void onParticipantAdded ( ParticipantAddedEvent event ) { handler . post ( ( ) -> listener . onParticipantAdded ( event ) ) ; log ( "Event published " + event . toString ( ) ) ; } | Dispatch participant added to a conversation event . | 47 | 8 |
24,001 | private void onParticipantUpdated ( ParticipantUpdatedEvent event ) { handler . post ( ( ) -> listener . onParticipantUpdated ( event ) ) ; log ( "Event published " + event . toString ( ) ) ; } | Dispatch participant updated event . | 47 | 5 |
24,002 | private void onParticipantRemoved ( ParticipantRemovedEvent event ) { handler . post ( ( ) -> listener . onParticipantRemoved ( event ) ) ; log ( "Event published " + event . toString ( ) ) ; } | Dispatch participant removed event . | 47 | 5 |
24,003 | private void onConversationUpdated ( ConversationUpdateEvent event ) { handler . post ( ( ) -> listener . onConversationUpdated ( event ) ) ; log ( "Event published " + event . toString ( ) ) ; } | Dispatch conversation updated event . | 49 | 5 |
24,004 | private void onConversationDeleted ( ConversationDeleteEvent event ) { handler . post ( ( ) -> listener . onConversationDeleted ( event ) ) ; log ( "Event published " + event . toString ( ) ) ; } | Dispatch conversation deleted event . | 51 | 5 |
24,005 | private void onConversationUndeleted ( ConversationUndeleteEvent event ) { handler . post ( ( ) -> listener . onConversationUndeleted ( event ) ) ; log ( "Event published " + event . toString ( ) ) ; } | Dispatch conversation restored event . | 55 | 5 |
24,006 | protected String getToken ( ) { return dataMgr . getSessionDAO ( ) . session ( ) != null ? dataMgr . getSessionDAO ( ) . session ( ) . getAccessToken ( ) : null ; } | Gets session access token . | 49 | 6 |
24,007 | public void init ( @ NonNull final Context context , @ Nullable final String suffix , @ NonNull final Logger log ) { deviceDAO = new DeviceDAO ( context , suffix ) ; onetimeDeviceSetup ( context ) ; logInfo ( log ) ; sessionDAO = new SessionDAO ( context , suffix ) ; } | Initialise Session Manager . | 70 | 5 |
24,008 | private void logInfo ( @ NonNull final Logger log ) { log . i ( "App ver. = " + deviceDAO . device ( ) . getAppVer ( ) ) ; log . i ( "Comapi device ID = " + deviceDAO . device ( ) . getDeviceId ( ) ) ; log . d ( "Firebase ID = " + deviceDAO . device ( ) . getInstanceId ( ) ) ; } | Log basic information about initialisation environment . | 94 | 8 |
24,009 | private static < T > Stream < T > enumerationAsStream ( Enumeration < ? extends T > e ) { Iterator < T > iterator = new Iterator < T > ( ) { @ Override public T next ( ) { return e . nextElement ( ) ; } @ Override public boolean hasNext ( ) { return e . hasMoreElements ( ) ; } } ; return StreamSupport . stream ( Spliterators . spliteratorUnknownSize ( iterator , Spliterator . ORDERED ) , false ) ; } | Returns a new stream that has the same contents as the given enumeration | 110 | 14 |
24,010 | public int getRowWidth ( ) { int overallWidth = 0 ; for ( int i = 0 ; i < data . length ; i ++ ) { overallWidth += getTable ( ) . getColumnWidth ( i ) ; } return overallWidth ; } | Returns the row s total width . | 52 | 7 |
24,011 | public static byte [ ] shuffle ( byte [ ] input ) { for ( int i = 0 ; i < input . length ; i ++ ) { int i2 = input [ i ] ; if ( i2 < 0 ) i2 = 127 + Math . abs ( i2 ) ; input [ i ] = shuffle [ i2 ] ; //result of more shuffles could just be mapped to the first // i2 = input[i]; // if(i2 < 0) // i2 = 127 + Math.abs(i2); // input[i] = (byte) shuffle2[i2]; // i2 = input[i]; // if(i2 < 0) // i2 = 127 + Math.abs(i2); // input[i] = (byte) shuffle3[i2]; } return input ; } | a minimal perfect hash function for a 32 byte input | 176 | 10 |
24,012 | public static byte [ ] getSHA256 ( byte [ ] input , boolean asSingleton ) { if ( SHA256_INSTANCE == null ) { if ( asSingleton ) { try { SHA256_INSTANCE = MessageDigest . getInstance ( "SHA-256" ) ; } catch ( NoSuchAlgorithmException e ) { e . printStackTrace ( ) ; } } else { return getHash ( "SHA-256" , input ) ; } } return SHA256_INSTANCE . digest ( input ) ; } | Get the SHA256 Hash of input | 112 | 7 |
24,013 | SocketInterface createSocket ( @ NonNull final String token , @ NonNull final WeakReference < SocketStateListener > stateListenerWeakReference ) { WebSocket socket = null ; WebSocketFactory factory = new WebSocketFactory ( ) ; // Configure proxy if provided if ( proxyAddress != null ) { ProxySettings settings = factory . getProxySettings ( ) ; settings . setServer ( proxyAddress ) ; } try { socket = factory . createSocket ( uri , TIMEOUT ) ; } catch ( IOException e ) { log . f ( "Creating socket failed" , e ) ; } if ( socket != null ) { String header = AuthManager . AUTH_PREFIX + token ; socket . addHeader ( "Authorization" , header ) ; socket . addListener ( createWebSocketAdapter ( stateListenerWeakReference ) ) ; socket . setPingInterval ( PING_INTERVAL ) ; return new SocketWrapperImpl ( socket ) ; } return null ; } | Creates and configures web socket instance . | 201 | 9 |
24,014 | protected WebSocketAdapter createWebSocketAdapter ( @ NonNull final WeakReference < SocketStateListener > stateListenerWeakReference ) { return new WebSocketAdapter ( ) { @ Override public void onConnected ( WebSocket websocket , Map < String , List < String > > headers ) throws Exception { super . onConnected ( websocket , headers ) ; final SocketStateListener stateListener = stateListenerWeakReference . get ( ) ; if ( stateListener != null ) { stateListener . onConnected ( ) ; } } @ Override public void onConnectError ( WebSocket websocket , WebSocketException exception ) throws Exception { super . onConnectError ( websocket , exception ) ; final SocketStateListener stateListener = stateListenerWeakReference . get ( ) ; if ( stateListener != null ) { stateListener . onError ( uri . getRawPath ( ) , proxyAddress , exception ) ; } } @ Override public void onDisconnected ( WebSocket websocket , WebSocketFrame serverCloseFrame , WebSocketFrame clientCloseFrame , boolean closedByServer ) throws Exception { super . onDisconnected ( websocket , serverCloseFrame , clientCloseFrame , closedByServer ) ; final SocketStateListener stateListener = stateListenerWeakReference . get ( ) ; if ( stateListener != null ) { stateListener . onDisconnected ( ) ; } } @ Override public void onTextMessage ( WebSocket websocket , String text ) throws Exception { super . onTextMessage ( websocket , text ) ; log . d ( "Socket message received = " + text ) ; messageListener . onMessage ( text ) ; } @ Override public void onBinaryMessage ( WebSocket websocket , byte [ ] binary ) throws Exception { super . onBinaryMessage ( websocket , binary ) ; log . d ( "Socket binary message received." ) ; } } ; } | Create adapter for websocket library events . | 391 | 8 |
24,015 | public static int getNumberOfAnnotatedRuns ( final Method meth ) { if ( ! isBenchmarkable ( meth ) ) { throw new IllegalArgumentException ( "Method " + meth + " must be a benchmarkable method." ) ; } final Bench benchAnno = meth . getAnnotation ( Bench . class ) ; final BenchClass benchClassAnno = meth . getDeclaringClass ( ) . getAnnotation ( BenchClass . class ) ; int returnVal ; if ( benchAnno == null ) { returnVal = benchClassAnno . runs ( ) ; } else { returnVal = benchAnno . runs ( ) ; // use runs from @BenchClass if none is set on method (issue #4) if ( ( returnVal == Bench . NONE_RUN ) && ( benchClassAnno != null ) ) { returnVal = benchClassAnno . runs ( ) ; } } return returnVal ; } | Getting the number of runs corresponding to a given method . The method MUST be a benchmarkable method otherwise an IllegalStateException exception arises . The number of runs of an annotated method is more powerful than the number of runs as denoted by the benchclass annotation . | 198 | 53 |
24,016 | public static Method findAndCheckAnyMethodByAnnotation ( final Class < ? > clazz , final Class < ? extends Annotation > anno ) throws PerfidixMethodCheckException { // needed variables, one for check for duplicates Method anyMethod = null ; // Scanning all methods final Method [ ] possAnnoMethods = clazz . getDeclaredMethods ( ) ; for ( final Method meth : possAnnoMethods ) { if ( meth . getAnnotation ( anno ) != null ) { // Check if there are multiple annotated methods, throwing // IllegalAccessException otherwise. if ( anyMethod == null ) { // Check if method is valid (no param, no returnval, // etc.), throwing IllegalAccessException otherwise. if ( isReflectedExecutable ( meth , anno ) ) { anyMethod = meth ; } else { throw new PerfidixMethodCheckException ( new IllegalAccessException ( anno . toString ( ) + "-annotated method " + meth + " is not executable." ) , meth , anno ) ; } } else { throw new PerfidixMethodCheckException ( new IllegalAccessException ( "Please use only one " + anno . toString ( ) + "-annotation in one class." ) , meth , anno ) ; } } } return anyMethod ; } | This class finds any method with a given annotation . The method is allowed to occur only once in the class and should match the requirements for Perfidix for an execution by reflection . | 279 | 37 |
24,017 | public static boolean isBenchmarkable ( final Method meth ) { boolean returnVal = true ; // Check if bench-anno is given. For testing purposes against // before/after annos final Bench benchAnno = meth . getAnnotation ( Bench . class ) ; // if method is annotated with SkipBench, the method is never // benchmarkable. final SkipBench skipBenchAnno = meth . getAnnotation ( SkipBench . class ) ; if ( skipBenchAnno != null ) { returnVal = false ; } // Check if method is defined as beforeClass, beforeFirstRun, // beforeEachRun, afterEachRun, afterLastRun, afterClass. A method can // either be a before/after class or afterwards be benchmarkable through // the BenchClass annotation. final BeforeBenchClass beforeClass = meth . getAnnotation ( BeforeBenchClass . class ) ; if ( beforeClass != null && benchAnno == null ) { returnVal = false ; } final BeforeFirstRun beforeFirstRun = meth . getAnnotation ( BeforeFirstRun . class ) ; if ( beforeFirstRun != null && benchAnno == null ) { returnVal = false ; } final BeforeEachRun beforeEachRun = meth . getAnnotation ( BeforeEachRun . class ) ; if ( beforeEachRun != null && benchAnno == null ) { returnVal = false ; } final AfterEachRun afterEachRun = meth . getAnnotation ( AfterEachRun . class ) ; if ( afterEachRun != null && benchAnno == null ) { returnVal = false ; } final AfterLastRun afterLastRun = meth . getAnnotation ( AfterLastRun . class ) ; if ( afterLastRun != null && benchAnno == null ) { returnVal = false ; } final AfterBenchClass afterClass = meth . getAnnotation ( AfterBenchClass . class ) ; if ( afterClass != null && benchAnno == null ) { returnVal = false ; } // if method is not annotated with Bench and class is not annotated with // BenchClass, the method is never benchmarkable. final BenchClass classBenchAnno = meth . getDeclaringClass ( ) . getAnnotation ( BenchClass . class ) ; if ( benchAnno == null && classBenchAnno == null ) { returnVal = false ; } // check if method is executable for perfidix purposes. if ( ! isReflectedExecutable ( meth , Bench . class ) ) { returnVal = false ; } return returnVal ; } | This method should act as a check to guarantee that only specific Benchmarkables are used for benching . | 527 | 21 |
24,018 | public static boolean isReflectedExecutable ( final Method meth , final Class < ? extends Annotation > anno ) { boolean returnVal = true ; // Check if DataProvider is valid if set. if ( anno . equals ( DataProvider . class ) && ! meth . getReturnType ( ) . isAssignableFrom ( Object [ ] [ ] . class ) ) { returnVal = false ; } // for all other methods, the return type must be void if ( ! anno . equals ( DataProvider . class ) && ! meth . getGenericReturnType ( ) . equals ( Void . TYPE ) ) { returnVal = false ; } // if method is static, the method is not benchmarkable if ( ! ( anno . equals ( BeforeBenchClass . class ) ) && Modifier . isStatic ( meth . getModifiers ( ) ) ) { returnVal = false ; } // if method is not public, the method is not benchmarkable if ( ! Modifier . isPublic ( meth . getModifiers ( ) ) ) { returnVal = false ; } return returnVal ; } | Checks if this method is executable via reflection for perfidix purposes . That means that the method has no parameters ( except for no return - value is non - static is public and throws no exceptions . | 229 | 41 |
24,019 | private Method findDataProvider ( ) throws PerfidixMethodCheckException { final Bench benchAnno = getMethodToBench ( ) . getAnnotation ( Bench . class ) ; Method dataProvider = null ; if ( benchAnno != null && ! benchAnno . dataProvider ( ) . equals ( "" ) ) { try { // Getting the String name for the dataProvider final String dataProviderIdentifier = benchAnno . dataProvider ( ) ; // Check if there is a Dataprovider with the name as identifier for ( final Method eachMeth : getMethodToBench ( ) . getDeclaringClass ( ) . getMethods ( ) ) { DataProvider anno = eachMeth . getAnnotation ( DataProvider . class ) ; if ( anno != null && anno . name ( ) . equals ( dataProviderIdentifier ) ) { if ( dataProvider == null ) { dataProvider = eachMeth ; } else { throw new PerfidixMethodCheckException ( new RuntimeException ( "Only one Dataprovider allowed, but found " + dataProvider + " and " + eachMeth ) , eachMeth , DataProvider . class ) ; } } } // if not, try to find a method with the name if ( dataProvider == null ) { dataProvider = getMethodToBench ( ) . getDeclaringClass ( ) . getDeclaredMethod ( dataProviderIdentifier ) ; } // perform the checks same as testng: two dimensional array for // return val, parameter is mapping of // class, array of instances. // checking return types of dataprovider method final Class < ? > returnType = dataProvider . getReturnType ( ) ; // final Class<?>[] parameters = meth.getParameterTypes(); if ( Object [ ] [ ] . class . isAssignableFrom ( returnType ) ) { // checking input types of bench method against the return // types of the parameter // Class<Object[][]> castedReturnType = (Class<Object[][]>) // returnType; // TODO implement check } } catch ( NoSuchMethodException | SecurityException e ) { // no data provider method, will be returned as false anyhow } } return dataProvider ; } | This method checks whether a method uses a data provider for dynamic input | 468 | 13 |
24,020 | public static void setDividerLocation ( final JSplitPane splitPane , final double location ) { SwingUtilities . invokeLater ( new Runnable ( ) { @ Override public void run ( ) { splitPane . setDividerLocation ( location ) ; splitPane . validate ( ) ; } } ) ; } | Set the location of the the given split pane to the given value later on the EDT and validate the split pane | 70 | 22 |
24,021 | private SessionData loadSession ( ) { synchronized ( sharedLock ) { SharedPreferences sharedPreferences = getSharedPreferences ( ) ; String id = sharedPreferences . getString ( KEY_PROFILE_ID , null ) ; if ( ! TextUtils . isEmpty ( id ) ) { sharedLock . notifyAll ( ) ; return new SessionData ( ) . setProfileId ( id ) . setSessionId ( sharedPreferences . getString ( KEY_SESSION_ID , null ) ) . setAccessToken ( sharedPreferences . getString ( KEY_ACCESS_TOKEN , null ) ) . setExpiresOn ( sharedPreferences . getLong ( KEY_EXPIRES_ON , 0 ) ) ; } sharedLock . notifyAll ( ) ; } return null ; } | Loads active session details from internal storage . | 168 | 9 |
24,022 | public String clearSession ( ) { synchronized ( sharedLock ) { SessionData session = loadSession ( ) ; String id = session != null ? session . getSessionId ( ) : null ; clearAll ( ) ; sharedLock . notifyAll ( ) ; return id ; } } | Deletes currently saved session . | 57 | 6 |
24,023 | public boolean startSession ( ) { synchronized ( sharedLock ) { SessionData session = loadSession ( ) ; if ( isSessionActive ( session ) ) { sharedLock . notifyAll ( ) ; return false ; } else { clearAll ( ) ; } sharedLock . notifyAll ( ) ; } return true ; } | Creates session if no session is active . | 65 | 9 |
24,024 | public boolean updateSessionDetails ( final SessionData session ) { synchronized ( sharedLock ) { if ( session != null ) { SharedPreferences . Editor editor = getSharedPreferences ( ) . edit ( ) ; editor . putString ( KEY_PROFILE_ID , session . getProfileId ( ) ) ; editor . putString ( KEY_SESSION_ID , session . getSessionId ( ) ) ; editor . putString ( KEY_ACCESS_TOKEN , session . getAccessToken ( ) ) ; editor . putLong ( KEY_EXPIRES_ON , session . getExpiresOn ( ) ) ; boolean isUpdated = editor . commit ( ) ; sharedLock . notifyAll ( ) ; return isUpdated ; } sharedLock . notifyAll ( ) ; } return false ; } | Updates session details obtained frm the services . | 167 | 10 |
24,025 | public static Object fromJSON ( String jsonString ) { List < Token > tokens = Derulo . toTokens ( jsonString ) ; return fromJSON ( tokens ) ; } | Get a java object from a JSON value | 35 | 8 |
24,026 | final void add ( final int e ) { if ( size == list . length ) list = Arrays . copyOf ( list , newSize ( ) ) ; list [ size ++ ] = e ; } | Adds an entry to the array . | 42 | 7 |
24,027 | public final boolean contains ( final int e ) { for ( int i = 0 ; i < size ; ++ i ) if ( list [ i ] == e ) return true ; return false ; } | Checks if the specified element is found in the list . | 40 | 12 |
24,028 | public final void insert ( final int i , final int [ ] e ) { final int l = e . length ; if ( l == 0 ) return ; if ( size + l > list . length ) list = Arrays . copyOf ( list , newSize ( size + l ) ) ; Array . move ( list , i , l , size - i ) ; System . arraycopy ( e , 0 , list , i , l ) ; size += l ; } | Inserts elements at the specified index position . | 97 | 9 |
24,029 | public static void expandAllFixedHeight ( JTree tree ) { // Determine a suitable row height for the tree, based on the // size of the component that is used for rendering the root TreeCellRenderer cellRenderer = tree . getCellRenderer ( ) ; Component treeCellRendererComponent = cellRenderer . getTreeCellRendererComponent ( tree , tree . getModel ( ) . getRoot ( ) , false , false , false , 1 , false ) ; int rowHeight = treeCellRendererComponent . getPreferredSize ( ) . height + 2 ; tree . setRowHeight ( rowHeight ) ; // Temporarily remove all listeners that would otherwise // be flooded with TreeExpansionEvents List < TreeExpansionListener > expansionListeners = Arrays . asList ( tree . getTreeExpansionListeners ( ) ) ; for ( TreeExpansionListener expansionListener : expansionListeners ) { tree . removeTreeExpansionListener ( expansionListener ) ; } // Recursively expand all nodes of the tree TreePath rootPath = new TreePath ( tree . getModel ( ) . getRoot ( ) ) ; expandAllRecursively ( tree , rootPath ) ; // Restore the listeners that the tree originally had for ( TreeExpansionListener expansionListener : expansionListeners ) { tree . addTreeExpansionListener ( expansionListener ) ; } // Trigger an update for the TreeExpansionListeners tree . collapsePath ( rootPath ) ; tree . expandPath ( rootPath ) ; } | Expand all rows of the given tree assuming a fixed height for the rows . | 321 | 16 |
24,030 | private static void expandAllRecursively ( JTree tree , TreePath treePath ) { TreeModel model = tree . getModel ( ) ; Object lastPathComponent = treePath . getLastPathComponent ( ) ; int childCount = model . getChildCount ( lastPathComponent ) ; if ( childCount == 0 ) { return ; } tree . expandPath ( treePath ) ; for ( int i = 0 ; i < childCount ; i ++ ) { Object child = model . getChild ( lastPathComponent , i ) ; int grandChildCount = model . getChildCount ( child ) ; if ( grandChildCount > 0 ) { class LocalTreePath extends TreePath { private static final long serialVersionUID = 0 ; public LocalTreePath ( TreePath parent , Object lastPathComponent ) { super ( parent , lastPathComponent ) ; } } TreePath nextTreePath = new LocalTreePath ( treePath , child ) ; expandAllRecursively ( tree , nextTreePath ) ; } } } | Recursively expand all paths in the given tree starting with the given path | 211 | 15 |
24,031 | public static void collapseAll ( JTree tree , boolean omitRoot ) { int rows = tree . getRowCount ( ) ; int limit = ( omitRoot ? 1 : 0 ) ; for ( int i = rows - 1 ; i >= limit ; i -- ) { tree . collapseRow ( i ) ; } } | Collapse all rows of the given tree | 65 | 8 |
24,032 | private static int countNodes ( TreeModel treeModel , Object node ) { int sum = 1 ; int n = treeModel . getChildCount ( node ) ; for ( int i = 0 ; i < n ; i ++ ) { sum += countNodes ( treeModel , treeModel . getChild ( node , i ) ) ; } return sum ; } | Recursively count the number of nodes in the given tree model starting with the given node | 75 | 18 |
24,033 | public static List < Object > getChildren ( TreeModel treeModel , Object node ) { List < Object > children = new ArrayList < Object > ( ) ; int n = treeModel . getChildCount ( node ) ; for ( int i = 0 ; i < n ; i ++ ) { Object child = treeModel . getChild ( node , i ) ; children . add ( child ) ; } return children ; } | Returns the children of the given node in the given tree model | 87 | 12 |
24,034 | public static List < Object > getAllNodes ( TreeModel treeModel ) { List < Object > result = new ArrayList < Object > ( ) ; getAllDescendants ( treeModel , treeModel . getRoot ( ) , result ) ; result . add ( 0 , treeModel . getRoot ( ) ) ; return result ; } | Return all nodes of the given tree model | 70 | 8 |
24,035 | private static void getAllDescendants ( TreeModel treeModel , Object node , List < Object > result ) { if ( node == null ) { return ; } result . add ( node ) ; List < Object > children = getChildren ( treeModel , node ) ; for ( Object child : children ) { getAllDescendants ( treeModel , child , result ) ; } } | Compute all descendants of the given node in the given tree model | 78 | 13 |
24,036 | public static List < Object > getLeafNodes ( TreeModel treeModel , Object node ) { List < Object > leafNodes = new ArrayList < Object > ( ) ; getLeafNodes ( treeModel , node , leafNodes ) ; return leafNodes ; } | Returns a list containing all leaf nodes from the given tree model that are descendants of the given node . These are the nodes that have 0 children . | 60 | 29 |
24,037 | private static void getLeafNodes ( TreeModel treeModel , Object node , Collection < Object > leafNodes ) { if ( node == null ) { return ; } int childCount = treeModel . getChildCount ( node ) ; if ( childCount == 0 ) { leafNodes . add ( node ) ; } else { for ( int i = 0 ; i < childCount ; i ++ ) { Object child = treeModel . getChild ( node , i ) ; getLeafNodes ( treeModel , child , leafNodes ) ; } } } | Recursively collect all leaf nodes in the given tree model that are descendants of the given node . | 119 | 20 |
24,038 | public static TreePath createTreePathToRoot ( TreeModel treeModel , Object node ) { List < Object > nodes = new ArrayList < Object > ( ) ; nodes . add ( node ) ; Object current = node ; while ( true ) { Object parent = getParent ( treeModel , current ) ; if ( parent == null ) { break ; } nodes . add ( 0 , parent ) ; current = parent ; } TreePath treePath = new TreePath ( nodes . toArray ( ) ) ; return treePath ; } | Returns the tree path from the given node to the root in the given tree model | 109 | 16 |
24,039 | public static List < TreePath > computeExpandedPaths ( JTree tree ) { List < TreePath > treePaths = new ArrayList < TreePath > ( ) ; int rows = tree . getRowCount ( ) ; for ( int i = 0 ; i < rows ; i ++ ) { TreePath treePath = tree . getPathForRow ( i ) ; treePaths . add ( treePath ) ; } return treePaths ; } | Compute the list of all tree paths in the given tree that are currently expanded | 95 | 16 |
24,040 | public static TreePath translatePath ( TreeModel newTreeModel , TreePath oldPath ) { return translatePath ( newTreeModel , oldPath , Objects :: equals ) ; } | Translates one TreePath to a new TreeModel . This methods assumes DefaultMutableTreeNodes . | 36 | 22 |
24,041 | public static TreePath translatePath ( TreeModel newTreeModel , TreePath oldPath , BiPredicate < Object , Object > equality ) { Object newRoot = newTreeModel . getRoot ( ) ; List < Object > newPath = new ArrayList < Object > ( ) ; newPath . add ( newRoot ) ; Object newPreviousElement = newRoot ; for ( int i = 1 ; i < oldPath . getPathCount ( ) ; i ++ ) { Object oldElement = oldPath . getPathComponent ( i ) ; Object oldUserObject = getUserObjectFromTreeNode ( oldElement ) ; Object newElement = getChildWith ( newPreviousElement , oldUserObject , equality ) ; if ( newElement == null ) { return null ; } newPath . add ( newElement ) ; newPreviousElement = newElement ; } return new TreePath ( newPath . toArray ( ) ) ; } | Translates one TreePath to a new TreeModel . This methods assumes DefaultMutableTreeNodes and identifies the path based on the equality of user objects using the given equality predicate . | 190 | 38 |
24,042 | private static Object getChildWith ( Object node , Object userObject , BiPredicate < Object , Object > equality ) { DefaultMutableTreeNode treeNode = ( DefaultMutableTreeNode ) node ; for ( int j = 0 ; j < treeNode . getChildCount ( ) ; j ++ ) { TreeNode child = treeNode . getChildAt ( j ) ; Object childUserObject = getUserObjectFromTreeNode ( child ) ; if ( equality . test ( userObject , childUserObject ) ) { return child ; } } return null ; } | Returns the child of the given tree node that has a user object that is equal to the given one based on the given equality predicate . Assumes DefaultMutableTreeNodes . | 117 | 36 |
24,043 | public static int computeIndexInParent ( Object nodeObject ) { if ( nodeObject instanceof DefaultMutableTreeNode ) { DefaultMutableTreeNode node = ( DefaultMutableTreeNode ) nodeObject ; TreeNode parent = node . getParent ( ) ; if ( parent == null ) { return - 1 ; } int childCount = parent . getChildCount ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { TreeNode child = parent . getChildAt ( i ) ; if ( child == nodeObject ) { return i ; } } } return - 1 ; } | Computes the index that the given node has in its parent node . Returns - 1 if the given node does not have a parent or the node is not a DefaultMutableTreeNode . | 126 | 38 |
24,044 | private void layoutChild ( Component component , int cellX , int cellY , int cellSizeX , int cellSizeY ) { int maxAspectW = ( int ) ( cellSizeY * aspect ) ; int maxAspectH = ( int ) ( cellSizeX / aspect ) ; if ( maxAspectW > cellSizeX ) { int w = cellSizeX ; int h = maxAspectH ; int space = cellSizeY - h ; int offset = ( int ) ( alignment * space ) ; component . setBounds ( cellX , cellY + offset , w , h ) ; } else { int w = maxAspectW ; int h = cellSizeY ; int space = cellSizeX - w ; int offset = ( int ) ( alignment * space ) ; component . setBounds ( cellX + offset , cellY , w , h ) ; } } | Lay out the given child component inside its parent obeying the aspect ratio and alignment constraints of this layout . | 188 | 21 |
24,045 | private static double computeWastedSpace ( double maxSizeX , double maxSizeY , double aspect ) { int maxAspectX = ( int ) ( maxSizeY * aspect ) ; int maxAspectY = ( int ) ( maxSizeX / aspect ) ; if ( maxAspectX > maxSizeX ) { double sizeX = maxSizeX ; double sizeY = maxAspectY ; double waste = maxSizeY - sizeY ; return waste * sizeX ; } double sizeX = maxAspectX ; double sizeY = maxSizeY ; double waste = maxSizeX - sizeX ; return waste * sizeY ; } | Compute the wasted space that is implied by the specified layout | 136 | 12 |
24,046 | String formatMessage ( int msgLogLevel , String tag , String msg , Throwable exception ) { if ( exception != null ) { return DateHelper . getUTC ( System . currentTimeMillis ( ) ) + "/" + getLevelTag ( msgLogLevel ) + tag + ": " + msg + "\n" + getStackTrace ( exception ) + "\n" ; } else { return DateHelper . getUTC ( System . currentTimeMillis ( ) ) + "/" + getLevelTag ( msgLogLevel ) + tag + ": " + msg + "\n" ; } } | Format log data into a log entry String . | 126 | 9 |
24,047 | private String getStackTrace ( final Throwable exception ) { if ( exception != null ) { StringBuilder sb = new StringBuilder ( ) ; StackTraceElement [ ] stackTrace = exception . getStackTrace ( ) ; for ( StackTraceElement element : stackTrace ) { sb . append ( element . toString ( ) ) ; sb . append ( ' ' ) ; } if ( exception . getCause ( ) != null ) { StackTraceElement [ ] stackTraceCause = exception . getCause ( ) . getStackTrace ( ) ; for ( StackTraceElement element : stackTraceCause ) { sb . append ( element . toString ( ) ) ; sb . append ( ' ' ) ; } } return sb . toString ( ) ; } return null ; } | Gets stacktrace as a String . | 175 | 8 |
24,048 | private void doSearch ( ) { setSearchPanelVisible ( true ) ; String selectedText = textComponent . getSelectedText ( ) ; if ( selectedText != null ) { searchPanel . setQuery ( selectedText ) ; } searchPanel . requestFocusForTextField ( ) ; } | Called to initiate the search . Will show the search panel and set the currently selected text as the query | 61 | 21 |
24,049 | void setSearchPanelVisible ( boolean b ) { if ( ! searchPanelVisible && b ) { add ( searchPanel , BorderLayout . NORTH ) ; revalidate ( ) ; } else if ( searchPanelVisible && ! b ) { remove ( searchPanel ) ; revalidate ( ) ; } searchPanelVisible = b ; } | Set whether the search panel is currently visible | 74 | 8 |
24,050 | void doFindNext ( ) { String query = searchPanel . getQuery ( ) ; if ( query . isEmpty ( ) ) { return ; } String text = getDocumentText ( ) ; boolean ignoreCase = ! searchPanel . isCaseSensitive ( ) ; int caretPosition = textComponent . getCaretPosition ( ) ; int textLength = text . length ( ) ; int newCaretPosition = ( caretPosition + 1 ) % textLength ; Point match = JTextComponents . findNext ( text , query , newCaretPosition , ignoreCase ) ; if ( match == null ) { match = JTextComponents . findNext ( text , query , 0 , ignoreCase ) ; } handleMatch ( match ) ; } | Find the next appearance of the search panel query | 156 | 9 |
24,051 | private String getDocumentText ( ) { try { Document document = textComponent . getDocument ( ) ; String text = document . getText ( 0 , document . getLength ( ) ) ; return text ; } catch ( BadLocationException e ) { logger . warning ( e . toString ( ) ) ; return textComponent . getText ( ) ; } } | Return the text of the document of the text component | 74 | 10 |
24,052 | private void addHighlights ( Collection < ? extends Point > points , Color color ) { removeHighlights ( points ) ; Map < Point , Object > newHighlights = JTextComponents . addHighlights ( textComponent , points , color ) ; highlights . putAll ( newHighlights ) ; } | Add highlights with the given color to the text component for all the given points | 63 | 15 |
24,053 | private void removeHighlights ( Collection < ? extends Point > points ) { Set < Object > highlightsToRemove = new LinkedHashSet < Object > ( ) ; for ( Point point : points ) { Object oldHighlight = highlights . remove ( point ) ; if ( oldHighlight != null ) { highlightsToRemove . add ( oldHighlight ) ; } } JTextComponents . removeHighlights ( textComponent , highlightsToRemove ) ; } | Remove the highlights that are associated with the given points | 94 | 10 |
24,054 | public final Collection < Double > getResultSet ( final AbstractMeter meter ) { checkIfMeterExists ( meter ) ; return this . meterResults . get ( meter ) ; } | an array of all data items in the structure . | 39 | 10 |
24,055 | public final double squareSum ( final AbstractMeter meter ) { checkIfMeterExists ( meter ) ; final AbstractUnivariateStatistic sqrSum = new SumOfSquares ( ) ; final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection ( this . meterResults . get ( meter ) ) ; return sqrSum . evaluate ( doubleColl . toArray ( ) , 0 , doubleColl . toArray ( ) . length ) ; } | Computes the square sum of the elements . | 93 | 9 |
24,056 | public final double getStandardDeviation ( final AbstractMeter meter ) { checkIfMeterExists ( meter ) ; final AbstractUnivariateStatistic stdDev = new StandardDeviation ( ) ; final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection ( this . meterResults . get ( meter ) ) ; return stdDev . evaluate ( doubleColl . toArray ( ) , 0 , doubleColl . toArray ( ) . length ) ; } | Computes the standard deviation . | 92 | 6 |
24,057 | public final double sum ( final AbstractMeter meter ) { checkIfMeterExists ( meter ) ; final AbstractUnivariateStatistic sum = new Sum ( ) ; final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection ( this . meterResults . get ( meter ) ) ; return sum . evaluate ( doubleColl . toArray ( ) , 0 , doubleColl . toArray ( ) . length ) ; } | Computes the sum over all data items . | 85 | 9 |
24,058 | public final double min ( final AbstractMeter meter ) { checkIfMeterExists ( meter ) ; final AbstractUnivariateStatistic min = new Min ( ) ; final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection ( this . meterResults . get ( meter ) ) ; return min . evaluate ( doubleColl . toArray ( ) , 0 , doubleColl . toArray ( ) . length ) ; } | Computes the minimum . | 85 | 5 |
24,059 | public final double getConf05 ( final AbstractMeter meter ) { checkIfMeterExists ( meter ) ; final AbstractUnivariateStatistic conf05 = new Percentile ( 5.0 ) ; final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection ( this . meterResults . get ( meter ) ) ; return conf05 . evaluate ( doubleColl . toArray ( ) , 0 , doubleColl . toArray ( ) . length ) ; } | Computes the confidence 05 interval - factor . This value has to be combined with the mean to get the confidence - interval . | 93 | 25 |
24,060 | public final double getConf95 ( final AbstractMeter meter ) { checkIfMeterExists ( meter ) ; final AbstractUnivariateStatistic conf95 = new Percentile ( 95.0 ) ; final CollectionDoubleCollection doubleColl = new CollectionDoubleCollection ( this . meterResults . get ( meter ) ) ; return conf95 . evaluate ( doubleColl . toArray ( ) , 0 , doubleColl . toArray ( ) . length ) ; } | Computes the confidence 95 interval - factor . This value has to be combined with the mean to get the confidence - interval . | 93 | 25 |
24,061 | final void addData ( final AbstractMeter meter , final double data ) { checkIfMeterExists ( meter ) ; meterResults . get ( meter ) . add ( data ) ; } | Adding a data to a meter . | 40 | 7 |
24,062 | private void checkIfMeterExists ( final AbstractMeter meter ) { if ( ! meterResults . containsKey ( meter ) ) { meterResults . put ( meter , new LinkedList < Double > ( ) ) ; } } | Checking method if meter is registered otherwise inserting a suitable data structure . | 49 | 14 |
24,063 | @ Override public void onTokenRefresh ( ) { Intent intent = new Intent ( ACTION_REFRESH_PUSH ) ; LocalBroadcastManager . getInstance ( getApplicationContext ( ) ) . sendBroadcast ( intent ) ; } | Called if InstanceID token is updated . This may occur if the security of the previous token had been compromised . Note that this is also called when the InstanceID token is initially generated so this is where you retrieve the token . | 51 | 48 |
24,064 | public static BenchmarkExecutor getExecutor ( final BenchmarkElement meth ) { if ( BENCHRES == null ) { throw new IllegalStateException ( "Call initialize method first!" ) ; } // check if new instance needs to be created if ( ! EXECUTOR . containsKey ( meth . getMeth ( ) ) ) { EXECUTOR . put ( meth . getMeth ( ) , new BenchmarkExecutor ( meth . getMeth ( ) ) ) ; int runsOnAnno = BenchmarkMethod . getNumberOfAnnotatedRuns ( meth . getMeth ( ) . getMethodToBench ( ) ) ; if ( runsOnAnno < 0 ) { runsOnAnno = CONFIG . getRuns ( ) ; } RUNS . put ( meth . getMeth ( ) , runsOnAnno ) ; } // returning the executor return EXECUTOR . get ( meth . getMeth ( ) ) ; } | Getting the executor corresponding to a BenchmarkElement . | 204 | 11 |
24,065 | public static void initialize ( final AbstractConfig config , final BenchmarkResult result ) { METERS_TO_BENCH . clear ( ) ; METERS_TO_BENCH . addAll ( Arrays . asList ( config . getMeters ( ) ) ) ; EXECUTOR . clear ( ) ; BENCHRES = result ; CONFIG = config ; } | Initializing the executor . | 78 | 6 |
24,066 | public static PerfidixMethodInvocationException invokeMethod ( final Object obj , final Class < ? extends Annotation > relatedAnno , final Method meth , final Object ... args ) { try { meth . invoke ( obj , args ) ; return null ; } catch ( final IllegalArgumentException e ) { return new PerfidixMethodInvocationException ( e , meth , relatedAnno ) ; } catch ( final IllegalAccessException e ) { return new PerfidixMethodInvocationException ( e , meth , relatedAnno ) ; } catch ( final InvocationTargetException e ) { return new PerfidixMethodInvocationException ( e . getCause ( ) , meth , relatedAnno ) ; } } | Method to invoke a reflective invokable method . | 152 | 10 |
24,067 | public static PerfidixMethodCheckException checkMethod ( final Object obj , final Class < ? extends Annotation > anno , final Method ... meths ) { for ( Method meth : meths ) { // check if the class of the object to be executed has the given // method boolean classMethodCorr = false ; for ( final Method methodOfClass : obj . getClass ( ) . getDeclaredMethods ( ) ) { if ( methodOfClass . equals ( meth ) ) { classMethodCorr = true ; } } if ( ! classMethodCorr ) { return new PerfidixMethodCheckException ( new IllegalStateException ( "Object to execute " + obj + " is not having a Method named " + meth + "." ) , meth , anno ) ; } // check if the method is reflected executable if ( ! BenchmarkMethod . isReflectedExecutable ( meth , anno ) ) { return new PerfidixMethodCheckException ( new IllegalAccessException ( "Method to execute " + meth + " is not reflected executable." ) , meth , anno ) ; } } return null ; } | Checking a method if it is reflective executable and if the mapping to the object fits . | 236 | 18 |
24,068 | public void executeBench ( final Object objToExecute , final Object ... args ) { final double [ ] meterResults = new double [ METERS_TO_BENCH . size ( ) ] ; final Method meth = element . getMethodToBench ( ) ; int meterIndex1 = 0 ; int meterIndex2 = 0 ; for ( final AbstractMeter meter : METERS_TO_BENCH ) { meterResults [ meterIndex1 ] = meter . getValue ( ) ; meterIndex1 ++ ; } final PerfidixMethodInvocationException res = invokeMethod ( objToExecute , Bench . class , meth , args ) ; for ( final AbstractMeter meter : METERS_TO_BENCH ) { meterResults [ meterIndex2 ] = meter . getValue ( ) - meterResults [ meterIndex2 ] ; meterIndex2 ++ ; } if ( res == null ) { meterIndex1 = 0 ; for ( final AbstractMeter meter : METERS_TO_BENCH ) { BENCHRES . addData ( element , meter , meterResults [ meterIndex1 ] ) ; meterIndex1 ++ ; } } else { BENCHRES . addException ( res ) ; } } | Execution of bench method . All data is stored corresponding to the meters . | 255 | 15 |
24,069 | private Device loadDevice ( ) { //Initialise object with the content saved in shared pref file. SharedPreferences sharedPreferences = getSharedPreferences ( ) ; return new Device ( ) . setApiSpaceId ( sharedPreferences . getString ( KEY_API_SPACE_ID , null ) ) . setAppVer ( sharedPreferences . getInt ( KEY_APP_VER , - 1 ) ) . setInstanceId ( sharedPreferences . getString ( KEY_INSTANCE_ID , null ) ) . setPushToken ( sharedPreferences . getString ( KEY_PUSH_TOKEN , null ) ) . setDeviceId ( sharedPreferences . getString ( KEY_DEVICE_ID , null ) ) ; } | Loads device details from internal storage . | 157 | 8 |
24,070 | public void insertRow ( int index , Object element ) { elements . add ( index , element ) ; fireTableRowsInserted ( index , index ) ; } | Add the given element as one row of the table | 34 | 10 |
24,071 | private void parseEvent ( JsonObject event , Parser parser , int i ) { JsonElement nameJE = event . get ( Event . KEY_NAME ) ; if ( nameJE != null ) { String name = nameJE . getAsString ( ) ; if ( MessageSentEvent . TYPE . equals ( name ) ) { MessageSentEvent parsed = parser . parse ( event , MessageSentEvent . class ) ; messageSent . add ( parsed ) ; map . put ( i , parsed ) ; } else if ( MessageDeliveredEvent . TYPE . equals ( name ) ) { MessageDeliveredEvent parsed = parser . parse ( event , MessageDeliveredEvent . class ) ; messageDelivered . add ( parsed ) ; map . put ( i , parsed ) ; } else if ( MessageReadEvent . TYPE . equals ( name ) ) { MessageReadEvent parsed = parser . parse ( event , MessageReadEvent . class ) ; messageRead . add ( parsed ) ; map . put ( i , parsed ) ; } } } | Parse event and add to appropriate list . | 216 | 9 |
24,072 | String formatMessage ( int msgLogLevel , String module , String msg ) { return getLevelTag ( msgLogLevel ) + module + ": " + msg ; } | Formats log message for console output . Short version . | 35 | 11 |
24,073 | public static JSpinner createSpinner ( SpinnerModel model , final int fractionDigits ) { return new JSpinner ( model ) { /** * Serial UID */ private static final long serialVersionUID = - 9185142711286020504L ; @ Override protected JComponent createEditor ( SpinnerModel model ) { if ( model instanceof SpinnerNumberModel ) { NumberEditor editor = new NumberEditor ( this ) ; DecimalFormat format = editor . getFormat ( ) ; format . setMaximumFractionDigits ( fractionDigits ) ; return editor ; } return super . createEditor ( model ) ; } } ; } | Create a spinner with the given model showing the given number of fraction digits for number models | 134 | 18 |
24,074 | public static void setSpinnerDraggingEnabled ( final JSpinner spinner , boolean enabled ) { SpinnerModel spinnerModel = spinner . getModel ( ) ; if ( ! ( spinnerModel instanceof SpinnerNumberModel ) ) { throw new IllegalArgumentException ( "Dragging is only possible for spinners with a " + "SpinnerNumberModel, found " + spinnerModel . getClass ( ) ) ; } if ( enabled ) { disableSpinnerDragging ( spinner ) ; enableSpinnerDragging ( spinner ) ; } else { disableSpinnerDragging ( spinner ) ; } } | Set whether the value of the given spinner may be changed with mouse drags | 132 | 16 |
24,075 | public void cacheFile ( ) { if ( orientation == Orientation . INV ) cache = new String [ fields ] [ elements ] ; else cache = new String [ elements ] [ fields ] ; int x = 0 , y = 0 ; Scanner file = null ; try { file = new Scanner ( csvFile ) ; } catch ( FileNotFoundException e ) { // TODO Auto-generated catch block e . printStackTrace ( ) ; } String line ; StringTokenizer tokenizer ; while ( file . hasNextLine ( ) ) { line = file . nextLine ( ) ; tokenizer = new StringTokenizer ( line , "," ) ; while ( tokenizer . hasMoreTokens ( ) ) { cache [ y ] [ x ] = tokenizer . nextToken ( ) ; x ++ ; } x = 0 ; y ++ ; } file . close ( ) ; cached = true ; } | load the entire CSV file into memory for much faster access subsequent use of getField will not use file access and will occur in constant time | 189 | 27 |
24,076 | public void clearAll ( ) { for ( int i = 0 ; i < textFields . size ( ) ; i ++ ) { JTextField textField = textFields . get ( i ) ; if ( textField == null ) { continue ; } textField . setText ( "" ) ; } } | Clear all text fields in this instance | 65 | 7 |
24,077 | public JTextField createFilterTextField ( int columnIndex ) { while ( textFields . size ( ) - 1 < columnIndex ) { textFields . add ( null ) ; } JTextField textField = new JTextField ( ) ; textFields . set ( columnIndex , textField ) ; Document document = textField . getDocument ( ) ; document . addDocumentListener ( new DocumentListener ( ) { @ Override public void removeUpdate ( DocumentEvent e ) { updateFilter ( ) ; } @ Override public void insertUpdate ( DocumentEvent e ) { updateFilter ( ) ; } @ Override public void changedUpdate ( DocumentEvent e ) { updateFilter ( ) ; } } ) ; return textField ; } | Create the text field for the specified column | 154 | 8 |
24,078 | private void updateFilter ( ) { List < RowFilter < TableModel , Integer > > regexFilters = new ArrayList < RowFilter < TableModel , Integer > > ( ) ; for ( int i = 0 ; i < textFields . size ( ) ; i ++ ) { JTextField textField = textFields . get ( i ) ; if ( textField == null ) { continue ; } String regex = textField . getText ( ) ; RowFilter < TableModel , Integer > regexFilter = createRegexFilter ( regex , i ) ; if ( regexFilter == null ) { continue ; } regexFilters . add ( regexFilter ) ; } if ( regexFilters . isEmpty ( ) ) { filterConsumer . accept ( null ) ; } else { RowFilter < TableModel , Integer > rowFilter = RowFilter . andFilter ( regexFilters ) ; filterConsumer . accept ( rowFilter ) ; } } | Update the row filter based on the contents of the text fields | 195 | 12 |
24,079 | public void detach ( ) { textComponent . removePropertyChangeListener ( documentPropertyChangeListener ) ; Document document = textComponent . getDocument ( ) ; document . removeUndoableEditListener ( undoableEditListener ) ; textComponent . getInputMap ( ) . remove ( undoKeyStroke ) ; textComponent . getActionMap ( ) . remove ( DO_UNDO_NAME ) ; textComponent . getInputMap ( ) . remove ( redoKeyStroke ) ; textComponent . getActionMap ( ) . remove ( DO_REDO_NAME ) ; } | Detach this handler from the text component . This will remove all listeners that have been attached to the text component its document and the elements of its input - and action maps . | 122 | 35 |
24,080 | static Map < Point , Object > addHighlights ( JTextComponent textComponent , Iterable < ? extends Point > appearances , Color color ) { Highlighter . HighlightPainter painter = new DefaultHighlighter . DefaultHighlightPainter ( color ) ; Highlighter highlighter = textComponent . getHighlighter ( ) ; Map < Point , Object > highlights = new LinkedHashMap < Point , Object > ( ) ; for ( Point appearance : appearances ) { try { Object highlight = highlighter . addHighlight ( appearance . x , appearance . y , painter ) ; highlights . put ( appearance , highlight ) ; } catch ( BadLocationException e ) { // Should never happen logger . severe ( e . toString ( ) ) ; } } return highlights ; } | Add the given highlights to the given text component . | 165 | 10 |
24,081 | static void removeHighlights ( JTextComponent textComponent , Iterable < ? > highlights ) { Highlighter highlighter = textComponent . getHighlighter ( ) ; for ( Object highlight : highlights ) { highlighter . removeHighlight ( highlight ) ; } } | Remove the given highlights from the given text component | 58 | 9 |
24,082 | synchronized void connect ( ) { if ( socket != null ) { socket . disconnect ( ) ; } final String token = getToken ( ) ; if ( ! TextUtils . isEmpty ( token ) ) { socket = factory . createSocket ( token , new WeakReference <> ( this ) ) ; if ( socket != null ) { socket . connect ( ) ; } } } | Start socket connection . | 80 | 4 |
24,083 | private String getToken ( ) { SessionData session = dataMgr . getSessionDAO ( ) . session ( ) ; if ( session != null && session . getExpiresOn ( ) > System . currentTimeMillis ( ) ) { return session . getAccessToken ( ) ; } return null ; } | Gets Comapi access token . | 65 | 7 |
24,084 | private void scheduleReconnection ( ) { if ( runnable != null ) { handler . removeCallbacks ( runnable ) ; } runnable = ( ) -> { if ( shouldReconnect ( ) && ( socket == null || ! socket . isOpen ( ) ) && retryStrategy . retry ( ) && ! isNetworkUnavailable ) { log . d ( "Reconnecting socket" ) ; connect ( ) ; } } ; long delay = retryStrategy . getDelay ( ) ; handler . postDelayed ( runnable , delay ) ; log . d ( "Socket reconnection in " + delay / 1000 + " seconds." ) ; } | Schedule socket connection retry . | 147 | 7 |
24,085 | public Map < String , Object > asMap ( ) { Map < String , Object > map = new HashMap <> ( ) ; map . putAll ( defaultProperties ) ; map . putAll ( customProperties ) ; return map ; } | Merge all profile properties to a single map . | 52 | 10 |
24,086 | private void minimize ( ) { if ( timer != null ) { timer . stop ( ) ; timer = null ; } currentHeight = getHeight ( ) ; double steps = ( double ) durationMS / delayMS ; double delta = currentHeight - minimizedHeight ; final int stepSize = ( int ) Math . ceil ( delta / steps ) ; //System.out.println("steps " + steps); //System.out.println("currentHeight " + currentHeight); //System.out.println("delta " + delta); //System.out.println("stepSize " + stepSize); timer = new Timer ( delayMS , new ActionListener ( ) { @ Override public void actionPerformed ( ActionEvent e ) { currentHeight -= stepSize ; currentHeight = Math . max ( currentHeight , minimizedHeight ) ; if ( currentHeight <= minimizedHeight ) { minimized = true ; timer . stop ( ) ; timer = null ; } revalidate ( ) ; } } ) ; timer . setInitialDelay ( 0 ) ; timer . start ( ) ; } | Performs the minimization process | 224 | 6 |
24,087 | private void maximize ( ) { if ( timer != null ) { timer . stop ( ) ; timer = null ; } final int targetHeight = getSuperPreferredHeight ( ) ; double steps = ( double ) durationMS / delayMS ; double delta = targetHeight - currentHeight ; final int stepSize = ( int ) Math . ceil ( delta / steps ) ; currentHeight = getHeight ( ) ; //System.out.println("steps " + steps); //System.out.println("currentHeight " + currentHeight); //System.out.println("delta " + delta); //System.out.println("stepSize " + stepSize); timer = new Timer ( delayMS , new ActionListener ( ) { @ Override public void actionPerformed ( ActionEvent e ) { minimized = false ; currentHeight += stepSize ; currentHeight = Math . min ( currentHeight , targetHeight ) ; if ( currentHeight >= targetHeight ) { currentHeight = Integer . MAX_VALUE ; timer . stop ( ) ; timer = null ; } revalidate ( ) ; } } ) ; timer . setInitialDelay ( 0 ) ; timer . start ( ) ; } | Performs the maximization process | 246 | 6 |
24,088 | public static BenchmarkResult runBenchs ( final String [ ] benchs ) throws ClassNotFoundException , InstantiationException , IllegalAccessException { final AbstractConfig conf = getConfiguration ( benchs ) ; final Benchmark bench = new Benchmark ( conf ) ; return setUpBenchmark ( benchs , bench ) . run ( ) ; } | Running one Benchmark . | 71 | 5 |
24,089 | public static Benchmark setUpBenchmark ( final String [ ] classes , final Benchmark benchmark ) throws ClassNotFoundException { for ( final String each : classes ) { benchmark . add ( Class . forName ( each ) ) ; } return benchmark ; } | Setting up an existing benchmark with the given number of class - files | 53 | 13 |
24,090 | void setId ( String sessionAuthId ) { synchronized ( lock ) { if ( isCreatingSession . get ( ) ) { this . sessionAuthId = sessionAuthId ; } lock . notifyAll ( ) ; } } | Sets id of current authentication process . | 46 | 8 |
24,091 | public void add ( final int [ ] e ) { if ( size == list . length ) list = Array . copyOf ( list , newSize ( ) ) ; list [ size ++ ] = e ; } | Adds an element . | 43 | 4 |
24,092 | public void set ( final int i , final int [ ] e ) { if ( i >= list . length ) list = Array . copyOf ( list , newSize ( i + 1 ) ) ; list [ i ] = e ; size = Math . max ( size , i + 1 ) ; } | Sets an element at the specified index . | 62 | 9 |
24,093 | private String buildFileName ( final String ... names ) { final StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < names . length ; i ++ ) { builder . append ( names [ i ] ) ; if ( i < names . length - 1 ) { builder . append ( SEPARATOR ) ; } } builder . append ( "." ) . append ( "csv" ) ; return builder . toString ( ) ; } | Helper method to build suitable fileNames . | 96 | 8 |
24,094 | private boolean handleWrapping ( MouseEvent e ) { if ( robot == null ) { return false ; } PointerInfo pointerInfo = null ; try { pointerInfo = MouseInfo . getPointerInfo ( ) ; } catch ( SecurityException ex ) { return false ; } Rectangle r = pointerInfo . getDevice ( ) . getDefaultConfiguration ( ) . getBounds ( ) ; Point onScreen = pointerInfo . getLocation ( ) ; if ( onScreen . y == 0 ) { robot . mouseMove ( onScreen . x , r . height - 2 ) ; previousPoint = new Point ( onScreen . x , r . height - 2 ) ; SwingUtilities . convertPointFromScreen ( previousPoint , spinner ) ; return true ; } else if ( onScreen . y == r . height - 1 ) { robot . mouseMove ( onScreen . x , 1 ) ; previousPoint = new Point ( onScreen . x , 1 ) ; SwingUtilities . convertPointFromScreen ( previousPoint , spinner ) ; return true ; } return false ; } | Let the mouse wrap from the top of the screen to the bottom or vice versa | 224 | 16 |
24,095 | private void tryCommit ( ) { try { JComponent editor = spinner . getEditor ( ) ; if ( editor instanceof JSpinner . DefaultEditor ) { JSpinner . DefaultEditor defaultEditor = ( JSpinner . DefaultEditor ) editor ; defaultEditor . commitEdit ( ) ; } } catch ( ParseException e1 ) { // Ignored } } | Try to commit the current value to the spinner editor . This is necessary in order to validate the number in the model against the displayed value . | 78 | 29 |
24,096 | @ Override protected List < BenchmarkElement > arrangeList ( final List < BenchmarkElement > elements ) { final List < BenchmarkElement > elementList = new LinkedList < BenchmarkElement > ( ) ; elementList . addAll ( elements ) ; return elementList ; } | Not arranging the list in this case . That means normally that all elements are occuring in the same order than defined in the class - file . | 59 | 29 |
24,097 | public @ Nullable List < ComapiValidationFailure > getValidationFailures ( ) { if ( errorBody != null && ! errorBody . isEmpty ( ) ) { ComapiValidationFailures failures = null ; try { failures = new Parser ( ) . parse ( errorBody , ComapiValidationFailures . class ) ; } catch ( Exception e ) { return null ; } return failures . validationFailures ; } return null ; } | Get API call validation failures details . | 95 | 7 |
24,098 | public static byte [ ] [ ] copyOf ( final byte [ ] [ ] a , final int s ) { final byte [ ] [ ] tmp = new byte [ s ] [ ] ; System . arraycopy ( a , 0 , tmp , 0 , Math . min ( s , a . length ) ) ; return tmp ; } | Copies the specified array . | 68 | 6 |
24,099 | public static < T > T [ ] add ( final T [ ] ar , final T e ) { final int s = ar . length ; final T [ ] t = Arrays . copyOf ( ar , s + 1 ) ; t [ s ] = e ; return t ; } | Adds an entry to the end of an array and returns the new array . | 59 | 15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.