idx
int64 0
34.9k
| question
stringlengths 12
26.4k
| target
stringlengths 15
2.3k
|
---|---|---|
600 | public boolean start ( float startScale , float targetScale , float centerX , float centerY ) { if ( mRunning ) { return false ; } mCenterX = centerX ; mCenterY = centerY ; mTargetScale = targetScale ; mStartTime = System . currentTimeMillis ( ) ; mStartScale = startScale ; mZoomingIn = mTargetScale > mStartScale ; mVelocity = ( mTargetScale - mStartScale ) / ZOOM_ANIMATION_DURATION ; mRunning = true ; mStop = false ; mHeader . post ( this ) ; return true ; } | Starts the animation. There is no target scale bounds check. |
601 | private void dispatchOnThirdPartyRegistrationFailed ( ) { synchronized ( this ) { for ( ThirdPartyRegistrationListener listener : mThirdPartyRegistrationListeners ) { try { listener . onThirdPartyRegistrationFailed ( ) ; } catch ( Exception e ) { Log . e ( LOG_TAG , "onSessionsRegistrationFailed " + e . getLocalizedMessage ( ) ) ; } } mThirdPartyRegistrationListeners . clear ( ) ; } } | Dispatch the onThirdPartyRegistrationFailed to the listeners. |
602 | public void removeCOSTemplates ( ) throws UMSException { ArrayList aList = ( ArrayList ) getCOSTemplates ( ) ; for ( int i = 0 ; i < aList . size ( ) ; i ++ ) { COSTemplate cosTemplate = ( COSTemplate ) aList . get ( i ) ; cosTemplate . remove ( ) ; } } | Removes all COS Templates from this COS definition. |
603 | private void writeObject ( java . io . ObjectOutputStream s ) throws java . io . IOException { s . defaultWriteObject ( ) ; for ( Node < K , V > n = findFirst ( ) ; n != null ; n = n . next ) { V v = n . getValidValue ( ) ; if ( v != null ) { s . writeObject ( n . key ) ; s . writeObject ( v ) ; } } s . writeObject ( null ) ; } | Save the state of this map to a stream. |
604 | private void collectReferences ( final IOperandTreeNode node , final Set < IAddress > references ) { for ( final IReference reference : node . getReferences ( ) ) { if ( ReferenceType . isCodeReference ( reference . getType ( ) ) ) { references . add ( reference . getTarget ( ) ) ; } } for ( final IOperandTreeNode child : node . getChildren ( ) ) { collectReferences ( child , references ) ; } } | Collects all code references from an operand tree node and all of its children. |
605 | private ApplyDeletesResult closeSegmentStates ( IndexWriter . ReaderPool pool , SegmentState [ ] segStates , boolean success , long gen ) throws IOException { int numReaders = segStates . length ; Throwable firstExc = null ; List < SegmentCommitInfo > allDeleted = null ; long totDelCount = 0 ; for ( int j = 0 ; j < numReaders ; j ++ ) { SegmentState segState = segStates [ j ] ; if ( success ) { totDelCount += segState . rld . getPendingDeleteCount ( ) - segState . startDelCount ; segState . reader . getSegmentInfo ( ) . setBufferedDeletesGen ( gen ) ; int fullDelCount = segState . rld . info . getDelCount ( ) + segState . rld . getPendingDeleteCount ( ) ; assert fullDelCount <= segState . rld . info . info . maxDoc ( ) ; if ( fullDelCount == segState . rld . info . info . maxDoc ( ) ) { if ( allDeleted == null ) { allDeleted = new ArrayList < > ( ) ; } allDeleted . add ( segState . reader . getSegmentInfo ( ) ) ; } } try { segStates [ j ] . finish ( pool ) ; } catch ( Throwable th ) { if ( firstExc != null ) { firstExc = th ; } } } if ( success ) { IOUtils . reThrow ( firstExc ) ; } if ( infoStream . isEnabled ( "BD" ) ) { infoStream . message ( "BD" , "applyDeletes: " + totDelCount + " new deleted documents" ) ; } return new ApplyDeletesResult ( totDelCount > 0 , gen , allDeleted ) ; } | Close segment states previously opened with openSegmentStates. |
606 | @ Override public double [ ] [ ] rankedAttributes ( ) throws Exception { if ( m_rankedAtts == null || m_rankedSoFar == - 1 ) { throw new Exception ( "Search must be performed before attributes " + "can be ranked." ) ; } m_doRank = true ; search ( m_ASEval , null ) ; double [ ] [ ] final_rank = new double [ m_rankedSoFar ] [ 2 ] ; for ( int i = 0 ; i < m_rankedSoFar ; i ++ ) { final_rank [ i ] [ 0 ] = m_rankedAtts [ i ] [ 0 ] ; final_rank [ i ] [ 1 ] = m_rankedAtts [ i ] [ 1 ] ; } resetOptions ( ) ; m_doneRanking = true ; if ( m_numToSelect > final_rank . length ) { throw new Exception ( "More attributes requested than exist in the data" ) ; } if ( m_numToSelect <= 0 ) { if ( m_threshold == - Double . MAX_VALUE ) { m_calculatedNumToSelect = final_rank . length ; } else { determineNumToSelectFromThreshold ( final_rank ) ; } } return final_rank ; } | Produces a ranked list of attributes. Search must have been performed prior to calling this function. Search is called by this function to complete the traversal of the the search space. A list of attributes and merits are returned. The attributes a ranked by the order they are added to the subset during a forward selection search. Individual merit values reflect the merit associated with adding the corresponding attribute to the subset; because of this, merit values may initially increase but then decrease as the best subset is "passed by" on the way to the far side of the search space. |
607 | private void handleYarnContainerChange ( String containerCountAsString ) throws IOException , YarnException { String applicationId = yarnUtil . getRunningAppId ( jobName , jobID ) ; int containerCount = Integer . valueOf ( containerCountAsString ) ; int currentNumTask = getCurrentNumTasks ( ) ; int currentNumContainers = getCurrentNumContainers ( ) ; if ( containerCount == currentNumContainers ) { log . error ( "The new number of containers is equal to the current number of containers, skipping this message" ) ; return ; } if ( containerCount <= 0 ) { log . error ( "The number of containers cannot be zero or less, skipping this message" ) ; return ; } if ( containerCount > currentNumTask ) { log . error ( "The number of containers cannot be more than the number of task, skipping this message" ) ; return ; } log . info ( "Killing the current job" ) ; yarnUtil . killApplication ( applicationId ) ; coordinatorServerURL = null ; try { String state = yarnUtil . getApplicationState ( applicationId ) ; Thread . sleep ( 1000 ) ; int countSleep = 1 ; while ( ! state . equals ( "KILLED" ) ) { state = yarnUtil . getApplicationState ( applicationId ) ; log . info ( "Job kill signal sent, but job not killed yet for " + applicationId + ". Sleeping for another 1000ms" ) ; Thread . sleep ( 1000 ) ; countSleep ++ ; if ( countSleep > 10 ) { throw new IllegalStateException ( "Job has not been killed after 10 attempts." ) ; } } } catch ( InterruptedException e ) { e . printStackTrace ( ) ; } log . info ( "Killed the current job successfully" ) ; log . info ( "Staring the job again" ) ; skipUnreadMessages ( ) ; JobRunner jobRunner = new JobRunner ( config ) ; jobRunner . run ( false ) ; } | This method handles setConfig messages that want to change the number of containers of a job |
608 | public final String translate ( final CharSequence input ) { if ( input == null ) { return null ; } try { final StringWriter writer = new StringWriter ( input . length ( ) * 2 ) ; translate ( input , writer ) ; return writer . toString ( ) ; } catch ( final IOException ioe ) { throw new RuntimeException ( ioe ) ; } } | Helper for non-Writer usage. |
609 | public static boolean compareCellValue ( Double v1 , Double v2 , double t , boolean ignoreNaN ) { if ( v1 == null ) v1 = 0.0 ; if ( v2 == null ) v2 = 0.0 ; if ( ignoreNaN && ( v1 . isNaN ( ) || v1 . isInfinite ( ) || v2 . isNaN ( ) || v2 . isInfinite ( ) ) ) return true ; if ( v1 . equals ( v2 ) ) return true ; return Math . abs ( v1 - v2 ) <= t ; } | Compares two double values regarding tolerance t. If one or both of them is null it is converted to 0.0. |
610 | public void testNegateMathContextNegative ( ) { String a = "-92948782094488478231212478987482988429808779810457634781384756794987" ; int aScale = 49 ; int precision = 46 ; RoundingMode rm = RoundingMode . CEILING ; MathContext mc = new MathContext ( precision , rm ) ; String c = "9294878209448847823.121247898748298842980877982" ; int cScale = 27 ; BigDecimal aNumber = new BigDecimal ( new BigInteger ( a ) , aScale ) ; BigDecimal res = aNumber . negate ( mc ) ; assertEquals ( "incorrect value" , c , res . toString ( ) ) ; assertEquals ( "incorrect scale" , cScale , res . scale ( ) ) ; } | negate(MathContext) for a negative BigDecimal |
611 | public static int ping ( String url ) throws Exception { URL u = new URL ( url ) ; HttpURLConnection c = ( HttpURLConnection ) u . openConnection ( ) ; c . connect ( ) ; int code = c . getResponseCode ( ) ; log . debug ( "ping=" + url + ", response.code=" + code ) ; c . disconnect ( ) ; return code ; } | ping the url, throw exception if occur error |
612 | public static int secondaryIdentityHash ( Object key ) { return secondaryHash ( System . identityHashCode ( key ) ) ; } | Computes an identity hash code and applies a supplemental hash function to defend against poor quality hash functions. This is critical because identity hash codes are currently implemented as object addresses, which will have been aligned by the underlying memory allocator causing all hash codes to have the same bottom bits. |
613 | public Config loadInstalledCodenvyConfig ( InstallType installType ) throws IOException { Map < String , String > properties = loadInstalledCodenvyProperties ( installType ) ; return new Config ( properties ) ; } | Loads appropriate Codenvy config for given installation type. |
614 | private void signalNotEmpty ( ) { final ReentrantLock takeLock = this . takeLock ; takeLock . lock ( ) ; try { notEmpty . signal ( ) ; } finally { takeLock . unlock ( ) ; } } | Signals a waiting take. Called only from put/offer (which do not otherwise ordinarily lock takeLock.) |
615 | public GeoDistanceSortBuilder point ( double lat , double lon ) { points . add ( new GeoPoint ( lat , lon ) ) ; return this ; } | The point to create the range distance facets from. |
616 | private void adjustLeft ( RectF rect , float left , RectF bounds , float snapMargin , float aspectRatio , boolean topMoves , boolean bottomMoves ) { float newLeft = left ; if ( newLeft < 0 ) { newLeft /= 1.05f ; mTouchOffset . x -= newLeft / 1.1f ; } if ( newLeft < bounds . left ) { mTouchOffset . x -= ( newLeft - bounds . left ) / 2f ; } if ( newLeft - bounds . left < snapMargin ) { newLeft = bounds . left ; } if ( rect . right - newLeft < mMinCropWidth ) { newLeft = rect . right - mMinCropWidth ; } if ( rect . right - newLeft > mMaxCropWidth ) { newLeft = rect . right - mMaxCropWidth ; } if ( newLeft - bounds . left < snapMargin ) { newLeft = bounds . left ; } if ( aspectRatio > 0 ) { float newHeight = ( rect . right - newLeft ) / aspectRatio ; if ( newHeight < mMinCropHeight ) { newLeft = Math . max ( bounds . left , rect . right - mMinCropHeight * aspectRatio ) ; newHeight = ( rect . right - newLeft ) / aspectRatio ; } if ( newHeight > mMaxCropHeight ) { newLeft = Math . max ( bounds . left , rect . right - mMaxCropHeight * aspectRatio ) ; newHeight = ( rect . right - newLeft ) / aspectRatio ; } if ( topMoves && bottomMoves ) { newLeft = Math . max ( newLeft , Math . max ( bounds . left , rect . right - bounds . height ( ) * aspectRatio ) ) ; } else { if ( topMoves && rect . bottom - newHeight < bounds . top ) { newLeft = Math . max ( bounds . left , rect . right - ( rect . bottom - bounds . top ) * aspectRatio ) ; newHeight = ( rect . right - newLeft ) / aspectRatio ; } if ( bottomMoves && rect . top + newHeight > bounds . bottom ) { newLeft = Math . max ( newLeft , Math . max ( bounds . left , rect . right - ( bounds . bottom - rect . top ) * aspectRatio ) ) ; } } } rect . left = newLeft ; } | Get the resulting x-position of the left edge of the crop window given the handle's position and the image's bounding box and snap radius. |
617 | protected int indexFirstOf ( final String s , final String delims , int offset ) { if ( s == null || s . length ( ) == 0 ) { return - 1 ; } if ( delims == null || delims . length ( ) == 0 ) { return - 1 ; } if ( offset < 0 ) { offset = 0 ; } else if ( offset > s . length ( ) ) { return - 1 ; } int min = s . length ( ) ; final char [ ] delim = delims . toCharArray ( ) ; for ( int i = 0 ; i < delim . length ; i ++ ) { final int at = s . indexOf ( delim [ i ] , offset ) ; if ( at >= 0 && at < min ) { min = at ; } } return ( min == s . length ( ) ) ? - 1 : min ; } | Get the earlier index that to be searched for the first occurrance in one of any of the given string. |
618 | public NamedColor ( String [ ] namesArray , int r , int g , int b ) { super ( r , g , b ) ; names = new HashSet < > ( ) ; names . addAll ( Arrays . asList ( namesArray ) ) ; namesLowercase = new HashSet < > ( ) ; for ( String thisName : namesArray ) { namesLowercase . add ( thisName . toLowerCase ( ) ) ; } if ( namesArray . length == 0 ) { name = "" ; } else { name = namesArray [ 0 ] ; } } | Constructs a new color with the given names and rgb values. The first name in the array is used as the primary name. |
619 | public void showContent ( ) { switchState ( CONTENT , null , null , null , null , null , Collections . < Integer > emptyList ( ) ) ; } | Hide all other states and show content |
620 | public synchronized void removeSeries ( int index ) { mSeries . remove ( index ) ; } | Removes the XY series from the list. |
621 | public static boolean isValidTemplate ( String template ) { template = template . trim ( ) ; if ( template . indexOf ( '{' ) == - 1 ) { return false ; } String s = template . trim ( ) ; if ( s . lastIndexOf ( '}' ) != s . length ( ) - 1 ) { return false ; } if ( getMethodSignature ( template ) == null ) { return false ; } if ( getMethodBody ( template ) == null ) { return false ; } return true ; } | Validates the provided template. |
622 | private double [ ] prune ( Tree tree , NodeRef node , ColourChangeMatrix mm ) { double [ ] p = new double [ colourCount ] ; if ( tree . isExternal ( node ) ) { p [ getColour ( node ) ] = 1.0 ; } else { NodeRef leftChild = tree . getChild ( node , 0 ) ; NodeRef rightChild = tree . getChild ( node , 1 ) ; double [ ] left = prune ( tree , leftChild , mm ) ; double [ ] right = prune ( tree , rightChild , mm ) ; double nodeHeight = tree . getNodeHeight ( node ) ; double leftTime = nodeHeight - tree . getNodeHeight ( tree . getChild ( node , 0 ) ) ; double rightTime = nodeHeight - tree . getNodeHeight ( tree . getChild ( node , 1 ) ) ; double maxp = 0.0 ; for ( int i = 0 ; i < colourCount ; i ++ ) { double leftSum = 0.0 ; double rightSum = 0.0 ; for ( int j = 0 ; j < colourCount ; j ++ ) { leftSum += mm . forwardTimeEvolution ( i , j , leftTime ) * left [ j ] ; rightSum += mm . forwardTimeEvolution ( i , j , rightTime ) * right [ j ] ; } p [ i ] = leftSum * rightSum ; if ( p [ i ] > maxp ) { maxp = p [ i ] ; } } if ( maxp < 1.0e-100 ) { for ( int i = 0 ; i < colourCount ; i ++ ) { p [ i ] *= 1.0e+100 ; } logNodePartialsRescaling -= Math . log ( 1.0e+100 ) ; } } nodePartials [ node . getNumber ( ) ] = p ; if ( debugNodePartials ) { prettyPrint ( "Node " + node . getNumber ( ) + " prune=" , p ) ; } return p ; } | Calculate probability of data at descendants from node, given a color at the node ('partials'), by a Felsenstein-like pruning algorithm. (First step in the color sampling algorithm) Side effect: updates nodePartials[] for this node and all its descendants. |
623 | private void awaitOperationsAvailable ( ) throws InterruptedException { flushLock . lock ( ) ; try { do { if ( writeCache . sizex ( ) <= cacheMaxSize || cacheMaxSize == 0 ) { if ( cacheFlushFreq > 0 ) canFlush . await ( cacheFlushFreq , TimeUnit . MILLISECONDS ) ; else canFlush . await ( ) ; } } while ( writeCache . sizex ( ) == 0 && ! stopping . get ( ) ) ; } finally { flushLock . unlock ( ) ; } } | This method awaits until enough elements in map are available or given timeout is over. |
624 | public static String sortCommonTokens ( String column ) { StringBuilder order = new StringBuilder ( ) ; order . append ( " (CASE " ) ; for ( String token : commonTokens ) { order . append ( " WHEN " + column + " LIKE '" + token + " %'" + " THEN SUBSTR(" + column + "," + String . valueOf ( token . length ( ) + 2 ) + ")" + " || ', " + token + "' " ) ; } order . append ( " ELSE " + column + " END) " ) ; return order . toString ( ) ; } | Given column create SQLite column expression to convert any sortTokens prefixes to suffixes eg.column = "title", commonTokens = {"The", "An", "A"}; ( CASE WHEN title LIKE 'The %' THEN SUBSTR(title,5) || ', The' WHEN title LIKE 'An %' THEN SUBSTR(title,4) || ', An' WHEN title LIKE 'A %' THEN SUBSTR(title,3) || ', A' ELSE title END ) This allows it to be used in SQL where a column expression is expected ( SELECT, ORDER BY ) |
625 | static boolean isFulfilling ( int m ) { return ( m & FULFILLING ) != 0 ; } | Returns true if m has fulfilling bit set. |
626 | private void writeAttribute ( java . lang . String namespace , java . lang . String attName , java . lang . String attValue , javax . xml . stream . XMLStreamWriter xmlWriter ) throws javax . xml . stream . XMLStreamException { if ( namespace . equals ( "" ) ) { xmlWriter . writeAttribute ( attName , attValue ) ; } else { registerPrefix ( xmlWriter , namespace ) ; xmlWriter . writeAttribute ( namespace , attName , attValue ) ; } } | Util method to write an attribute without the ns prefix |
627 | public String toString ( ) { StringBuffer buf = new StringBuffer ( ) ; if ( _isBoot || ( _dataChars [ 0 ] == SprogMessage . STX ) ) { for ( int i = 0 ; i < _nDataChars ; i ++ ) { buf . append ( "<" ) ; buf . append ( _dataChars [ i ] ) ; buf . append ( ">" ) ; } } else { for ( int i = 0 ; i < _nDataChars ; i ++ ) { buf . append ( ( char ) _dataChars [ i ] ) ; } } return buf . toString ( ) ; } | Returns a string representation of this SprogReply |
628 | public static boolean isNativeCodeLoaded ( ) { return NativeCodeLoader . isNativeCodeLoaded ( ) ; } | Checks whether the native code has been successfully loaded for the platform. |
629 | abstract void replay ( ) ; | Reapplies the change to prefsCache. |
630 | private boolean readyToConnect ( ) { long now = System . currentTimeMillis ( ) ; long lastExchangeMillis = mStore . getLong ( LAST_EXCHANGE_TIME_KEY , - 1 ) ; boolean timeSinceLastOK ; if ( lastExchangeMillis == - 1 ) { timeSinceLastOK = true ; } else if ( now - lastExchangeMillis < TIME_BETWEEN_EXCHANGES_MILLIS ) { timeSinceLastOK = false ; } else { timeSinceLastOK = true ; } if ( ! USE_MINIMAL_LOGGING ) { log . info ( "Ready to connect? " + ( timeSinceLastOK && ( getConnecting ( ) == null ) ) ) ; log . info ( "Connecting: " + getConnecting ( ) ) ; log . info ( "timeSinceLastOK: " + timeSinceLastOK ) ; } return timeSinceLastOK && ( getConnecting ( ) == null ) ; } | Check whether we can connect, according to our policies. Currently, checks that we've waited TIME_BETWEEN_EXCHANGES_MILLIS milliseconds since the last exchange and that we're not already connecting. |
631 | public static void putDouble ( long addr , double val ) { if ( UNALIGNED ) UNSAFE . putDouble ( addr , val ) ; else putLongByByte ( addr , Double . doubleToLongBits ( val ) , BIG_ENDIAN ) ; } | Stores given double value. Alignment aware. |
632 | public void add ( T item ) { if ( items . add ( item ) ) { notifyDataSetChanged ( ) ; } } | Adds a new item to the adapter's list. |
633 | public DsnLayerStructure ( Collection < DsnLayer > p_layer_list ) { arr = new DsnLayer [ p_layer_list . size ( ) ] ; Iterator < DsnLayer > it = p_layer_list . iterator ( ) ; for ( int i = 0 ; i < arr . length ; ++ i ) { arr [ i ] = it . next ( ) ; } } | Creates a new instance of LayerStructure from a list of layers |
634 | public void writeNext ( String [ ] nextLine , boolean applyQuotesToAll ) { if ( nextLine == null ) { return ; } StringBuilder sb = new StringBuilder ( INITIAL_STRING_SIZE ) ; for ( int i = 0 ; i < nextLine . length ; i ++ ) { if ( i != 0 ) { sb . append ( separator ) ; } String nextElement = nextLine [ i ] ; if ( nextElement == null ) { continue ; } Boolean stringContainsSpecialCharacters = stringContainsSpecialCharacters ( nextElement ) ; if ( ( applyQuotesToAll || stringContainsSpecialCharacters ) && quotechar != NO_QUOTE_CHARACTER ) { sb . append ( quotechar ) ; } if ( stringContainsSpecialCharacters ) { sb . append ( processLine ( nextElement ) ) ; } else { sb . append ( nextElement ) ; } if ( ( applyQuotesToAll || stringContainsSpecialCharacters ) && quotechar != NO_QUOTE_CHARACTER ) { sb . append ( quotechar ) ; } } sb . append ( lineEnd ) ; pw . write ( sb . toString ( ) ) ; } | Writes the next line to the file. |
635 | public double [ ] incomingInstanceToVectorFieldVals ( double [ ] incoming ) throws Exception { double [ ] newInst = new double [ m_vectorFields . size ( ) ] ; for ( int i = 0 ; i < m_vectorFields . size ( ) ; i ++ ) { FieldRef fr = m_vectorFields . get ( i ) ; newInst [ i ] = fr . getResult ( incoming ) ; } return newInst ; } | Convert an incoming instance to an array of values that corresponds to the fields referenced by the support vectors in the vector dictionary |
636 | public Source resolveURI ( String base , String urlString , SourceLocator locator ) throws TransformerException , IOException { Source source = null ; if ( null != m_uriResolver ) { source = m_uriResolver . resolve ( urlString , base ) ; } if ( null == source ) { String uri = SystemIDResolver . getAbsoluteURI ( urlString , base ) ; source = new StreamSource ( uri ) ; } return source ; } | This will be called by the processor when it encounters an xsl:include, xsl:import, or document() function. |
637 | private boolean checkTouchSlop ( View child , float dx , float dy ) { if ( child == null ) { return false ; } final boolean checkHorizontal = mCallback . getViewHorizontalDragRange ( child ) > 0 ; final boolean checkVertical = mCallback . getViewVerticalDragRange ( child ) > 0 ; if ( checkHorizontal && checkVertical ) { return dx * dx + dy * dy > mTouchSlop * mTouchSlop ; } else if ( checkHorizontal ) { return Math . abs ( dx ) > mTouchSlop ; } else if ( checkVertical ) { return Math . abs ( dy ) > mTouchSlop ; } return false ; } | Check if we've crossed a reasonable touch slop for the given child view. If the child cannot be dragged along the horizontal or vertical axis, motion along that axis will not count toward the slop check. |
638 | private static void logNodeProperties ( org . osgi . service . prefs . Preferences node ) { if ( node == null ) { return ; } try { LOG . info ( node . name ( ) + " properties: " ) ; logProperties ( node ) ; String [ ] childrenNames = node . childrenNames ( ) ; for ( int i = 0 ; i < childrenNames . length ; i ++ ) { logNodeProperties ( node . node ( childrenNames [ i ] ) ) ; } } catch ( Exception t ) { LOG . error ( "Error while logging preferences." , t ) ; } } | Logs all properties of a preference node and calls logNodeProperties for all children of this node. |
639 | public static < T extends DataObject > T findInCollection ( Collection < T > col , T obj ) { if ( col != null && obj != null ) { return findInCollection ( col , obj . getId ( ) ) ; } return null ; } | Finds an DataObject in a collection by matching it by Id |
640 | public CodeViewer ( ) { setHighlightColor ( DEFAULT_HIGHLIGHT_COLOR ) ; initActions ( ) ; setLayout ( new BorderLayout ( ) ) ; codeHighlightBar = createCodeHighlightBar ( ) ; codeHighlightBar . setVisible ( false ) ; add ( codeHighlightBar , BorderLayout . NORTH ) ; codePanel = createCodePanel ( ) ; add ( codePanel , BorderLayout . CENTER ) ; applyDefaults ( ) ; } | Creates a new instance of CodeViewer |
641 | @ Override public boolean equals ( Object obj ) { if ( this == obj ) return true ; if ( obj == null ) return false ; if ( getClass ( ) != obj . getClass ( ) ) return false ; IfdStructure other = ( IfdStructure ) obj ; if ( count != other . count ) return false ; if ( offsetValue != other . offsetValue ) return false ; if ( tag != other . tag ) return false ; if ( type != other . type ) return false ; return true ; } | Returns whether this object is equal to the given object. |
642 | public boolean isAbsoluteURI ( ) { return ( _scheme != null ) ; } | Tell whether or not this URI is absolute. |
643 | public synchronized boolean isConsumer ( ImageConsumer ic ) { return ics . contains ( ic ) ; } | Determine if an ImageConsumer is on the list of consumers currently interested in data for this image. |
644 | public boolean isMandatory ( ) { return flags . contains ( DiagnosticFlag . MANDATORY ) ; } | Check whether or not this diagnostic is required to be shown. |
645 | public < T extends Number > double [ ] next ( Collection < T > values , int numForecasts ) { if ( values . size ( ) < period * 2 ) { throw new AggregationExecutionException ( "Holt-Winters aggregation requires at least (2 * period == 2 * " + period + " == " + ( 2 * period ) + ") data-points to function. Only [" + values . size ( ) + "] were provided." ) ; } double s = 0 ; double last_s ; double b = 0 ; double last_b = 0 ; double [ ] seasonal = new double [ values . size ( ) ] ; int counter = 0 ; double [ ] vs = new double [ values . size ( ) ] ; for ( T v : values ) { vs [ counter ] = v . doubleValue ( ) + padding ; counter += 1 ; } for ( int i = 0 ; i < period ; i ++ ) { s += vs [ i ] ; b += ( vs [ i + period ] - vs [ i ] ) / period ; } s /= ( double ) period ; b /= ( double ) period ; last_s = s ; if ( Double . compare ( s , 0.0 ) == 0 || Double . compare ( s , - 0.0 ) == 0 ) { Arrays . fill ( seasonal , 0.0 ) ; } else { for ( int i = 0 ; i < period ; i ++ ) { seasonal [ i ] = vs [ i ] / s ; } } for ( int i = period ; i < vs . length ; i ++ ) { if ( seasonalityType . equals ( SeasonalityType . MULTIPLICATIVE ) ) { s = alpha * ( vs [ i ] / seasonal [ i - period ] ) + ( 1.0d - alpha ) * ( last_s + last_b ) ; } else { s = alpha * ( vs [ i ] - seasonal [ i - period ] ) + ( 1.0d - alpha ) * ( last_s + last_b ) ; } b = beta * ( s - last_s ) + ( 1 - beta ) * last_b ; if ( seasonalityType . equals ( SeasonalityType . MULTIPLICATIVE ) ) { seasonal [ i ] = gamma * ( vs [ i ] / ( last_s + last_b ) ) + ( 1 - gamma ) * seasonal [ i - period ] ; } else { seasonal [ i ] = gamma * ( vs [ i ] - ( last_s - last_b ) ) + ( 1 - gamma ) * seasonal [ i - period ] ; } last_s = s ; last_b = b ; } double [ ] forecastValues = new double [ numForecasts ] ; for ( int i = 1 ; i <= numForecasts ; i ++ ) { int idx = values . size ( ) - period + ( ( i - 1 ) % period ) ; if ( seasonalityType . equals ( SeasonalityType . MULTIPLICATIVE ) ) { forecastValues [ i - 1 ] = ( s + ( i * b ) ) * seasonal [ idx ] ; } else { forecastValues [ i - 1 ] = s + ( i * b ) + seasonal [ idx ] ; } } return forecastValues ; } | Calculate a doubly exponential weighted moving average |
646 | public static AlarmCacheObject createTestAlarm1 ( ) { AlarmCacheObject alarm1 = new AlarmCacheObject ( ) ; alarm1 . setId ( Long . valueOf ( 1 ) ) ; alarm1 . setFaultFamily ( "fault family" ) ; alarm1 . setFaultMember ( "fault member" ) ; alarm1 . setFaultCode ( 0 ) ; AlarmCondition condition = AlarmCondition . fromConfigXML ( "<AlarmCondition class=\"cern.c2mon.server.common.alarm.ValueAlarmCondition\">" + "<alarm-value type=\"String\">DOWN</alarm-value></AlarmCondition>" ) ; alarm1 . setCondition ( condition ) ; alarm1 . setInfo ( "alarm info" ) ; alarm1 . setState ( AlarmCondition . TERMINATE ) ; alarm1 . setTimestamp ( new Timestamp ( System . currentTimeMillis ( ) - 2000 ) ) ; alarm1 . setDataTagId ( 100003L ) ; return alarm1 ; } | Does not set reference to tag id. |
647 | public boolean justSerialized ( ) { return serialized . getAndSet ( false ) ; } | This is called on deserialization. You can only call it once to get a meaningful value as it resets the serialized state. In other words, this call is not idempotent. |
648 | public Object read ( String xml ) throws Exception { return fromXML ( m_Document . read ( xml ) ) ; } | parses the given XML string (can be XML or a filename) and returns an Object generated from the representation |
649 | protected T newInstance ( final Class < ? extends T > cls , final IIndexManager indexManager , final NT nt , final Properties properties ) { if ( cls == null ) throw new IllegalArgumentException ( ) ; if ( indexManager == null ) throw new IllegalArgumentException ( ) ; if ( nt == null ) throw new IllegalArgumentException ( ) ; if ( properties == null ) throw new IllegalArgumentException ( ) ; final Constructor < ? extends T > ctor ; try { ctor = cls . getConstructor ( new Class [ ] { IIndexManager . class , String . class , Long . class , Properties . class } ) ; } catch ( Exception e ) { throw new RuntimeException ( "No appropriate ctor?: cls=" + cls . getName ( ) + " : " + e , e ) ; } final T r ; try { r = ctor . newInstance ( new Object [ ] { indexManager , nt . getName ( ) , nt . getTimestamp ( ) , properties } ) ; r . init ( ) ; if ( INFO ) { log . info ( "new instance: " + r ) ; } return r ; } catch ( Exception ex ) { throw new RuntimeException ( "Could not instantiate relation: " + ex , ex ) ; } } | Create a new view of the relation. |
650 | public Builder ( ) { } | Creates a new Property.Builder |
651 | protected MapTile findCovering ( int zoom , long i , long j ) { while ( zoom > 0 ) { zoom -- ; i = i / 2 ; j = j / 2 ; MapTile candidate = findTile ( zoom , i , j ) ; if ( ( candidate != null ) && ( ! candidate . loading ( ) ) ) { return candidate ; } } return null ; } | Find the "nearest" lower-zoom tile that covers a specific tile. This is used to find out what tile we have to show while a new tile is still loading |
652 | @ Override public String format ( Object obj ) throws IllegalArgumentException { return format ( obj , new StringBuffer ( ) ) ; } | Format a given object. |
653 | public boolean isEmpty ( ) { return ( ( values == null ) || ( values . isEmpty ( ) ) ) ; } | Obtiene si la lista de valores esta vacia |
654 | private static String [ ] processObjectClasses ( final String objectClass ) { String [ ] objectClasses = null ; if ( objectClass != null ) { objectClasses = objectClass . split ( "," ) ; } if ( objectClasses != null ) { String objClass = null ; for ( int i = 0 ; i < objectClasses . length ; i ++ ) { objClass = objectClasses [ i ] ; if ( objClass != null ) { objectClasses [ i ] = objClass . trim ( ) ; } } } return objectClasses ; } | Procesa un string con clases separadas por , para devolver un array |
655 | public static String [ ] filterLightColors ( String [ ] aPalette , int aThreshold ) { List < String > filtered = new ArrayList < String > ( ) ; for ( String color : aPalette ) { if ( ! isTooLight ( color , aThreshold ) ) { filtered . add ( color ) ; } } return ( String [ ] ) filtered . toArray ( new String [ filtered . size ( ) ] ) ; } | Filter out too light colors from the palette - those that do not show propely on a ligth background. The threshold controls what to filter. |
656 | synchronized int lookup ( final Object tx , final boolean insert ) { if ( tx == null ) { throw new IllegalArgumentException ( "transaction object is null" ) ; } Integer index = ( Integer ) mapping . get ( tx ) ; if ( index == null ) { if ( insert ) { final int capacity = capacity ( ) ; final int nvertices = mapping . size ( ) ; if ( nvertices == capacity ) { throw new MultiprogrammingCapacityExceededException ( "capacity=" + capacity + ", nvertices=" + nvertices ) ; } index = ( Integer ) indices . remove ( 0 ) ; mapping . put ( tx , index ) ; final int ndx = index . intValue ( ) ; if ( transactions [ ndx ] != null ) { throw new AssertionError ( ) ; } transactions [ ndx ] = tx ; } else { return - 1 ; } } return index . intValue ( ) ; } | Lookup index assigned to transaction object. |
657 | public void delete ( ) throws IOException { close ( ) ; Util . deleteContents ( directory ) ; } | Closes the cache and deletes all of its stored values. This will delete all files in the cache directory including files that weren't created by the cache. |
658 | public void deregister ( TrainSchedule schedule ) { if ( schedule == null ) { return ; } Integer oldSize = Integer . valueOf ( _scheduleHashTable . size ( ) ) ; _scheduleHashTable . remove ( schedule . getId ( ) ) ; setDirtyAndFirePropertyChange ( LISTLENGTH_CHANGED_PROPERTY , oldSize , Integer . valueOf ( _scheduleHashTable . size ( ) ) ) ; } | Forget a NamedBean Object created outside the manager. |
659 | public int readLEInt ( ) throws IOException { int byte1 , byte2 , byte3 , byte4 ; synchronized ( this ) { byte1 = in . read ( ) ; byte2 = in . read ( ) ; byte3 = in . read ( ) ; byte4 = in . read ( ) ; } if ( byte4 == - 1 ) { throw new EOFException ( ) ; } return ( byte4 << 24 ) + ( byte3 << 16 ) + ( byte2 << 8 ) + byte1 ; } | Translates a little endian int into a big endian int |
660 | protected AbstractSimplex ( final double [ ] steps ) { if ( steps == null ) { throw new NullArgumentException ( ) ; } if ( steps . length == 0 ) { throw new MathIllegalArgumentException ( LocalizedCoreFormats . ZERO_NOT_ALLOWED ) ; } dimension = steps . length ; startConfiguration = new double [ dimension ] [ dimension ] ; for ( int i = 0 ; i < dimension ; i ++ ) { final double [ ] vertexI = startConfiguration [ i ] ; for ( int j = 0 ; j < i + 1 ; j ++ ) { if ( steps [ j ] == 0 ) { throw new MathIllegalArgumentException ( LocalizedOptimFormats . EQUAL_VERTICES_IN_SIMPLEX ) ; } System . arraycopy ( steps , 0 , vertexI , 0 , j + 1 ) ; } } } | The start configuration for simplex is built from a box parallel to the canonical axes of the space. The simplex is the subset of vertices of a box parallel to the canonical axes. It is built as the path followed while traveling from one vertex of the box to the diagonally opposite vertex moving only along the box edges. The first vertex of the box will be located at the start point of the optimization. As an example, in dimension 3 a simplex has 4 vertices. Setting the steps to (1, 10, 2) and the start point to (1, 1, 1) would imply the start simplex would be: { (1, 1, 1), (2, 1, 1), (2, 11, 1), (2, 11, 3) }. The first vertex would be set to the start point at (1, 1, 1) and the last vertex would be set to the diagonally opposite vertex at (2, 11, 3). |
661 | protected void logDiagnostic ( String msg ) { if ( isDiagnosticsEnabled ( ) ) { logRawDiagnostic ( diagnosticPrefix + msg ) ; } } | Output a diagnostic message to a user-specified destination (if the user has enabled diagnostic logging). |
662 | 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. |
663 | public void initializeAtomsForDP ( List < Datum > data , String filename , Random random ) { omega = new ArrayList < > ( K ) ; dof = new double [ K ] ; beta = new double [ K ] ; if ( filename != null ) { try { loc = BatchMixtureModel . initializeClustersFromFile ( filename , K ) ; log . debug ( "loc : {}" , loc ) ; if ( loc . size ( ) < K ) { loc = BatchMixtureModel . gonzalezInitializeMixtureCenters ( loc , data , K , random ) ; } } catch ( FileNotFoundException e ) { log . debug ( "failed to initialized from file" ) ; e . printStackTrace ( ) ; loc = BatchMixtureModel . gonzalezInitializeMixtureCenters ( data , K , random ) ; } } else { loc = BatchMixtureModel . gonzalezInitializeMixtureCenters ( data , K , random ) ; } for ( int i = 0 ; i < K ; i ++ ) { beta [ i ] = 1 ; dof [ i ] = baseNu ; omega . add ( 0 , AlgebraUtils . invertMatrix ( baseOmegaInverse ) ) ; } } | Initializes atom (component) distributions. This method works great with DP mixture model. |
664 | private String determineEventTypeBasedOnOperationalStatus ( Hashtable < String , String > notification , String [ ] descs , String [ ] codes , String evtOKType , String evtNOTOKType , List < String > propDescriptions , List < String > propCodes ) { logMessage ( "Determiming Operational Status for Event" , new Object [ ] { } ) ; String evtType = null ; String [ ] values = descs ; if ( values . length > 0 ) { evtType = evtNOTOKType ; for ( String value : values ) { if ( propDescriptions . contains ( value ) ) { evtType = evtOKType ; break ; } } } else { values = codes ; if ( values . length > 0 ) { evtType = evtNOTOKType ; for ( String value : values ) { if ( propCodes . contains ( value ) ) { evtType = evtOKType ; break ; } } } else { logMessage ( "No Operational Status Values Found for this Event" , new Object [ ] { } ) ; } } return evtType ; } | Figure out the File and Block related event type based on the operational status values available in the indication |
665 | public static int toIntAccess ( String access ) throws ApplicationException { access = StringUtil . toLowerCase ( access . trim ( ) ) ; if ( access . equals ( "package" ) ) return Component . ACCESS_PACKAGE ; else if ( access . equals ( "private" ) ) return Component . ACCESS_PRIVATE ; else if ( access . equals ( "public" ) ) return Component . ACCESS_PUBLIC ; else if ( access . equals ( "remote" ) ) return Component . ACCESS_REMOTE ; throw new ApplicationException ( "invalid access type [" + access + "], access types are remote, public, package, private" ) ; } | cast a strong access definition to the int type |
666 | static byte [ ] ntlm2SessionResponse ( final byte [ ] ntlmHash , final byte [ ] challenge , final byte [ ] clientChallenge ) throws AuthenticationException { try { final MessageDigest md5 = MessageDigest . getInstance ( "MD5" ) ; md5 . update ( challenge ) ; md5 . update ( clientChallenge ) ; final byte [ ] digest = md5 . digest ( ) ; final byte [ ] sessionHash = new byte [ 8 ] ; System . arraycopy ( digest , 0 , sessionHash , 0 , 8 ) ; return lmResponse ( ntlmHash , sessionHash ) ; } catch ( Exception e ) { if ( e instanceof AuthenticationException ) throw ( AuthenticationException ) e ; throw new AuthenticationException ( e . getMessage ( ) , e ) ; } } | Calculates the NTLM2 Session Response for the given challenge, using the specified password and client challenge. |
667 | private boolean checkTouchSlop ( View child , float dx , float dy ) { if ( child == null ) { return false ; } final boolean checkHorizontal = mCallback . getViewHorizontalDragRange ( child ) > 0 ; final boolean checkVertical = mCallback . getViewVerticalDragRange ( child ) > 0 ; if ( checkHorizontal && checkVertical ) { return dx * dx + dy * dy > mTouchSlop * mTouchSlop ; } else if ( checkHorizontal ) { return Math . abs ( dx ) > mTouchSlop ; } else if ( checkVertical ) { return Math . abs ( dy ) > mTouchSlop ; } return false ; } | Check if we've crossed a reasonable touch slop for the given child view. If the child cannot be dragged along the horizontal or vertical axis, motion along that axis will not count toward the slop check. |
668 | public boolean isAncestorOf ( IJavaElement e ) { IJavaElement parentElement = e . getParent ( ) ; while ( parentElement != null && ! parentElement . equals ( this ) ) { parentElement = parentElement . getParent ( ) ; } return parentElement != null ; } | Returns true if this element is an ancestor of the given element, otherwise false. |
669 | @ RequestProcessing ( value = "/member/{userName}" , method = HTTPRequestMethod . GET ) @ Before ( adviceClass = { StopwatchStartAdvice . class , AnonymousViewCheck . class , UserBlockCheck . class } ) @ After ( adviceClass = StopwatchEndAdvice . class ) public void showHome ( final HTTPRequestContext context , final HttpServletRequest request , final HttpServletResponse response , final String userName ) throws Exception { final JSONObject user = ( JSONObject ) request . getAttribute ( User . USER ) ; String pageNumStr = request . getParameter ( "p" ) ; if ( Strings . isEmptyOrNull ( pageNumStr ) || ! Strings . isNumeric ( pageNumStr ) ) { pageNumStr = "1" ; } final int pageNum = Integer . valueOf ( pageNumStr ) ; request . setAttribute ( Keys . TEMAPLTE_DIR_NAME , Symphonys . get ( "skinDirName" ) ) ; final AbstractFreeMarkerRenderer renderer = new SkinRenderer ( ) ; context . setRenderer ( renderer ) ; final Map < String , Object > dataModel = renderer . getDataModel ( ) ; filler . fillHeaderAndFooter ( request , response , dataModel ) ; final String followingId = user . optString ( Keys . OBJECT_ID ) ; dataModel . put ( Follow . FOLLOWING_ID , followingId ) ; renderer . setTemplateName ( "/home/home.ftl" ) ; dataModel . put ( User . USER , user ) ; fillHomeUser ( dataModel , user ) ; avatarQueryService . fillUserAvatarURL ( user ) ; final boolean isLoggedIn = ( Boolean ) dataModel . get ( Common . IS_LOGGED_IN ) ; if ( isLoggedIn ) { final JSONObject currentUser = ( JSONObject ) dataModel . get ( Common . CURRENT_USER ) ; final String followerId = currentUser . optString ( Keys . OBJECT_ID ) ; final boolean isFollowing = followQueryService . isFollowing ( followerId , followingId ) ; dataModel . put ( Common . IS_FOLLOWING , isFollowing ) ; } user . put ( UserExt . USER_T_CREATE_TIME , new Date ( user . getLong ( Keys . OBJECT_ID ) ) ) ; final int pageSize = Symphonys . getInt ( "userHomeArticlesCnt" ) ; final int windowSize = Symphonys . getInt ( "userHomeArticlesWindowSize" ) ; final List < JSONObject > userArticles = articleQueryService . getUserArticles ( user . optString ( Keys . OBJECT_ID ) , pageNum , pageSize ) ; dataModel . put ( Common . USER_HOME_ARTICLES , userArticles ) ; final int articleCnt = user . optInt ( UserExt . USER_ARTICLE_COUNT ) ; final int pageCount = ( int ) Math . ceil ( ( double ) articleCnt / ( double ) pageSize ) ; final List < Integer > pageNums = Paginator . paginate ( pageNum , pageSize , pageCount , windowSize ) ; if ( ! pageNums . isEmpty ( ) ) { dataModel . put ( Pagination . PAGINATION_FIRST_PAGE_NUM , pageNums . get ( 0 ) ) ; dataModel . put ( Pagination . PAGINATION_LAST_PAGE_NUM , pageNums . get ( pageNums . size ( ) - 1 ) ) ; } dataModel . put ( Pagination . PAGINATION_CURRENT_PAGE_NUM , pageNum ) ; dataModel . put ( Pagination . PAGINATION_PAGE_COUNT , pageCount ) ; dataModel . put ( Pagination . PAGINATION_PAGE_NUMS , pageNums ) ; final JSONObject currentUser = Sessions . currentUser ( request ) ; if ( null == currentUser ) { dataModel . put ( Common . IS_MY_ARTICLE , false ) ; } else { dataModel . put ( Common . IS_MY_ARTICLE , userName . equals ( currentUser . optString ( User . USER_NAME ) ) ) ; } } | Shows user home page. |
670 | protected final void enableRetransmissionTimer ( int tickCount ) { if ( isInviteTransaction ( ) && ( this instanceof SIPClientTransaction ) ) { retransmissionTimerTicksLeft = tickCount ; } else { retransmissionTimerTicksLeft = Math . min ( tickCount , MAXIMUM_RETRANSMISSION_TICK_COUNT ) ; } retransmissionTimerLastTickCount = retransmissionTimerTicksLeft ; retransmissionOutdatedTime = SystemClock . elapsedRealtime ( ) + retransmissionTimerTicksLeft * BASE_TIMER_INTERVAL ; } | Enables retransmission timer events for this transaction to begin after the number of ticks passed to this routine. |
671 | void tidy ( int windowStartYear ) { if ( lastRuleList . size ( ) == 1 ) { throw new IllegalStateException ( "Cannot have only one rule defined as being forever" ) ; } if ( windowEnd . equals ( LocalDateTime . MAX ) ) { maxLastRuleStartYear = Math . max ( maxLastRuleStartYear , windowStartYear ) + 1 ; for ( TZRule lastRule : lastRuleList ) { addRule ( lastRule . year , maxLastRuleStartYear , lastRule . month , lastRule . dayOfMonthIndicator , lastRule . dayOfWeek , lastRule . time , lastRule . timeEndOfDay , lastRule . timeDefinition , lastRule . savingAmountSecs ) ; lastRule . year = maxLastRuleStartYear + 1 ; } if ( maxLastRuleStartYear == YEAR_MAX_VALUE ) { lastRuleList . clear ( ) ; } else { maxLastRuleStartYear ++ ; } } else { int endYear = windowEnd . getYear ( ) ; for ( TZRule lastRule : lastRuleList ) { addRule ( lastRule . year , endYear + 1 , lastRule . month , lastRule . dayOfMonthIndicator , lastRule . dayOfWeek , lastRule . time , lastRule . timeEndOfDay , lastRule . timeDefinition , lastRule . savingAmountSecs ) ; } lastRuleList . clear ( ) ; maxLastRuleStartYear = YEAR_MAX_VALUE ; } Collections . sort ( ruleList ) ; Collections . sort ( lastRuleList ) ; if ( ruleList . size ( ) == 0 && fixedSavingAmountSecs == null ) { fixedSavingAmountSecs = 0 ; } } | Adds rules to make the last rules all start from the same year. Also add one more year to avoid weird case where penultimate year has odd offset. |
672 | private int [ ] determineDimensions ( int sourceCodeWords , int errorCorrectionCodeWords ) throws WriterException { float ratio = 0.0f ; int [ ] dimension = null ; for ( int cols = minCols ; cols <= maxCols ; cols ++ ) { int rows = calculateNumberOfRows ( sourceCodeWords , errorCorrectionCodeWords , cols ) ; if ( rows < minRows ) { break ; } if ( rows > maxRows ) { continue ; } float newRatio = ( ( 17 * cols + 69 ) * DEFAULT_MODULE_WIDTH ) / ( rows * HEIGHT ) ; if ( dimension != null && Math . abs ( newRatio - PREFERRED_RATIO ) > Math . abs ( ratio - PREFERRED_RATIO ) ) { continue ; } ratio = newRatio ; dimension = new int [ ] { cols , rows } ; } if ( dimension == null ) { int rows = calculateNumberOfRows ( sourceCodeWords , errorCorrectionCodeWords , minCols ) ; if ( rows < minRows ) { dimension = new int [ ] { minCols , minRows } ; } } if ( dimension == null ) { throw new WriterException ( "Unable to fit message in columns" ) ; } return dimension ; } | Determine optimal nr of columns and rows for the specified number of codewords. |
673 | private void logAfterLoad ( ) { Enumeration elem = properties . keys ( ) ; List lp = Collections . list ( elem ) ; Collections . sort ( lp ) ; Iterator iter = lp . iterator ( ) ; finer ( "Configuration contains " + properties . size ( ) + " keys." ) ; finer ( "List of configuration properties, after override:" ) ; while ( iter . hasNext ( ) ) { String key = ( String ) iter . next ( ) ; String val = properties . getProperty ( key ) ; finer ( " " + key + " = " + val ) ; } finer ( "Properties list complete." ) ; } | Writes a log of loaded properties to the plumbing.init Logger. |
674 | public T removeItemByPosition ( int position ) { if ( position < mObjects . size ( ) && position != INVALID_POSITION ) { mObjectDeleted = mObjects . remove ( position ) ; mHasDeletedPosition = position ; notifyDataSetChanged ( ) ; return mObjectDeleted ; } else { throw new IndexOutOfBoundsException ( "The position is invalid!" ) ; } } | remove the specified object by the position. |
675 | public static QName valueOf ( CharSequence name ) { QName qName = ( QName ) FULL_NAME_TO_QNAME . get ( name ) ; return ( qName != null ) ? qName : QName . createNoNamespace ( name . toString ( ) ) ; } | Returns the qualified name corresponding to the specified character sequence representation (may include the "{namespaceURI}" prefix). |
676 | protected final void putChar ( char ch ) { if ( sp == sbuf . length ) { char [ ] newsbuf = new char [ sbuf . length * 2 ] ; System . arraycopy ( sbuf , 0 , newsbuf , 0 , sbuf . length ) ; sbuf = newsbuf ; } sbuf [ sp ++ ] = ch ; } | Append a character to sbuf. |
677 | @ Transactional ( readOnly = true ) @ Cacheable ( value = "network_download_count" , key = "#user.id" ) public int countDownloadsByUserSince ( final User user , final Long period ) { Objects . requireNonNull ( user , "'user' parameter is null" ) ; Objects . requireNonNull ( period , "'period' parameter is null" ) ; long current_timestamp = System . currentTimeMillis ( ) ; if ( period < 0 || period > current_timestamp ) { throw new IllegalArgumentException ( "period time too high" ) ; } Date date = new Date ( current_timestamp - period ) ; return networkUsageDao . countDownloadByUserSince ( user , date ) ; } | Returns number of downloads by a user on a given period. |
678 | public UMUserPasswordResetOptionsData ( String question , String questionLocalizedName , String answer , int dataStatus ) { this . question = question . trim ( ) ; this . questionLocalizedName = questionLocalizedName ; this . answer = answer . trim ( ) ; this . dataStatus = dataStatus ; } | Constructs a user password reset options data object |
679 | private void assertCharVectors ( int n ) { int k = 2 * n + 1 ; int limit = ( int ) Math . pow ( 2 , k + 2 ) ; for ( int i = 0 ; i < limit ; i ++ ) { String encoded = Integer . toString ( i , 2 ) ; assertLev ( encoded , n ) ; } } | Tests all possible characteristic vectors for some n This exhaustively tests the parametric transitions tables. |
680 | static String expandEnvironmentVariables ( String value ) { if ( null == value ) { return null ; } Matcher m = ENV_VAR_PATTERN . matcher ( value ) ; StringBuffer sb = new StringBuffer ( ) ; while ( m . find ( ) ) { String envVarValue = null ; String envVarName = null == m . group ( 1 ) ? m . group ( 2 ) : m . group ( 1 ) ; if ( envVarName . startsWith ( ( "env." ) ) ) { envVarValue = System . getenv ( envVarName . substring ( 3 ) ) ; } else { envVarValue = System . getProperty ( envVarName ) ; } m . appendReplacement ( sb , null == envVarValue ? "" : Matcher . quoteReplacement ( envVarValue ) ) ; } m . appendTail ( sb ) ; return sb . toString ( ) ; } | Return the string value, expanding any environment variables found in the expression. <p> For example "Home dir is ${env.HOME}" will expand using the env var "HOME" to something like "Home dir is /home/justin_bieber" |
681 | public HashTokenSessionMap ( Environment environment ) { int sessionTimeoutValue ; try { sessionTimeoutValue = environment . getProperty ( API_SESSION_TIMEOUT , 60 ) ; } catch ( GuacamoleException e ) { logger . error ( "Unable to read guacamole.properties: {}" , e . getMessage ( ) ) ; logger . debug ( "Error while reading session timeout value." , e ) ; sessionTimeoutValue = 60 ; } logger . info ( "Sessions will expire after {} minutes of inactivity." , sessionTimeoutValue ) ; executor . scheduleAtFixedRate ( new SessionEvictionTask ( sessionTimeoutValue * 60000l ) , 1 , 1 , TimeUnit . MINUTES ) ; } | Create a new HashTokenSessionMap configured using the given environment. |
682 | private int oidcClaimsUsageCount ( String uuid ) throws SSOException , SMSException { SMSEntry smsEntry = new SMSEntry ( getToken ( ) , getOAuth2ProviderBaseDN ( ) ) ; Map < String , Set < String > > attributes = smsEntry . getAttributes ( ) ; try { Set < String > sunKeyValues = getMapSetThrows ( attributes , "sunKeyValue" ) ; if ( sunKeyValues . contains ( "forgerock-oauth2-provider-oidc-claims-extension-script=" + uuid ) ) { return 1 ; } } catch ( ValueNotFoundException ignored ) { } return 0 ; } | Count how many times the script identified by the specified uuid is used in OIDC claims. |
683 | public synchronized AlphabeticIndex addLabels ( Locale locale ) { addLabels ( peer , locale . toString ( ) ) ; return this ; } | Adds the index characters from the given locale to the index. The labels are added to those that are already in the index; they do not replace the existing index characters. The collation order for this index is not changed; it remains that of the locale that was originally specified when creating this index. |
684 | public EventExpireThread ( ) { super ( "event expire" ) ; setDaemon ( true ) ; } | Create a daemon thread |
685 | public boolean isHeader ( int position ) { return position >= 0 && position < mHeaderViews . size ( ) ; } | jude is head view |
686 | public void testCase6 ( ) { byte aBytes [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 1 , 2 , 3 } ; byte bBytes [ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 10 , 20 , 30 } ; int aSign = - 1 ; int bSign = - 1 ; byte rBytes [ ] = { 9 , 18 , 27 , 36 , 45 , 54 , 63 , 9 , 18 , 27 } ; BigInteger aNumber = new BigInteger ( aSign , aBytes ) ; BigInteger bNumber = new BigInteger ( bSign , bBytes ) ; BigInteger result = aNumber . subtract ( bNumber ) ; byte resBytes [ ] = new byte [ rBytes . length ] ; resBytes = result . toByteArray ( ) ; for ( int i = 0 ; i < resBytes . length ; i ++ ) { assertTrue ( resBytes [ i ] == rBytes [ i ] ) ; } assertEquals ( 1 , result . signum ( ) ) ; } | Subtract two negative numbers of the same length. The second is greater in absolute value. |
687 | @ Override public void drawRangeMarker ( Graphics2D g2 , CategoryPlot plot , ValueAxis axis , Marker marker , Rectangle2D dataArea ) { Rectangle2D adjusted = new Rectangle2D . Double ( dataArea . getX ( ) , dataArea . getY ( ) + getYOffset ( ) , dataArea . getWidth ( ) - getXOffset ( ) , dataArea . getHeight ( ) - getYOffset ( ) ) ; if ( marker instanceof ValueMarker ) { ValueMarker vm = ( ValueMarker ) marker ; double value = vm . getValue ( ) ; Range range = axis . getRange ( ) ; if ( ! range . contains ( value ) ) { return ; } GeneralPath path = null ; PlotOrientation orientation = plot . getOrientation ( ) ; if ( orientation == PlotOrientation . HORIZONTAL ) { float x = ( float ) axis . valueToJava2D ( value , adjusted , plot . getRangeAxisEdge ( ) ) ; float y = ( float ) adjusted . getMaxY ( ) ; path = new GeneralPath ( ) ; path . moveTo ( x , y ) ; path . lineTo ( ( float ) ( x + getXOffset ( ) ) , y - ( float ) getYOffset ( ) ) ; path . lineTo ( ( float ) ( x + getXOffset ( ) ) , ( float ) ( adjusted . getMinY ( ) - getYOffset ( ) ) ) ; path . lineTo ( x , ( float ) adjusted . getMinY ( ) ) ; path . closePath ( ) ; } else if ( orientation == PlotOrientation . VERTICAL ) { float y = ( float ) axis . valueToJava2D ( value , adjusted , plot . getRangeAxisEdge ( ) ) ; float x = ( float ) dataArea . getX ( ) ; path = new GeneralPath ( ) ; path . moveTo ( x , y ) ; path . lineTo ( x + ( float ) this . xOffset , y - ( float ) this . yOffset ) ; path . lineTo ( ( float ) ( adjusted . getMaxX ( ) + this . xOffset ) , y - ( float ) this . yOffset ) ; path . lineTo ( ( float ) ( adjusted . getMaxX ( ) ) , y ) ; path . closePath ( ) ; } else { throw new IllegalStateException ( ) ; } g2 . setPaint ( marker . getPaint ( ) ) ; g2 . fill ( path ) ; g2 . setPaint ( marker . getOutlinePaint ( ) ) ; g2 . draw ( path ) ; String label = marker . getLabel ( ) ; RectangleAnchor anchor = marker . getLabelAnchor ( ) ; if ( label != null ) { Font labelFont = marker . getLabelFont ( ) ; g2 . setFont ( labelFont ) ; g2 . setPaint ( marker . getLabelPaint ( ) ) ; Point2D coordinates = calculateRangeMarkerTextAnchorPoint ( g2 , orientation , dataArea , path . getBounds2D ( ) , marker . getLabelOffset ( ) , LengthAdjustmentType . EXPAND , anchor ) ; TextUtilities . drawAlignedString ( label , g2 , ( float ) coordinates . getX ( ) , ( float ) coordinates . getY ( ) , marker . getLabelTextAnchor ( ) ) ; } } else { super . drawRangeMarker ( g2 , plot , axis , marker , adjusted ) ; } } | Draws a range marker. |
688 | public void clearBreakpointsPassive ( final BreakpointType type ) { Preconditions . checkNotNull ( type , "IE01011: Type argument can not be null" ) ; NaviLogger . info ( "Clearing all breakpoints of type '%s' passively" , type ) ; switch ( type ) { case REGULAR : throw new IllegalStateException ( "IE01018: Regular breakpoints can not be cleared passively" ) ; case ECHO : echoBreakpointStorage . clear ( ) ; return ; case STEP : stepBreakpointStorage . clear ( ) ; return ; default : throw new IllegalStateException ( String . format ( "IE01017: Invalid breakpoint type '%s'" , type ) ) ; } } | Clears all echo breakpoints without notifying the listeners about the deleted breakpoints. |
689 | public Enumeration content ( ) { return table . elements ( ) ; } | Returns Enumeration of the elements of the Hashtable "Table", which are pair of the form (Pair link, SymbolNode sn) |
690 | @ Override @ SuppressWarnings ( "unchecked" ) public synchronized < T > T [ ] toArray ( T [ ] contents ) { if ( elementCount > contents . length ) { return null ; } System . arraycopy ( elementData , 0 , contents , 0 , elementCount ) ; if ( elementCount < contents . length ) { contents [ elementCount ] = null ; } return contents ; } | Returns an array containing all elements contained in this vector. If the specified array is large enough to hold the elements, the specified array is used, otherwise an array of the same type is created. If the specified array is used and is larger than this vector, the array element following the collection elements is set to null. |
691 | static private boolean isNoncapturingParen ( String s , int pos ) { boolean isLookbehind = false ; { String pre = s . substring ( pos , pos + 4 ) ; isLookbehind = pre . equals ( "(?<=" ) || pre . equals ( "(?<!" ) ; } return s . charAt ( pos + 1 ) == '?' && ( isLookbehind || s . charAt ( pos + 2 ) != '<' ) ; } | Determines if the parenthesis at the specified position of a string is for a non-capturing group, which is one of the flag specifiers (e.g., (?s) or (?m) or (?:pattern). If the parenthesis is followed by "?", it must be a non- capturing group unless it's a named group (which begins with "?<"). Make sure not to confuse it with the lookbehind construct ("?<=" or "?<!"). |
692 | public synchronized void clearDynamicProperties ( ) throws ReplicatorException { logger . info ( "Clearing dynamic properties" ) ; if ( dynamicProperties != null ) dynamicProperties . clear ( ) ; if ( dynamicPropertiesFile . exists ( ) ) { if ( ! dynamicPropertiesFile . delete ( ) ) logger . error ( "Unable to delete dynamic properties file: " + dynamicPropertiesFile . getAbsolutePath ( ) ) ; } if ( dynamicRoleFile != null ) { if ( dynamicRoleFile . exists ( ) ) { if ( ! dynamicRoleFile . delete ( ) ) logger . error ( "Unable to delete dynamic role file: " + dynamicRoleFile . getAbsolutePath ( ) ) ; } } } | Clear in-memory dynamic properties and delete on-disk file, if it exists. |
693 | public String pullRequestsUrl ( String account , String collection , String repoId ) { Objects . requireNonNull ( repoId , "Repository id required" ) ; return getTeamBaseUrl ( account , collection ) + format ( PULL_REQUESTS , repoId ) + getApiVersion ( ) ; } | Returns the url for pull requests. |
694 | public final void append ( char value ) { char [ ] chunk ; if ( m_firstFree < m_chunkSize ) chunk = m_array [ m_lastChunk ] ; else { int i = m_array . length ; if ( m_lastChunk + 1 == i ) { char [ ] [ ] newarray = new char [ i + 16 ] [ ] ; System . arraycopy ( m_array , 0 , newarray , 0 , i ) ; m_array = newarray ; } chunk = m_array [ ++ m_lastChunk ] ; if ( chunk == null ) { if ( m_lastChunk == 1 << m_rebundleBits && m_chunkBits < m_maxChunkBits ) { m_innerFSB = new FastStringBuffer ( this ) ; } chunk = m_array [ m_lastChunk ] = new char [ m_chunkSize ] ; } m_firstFree = 0 ; } chunk [ m_firstFree ++ ] = value ; } | Append a single character onto the FastStringBuffer, growing the storage if necessary. <p> NOTE THAT after calling append(), previously obtained references to m_array[][] may no longer be valid.... though in fact they should be in this instance. |
695 | protected abstract String defaultColumnName ( ) ; | Returns default name for Cassandra column (if it's not specified explicitly). |
696 | private void publishRtf ( Resource resource , BigDecimal version ) throws PublicationException { if ( isLocked ( resource . getShortname ( ) ) ) { throw new PublicationException ( PublicationException . TYPE . LOCKED , "Resource " + resource . getShortname ( ) + " is currently locked by another process" ) ; } Document doc = new Document ( ) ; File rtfFile = dataDir . resourceRtfFile ( resource . getShortname ( ) , version ) ; OutputStream out = null ; try { out = new FileOutputStream ( rtfFile ) ; RtfWriter2 . getInstance ( doc , out ) ; eml2Rtf . writeEmlIntoRtf ( doc , resource ) ; } catch ( FileNotFoundException e ) { throw new PublicationException ( PublicationException . TYPE . RTF , "Can't find rtf file to write metadata to: " + rtfFile . getAbsolutePath ( ) , e ) ; } catch ( DocumentException e ) { throw new PublicationException ( PublicationException . TYPE . RTF , "RTF DocumentException while writing to file: " + rtfFile . getAbsolutePath ( ) , e ) ; } catch ( Exception e ) { throw new PublicationException ( PublicationException . TYPE . RTF , "An unexpected error occurred while writing RTF file: " + e . getMessage ( ) , e ) ; } finally { if ( out != null ) { try { out . close ( ) ; } catch ( IOException e ) { log . warn ( "FileOutputStream to RTF file could not be closed" ) ; } } } } | Publishes a new version of the RTF file for the given resource. |
697 | public synchronized void returnBuf ( byte [ ] buf ) { if ( buf == null || buf . length > mSizeLimit ) { return ; } mBuffersByLastUse . add ( buf ) ; int pos = Collections . binarySearch ( mBuffersBySize , buf , BUF_COMPARATOR ) ; if ( pos < 0 ) { pos = - pos - 1 ; } mBuffersBySize . add ( pos , buf ) ; mCurrentSize += buf . length ; trim ( ) ; } | Returns a buffer to the pool, throwing away old buffers if the pool would exceed its allotted size. |
698 | public static String slurpFile ( File file ) throws IOException { Reader r = new FileReader ( file ) ; return slurpReader ( r ) ; } | Returns all the text in the given File. |
699 | public boolean connectToBroker ( final MqttAsyncConnection connection ) { try { connection . connect ( new MqttCallbackHandler ( connection ) , new MqttAsyncConnectionRunnable ( connection ) ) ; return true ; } catch ( SpyException e ) { Platform . runLater ( new MqttEventHandler ( new MqttConnectionAttemptFailureEvent ( connection , e ) ) ) ; logger . error ( e . getMessage ( ) , e ) ; } return false ; } | Connects the specified connection to a broker. |
Subsets and Splits