idx
int64
0
34.9k
question
stringlengths
12
26.4k
target
stringlengths
15
2.3k
34,600
protected abstract void sessionRemoved ( SSLSession session ) ;
Called when a session is removed. Used by ClientSessionContext to update its host-and-port based cache.
34,601
public static double coefficient ( double [ ] x , double [ ] y ) { final int xdim = x . length ; final int ydim = y . length ; if ( xdim != ydim ) { throw new IllegalArgumentException ( "Invalid arguments: arrays differ in length." ) ; } double sumXX = 0. , sumYY = 0. , sumXY = 0. ; double meanX = x [ 0 ] , meanY = y [ 0 ] ; int i = 1 ; while ( i < xdim ) { final double xv = x [ i ] , yv = y [ i ] ; final double deltaX = xv - meanX ; final double deltaY = yv - meanY ; ++ i ; meanX += deltaX / i ; meanY += deltaY / i ; final double neltaX = xv - meanX ; final double neltaY = yv - meanY ; sumXX += deltaX * neltaX ; sumYY += deltaY * neltaY ; sumXY += deltaX * neltaY ; } if ( ! ( sumXX > 0. && sumYY > 0. ) ) { return ( sumXX == sumYY ) ? 1. : 0. ; } return sumXY / Math . sqrt ( sumXX * sumYY ) ; }
Compute the Pearson product-moment correlation coefficient for two FeatureVectors.
34,602
private String constructAddLUNQuery ( String systemId , String targetPortId , String domainId , Map < String , String > deviceLunList , List < Path > pathList , String model ) throws Exception { Map < String , Object > attributeMap = new HashMap < String , Object > ( ) ; StorageArray array = new StorageArray ( systemId ) ; Add addOp = new Add ( HDSConstants . LUN_TARGET ) ; attributeMap . put ( HDSConstants . STORAGEARRAY , array ) ; attributeMap . put ( HDSConstants . ADD , addOp ) ; attributeMap . put ( HDSConstants . MODEL , model ) ; if ( null != deviceLunList && ! deviceLunList . isEmpty ( ) ) { for ( String device : deviceLunList . keySet ( ) ) { String lun = deviceLunList . get ( device ) ; Path path = new Path ( targetPortId , domainId , null , lun , device ) ; pathList . add ( path ) ; log . info ( "Device :{} lun:{}" , device , lun ) ; } } attributeMap . put ( HDSConstants . PATH_LIST , pathList ) ; String addLunInputXML = InputXMLGenerationClient . getInputXMLString ( HDSConstants . ADD_PATH_TO_HSD_OP , attributeMap , HDSConstants . HITACHI_INPUT_XML_CONTEXT_FILE , HDSConstants . HITACHI_SMOOKS_CONFIG_FILE ) ; return addLunInputXML ; }
Constructs the addLun query using multiple path elements. Each path element defines the path from volume to initiators.
34,603
@ Override public boolean equals ( Object object ) { if ( this == object ) { return true ; } if ( ( null == object ) || ( getClass ( ) != object . getClass ( ) ) ) { return false ; } final Player other = ( Player ) object ; return other . id == id ; }
Two players are equal if their ids are equal
34,604
public static String cleanBeginWhitespace ( String in ) { int len = in . length ( ) ; int st = 0 ; int off = 0 ; char [ ] val = in . toCharArray ( ) ; while ( ( st < len ) && ( val [ off + st ] <= ' ' ) ) { st ++ ; } return ( ( st > 0 ) || ( len < in . length ( ) ) ) ? in . substring ( st , len ) : in ; }
remove white space from the begin
34,605
@ Override @ SuppressForbidden ( reason = "System#out" ) public void activateOptions ( ) { if ( follow ) { if ( target . equals ( SYSTEM_ERR ) ) { setWriter ( createWriter ( new SystemErrStream ( ) ) ) ; } else { setWriter ( createWriter ( new SystemOutStream ( ) ) ) ; } } else { if ( target . equals ( SYSTEM_ERR ) ) { setWriter ( createWriter ( System . err ) ) ; } else { setWriter ( createWriter ( System . out ) ) ; } } super . activateOptions ( ) ; }
Prepares the appender for use.
34,606
private boolean addIfAbsent ( E e , Object [ ] snapshot ) { final ReentrantLock lock = this . lock ; lock . lock ( ) ; try { Object [ ] current = getArray ( ) ; int len = current . length ; if ( snapshot != current ) { int common = Math . min ( snapshot . length , len ) ; for ( int i = 0 ; i < common ; i ++ ) if ( current [ i ] != snapshot [ i ] && eq ( e , current [ i ] ) ) return false ; if ( indexOf ( e , current , common , len ) >= 0 ) return false ; } Object [ ] newElements = Arrays . copyOf ( current , len + 1 ) ; newElements [ len ] = e ; setArray ( newElements ) ; return true ; } finally { lock . unlock ( ) ; } }
A version of addIfAbsent using the strong hint that given recent snapshot does not contain e.
34,607
static int applyMaskPenaltyRule4 ( ByteMatrix matrix ) { int numDarkCells = 0 ; byte [ ] [ ] array = matrix . getArray ( ) ; int width = matrix . getWidth ( ) ; int height = matrix . getHeight ( ) ; for ( int y = 0 ; y < height ; y ++ ) { byte [ ] arrayY = array [ y ] ; for ( int x = 0 ; x < width ; x ++ ) { if ( arrayY [ x ] == 1 ) { numDarkCells ++ ; } } } int numTotalCells = matrix . getHeight ( ) * matrix . getWidth ( ) ; int fivePercentVariances = Math . abs ( numDarkCells * 2 - numTotalCells ) * 10 / numTotalCells ; return fivePercentVariances * N4 ; }
Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.
34,608
public static String formatURL ( String url ) { if ( ! Strings . isNullOrEmpty ( url ) ) { try { URI uri = URI . create ( url ) ; if ( uri . isAbsolute ( ) ) { return url ; } else { return "http://" + url ; } } catch ( IllegalArgumentException e ) { return null ; } } else { return null ; } }
Returns a formatted URL string, prefixing it with a default scheme component if its not an absolute URL.
34,609
void recomposeVariables ( ElemVariable elemVar ) { if ( getVariableOrParamComposed ( elemVar . getName ( ) ) == null ) { elemVar . setIsTopLevel ( true ) ; elemVar . setIndex ( m_variables . size ( ) ) ; m_variables . addElement ( elemVar ) ; } }
Recompose the top level variable and parameter declarations.
34,610
public int compareTo ( DebugScript other ) { return comparableName . compareTo ( other . comparableName ) ; }
Implement Comparable interface for sorting DebugScripts
34,611
public void publish ( AWSIotMessage message ) throws AWSIotException { try { publishMessage ( message ) ; } catch ( AwsIotRetryableException e ) { if ( client . getMaxOfflineQueueSize ( ) > 0 && publishQueue . size ( ) < client . getMaxOfflineQueueSize ( ) ) { publishQueue . add ( message ) ; } else { LOGGER . info ( "Failed to publish message to " + message . getTopic ( ) ) ; throw new AWSIotException ( e ) ; } } }
The actual publish method exposed by this class.
34,612
public void testRotateMapViewInTrackDetailActivity ( ) { if ( ! runTest ) { Log . d ( TAG , BigTestUtils . DISABLE_MESSAGE ) ; return ; } EndToEndTestUtils . startRecording ( ) ; for ( int i = 0 ; ( System . currentTimeMillis ( ) - startTime ) < TEST_DURATION_IN_MILLISECONDS ; i ++ ) { EndToEndTestUtils . sendGps ( 10 , i * 10 ) ; EndToEndTestUtils . rotateCurrentActivity ( ) ; Log . d ( TAG , String . format ( "Totate %d times in %d minutes!" , i , ( System . currentTimeMillis ( ) - startTime ) / 1000 / 60 ) ) ; } }
Rotates screen when display map view. Keeps sending different GPS locations in each track, making it closer to the real stress.
34,613
public void testWriteReadEmpty ( ) throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream ( 0 ) ; ObjectOutputStream os = new ObjectOutputStream ( out ) ; os . writeObject ( empty ) ; ObjectInputStream is = new ObjectInputStream ( new ByteArrayInputStream ( out . toByteArray ( ) ) ) ; LoadBalancingPolicy copy = ( LoadBalancingPolicy ) is . readObject ( ) ; is . close ( ) ; os . close ( ) ; assertTrue ( helper . areEquals ( empty , copy ) ) ; }
Test read and write empty ClusterPolicy object
34,614
public void trimToSize ( ) { if ( names != null ) names . trimToSize ( ) ; if ( requiredChildren != null ) { requiredChildren . trimToSize ( ) ; for ( GazEntry nextkey : requiredChildren . values ( ) ) { nextkey . trimToSize ( ) ; } } }
when we are done loading up all the gazetteers, we will trim all the collections down to size to save memory.
34,615
public ImageTitle ( Image image , RectangleEdge position , HorizontalAlignment horizontalAlignment , VerticalAlignment verticalAlignment ) { this ( image , image . getHeight ( null ) , image . getWidth ( null ) , position , horizontalAlignment , verticalAlignment , Title . DEFAULT_PADDING ) ; }
Creates a new image title.
34,616
public boolean hasFinished ( ) { return finished . get ( ) ; }
Check whether execution has finished.
34,617
TreeBin ( TreeNode < K > b ) { super ( TREEBIN , null , null ) ; this . first = b ; TreeNode < K > r = null ; for ( TreeNode < K > x = b , next ; x != null ; x = next ) { next = ( TreeNode < K > ) x . next ; x . left = x . right = null ; if ( r == null ) { x . parent = null ; x . red = false ; r = x ; } else { K k = x . key ; int h = x . hash ; Class < ? > kc = null ; for ( TreeNode < K > p = r ; ; ) { int dir , ph ; K pk = p . key ; if ( ( ph = p . hash ) > h ) dir = - 1 ; else if ( ph < h ) dir = 1 ; else if ( ( kc == null && ( kc = comparableClassFor ( k ) ) == null ) || ( dir = compareComparables ( kc , k , pk ) ) == 0 ) dir = tieBreakOrder ( k , pk ) ; TreeNode < K > xp = p ; if ( ( p = ( dir <= 0 ) ? p . left : p . right ) == null ) { x . parent = xp ; if ( dir <= 0 ) xp . left = x ; else xp . right = x ; r = balanceInsertion ( r , x ) ; break ; } } } } this . root = r ; assert checkInvariants ( root ) ; }
Creates bin with initial set of nodes headed by b.
34,618
private void updateProgress ( String progressLabel , int progress ) { if ( myHost != null && ( ( progress != previousProgress ) || ( ! progressLabel . equals ( previousProgressLabel ) ) ) ) { myHost . updateProgress ( progressLabel , progress ) ; } previousProgress = progress ; previousProgressLabel = progressLabel ; }
Used to communicate a progress update between a plugin tool and the main Whitebox user interface.
34,619
public CertId ( DerInputStream derIn ) throws IOException { hashAlgId = AlgorithmId . parse ( derIn . getDerValue ( ) ) ; issuerNameHash = derIn . getOctetString ( ) ; issuerKeyHash = derIn . getOctetString ( ) ; certSerialNumber = new SerialNumber ( derIn ) ; }
Creates a CertId from its ASN.1 DER encoding.
34,620
public void testSignerString ( ) throws Exception { Signer s = new SignerStub ( "sss3" ) ; assertNotNull ( s ) ; assertEquals ( "sss3" , s . getName ( ) ) ; assertNull ( s . getPrivateKey ( ) ) ; Signer s2 = new SignerStub ( null ) ; assertNull ( s2 . getName ( ) ) ; }
verify Signer(String) creates instance
34,621
public void copyChars ( char [ ] otherChars , int otherOffset , int otherLength ) { grow ( otherLength ) ; System . arraycopy ( otherChars , otherOffset , ref . chars , 0 , otherLength ) ; ref . length = otherLength ; }
Copies the given array into this instance.
34,622
@ Override public String toString ( ) { return expressionStr ; }
Returns a string representation of the expression
34,623
void onStartTrackingTouch ( ) { mIsDragging = true ; }
This is called when the user has started touching this widget.
34,624
private void updateDiskGCRVV ( RegionVersionVector diskRVV , RegionVersionVector inMemoryRVV , VersionSource member ) { long diskVersion = diskRVV . getVersionForMember ( member ) ; long memoryGCVersion = inMemoryRVV . getGCVersion ( member ) ; if ( memoryGCVersion <= diskVersion ) { diskRVV . recordGCVersion ( member , memoryGCVersion ) ; } }
Update the on disk GC version for the given member, only if the disk has actually recorded all of the updates including that member.
34,625
public int length ( List < String > ls ) { return ls . size ( ) ; }
Simple function to make algorithm more closely resemble pseudocode
34,626
private static void popTransactionStartStamp ( ) { ListOrderedMap map = ( ListOrderedMap ) suspendedTxStartStamps . get ( ) ; if ( map . size ( ) > 0 ) { transactionStartStamp . set ( ( Timestamp ) map . remove ( map . lastKey ( ) ) ) ; } else { Debug . logError ( "Error in transaction handling - no saved start stamp found - using NOW." , module ) ; transactionStartStamp . set ( UtilDateTime . nowTimestamp ( ) ) ; } }
Remove the stamp from stack (when resuming)
34,627
public static byte [ ] unPad ( byte [ ] seq , boolean forward ) { if ( seq != null && seq . length == CG2_PADDED_LENGTH ) { final int pos = forward ? CG2_PAD_POSITION : CG2_PAD_POSITION_REV ; final byte [ ] result = new byte [ seq . length - 1 ] ; System . arraycopy ( seq , 0 , result , 0 , pos ) ; System . arraycopy ( seq , pos + 1 , result , pos , seq . length - pos - 1 ) ; return result ; } else { return seq ; } }
Strip single padding base that Complete Genomics v2 reads contain, if present.
34,628
Operand peek ( Register s ) { Stack < Operand > stack = get ( s ) ; if ( stack == null || stack . isEmpty ( ) ) { return null ; } else { return stack . peek ( ) ; } }
Get the name at the top of the stack for a particular register
34,629
public void addUpdateListener ( AnimatorUpdateListener listener ) { if ( mUpdateListeners == null ) { mUpdateListeners = new ArrayList < AnimatorUpdateListener > ( ) ; } mUpdateListeners . add ( listener ) ; }
Adds a listener to the set of listeners that are sent update events through the life of an animation. This method is called on all listeners for every frame of the animation, after the values for the animation have been calculated.
34,630
public void done ( ) { m_TrainingData = null ; if ( m_NumIterationsPerformed > 0 ) { m_ZeroR = null ; } }
Clean up after boosting.
34,631
@ Override public V put ( K key , V value ) { V oldValue = super . put ( key , value ) ; return ( oldValue == null ) ? delegate . get ( key ) : oldValue ; }
Adds the key and value to the local map, potentially overshadowing a version in the delegate map.
34,632
protected void acceptDrag ( int dragOperation ) { DropTargetContextPeer peer = getDropTargetContextPeer ( ) ; if ( peer != null ) { peer . acceptDrag ( dragOperation ) ; } }
accept the Drag. <P>
34,633
public boolean matches ( String line , String route ) { if ( ! lines . isEmpty ( ) && ! lines . contains ( line ) ) return false ; if ( ! routes . isEmpty ( ) && ! routes . contains ( route ) ) return false ; return true ; }
Determines whether this discount interval applies for a given time and a given vehicle type
34,634
@ Bean ( initMethod = "start" , destroyMethod = "stop" ) @ Profile ( Constants . SPRING_PROFILE_DEVELOPMENT ) public Server h2TCPServer ( ) throws SQLException { return Server . createTcpServer ( "-tcp" , "-tcpAllowOthers" ) ; }
Open the TCP port for the H2 database, so it is available remotely.
34,635
public static void deleteFileIfExistsWithRetry ( Path path ) throws IOException { try { if ( Files . exists ( path ) ) deleteFileWithRetry0 ( path ) ; } catch ( InterruptedException x ) { throw new IOException ( "Interrupted while deleting." , x ) ; } }
Deletes a file, retrying if necessary. No exception thrown if file doesn't exist.
34,636
public void waitForExit ( ) throws IOException { Thread thread = Thread . currentThread ( ) ; ClassLoader oldLoader = thread . getContextClassLoader ( ) ; try { thread . setContextClassLoader ( _systemManager . getClassLoader ( ) ) ; _waitForExitService = new WaitForExitService3 ( this , _systemManager ) ; _waitForExitService . waitForExit ( ) ; } finally { thread . setContextClassLoader ( oldLoader ) ; } }
Thread to wait until Baratine should be stopped.
34,637
void pushElemTemplateElement ( ElemTemplateElement elem ) { if ( elem . getUid ( ) == - 1 ) elem . setUid ( nextUid ( ) ) ; m_elems . push ( elem ) ; }
Push the current XSLTElementProcessor to the top of the stack. As a side-effect, set the document order index (simply because this is a convenient place to set it).
34,638
private synchronized void rebuildJournal ( ) throws IOException { if ( journalWriter != null ) { journalWriter . close ( ) ; } Writer writer = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( journalFileTmp ) , Util . US_ASCII ) ) ; try { writer . write ( MAGIC ) ; writer . write ( "\n" ) ; writer . write ( VERSION_1 ) ; writer . write ( "\n" ) ; writer . write ( Integer . toString ( appVersion ) ) ; writer . write ( "\n" ) ; writer . write ( Integer . toString ( valueCount ) ) ; writer . write ( "\n" ) ; writer . write ( "\n" ) ; for ( Entry entry : lruEntries . values ( ) ) { if ( entry . currentEditor != null ) { writer . write ( DIRTY + ' ' + entry . key + '\n' ) ; } else { writer . write ( CLEAN + ' ' + entry . key + entry . getLengths ( ) + '\n' ) ; } } } finally { writer . close ( ) ; } if ( journalFile . exists ( ) ) { renameTo ( journalFile , journalFileBackup , true ) ; } renameTo ( journalFileTmp , journalFile , false ) ; journalFileBackup . delete ( ) ; journalWriter = new BufferedWriter ( new OutputStreamWriter ( new FileOutputStream ( journalFile , true ) , Util . US_ASCII ) ) ; }
Creates a new journal that omits redundant information. This replaces the current journal if it exists.
34,639
public void showLoading ( ) { switchState ( LOADING , null , null , null , null , null , Collections . < Integer > emptyList ( ) ) ; }
Hide content and show the progress bar
34,640
public void onShowNotification ( NotificationView view , View contentView , NotificationEntry entry , int layoutId ) { if ( DBG ) Log . v ( TAG , "onShowNotification - " + entry . ID ) ; final Drawable icon = entry . iconDrawable ; final CharSequence title = entry . title ; final CharSequence text = entry . text ; final CharSequence when = entry . showWhen ? entry . whenFormatted : null ; ChildViewManager mgr = view . getChildViewManager ( ) ; if ( layoutId == R . layout . notification_simple || layoutId == R . layout . notification_large_icon || layoutId == R . layout . notification_full ) { boolean titleChanged = true ; boolean contentChanged = view . isContentLayoutChanged ( ) ; NotificationEntry lastEntry = view . getLastNotification ( ) ; if ( ! contentChanged && title != null && lastEntry != null && title . equals ( lastEntry . title ) ) { titleChanged = false ; } mgr . setImageDrawable ( ICON , icon , titleChanged ) ; mgr . setText ( TITLE , title , titleChanged ) ; mgr . setText ( TEXT , text ) ; mgr . setText ( WHEN , when ) ; } else if ( layoutId == R . layout . notification_simple_2 ) { mgr . setImageDrawable ( ICON , icon ) ; mgr . setText ( TITLE , title ) ; mgr . setText ( TEXT , text ) ; mgr . setText ( WHEN , when ) ; } }
Called when a notification is being displayed. This is the place to update the user interface of child-views for the new notification.
34,641
private double [ ] [ ] createInitialSimplex ( double [ ] initial ) { double [ ] [ ] points = new double [ initial . length + 1 ] [ ] ; for ( int i = 0 ; i < points . length ; i ++ ) { points [ i ] = new double [ initial . length ] ; } System . arraycopy ( initial , 0 , points [ 0 ] , 0 , initial . length ) ; for ( int i = 1 ; i < points . length ; i ++ ) { System . arraycopy ( initial , 0 , points [ i ] , 0 , initial . length ) ; points [ i ] [ i - 1 ] += lambda ; } return points ; }
Create initial n+1 simplex points using given initial point for point[0] and setting all other points to point[0] + lambda+unit_vector_(i-1]
34,642
private LinkedList < Diff > diff_compute ( String text1 , String text2 , boolean checklines , long deadline ) { LinkedList < Diff > diffs = new LinkedList < Diff > ( ) ; if ( text1 . length ( ) == 0 ) { diffs . add ( new Diff ( Operation . INSERT , text2 ) ) ; return diffs ; } if ( text2 . length ( ) == 0 ) { diffs . add ( new Diff ( Operation . DELETE , text1 ) ) ; return diffs ; } String longtext = text1 . length ( ) > text2 . length ( ) ? text1 : text2 ; String shorttext = text1 . length ( ) > text2 . length ( ) ? text2 : text1 ; int i = longtext . indexOf ( shorttext ) ; if ( i != - 1 ) { Operation op = ( text1 . length ( ) > text2 . length ( ) ) ? Operation . DELETE : Operation . INSERT ; diffs . add ( new Diff ( op , longtext . substring ( 0 , i ) ) ) ; diffs . add ( new Diff ( Operation . EQUAL , shorttext ) ) ; diffs . add ( new Diff ( op , longtext . substring ( i + shorttext . length ( ) ) ) ) ; return diffs ; } if ( shorttext . length ( ) == 1 ) { diffs . add ( new Diff ( Operation . DELETE , text1 ) ) ; diffs . add ( new Diff ( Operation . INSERT , text2 ) ) ; return diffs ; } String [ ] hm = diff_halfMatch ( text1 , text2 ) ; if ( hm != null ) { String text1_a = hm [ 0 ] ; String text1_b = hm [ 1 ] ; String text2_a = hm [ 2 ] ; String text2_b = hm [ 3 ] ; String mid_common = hm [ 4 ] ; LinkedList < Diff > diffs_a = diff_main ( text1_a , text2_a , checklines , deadline ) ; LinkedList < Diff > diffs_b = diff_main ( text1_b , text2_b , checklines , deadline ) ; diffs = diffs_a ; diffs . add ( new Diff ( Operation . EQUAL , mid_common ) ) ; diffs . addAll ( diffs_b ) ; return diffs ; } if ( checklines && text1 . length ( ) > 100 && text2 . length ( ) > 100 ) { return diff_lineMode ( text1 , text2 , deadline ) ; } return diff_bisect ( text1 , text2 , deadline ) ; }
Find the differences between two texts. Assumes that the texts do not have any common prefix or suffix.
34,643
private OptionScanNode buildTreeFromNodeList ( List < OptionScanNode > nodeList , int treeNodeType , OptionScanNode lastScanNode ) { if ( nodeList . size ( ) == mDegree ) { nodeList . add ( lastScanNode ) ; List < OptionScanNode > children = nodeList . subList ( 0 , nodeList . size ( ) - 2 ) ; OptionScanNode lastChild = createTree ( nodeList . subList ( nodeList . size ( ) - 2 , nodeList . size ( ) ) , treeNodeType ) ; children . add ( lastChild ) ; return createTree ( children , treeNodeType ) ; } else if ( nodeList . size ( ) < mDegree ) { nodeList . add ( lastScanNode ) ; return createTree ( nodeList , treeNodeType ) ; } else { List < OptionScanNode > subtrees = new ArrayList < > ( ) ; int elemNum = nodeList . size ( ) / mDegree ; int elemRemainder = nodeList . size ( ) % mDegree ; int startIndex = 0 , endIndex = 0 ; List < OptionScanNode > subtreeNodes ; while ( startIndex < nodeList . size ( ) ) { endIndex = ( elemRemainder > 0 ) ? endIndex + elemNum + 1 : endIndex + elemNum ; elemRemainder -- ; subtreeNodes = new ArrayList < > ( nodeList . subList ( startIndex , endIndex ) ) ; if ( ( subtreeNodes . size ( ) == 1 ) && ( endIndex < nodeList . size ( ) ) ) { subtrees . add ( subtreeNodes . get ( 0 ) ) ; } else { subtrees . add ( buildTreeFromNodeList ( subtreeNodes , treeNodeType , lastScanNode ) ) ; } startIndex = endIndex ; } return createTree ( subtrees , treeNodeType ) ; } }
Builds an n-ary tree from a list of nodes to be included in the tree.
34,644
public JettySolrRunner startJettySolrRunner ( ) throws Exception { return startJettySolrRunner ( newNodeName ( ) , jettyConfig . context , jettyConfig ) ; }
Start a new Solr instance, using the default config
34,645
public static long determineCeilingFromMaxValue ( long number , int yNumOfDivs ) { long tempInt = number ; tempInt = tempInt / 5 + tempInt ; if ( tempInt < 100 ) { while ( tempInt % yNumOfDivs != 0 ) { tempInt ++ ; } return tempInt ; } else { int counter = 0 ; String numStr = "" + number ; for ( int i = 0 ; i < numStr . length ( ) - 2 ; i ++ ) { tempInt = tempInt / 10 ; counter ++ ; } tempInt ++ ; while ( tempInt % yNumOfDivs != 0 ) { tempInt ++ ; } return ( long ) Math . pow ( 10 , counter ) * tempInt ; } }
Returns a integer for the maximum y value to be used by the graph that is divisible by the number of y scale divisions.
34,646
boolean isEmpty ( ) { return buffer . length ( ) == 0 ; }
Determines if the concatenation is empty
34,647
public ParseACL ( ParseUser owner ) { this ( ) ; setReadAccess ( owner , true ) ; setWriteAccess ( owner , true ) ; }
Creates an ACL where only the provided user has access.
34,648
public Object resizeCell ( Object cell , mxRectangle bounds ) { return resizeCells ( new Object [ ] { cell } , new mxRectangle [ ] { bounds } ) [ 0 ] ; }
Sets the bounds of the given cell using resizeCells. Returns the cell which was passed to the function.
34,649
public boolean closeDurableClientProxy ( String durableClientId ) throws CacheException { CacheClientProxy ccp = getClientProxy ( durableClientId ) ; if ( ccp == null ) { return false ; } if ( ccp . isPaused ( ) && ! ccp . isConnected ( ) ) { ccp . setKeepAlive ( false ) ; closeDeadProxies ( Collections . singletonList ( ccp ) , true ) ; return true ; } else { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Cannot close running durable client: {}" , durableClientId ) ; } throw new CacheException ( "Cannot close a running durable client : " + durableClientId ) { } ; } }
Shuts down durable client proxy
34,650
private static File createTempFile ( String tempSubdirectoryName , String name ) throws IOException { String tempDirName = System . getProperty ( "java.io.tmpdir" ) ; File tempSubDirectory = new File ( tempDirName + File . separator + tempSubdirectoryName ) ; if ( ! tempSubDirectory . exists ( ) ) { boolean createdDirectory = tempSubDirectory . mkdirs ( ) ; if ( ! createdDirectory ) { throw new IOException ( "Could not create directory for temporary file: " + tempSubDirectory ) ; } } String tempFileName = tempSubDirectory + File . separator + name ; File tempFile = new File ( tempFileName ) ; return tempFile ; }
Create a file object representing the file with the given name in the specified subdirectory of the default "temp" directory. If the specified subdirectory does not exist yet, it is created.
34,651
private boolean isVpoolQuotaUpdate ( Map < String , String > updateMap ) { for ( String iter : updateMap . keySet ( ) ) { if ( iter . startsWith ( "volumes_" ) || iter . startsWith ( "snapshots_" ) || iter . startsWith ( "gigabytes_" ) ) { return true ; } } return false ; }
This function will return true, if the user is updating the quota of a vpool w.r.t a project otherwise it will be set to false, if the user is updating the quota of the project
34,652
public CoreTokenException ( int errorCode , Object [ ] params , int httpStatusCode ) { this . errorCode = errorCode ; this . params = params ; this . httpStatusCode = httpStatusCode ; this . message = getLocalizedMessage ( Locale . getDefault ( ) ) ; }
Creates a core token service exception.
34,653
public BufferedImage toImage ( Drawing drawing , java . util . List < Figure > figures , AffineTransform transform , Dimension imageSize ) { Color background = drawing . get ( CANVAS_FILL_COLOR ) ; double opacity = drawing . get ( CANVAS_FILL_OPACITY ) ; if ( background == null ) { background = new Color ( 0xff , 0xff , 0xff , 0x0 ) ; } else { background = new Color ( background . getRed ( ) , background . getGreen ( ) , background . getBlue ( ) , ( int ) ( background . getAlpha ( ) * opacity ) ) ; } BufferedImage buf = new BufferedImage ( Math . max ( 1 , imageSize . width ) , Math . max ( 1 , imageSize . height ) , ( background . getAlpha ( ) == 255 ) ? BufferedImage . TYPE_INT_RGB : BufferedImage . TYPE_INT_ARGB ) ; Graphics2D g = buf . createGraphics ( ) ; Composite savedComposite = g . getComposite ( ) ; g . setComposite ( AlphaComposite . getInstance ( AlphaComposite . SRC ) ) ; g . setColor ( background ) ; g . fillRect ( 0 , 0 , buf . getWidth ( ) , buf . getHeight ( ) ) ; g . setComposite ( savedComposite ) ; setRenderingHints ( g ) ; g . transform ( transform ) ; for ( Figure f : figures ) { f . draw ( g ) ; } g . dispose ( ) ; if ( imageType != BufferedImage . TYPE_INT_ARGB ) { BufferedImage buf2 = new BufferedImage ( buf . getWidth ( ) , buf . getHeight ( ) , imageType ) ; g = buf2 . createGraphics ( ) ; setRenderingHints ( g ) ; g . setComposite ( AlphaComposite . getInstance ( AlphaComposite . SRC ) ) ; g . drawImage ( buf , 0 , 0 , null ) ; g . dispose ( ) ; buf . flush ( ) ; buf = buf2 ; } return buf ; }
Creates a BufferedImage from the specified list of figures.
34,654
public void testSubmitCallable ( ) throws Throwable { ExecutorService e = new ForkJoinPool ( 1 ) ; PoolCleaner cleaner = null ; try { cleaner = cleaner ( e ) ; Future < String > future = e . submit ( new StringTask ( ) ) ; assertSame ( TEST_STRING , future . get ( ) ) ; assertTrue ( future . isDone ( ) ) ; assertFalse ( future . isCancelled ( ) ) ; } finally { if ( cleaner != null ) { cleaner . close ( ) ; } } }
Completed submit(callable) returns result
34,655
public static void markup ( Element e , String text , String linkCssClass ) { e . setInnerHTML ( "" ) ; List < String > paragraphs = StringUtils . split ( text , "\n\n" ) ; for ( String paragraph : paragraphs ) { markupParagraph ( e , paragraph , linkCssClass ) ; } }
Scans a string converting any recognizable html links into an anchor tag and replacing newlines with a &lt;br/&gt;. Once built the result is appended to the provided element.
34,656
public String generateDocumentation ( String containerId ) throws Exception { StringBuilder output = new StringBuilder ( ) ; output . append ( "{note}This page has been automatically generated by Cargo's build. " + "Do not edit it directly as it'll be overwritten next time it's generated again." + "{note}" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( LINE_SEPARATOR ) ; if ( containerId . equals ( "geronimo1x" ) ) { output . append ( "{note}The Geronimo 1.x CARGO container REQUIRES Geronimo 1.1.1.{note}" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( LINE_SEPARATOR ) ; } else if ( containerId . equals ( "glassfish4x" ) ) { output . append ( "{info}The GlassFish 4.x container also works with " ) ; output . append ( "[Payara|http://www.payara.fish/].{info}" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( LINE_SEPARATOR ) ; } else if ( containerId . startsWith ( "jboss6" ) || containerId . startsWith ( "jboss7" ) || containerId . startsWith ( "wildfly10" ) ) { output . append ( "{note}With the opening of the JBoss EAP to the public and the split " ) ; output . append ( "between JBoss and WildFly, the below naming correspondance should be " ) ; output . append ( "used with JBoss EAP containers:" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( "* What Cargo calls [JBoss 6.1.x] is what JBoss refers to as JBoss " ) ; output . append ( "Application Server version 6.1; i.e. the version released in August " ) ; output . append ( "2011" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( "* What Cargo calls [JBoss 7.2.x] is what JBoss refers to as JBoss " ) ; output . append ( "Enterprise Application Platform (EAP) version 6.1; i.e. the build " ) ; output . append ( "from JBoss Application Server (AS) version 7.2 released in May 2013" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( "* What Cargo calls [JBoss 7.3.x] is what JBoss refers to as JBoss " ) ; output . append ( "Enterprise Application Platform (EAP) version 6.2; i.e. the build " ) ; output . append ( "from JBoss Application Server (AS) version 7.3 released in October " ) ; output . append ( "2013" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( "* What Cargo calls [JBoss 7.4.x] is what JBoss refers to as JBoss " ) ; output . append ( "Enterprise Application Platform (EAP) version 6.3; i.e. the build " ) ; output . append ( "from JBoss Application Server (AS) version 7.4 released in June " ) ; output . append ( "2014" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( "* What Cargo calls [JBoss 7.5.x] is what JBoss refers to as JBoss " ) ; output . append ( "Enterprise Application Platform (EAP) version 6.4; i.e. the build " ) ; output . append ( "from JBoss Application Server (AS) version 7.5 released in October " ) ; output . append ( "2015" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( "* The [WildFly 10.x] container can be used with the JBoss Enterprise " ) ; output . append ( "Application Platform (EAP) version 7; i.e. the version released in " ) ; output . append ( "May 2016" ) ; output . append ( "{note}" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( LINE_SEPARATOR ) ; } else if ( containerId . startsWith ( "weblogic12" ) ) { if ( containerId . equals ( "weblogic12x" ) ) { output . append ( "{info}The WebLogic 12.x container lacks from the many features " ) ; output . append ( "provided by the [WebLogic 12.1.x] and [WebLogic 12.2.x] " ) ; output . append ( "containers - We would hence recommend using one of these " ) ; output . append ( "instead of the WebLogic 12.x container.{info}" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( LINE_SEPARATOR ) ; } output . append ( "{note}" ) ; output . append ( "If you are using the WebLogic 12 Developer's Edition, after you have " ) ; output . append ( "downloaded the distribution, please remember to also configure " ) ; output . append ( "WebLogic." ) ; output . append ( LINE_SEPARATOR ) ; output . append ( "You can read http://www.oracle.com/webfolder/technetwork/tutorials/" ) ; output . append ( "obe/java/wls_12c_netbeans_install/wls_12c_netbeans_install.html for " ) ; output . append ( "details." ) ; output . append ( "{note}" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( LINE_SEPARATOR ) ; } else if ( containerId . startsWith ( "websphere" ) ) { output . append ( "{note}" ) ; output . append ( "The WebSphere container does +not+ support WebSphere Application " ) ; output . append ( "Server Community Edition, please prefer to use the \"full\" " ) ; output . append ( "WebSphere package or WebSphere Application Server for Developers." ) ; output . append ( "{note}" ) ; output . append ( LINE_SEPARATOR ) ; output . append ( LINE_SEPARATOR ) ; } output . append ( generateContainerFeaturesText ( containerId ) ) ; output . append ( LINE_SEPARATOR ) ; output . append ( generateConfigurationFeaturesText ( containerId ) ) ; output . append ( LINE_SEPARATOR ) ; output . append ( generateDeployerFeaturesText ( containerId ) ) ; output . append ( LINE_SEPARATOR ) ; output . append ( generateOtherFeaturesText ( containerId ) ) ; output . append ( LINE_SEPARATOR ) ; output . append ( generateConfigurationPropertiesText ( containerId ) ) ; output . append ( LINE_SEPARATOR ) ; output . append ( generateSamplesInfoText ( containerId ) ) ; output . append ( LINE_SEPARATOR ) ; return output . toString ( ) ; }
Generate documentation for a given container.
34,657
public AbstractMicroserviceClient ( String serviceName ) { this . serviceName = serviceName . toUpperCase ( ) ; }
force the descendants to call super("SERVICE_NAME")
34,658
@ Override public boolean isVisible ( ) { return false ; }
This is a workaround to fix a Swing bug with causes the drag cursor to flicker. See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6700748 TODO: Occasionally check whether this bug was resolved by Sun.
34,659
protected List < MethodNode > findMethodsWithGenerated ( ClassNode receiver , String name ) { List < MethodNode > methods = receiver . getMethods ( name ) ; if ( methods . isEmpty ( ) || receiver . isResolved ( ) ) return methods ; List < MethodNode > result = addGeneratedMethods ( receiver , methods ) ; return result ; }
This method returns the list of methods named against the supplied parameter that are defined on the specified receiver, but it will also add "non existing" methods that will be generated afterwards by the compiler, for example if a method is using default values and that the specified class node isn't compiled yet.
34,660
public static String buildString ( Consumer < StringPrinter > printer ) { StringBuilder builder = new StringBuilder ( ) ; printer . accept ( new StringPrinter ( null ) ) ; return builder . toString ( ) ; }
Easy way to create a String using a StringPrinter.
34,661
private boolean canAddVelocimacro ( String name , String sourceTemplate ) { if ( getAutoload ( ) ) { for ( int i = 0 ; i < macroLibVec . size ( ) ; i ++ ) { String lib = ( String ) macroLibVec . elementAt ( i ) ; if ( lib . equals ( sourceTemplate ) ) { return true ; } } } if ( ! addNewAllowed ) { logVMMessageWarn ( "Velocimacro : VM addition rejected : " + name + " : inline VMs not allowed." ) ; return false ; } if ( ! templateLocal ) { if ( isVelocimacro ( name , sourceTemplate ) && ! replaceAllowed ) { logVMMessageWarn ( "Velocimacro : VM addition rejected : " + name + " : inline not allowed to replace existing VM" ) ; return false ; } } return true ; }
determines if a given macro/namespace (name, source) combo is allowed to be added
34,662
public void initialize ( Callbacks callbacks ) { synchronized ( mLock ) { unbindItemInfosAndClearQueuedBindRunnables ( ) ; mCallbacks = new WeakReference < Callbacks > ( callbacks ) ; } }
Set this as the current Launcher activity object for the loader.
34,663
public String removeOption ( String name ) { if ( options != null ) { ReplOption existingOption = null ; for ( ReplOption replOption : options ) { if ( name . equals ( replOption . getOptionName ( ) ) ) existingOption = replOption ; } if ( existingOption != null ) { options . remove ( existingOption ) ; return existingOption . getOptionValue ( ) ; } } return null ; }
Remove an option and return its value if it exists.
34,664
public static String generatePop ( final ITranslationEnvironment environment , final long offset , final OperandSize size , final String target , final List < ReilInstruction > instructions ) throws IllegalArgumentException { Preconditions . checkNotNull ( environment , "Error: Argument environment can't be null" ) ; Preconditions . checkNotNull ( size , "Error: Argument size can't be null" ) ; Preconditions . checkNotNull ( instructions , "Error: Argument instructions can't be null" ) ; final OperandSize archSize = environment . getArchitectureSize ( ) ; final OperandSize resultSize = TranslationHelpers . getNextSize ( archSize ) ; final String loadedValue = target == null ? environment . getNextVariableString ( ) : target ; instructions . add ( ReilHelpers . createLdm ( offset , archSize , "esp" , size , loadedValue ) ) ; final String tempEsp = environment . getNextVariableString ( ) ; final String truncateMask = String . valueOf ( TranslationHelpers . getAllBitsMask ( archSize ) ) ; final String stackValue = String . valueOf ( size . getByteSize ( ) ) ; instructions . add ( ReilHelpers . createAdd ( offset + 1 , archSize , "esp" , archSize , stackValue , resultSize , tempEsp ) ) ; instructions . add ( ReilHelpers . createAnd ( offset + 2 , resultSize , tempEsp , archSize , truncateMask , archSize , "esp" ) ) ; return loadedValue ; }
Generates code that pops a value off the stack
34,665
public void loadStatus ( ) throws IOException , SolrCoreLoadException { String command = String . format ( "http://%s:%s/solr/admin/cores?action=STATUS&core=%s" , host , SolrInteractionUtils . DEFAULT_SOLR_PORT , name ) ; InputStream result = null ; try { result = SolrInteractionUtils . executeSolrCommandAndGetInputStream ( command ) ; List < String > data = SolrInteractionUtils . parseStatusResponse ( result , new String [ ] { String . format ( "/response/lst[@name='status']/lst[@name='%s']/lst[@name='index']/int[@name='numDocs']/text()" , name ) , String . format ( "/response/lst[@name='status']/lst[@name='%s']/lst[@name='index']/int[@name='maxDoc']/text()" , name ) , String . format ( "/response/lst[@name='status']/lst[@name='%s']/lst[@name='index']/int[@name='deletedDocs']/text()" , name ) , String . format ( "/response/lst[@name='status']/lst[@name='%s']/lst[@name='index']/long[@name='version']/text()" , name ) , String . format ( "/response/lst[@name='status']/lst[@name='%s']/lst[@name='index']/int[@name='segmentCount']/text()" , name ) , String . format ( "/response/lst[@name='status']/lst[@name='%s']/lst[@name='index']/date[@name='lastModified']/text()" , name ) , String . format ( "/response/lst[@name='status']/lst[@name='%s']/lst[@name='index']/long[@name='sizeInBytes']/text()" , name ) , String . format ( "/response/lst[@name='initFailures']/lst[@name='%s']/text()" , name ) , String . format ( "/response/lst[@name='status']/lst[@name='%s']/lst[@name='index']/bool[@name='current']/text()" , name ) } ) ; boolean isCleanCore = StringUtils . isBlank ( data . get ( 7 ) ) ; if ( ! isCleanCore ) { String message = String . format ( "Core %s has initialization exceptions.." , name ) ; logger . info ( message ) ; throw new SolrCoreLoadException ( message ) ; } numDocs = Integer . parseInt ( data . get ( 0 ) ) ; if ( ! StringUtils . isBlank ( data . get ( 1 ) ) ) { maxDocs = Integer . parseInt ( data . get ( 1 ) ) ; } deletedDocs = Integer . parseInt ( data . get ( 2 ) ) ; version = Long . parseLong ( data . get ( 3 ) ) ; if ( ! StringUtils . isBlank ( data . get ( 4 ) ) ) { segmentCount = Integer . parseInt ( data . get ( 4 ) ) ; } if ( ! StringUtils . isBlank ( data . get ( 5 ) ) ) { lastModified = data . get ( 5 ) ; } if ( ! StringUtils . isBlank ( data . get ( 6 ) ) ) { sizeInBytes = Long . parseLong ( data . get ( 6 ) ) ; } if ( ! StringUtils . isBlank ( data . get ( 8 ) ) ) { this . current = Boolean . parseBoolean ( data . get ( 8 ) ) ; } this . available = true ; } catch ( Exception e ) { throw new SolrCoreLoadException ( "Exception while trying to get core status for " + name ) ; } finally { if ( result != null ) { result . close ( ) ; } } }
Load the solr core status
34,666
private String optNodeDigest ( ParseTreeNode node ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( '(' ) ; for ( ParseTreeNode child : node . children ( ) ) { nodeDigest ( child , sb ) ; if ( sb . length ( ) > longestKeyLength ) { return null ; } } nodeTail ( node , sb ) ; if ( sb . length ( ) > longestKeyLength ) { return null ; } return sb . toString ( ) ; }
Returns the digest of node, or null if the digest would be longer than the longest key in the knowledge base, and thus unable to match any key in the knowledge base.
34,667
public Map < Span , SuffixArraySample > lookupFrequentSourceNgrams ( int sampleSize , int minOccurrences ) { if ( sampleSize >= minOccurrences ) throw new IllegalArgumentException ( ) ; if ( srcSuffixArray . length == 0 ) return Collections . emptyMap ( ) ; logger . info ( "Building query cache with threshold {}" , minOccurrences ) ; Map < Span , SuffixArraySample > queryCache = new HashMap < > ( 1000 ) ; int nCnt = 1 , nnCnt = 1 , nnnCnt = 1 ; int nStart = 0 , nnStart = 0 , nnnStart = 0 ; Suffix firstSuffix = new Suffix ( srcSuffixArray [ 0 ] , true ) ; Span nSpan = new Span ( firstSuffix , 1 ) , nnSpan = new Span ( firstSuffix , 2 ) , nnnSpan = new Span ( firstSuffix , 3 ) ; for ( int i = 1 ; i < srcSuffixArray . length ; ++ i ) { Suffix suffix = new Suffix ( srcSuffixArray [ i ] , true ) ; Span nSpanThis = new Span ( suffix , 1 ) ; Span nnSpanThis = new Span ( suffix , 2 ) ; Span nnnSpanThis = new Span ( suffix , 3 ) ; nCnt = checkSpan ( nSpan , nSpanThis , nStart , i , nCnt , minOccurrences , sampleSize , queryCache ) ; if ( nCnt == 1 ) { nStart = i ; nSpan = nSpanThis ; } nnCnt = checkSpan ( nnSpan , nnSpanThis , nnStart , i , nnCnt , minOccurrences , sampleSize , queryCache ) ; if ( nnCnt == 1 ) { nnStart = i ; nnSpan = nnSpanThis ; } nnnCnt = checkSpan ( nnnSpan , nnnSpanThis , nnnStart , i , nnnCnt , minOccurrences , sampleSize , queryCache ) ; if ( nnnCnt == 1 ) { nnnStart = i ; nnnSpan = nnnSpanThis ; } } ; logger . info ( "Query cache size: {}" , queryCache . size ( ) ) ; logger . info ( "Creating target unigram caches for the count() function..." ) ; this . tgtCountLBCache = new int [ vocabulary . size ( ) ] ; Arrays . fill ( tgtCountLBCache , - 1 ) ; this . tgtCountUBCache = new int [ vocabulary . size ( ) ] ; Arrays . fill ( tgtCountUBCache , - 1 ) ; int lastId = tgtBitext [ tgtSuffixArray [ 0 ] ] ; for ( int i = 0 ; i < tgtSuffixArray . length ; ++ i ) { int tgtId = tgtBitext [ tgtSuffixArray [ i ] ] ; assert tgtId >= 0 ; if ( tgtCountLBCache [ tgtId ] < 0 ) { tgtCountLBCache [ tgtId ] = i ; } if ( lastId != tgtId ) { tgtCountUBCache [ lastId ] = i - 1 ; assert tgtCountUBCache [ lastId ] >= tgtCountLBCache [ lastId ] : String . format ( "%d %d %d" , i , lastId , tgtId ) ; } lastId = tgtId ; } tgtCountUBCache [ lastId ] = tgtSuffixArray . length ; assert tgtCountUBCache [ lastId ] >= tgtCountLBCache [ lastId ] : String . format ( "%d %d final" , tgtSuffixArray . length , lastId ) ; logger . info ( "Finished building count() cache." ) ; return queryCache ; }
Find all source spans up to dimension == 3. TODO(spenceg) Lopez reports finding a few order=5 n-grams of high frequency so maybe generalize this lookup.
34,668
@ Override public void write ( byte [ ] b , int off , int len ) { if ( ( off < 0 ) || ( off > b . length ) || ( len < 0 ) || ( ( off + len ) > b . length ) || ( ( off + len ) < 0 ) ) { throw new IndexOutOfBoundsException ( ) ; } else if ( len == 0 ) { return ; } synchronized ( this ) { int newcount = count + len ; int remaining = len ; int inBufferPos = count - filledBufferSum ; while ( remaining > 0 ) { int part = Math . min ( remaining , currentBuffer . length - inBufferPos ) ; System . arraycopy ( b , off + len - remaining , currentBuffer , inBufferPos , part ) ; remaining -= part ; if ( remaining > 0 ) { needNewBuffer ( newcount ) ; inBufferPos = 0 ; } } count = newcount ; } }
Write the bytes to byte array.
34,669
public static void copy ( String in , Writer out ) throws IOException { Assert . notNull ( in , "No input String specified" ) ; Assert . notNull ( out , "No Writer specified" ) ; try { out . write ( in ) ; } finally { try { out . close ( ) ; } catch ( IOException ex ) { } } }
Copy the contents of the given String to the given output Writer. Closes the writer when done.
34,670
public static String convertByte2HexString ( byte b ) { char u8 = convertByte2Uint8 ( b ) ; return Integer . toHexString ( u8 ) ; }
Convert byte to Hex String
34,671
@ Override protected void deviceDrawLine ( int xBegin , int yBegin , int xEnd , int yEnd , Color color ) { Stroke stroke = getStroke ( ) ; if ( stroke instanceof BasicStroke ) { BasicStroke lineStroke = ( BasicStroke ) stroke ; if ( lineStroke . getDashArray ( ) != null ) { draw ( new Line2D . Float ( xBegin , yBegin , xEnd , yEnd ) ) ; return ; } float lineWidth = lineStroke . getLineWidth ( ) ; Point2D . Float penSize = new Point2D . Float ( lineWidth , lineWidth ) ; AffineTransform deviceTransform = getTransform ( ) ; deviceTransform . deltaTransform ( penSize , penSize ) ; float deviceLineWidth = Math . min ( Math . abs ( penSize . x ) , Math . abs ( penSize . y ) ) ; Point2D . Float begin_pos = new Point2D . Float ( xBegin , yBegin ) ; deviceTransform . transform ( begin_pos , begin_pos ) ; Point2D . Float end_pos = new Point2D . Float ( xEnd , yEnd ) ; deviceTransform . transform ( end_pos , end_pos ) ; int endCap = lineStroke . getEndCap ( ) ; int lineJoin = lineStroke . getLineJoin ( ) ; if ( ( end_pos . getX ( ) == begin_pos . getX ( ) ) && ( end_pos . getY ( ) == begin_pos . getY ( ) ) ) { endCap = BasicStroke . CAP_ROUND ; } WPrinterJob wPrinterJob = ( WPrinterJob ) getPrinterJob ( ) ; if ( wPrinterJob . selectStylePen ( endCap , lineJoin , deviceLineWidth , color ) ) { wPrinterJob . moveTo ( ( float ) begin_pos . getX ( ) , ( float ) begin_pos . getY ( ) ) ; wPrinterJob . lineTo ( ( float ) end_pos . getX ( ) , ( float ) end_pos . getY ( ) ) ; } else { double lowerRes = Math . min ( wPrinterJob . getXRes ( ) , wPrinterJob . getYRes ( ) ) ; if ( ( endCap == BasicStroke . CAP_ROUND ) || ( ( ( xBegin == xEnd ) || ( yBegin == yEnd ) ) && ( deviceLineWidth / lowerRes < MAX_THINLINE_INCHES ) ) ) { wPrinterJob . selectPen ( deviceLineWidth , color ) ; wPrinterJob . moveTo ( ( float ) begin_pos . getX ( ) , ( float ) begin_pos . getY ( ) ) ; wPrinterJob . lineTo ( ( float ) end_pos . getX ( ) , ( float ) end_pos . getY ( ) ) ; } else { draw ( new Line2D . Float ( xBegin , yBegin , xEnd , yEnd ) ) ; } } } }
Draw a line using a pen created using the specified color and current stroke properties.
34,672
public void seek ( long seekBytes ) throws FileNotFoundException , IOException , InterruptedException { try { if ( fileInput != null ) { fileInput . close ( ) ; } fileInput = new FileInputStream ( file ) ; fileChannel = fileInput . getChannel ( ) ; fileChannel . position ( seekBytes ) ; } catch ( ClosedByInterruptException e ) { throw new InterruptedException ( ) ; } bufferedInput = new BufferedInputStream ( fileInput , size ) ; dataInput = new DataInputStream ( bufferedInput ) ; offset = seekBytes ; markOffset = - 1 ; available ( ) ; }
Seek to a specific offset in the file.
34,673
public NumberRangeModel ( Number lo , Number hi , Number min , Number max ) { m_type = TypeLib . getPrimitiveType ( min . getClass ( ) ) ; setValueRange ( lo , hi , min , max ) ; }
Create a new NumberRangeModel for the given range.
34,674
public static void printNode ( Node node , OutputStream out ) throws IOException { printNode ( node , new StreamResult ( out ) ) ; out . write ( '\n' ) ; out . flush ( ) ; }
Serializes an XML Node to an OutputStream (as UTF-8).
34,675
public void actionPerformed ( ActionEvent e ) { if ( EDIT . equals ( e . getActionCommand ( ) ) ) { button . setBackground ( currentColor ) ; colorChooser . setColor ( currentColor ) ; dialog . setVisible ( true ) ; fireEditingStopped ( ) ; } else { currentColor = colorChooser . getColor ( ) ; } }
Handles events from the editor button and from the dialog's OK button.
34,676
@ Override public double cos ( int step ) { step = Math . abs ( step ) % steps ; if ( step < costable . length ) { return costable [ step ] ; } if ( step > halfsteps ) { step = steps - step ; if ( step < costable . length ) { return costable [ step ] ; } } step = halfsteps - step ; return - costable [ step ] ; }
Get Cosine by step value.
34,677
public void addClickingListener ( OnWheelClickedListener listener ) { clickingListeners . add ( listener ) ; }
Adds wheel clicking listener
34,678
public static Place createPlace ( final String rawJSON ) throws TwitterException { try { final JSONObject json = new JSONObject ( rawJSON ) ; return placeConstructor . newInstance ( json ) ; } catch ( final InstantiationException e ) { throw new TwitterException ( e ) ; } catch ( final IllegalAccessException e ) { throw new AssertionError ( e ) ; } catch ( final InvocationTargetException e ) { throw new TwitterException ( e ) ; } catch ( final JSONException e ) { throw new TwitterException ( e ) ; } }
Constructs a Place object from rawJSON string.
34,679
private static DatabaseFieldConfig buildConfig ( DatabaseField databaseField , String tableName , Field field ) throws Exception { InvocationHandler proxy = Proxy . getInvocationHandler ( databaseField ) ; if ( proxy . getClass ( ) != annotationFactoryClazz ) { return null ; } Object elementsObject = elementsField . get ( proxy ) ; if ( elementsObject == null ) { return null ; } DatabaseFieldConfig config = new DatabaseFieldConfig ( field . getName ( ) ) ; Object [ ] objs = ( Object [ ] ) elementsObject ; for ( int i = 0 ; i < configFieldNums . length ; i ++ ) { Object value = valueField . get ( objs [ i ] ) ; if ( value != null ) { assignConfigField ( configFieldNums [ i ] , config , field , value ) ; } } return config ; }
Instead of calling the annotation methods directly, we peer inside the proxy and investigate the array of AnnotationMember objects stored by the AnnotationFactory.
34,680
protected final void fireIndexedPropertyChange ( String propertyName , int index , Object oldValue , Object newValue ) { PropertyChangeSupport aChangeSupport = this . changeSupport ; if ( aChangeSupport == null ) { return ; } aChangeSupport . fireIndexedPropertyChange ( propertyName , index , oldValue , newValue ) ; }
Report a bound indexed property update to any registered listeners.<p> No event is fired if old and new values are equal and non-null.
34,681
public void testConstrStringWithExponentWithPoint3 ( ) { String a = "2380964839238475457356735674573563567890.295784902768787678287E+21" ; int aScale = 0 ; BigInteger bA = new BigInteger ( "2380964839238475457356735674573563567890295784902768787678287" ) ; BigDecimal aNumber = new BigDecimal ( a ) ; assertEquals ( "incorrect value" , bA , aNumber . unscaledValue ( ) ) ; assertEquals ( "incorrect scale" , aScale , aNumber . scale ( ) ) ; }
new BigDecimal(String value); value contains both exponent and decimal point
34,682
public static int geometric ( double p ) { return ( int ) Math . ceil ( Math . log ( uniform ( ) ) / Math . log ( 1.0 - p ) ) ; }
Return an integer with a geometric distribution with mean 1/p.
34,683
@ Override public Object clone ( ) throws CloneNotSupportedException { SegmentedTimeline clone = ( SegmentedTimeline ) super . clone ( ) ; return clone ; }
Returns a clone of the timeline.
34,684
public boolean addItemUnique ( Playlist p ) { if ( ! mPlaylists . contains ( p ) ) { mPlaylists . add ( p ) ; return true ; } else { return false ; } }
Adds the playlist to the adapter if it's not already there
34,685
private void showFindReplaceDialog ( ) { JFrame frame = new JFrame ( ) ; FindReplaceDialog dialog = new FindReplaceDialog ( frame , this ) ; frame . setContentPane ( dialog ) ; frame . setTitle ( "Find / Replace" ) ; frame . setVisible ( true ) ; frame . pack ( ) ; frame . setLocationRelativeTo ( null ) ; }
Show the find/replace dialog
34,686
public void clickByImage ( String targetImgPath ) { Point2D coords = getCoords ( takeScreenshot ( ) , targetImgPath ) ; if ( ( coords . getX ( ) >= 0 ) && ( coords . getY ( ) >= 0 ) ) { driver . tap ( 1 , ( int ) coords . getX ( ) , ( int ) coords . getY ( ) , 100 ) ; } else { throw new ElementNotVisibleException ( "Element not found - " + targetImgPath ) ; } }
clickByImage is the main method that you should be using to tap on elements on screen using an image.
34,687
public static double round ( double number ) { return ( double ) Math . round ( number * Math . pow ( 10 , 0 ) ) / Math . pow ( 10 , 0 ) ; }
Return the double value number rounded to ndigits digits after the decimal point. If ndigits is omitted, it defaults to zero. The result is a double.
34,688
void write ( Environment env , DataOutputStream out , ConstantPool tab ) throws IOException { out . writeByte ( CONSTANT_UTF8 ) ; out . writeUTF ( str ) ; }
Write the constant to the output stream
34,689
public JPopupMenu createNetworkContextMenu ( ) { JPopupMenu contextMenu = super . createNetworkContextMenu ( ) ; contextMenu . addSeparator ( ) ; contextMenu . add ( NetworkScriptMenu . getNetworkScriptMenu ( this ) ) ; return contextMenu ; }
This version adds the script menu.
34,690
@ Override public Object clone ( ) { try { return super . clone ( ) ; } catch ( CloneNotSupportedException e ) { throw new RuntimeException ( e . getMessage ( ) ) ; } }
Create and return a copy of this object.
34,691
public void pushStylesheet ( Stylesheet s ) { if ( m_stylesheets . size ( ) == 0 ) m_stylesheetRoot = ( StylesheetRoot ) s ; m_stylesheets . push ( s ) ; }
Push the current stylesheet being constructed. If no other stylesheets have been pushed onto the stack, assume the argument is a stylesheet root, and also set the stylesheet root member.
34,692
public Object next ( ) throws IOException { if ( prevPos <= 0 ) return null ; long endOfThisRecord = prevPos ; int thisLength = nextLength ; long recordStart = prevPos - thisLength ; prevPos = recordStart - 4 ; if ( prevPos <= 0 ) return null ; long bufferPos = fis . getBufferPos ( ) ; if ( prevPos >= bufferPos ) { } else { long seekPos = endOfThisRecord - fis . getBufferSize ( ) ; seekPos = Math . min ( seekPos , prevPos ) ; seekPos = Math . max ( seekPos , 0 ) ; fis . seek ( seekPos ) ; fis . peek ( ) ; } fis . seek ( prevPos ) ; nextLength = fis . readInt ( ) ; Object o = codec . readVal ( fis ) ; return o ; }
Returns the next object from the log, or null if none available.
34,693
public Element drawShape ( int x , int y , int w , int h , Map < String , Object > style ) { String fillColor = mxUtils . getString ( style , mxConstants . STYLE_FILLCOLOR , "none" ) ; String strokeColor = mxUtils . getString ( style , mxConstants . STYLE_STROKECOLOR ) ; float strokeWidth = ( float ) ( mxUtils . getFloat ( style , mxConstants . STYLE_STROKEWIDTH , 1 ) * scale ) ; String shape = mxUtils . getString ( style , mxConstants . STYLE_SHAPE ) ; Element elem = null ; Element background = null ; if ( shape . equals ( mxConstants . SHAPE_IMAGE ) ) { String img = getImageForStyle ( style ) ; if ( img != null ) { elem = document . createElement ( "image" ) ; elem . setAttribute ( "x" , String . valueOf ( x ) ) ; elem . setAttribute ( "y" , String . valueOf ( y ) ) ; elem . setAttribute ( "width" , String . valueOf ( w ) ) ; elem . setAttribute ( "height" , String . valueOf ( h ) ) ; elem . setAttributeNS ( mxConstants . NS_XLINK , "xlink:href" , img ) ; } } else if ( shape . equals ( mxConstants . SHAPE_LINE ) ) { String direction = mxUtils . getString ( style , mxConstants . STYLE_DIRECTION , mxConstants . DIRECTION_EAST ) ; String d = null ; if ( direction . equals ( mxConstants . DIRECTION_EAST ) || direction . equals ( mxConstants . DIRECTION_WEST ) ) { int mid = ( int ) ( y + h / 2 ) ; d = "M " + x + " " + mid + " L " + ( x + w ) + " " + mid ; } else { int mid = ( int ) ( x + w / 2 ) ; d = "M " + mid + " " + y + " L " + mid + " " + ( y + h ) ; } elem = document . createElement ( "path" ) ; elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_ELLIPSE ) ) { elem = document . createElement ( "ellipse" ) ; elem . setAttribute ( "cx" , String . valueOf ( x + w / 2 ) ) ; elem . setAttribute ( "cy" , String . valueOf ( y + h / 2 ) ) ; elem . setAttribute ( "rx" , String . valueOf ( w / 2 ) ) ; elem . setAttribute ( "ry" , String . valueOf ( h / 2 ) ) ; } else if ( shape . equals ( mxConstants . SHAPE_DOUBLE_ELLIPSE ) ) { elem = document . createElement ( "g" ) ; background = document . createElement ( "ellipse" ) ; background . setAttribute ( "cx" , String . valueOf ( x + w / 2 ) ) ; background . setAttribute ( "cy" , String . valueOf ( y + h / 2 ) ) ; background . setAttribute ( "rx" , String . valueOf ( w / 2 ) ) ; background . setAttribute ( "ry" , String . valueOf ( h / 2 ) ) ; elem . appendChild ( background ) ; int inset = ( int ) ( ( 3 + strokeWidth ) * scale ) ; Element foreground = document . createElement ( "ellipse" ) ; foreground . setAttribute ( "fill" , "none" ) ; foreground . setAttribute ( "stroke" , strokeColor ) ; foreground . setAttribute ( "stroke-width" , String . valueOf ( strokeWidth ) ) ; foreground . setAttribute ( "cx" , String . valueOf ( x + w / 2 ) ) ; foreground . setAttribute ( "cy" , String . valueOf ( y + h / 2 ) ) ; foreground . setAttribute ( "rx" , String . valueOf ( w / 2 - inset ) ) ; foreground . setAttribute ( "ry" , String . valueOf ( h / 2 - inset ) ) ; elem . appendChild ( foreground ) ; } else if ( shape . equals ( mxConstants . SHAPE_RHOMBUS ) ) { elem = document . createElement ( "path" ) ; String d = "M " + ( x + w / 2 ) + " " + y + " L " + ( x + w ) + " " + ( y + h / 2 ) + " L " + ( x + w / 2 ) + " " + ( y + h ) + " L " + x + " " + ( y + h / 2 ) ; elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_TRIANGLE ) ) { elem = document . createElement ( "path" ) ; String direction = mxUtils . getString ( style , mxConstants . STYLE_DIRECTION , "" ) ; String d = null ; if ( direction . equals ( mxConstants . DIRECTION_NORTH ) ) { d = "M " + x + " " + ( y + h ) + " L " + ( x + w / 2 ) + " " + y + " L " + ( x + w ) + " " + ( y + h ) ; } else if ( direction . equals ( mxConstants . DIRECTION_SOUTH ) ) { d = "M " + x + " " + y + " L " + ( x + w / 2 ) + " " + ( y + h ) + " L " + ( x + w ) + " " + y ; } else if ( direction . equals ( mxConstants . DIRECTION_WEST ) ) { d = "M " + ( x + w ) + " " + y + " L " + x + " " + ( y + h / 2 ) + " L " + ( x + w ) + " " + ( y + h ) ; } else { d = "M " + x + " " + y + " L " + ( x + w ) + " " + ( y + h / 2 ) + " L " + x + " " + ( y + h ) ; } elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_HEXAGON ) ) { elem = document . createElement ( "path" ) ; String direction = mxUtils . getString ( style , mxConstants . STYLE_DIRECTION , "" ) ; String d = null ; if ( direction . equals ( mxConstants . DIRECTION_NORTH ) || direction . equals ( mxConstants . DIRECTION_SOUTH ) ) { d = "M " + ( x + 0.5 * w ) + " " + y + " L " + ( x + w ) + " " + ( y + 0.25 * h ) + " L " + ( x + w ) + " " + ( y + 0.75 * h ) + " L " + ( x + 0.5 * w ) + " " + ( y + h ) + " L " + x + " " + ( y + 0.75 * h ) + " L " + x + " " + ( y + 0.25 * h ) ; } else { d = "M " + ( x + 0.25 * w ) + " " + y + " L " + ( x + 0.75 * w ) + " " + y + " L " + ( x + w ) + " " + ( y + 0.5 * h ) + " L " + ( x + 0.75 * w ) + " " + ( y + h ) + " L " + ( x + 0.25 * w ) + " " + ( y + h ) + " L " + x + " " + ( y + 0.5 * h ) ; } elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_CLOUD ) ) { elem = document . createElement ( "path" ) ; String d = "M " + ( x + 0.25 * w ) + " " + ( y + 0.25 * h ) + " C " + ( x + 0.05 * w ) + " " + ( y + 0.25 * h ) + " " + x + " " + ( y + 0.5 * h ) + " " + ( x + 0.16 * w ) + " " + ( y + 0.55 * h ) + " C " + x + " " + ( y + 0.66 * h ) + " " + ( x + 0.18 * w ) + " " + ( y + 0.9 * h ) + " " + ( x + 0.31 * w ) + " " + ( y + 0.8 * h ) + " C " + ( x + 0.4 * w ) + " " + ( y + h ) + " " + ( x + 0.7 * w ) + " " + ( y + h ) + " " + ( x + 0.8 * w ) + " " + ( y + 0.8 * h ) + " C " + ( x + w ) + " " + ( y + 0.8 * h ) + " " + ( x + w ) + " " + ( y + 0.6 * h ) + " " + ( x + 0.875 * w ) + " " + ( y + 0.5 * h ) + " C " + ( x + w ) + " " + ( y + 0.3 * h ) + " " + ( x + 0.8 * w ) + " " + ( y + 0.1 * h ) + " " + ( x + 0.625 * w ) + " " + ( y + 0.2 * h ) + " C " + ( x + 0.5 * w ) + " " + ( y + 0.05 * h ) + " " + ( x + 0.3 * w ) + " " + ( y + 0.05 * h ) + " " + ( x + 0.25 * w ) + " " + ( y + 0.25 * h ) ; elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_ACTOR ) ) { elem = document . createElement ( "path" ) ; double width3 = w / 3 ; String d = " M " + x + " " + ( y + h ) + " C " + x + " " + ( y + 3 * h / 5 ) + " " + x + " " + ( y + 2 * h / 5 ) + " " + ( x + w / 2 ) + " " + ( y + 2 * h / 5 ) + " C " + ( x + w / 2 - width3 ) + " " + ( y + 2 * h / 5 ) + " " + ( x + w / 2 - width3 ) + " " + y + " " + ( x + w / 2 ) + " " + y + " C " + ( x + w / 2 + width3 ) + " " + y + " " + ( x + w / 2 + width3 ) + " " + ( y + 2 * h / 5 ) + " " + ( x + w / 2 ) + " " + ( y + 2 * h / 5 ) + " C " + ( x + w ) + " " + ( y + 2 * h / 5 ) + " " + ( x + w ) + " " + ( y + 3 * h / 5 ) + " " + ( x + w ) + " " + ( y + h ) ; elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_CYLINDER ) ) { elem = document . createElement ( "g" ) ; background = document . createElement ( "path" ) ; double dy = Math . min ( 40 , Math . floor ( h / 5 ) ) ; String d = " M " + x + " " + ( y + dy ) + " C " + x + " " + ( y - dy / 3 ) + " " + ( x + w ) + " " + ( y - dy / 3 ) + " " + ( x + w ) + " " + ( y + dy ) + " L " + ( x + w ) + " " + ( y + h - dy ) + " C " + ( x + w ) + " " + ( y + h + dy / 3 ) + " " + x + " " + ( y + h + dy / 3 ) + " " + x + " " + ( y + h - dy ) ; background . setAttribute ( "d" , d + " Z" ) ; elem . appendChild ( background ) ; Element foreground = document . createElement ( "path" ) ; d = "M " + x + " " + ( y + dy ) + " C " + x + " " + ( y + 2 * dy ) + " " + ( x + w ) + " " + ( y + 2 * dy ) + " " + ( x + w ) + " " + ( y + dy ) ; foreground . setAttribute ( "d" , d ) ; foreground . setAttribute ( "fill" , "none" ) ; foreground . setAttribute ( "stroke" , strokeColor ) ; foreground . setAttribute ( "stroke-width" , String . valueOf ( strokeWidth ) ) ; elem . appendChild ( foreground ) ; } else { elem = document . createElement ( "rect" ) ; elem . setAttribute ( "x" , String . valueOf ( x ) ) ; elem . setAttribute ( "y" , String . valueOf ( y ) ) ; elem . setAttribute ( "width" , String . valueOf ( w ) ) ; elem . setAttribute ( "height" , String . valueOf ( h ) ) ; if ( mxUtils . isTrue ( style , mxConstants . STYLE_ROUNDED , false ) ) { elem . setAttribute ( "rx" , String . valueOf ( w * mxConstants . RECTANGLE_ROUNDING_FACTOR ) ) ; elem . setAttribute ( "ry" , String . valueOf ( h * mxConstants . RECTANGLE_ROUNDING_FACTOR ) ) ; } } Element bg = background ; if ( bg == null ) { bg = elem ; } bg . setAttribute ( "fill" , fillColor ) ; bg . setAttribute ( "stroke" , strokeColor ) ; bg . setAttribute ( "stroke-width" , String . valueOf ( strokeWidth ) ) ; Element shadowElement = null ; if ( mxUtils . isTrue ( style , mxConstants . STYLE_SHADOW , false ) && ! fillColor . equals ( "none" ) ) { shadowElement = ( Element ) bg . cloneNode ( true ) ; shadowElement . setAttribute ( "transform" , mxConstants . SVG_SHADOWTRANSFORM ) ; shadowElement . setAttribute ( "fill" , mxConstants . W3C_SHADOWCOLOR ) ; shadowElement . setAttribute ( "stroke" , mxConstants . W3C_SHADOWCOLOR ) ; shadowElement . setAttribute ( "stroke-width" , String . valueOf ( strokeWidth ) ) ; appendSvgElement ( shadowElement ) ; } double rotation = mxUtils . getDouble ( style , mxConstants . STYLE_ROTATION ) ; if ( rotation != 0 ) { int cx = x + w / 2 ; int cy = y + h / 2 ; elem . setAttribute ( "transform" , "rotate(" + rotation + "," + cx + "," + cy + ")" ) ; if ( shadowElement != null ) { shadowElement . setAttribute ( "transform" , "rotate(" + rotation + "," + cx + "," + cy + ") " + mxConstants . SVG_SHADOWTRANSFORM ) ; } } float opacity = mxUtils . getFloat ( style , mxConstants . STYLE_OPACITY , 100 ) ; if ( opacity != 100 ) { String value = String . valueOf ( opacity / 100 ) ; elem . setAttribute ( "fill-opacity" , value ) ; elem . setAttribute ( "stroke-opacity" , value ) ; if ( shadowElement != null ) { shadowElement . setAttribute ( "fill-opacity" , value ) ; shadowElement . setAttribute ( "stroke-opacity" , value ) ; } } appendSvgElement ( elem ) ; return elem ; }
Draws the shape specified with the STYLE_SHAPE key in the given style.
34,694
private int estimateDist ( AreaPanel ap1 , AreaPanel ap2 ) { int yDist = Math . abs ( ap1 . getCenterY ( ) - ap2 . getCenterY ( ) ) ; int xDist = Math . abs ( ap1 . getCenterX ( ) - ap2 . getCenterX ( ) ) ; if ( xDist < ( yDist > > 1 ) || yDist < ( xDist > > 1 ) ) return xDist + yDist ; return ( int ) ( ( xDist + yDist ) * 7l / 10 ) ; }
This calculates a really cheap estimate of distance in meters between the center of the aps. It is only used to choose a proper size of the view node, so we really don't care much.
34,695
private void checkNotEqual ( UnknownFieldSet s1 , UnknownFieldSet s2 ) { String equalsError = String . format ( "%s should not be equal to %s" , s1 , s2 ) ; assertFalse ( equalsError , s1 . equals ( s2 ) ) ; assertFalse ( equalsError , s2 . equals ( s1 ) ) ; assertFalse ( String . format ( "%s should have a different hash code from %s" , s1 , s2 ) , s1 . hashCode ( ) == s2 . hashCode ( ) ) ; }
Asserts that the given field sets are not equal and have different hash codes.
34,696
synchronized void discardQueue ( ) { queue . removeAllElements ( ) ; for ( Enumeration e = running . elements ( ) ; e . hasMoreElements ( ) ; ) { ResourceThread t = ( ResourceThread ) e . nextElement ( ) ; t . cancel ( ) ; } running . removeAllElements ( ) ; bgImageCompsSelected . removeAllElements ( ) ; bgImageCompsUnselected . removeAllElements ( ) ; bgImageCompsPressed . removeAllElements ( ) ; threadCount = 0 ; cssCount = - 1 ; started = false ; }
Discards the entire queue and signals the running threads to cancel. THis will be triggered if the user cancelled the page or moved to another page.
34,697
private Set < String > loadFile ( String fileName ) throws IOException { Set < String > container = new HashSet < String > ( ) ; FileInputStream fstream = null ; DataInputStream in = null ; BufferedReader br = null ; try { fstream = new FileInputStream ( fileName ) ; in = new DataInputStream ( fstream ) ; br = new BufferedReader ( new InputStreamReader ( in ) ) ; String strLine ; while ( ( strLine = br . readLine ( ) ) != null ) { container . add ( strLine ) ; } } finally { if ( br != null ) { br . close ( ) ; } if ( in != null ) { in . close ( ) ; } if ( fstream != null ) { fstream . close ( ) ; } } return container ; }
Loads a text file line-by-line into a Set of Strings.
34,698
public void testConstructorStringRadix16 ( ) { String value = "fe2340a8b5ce790" ; int radix = 16 ; byte rBytes [ ] = { 15 , - 30 , 52 , 10 , - 117 , 92 , - 25 , - 112 } ; BigInteger aNumber = new BigInteger ( value , radix ) ; byte resBytes [ ] = new byte [ rBytes . length ] ; resBytes = aNumber . toByteArray ( ) ; for ( int i = 0 ; i < resBytes . length ; i ++ ) { assertTrue ( resBytes [ i ] == rBytes [ i ] ) ; } assertEquals ( "incorrect sign" , 1 , aNumber . signum ( ) ) ; }
Create a positive number from a string value and radix 16.
34,699
public static String toString ( int M_ [ ] [ ] ) { StringBuilder sb = new StringBuilder ( ) ; for ( int j = 0 ; j < M_ . length ; j ++ ) { for ( int k = 0 ; k < M_ [ j ] . length ; k ++ ) { String num = String . format ( "%5d" , M_ [ j ] [ k ] ) ; sb . append ( num ) ; } sb . append ( "\n" ) ; } return sb . toString ( ) ; }
ToString - return a String representation.