idx
int64 0
34.9k
| question
stringlengths 12
26.4k
| target
stringlengths 15
2.3k
|
---|---|---|
400 | protected ASN1Sequence ( ASN1EncodableVector v ) { for ( int i = 0 ; i != v . size ( ) ; i ++ ) { seq . addElement ( v . get ( i ) ) ; } } | create a sequence containing a vector of objects. |
401 | private final double readDatum ( final DataInput in , final ColumnType columnType ) throws IOException { switch ( columnType ) { case DOUBLE : return in . readDouble ( ) ; case INTEGER : int iValue = in . readInt ( ) ; if ( iValue == Integer . MIN_VALUE + 1 ) { boolean isMissing = in . readBoolean ( ) ; if ( isMissing ) { return Double . NaN ; } else { return iValue ; } } else { return iValue ; } case NOMINAL_BYTE : byte bValue = in . readByte ( ) ; if ( bValue == - 1 ) { return Double . NaN ; } else { return bValue ; } case NOMINAL_INTEGER : iValue = in . readInt ( ) ; if ( iValue == - 1 ) { return Double . NaN ; } else { return iValue ; } case NOMINAL_SHORT : short sValue = in . readShort ( ) ; if ( sValue == - 1 ) { return Double . NaN ; } else { return sValue ; } default : throw new RuntimeException ( "Illegal type: " + columnType ) ; } } | Reads a single datum in non-sparse representation of the given type and returns it as a double. |
402 | protected void closeTransportLayer ( ) throws IOException { super . close ( ) ; if ( input != null ) { input . close ( ) ; output . close ( ) ; } } | Closes the transport data streams. |
403 | public double op ( final double x ) { final double sn = Math . sin ( this . asr * ( - x + 1 ) * 0.5 ) ; return Math . exp ( ( sn * hk - hs ) / ( 1.0 - sn * sn ) ) ; } | Computes equation 3, see references |
404 | public void listen ( StanzaListener stanzaListener , StanzaFilter stanzaFilter ) { connection . addAsyncStanzaListener ( stanzaListener , stanzaFilter ) ; logger . info ( "Listening for incoming XMPP Stanzas..." ) ; } | Begin listening for incoming messages. |
405 | public static void addInputMode ( String name , Hashtable values , boolean firstUpcase ) { initInputModes ( ) ; inputModes . put ( name , values ) ; if ( firstUpcase ) { firstUppercaseInputMode . addElement ( name ) ; } } | Adds a new inputmode hashtable with the given name and set of values |
406 | private static String doGetPath ( String filename , int separatorAdd ) { if ( filename == null ) { return null ; } int prefix = getPrefixLength ( filename ) ; if ( prefix < 0 ) { return null ; } int index = indexOfLastSeparator ( filename ) ; int endIndex = index + separatorAdd ; if ( prefix >= filename . length ( ) || index < 0 || prefix >= endIndex ) { return "" ; } return filename . substring ( prefix , endIndex ) ; } | Does the work of getting the path. |
407 | @ Override public void addEnvVarUpdatedListener ( EnvVarUpdateInterface listener ) { if ( ! listenerList . contains ( listener ) ) { listenerList . add ( listener ) ; } } | Adds the env var updated listener. |
408 | private void init ( Configuration exp ) throws IOException { isInitialized = true ; } | Private initializer method that sets up the generic resources. |
409 | public List < LocalVariable > visibleVariables ( ) throws AbsentInformationException { validateStackFrame ( ) ; createVisibleVariables ( ) ; List < LocalVariable > mapAsList = new ArrayList < LocalVariable > ( visibleVariables . values ( ) ) ; Collections . sort ( mapAsList ) ; return mapAsList ; } | Return the list of visible variable in the frame. Need not be synchronized since it cannot be provably stale. |
410 | private static List < Object > createEqualityKey ( Node node ) { List < Object > values = new ArrayList < Object > ( ) ; values . add ( node . getNodeType ( ) ) ; values . add ( node . getNodeName ( ) ) ; values . add ( node . getLocalName ( ) ) ; values . add ( node . getNamespaceURI ( ) ) ; values . add ( node . getPrefix ( ) ) ; values . add ( node . getNodeValue ( ) ) ; for ( Node child = node . getFirstChild ( ) ; child != null ; child = child . getNextSibling ( ) ) { values . add ( child ) ; } switch ( node . getNodeType ( ) ) { case DOCUMENT_TYPE_NODE : DocumentTypeImpl doctype = ( DocumentTypeImpl ) node ; values . add ( doctype . getPublicId ( ) ) ; values . add ( doctype . getSystemId ( ) ) ; values . add ( doctype . getInternalSubset ( ) ) ; values . add ( doctype . getEntities ( ) ) ; values . add ( doctype . getNotations ( ) ) ; break ; case ELEMENT_NODE : Element element = ( Element ) node ; values . add ( element . getAttributes ( ) ) ; break ; } return values ; } | Returns a list of objects such that two nodes are equal if their lists are equal. Be careful: the lists may contain NamedNodeMaps and Nodes, neither of which override Object.equals(). Such values must be compared manually. |
411 | public static void startServices ( ServiceHost host , Class ... services ) throws InstantiationException , IllegalAccessException { checkArgument ( services != null , "services cannot be null" ) ; for ( Class service : services ) { startService ( host , service ) ; } } | Starts the list of services on the host. |
412 | private AppliedMigration createAppliedMigration ( int version , String description ) { return new AppliedMigration ( version , version , MigrationVersion . fromVersion ( Integer . toString ( version ) ) , description , MigrationType . CQL , "x" , null , new Date ( ) , "sa" , 123 , true ) ; } | Creates a new applied migration with this version. |
413 | TemplateEntry nextEntry ( ) { if ( ! hasNext ( ) ) { throw new NoSuchElementException ( ) ; } final TemplateEntry entry = nextEntry ; nextEntry = null ; return entry ; } | Returns the next generated entry. |
414 | private void createRecordHolderQueue ( File [ ] listFiles ) { this . recordHolderHeap = new PriorityQueue < SortTempFileChunkHolder > ( listFiles . length ) ; } | This method will be used to create the heap which will be used to hold the chunk of data |
415 | public static double correlation ( double [ ] x , double [ ] y ) { if ( x . length == y . length ) { double mx = MathUtils . mean ( x ) ; double my = MathUtils . mean ( y ) ; double sx = Math . sqrt ( MathUtils . variance ( x ) ) ; double sy = Math . sqrt ( MathUtils . variance ( y ) ) ; int n = x . length ; double nval = 0.0 ; for ( int i = 0 ; i < n ; i ++ ) { nval += ( x [ i ] - mx ) * ( y [ i ] - my ) ; } double r = nval / ( ( n - 1 ) * sx * sy ) ; return r ; } else throw new IllegalArgumentException ( "vectors of different size" ) ; } | Sample correlation coefficient Ref: http://en.wikipedia.org/wiki/Correlation_and_dependence |
416 | public static int writeMessageFully ( Message msg , OutputStream out , ByteBuffer buf , MessageWriter writer ) throws IOException { assert msg != null ; assert out != null ; assert buf != null ; assert buf . hasArray ( ) ; if ( writer != null ) writer . setCurrentWriteClass ( msg . getClass ( ) ) ; boolean finished = false ; int cnt = 0 ; while ( ! finished ) { finished = msg . writeTo ( buf , writer ) ; out . write ( buf . array ( ) , 0 , buf . position ( ) ) ; cnt += buf . position ( ) ; buf . clear ( ) ; } return cnt ; } | Fully writes communication message to provided stream. |
417 | @ Override public boolean connectionAllowed ( EventSetDescriptor esd ) { return connectionAllowed ( esd . getName ( ) ) ; } | Returns true if, at this time, the object will accept a connection according to the supplied EventSetDescriptor |
418 | protected final void dragExit ( final int x , final int y ) { DragSourceEvent event = new DragSourceEvent ( getDragSourceContext ( ) , x , y ) ; EventDispatcher dispatcher = new EventDispatcher ( DISPATCH_EXIT , event ) ; SunToolkit . invokeLaterOnAppContext ( SunToolkit . targetToAppContext ( getComponent ( ) ) , dispatcher ) ; startSecondaryEventLoop ( ) ; } | upcall from native code |
419 | public static String generateRandomString ( int count ) { Random random = new Random ( ) ; StringBuffer buffer = new StringBuffer ( ) ; while ( count -- != 0 ) { char ch = ( char ) ( random . nextInt ( 96 ) + 32 ) ; buffer . append ( ch ) ; } return buffer . toString ( ) ; } | Generate a random string. This is used for password encryption. |
420 | public void decrement ( ) { int counterVal = counter . decrementAndGet ( ) ; if ( counterVal == 0 ) { if ( null != resourceCallback ) { resourceCallback . onTransitionToIdle ( ) ; } becameIdleAt = SystemClock . uptimeMillis ( ) ; } if ( debugCounting ) { if ( counterVal == 0 ) { Log . i ( TAG , "Resource: " + resourceName + " went idle! (Time spent not idle: " + ( becameIdleAt - becameBusyAt ) + ")" ) ; } else { Log . i ( TAG , "Resource: " + resourceName + " in-use-count decremented to: " + counterVal ) ; } } if ( counterVal < 0 ) { throw new IllegalArgumentException ( "Counter has been corrupted!" ) ; } } | Decrements the count of in-flight transactions to the resource being monitored. If this operation results in the counter falling below 0 - an exception is raised. |
421 | public void removeTestingCallback ( OneSheeldTestingCallback testingCallback ) { if ( testingCallback != null && testingCallbacks . contains ( testingCallback ) ) testingCallbacks . remove ( testingCallback ) ; } | Remove a testing callback. |
422 | public boolean shouldDataBeRouted ( SimpleRouterContext context , DataMetaData dataMetaData , Node node , boolean initialLoad , boolean initialLoadSelectUsed , TriggerRouter triggerRouter ) { IDataRouter router = getDataRouter ( dataMetaData . getRouter ( ) ) ; Set < Node > oneNodeSet = new HashSet < Node > ( 1 ) ; oneNodeSet . add ( node ) ; Collection < String > nodeIds = router . routeToNodes ( context , dataMetaData , oneNodeSet , initialLoad , initialLoadSelectUsed , triggerRouter ) ; return nodeIds != null && nodeIds . contains ( node . getNodeId ( ) ) ; } | For use in data load events |
423 | private void verifyIsRoot ( ) { if ( hierarchyElements . size ( ) != 0 ) { throw new IllegalStateException ( "This is not the root. Can " + "only call addCounter() on the root node. Current node: " + hierarchy ) ; } } | verify that this node is the root |
424 | @ Override public Object put ( Object key , Object value ) { Entry tab [ ] = table ; int hash = 0 ; int index = 0 ; if ( key != null ) { hash = System . identityHashCode ( key ) ; index = ( hash & 0x7FFFFFFF ) % tab . length ; for ( Entry e = tab [ index ] ; e != null ; e = e . next ) { if ( ( e . hash == hash ) && key == e . key ) { Object old = e . value ; e . value = value ; return old ; } } } else { for ( Entry e = tab [ 0 ] ; e != null ; e = e . next ) { if ( e . key == null ) { Object old = e . value ; e . value = value ; return old ; } } } modCount ++ ; if ( count >= threshold ) { rehash ( ) ; tab = table ; index = ( hash & 0x7FFFFFFF ) % tab . length ; } Entry e = new Entry ( hash , key , value , tab [ index ] ) ; tab [ index ] = e ; count ++ ; return null ; } | Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced. |
425 | public static String backQuoteChars ( String string , char [ ] find , String [ ] replace ) { int index ; StringBuilder newStr ; int i ; if ( string == null ) return string ; for ( i = 0 ; i < find . length ; i ++ ) { if ( string . indexOf ( find [ i ] ) != - 1 ) { newStr = new StringBuilder ( ) ; while ( ( index = string . indexOf ( find [ i ] ) ) != - 1 ) { if ( index > 0 ) newStr . append ( string . substring ( 0 , index ) ) ; newStr . append ( replace [ i ] ) ; if ( ( index + 1 ) < string . length ( ) ) string = string . substring ( index + 1 ) ; else string = "" ; } newStr . append ( string ) ; string = newStr . toString ( ) ; } } return string ; } | Converts specified characters into the string equivalents. |
426 | public void testBitLengthNegative2 ( ) { byte aBytes [ ] = { - 128 , 56 , 100 , - 2 , - 76 , 89 , 45 , 91 , 3 , - 15 , 35 , 26 } ; int aSign = - 1 ; BigInteger aNumber = new BigInteger ( aSign , aBytes ) ; assertEquals ( 96 , aNumber . bitLength ( ) ) ; } | bitLength() of a negative number with the leftmost bit set |
427 | public void addLanguage ( ExecutionLanguage language ) { languages . add ( 1 , language ) ; } | Registers a new ExecutionLanguage to the registry. |
428 | private static boolean memberEquals ( final Class < ? > type , final Object o1 , final Object o2 ) { if ( o1 == o2 ) { return true ; } if ( o1 == null || o2 == null ) { return false ; } if ( type . isArray ( ) ) { return arrayMemberEquals ( type . getComponentType ( ) , o1 , o2 ) ; } if ( type . isAnnotation ( ) ) { return equals ( ( Annotation ) o1 , ( Annotation ) o2 ) ; } return o1 . equals ( o2 ) ; } | Helper method for checking whether two objects of the given type are equal. This method is used to compare the parameters of two annotation instances. |
429 | public Encoding ( String name ) { this . name = name ; } | Constructs a new encoding. |
430 | private String base64 ( String value ) { StringBuffer cb = new StringBuffer ( ) ; int i = 0 ; for ( i = 0 ; i + 2 < value . length ( ) ; i += 3 ) { long chunk = ( int ) value . charAt ( i ) ; chunk = ( chunk << 8 ) + ( int ) value . charAt ( i + 1 ) ; chunk = ( chunk << 8 ) + ( int ) value . charAt ( i + 2 ) ; cb . append ( encode ( chunk > > 18 ) ) ; cb . append ( encode ( chunk > > 12 ) ) ; cb . append ( encode ( chunk > > 6 ) ) ; cb . append ( encode ( chunk ) ) ; } if ( i + 1 < value . length ( ) ) { long chunk = ( int ) value . charAt ( i ) ; chunk = ( chunk << 8 ) + ( int ) value . charAt ( i + 1 ) ; chunk <<= 8 ; cb . append ( encode ( chunk > > 18 ) ) ; cb . append ( encode ( chunk > > 12 ) ) ; cb . append ( encode ( chunk > > 6 ) ) ; cb . append ( '=' ) ; } else if ( i < value . length ( ) ) { long chunk = ( int ) value . charAt ( i ) ; chunk <<= 16 ; cb . append ( encode ( chunk > > 18 ) ) ; cb . append ( encode ( chunk > > 12 ) ) ; cb . append ( '=' ) ; cb . append ( '=' ) ; } return cb . toString ( ) ; } | Creates the Base64 value. |
431 | public String writeLongToString ( ) { StringBuilder builder = new StringBuilder ( ) ; for ( int i = 0 ; i < ( bitSet . getBits ( ) . length ) ; ++ i ) { builder . append ( Long . toString ( bitSet . getBits ( ) [ i ] ) + "|" ) ; } return builder . toString ( ) ; } | Writes vector to a string of the form 010 etc. (no delimiters). No terminating newline or delimiter. |
432 | @ Override public void committed ( long committedWindowId ) throws IOException { LOG . debug ( "data manager committed {}" , committedWindowId ) ; for ( Long currentWindow : savedWindows . keySet ( ) ) { if ( currentWindow <= largestWindowAddedToTransferQueue ) { continue ; } if ( currentWindow <= committedWindowId ) { LOG . debug ( "to transfer {}" , currentWindow ) ; largestWindowAddedToTransferQueue = currentWindow ; windowsToTransfer . add ( currentWindow ) ; } else { break ; } } } | Transfers the data which has been committed till windowId to data files. |
433 | public void delete ( RandomAccessFile raf , RandomAccessFile tempRaf ) throws CannotReadException , CannotWriteException , IOException { raf . seek ( 0 ) ; tempRaf . seek ( 0 ) ; deleteTag ( raf , tempRaf ) ; } | Delete the tag (if any) present in the given randomaccessfile, and do not close it at the end. |
434 | void onDeferredEndDrag ( DragView dragView ) { dragView . remove ( ) ; if ( mDragObject . deferDragViewCleanupPostAnimation ) { for ( DragListener listener : new ArrayList < > ( mListeners ) ) { listener . onDragEnd ( ) ; } } } | This only gets called as a result of drag view cleanup being deferred in endDrag(); |
435 | private byte [ ] pageToByteArray ( P page ) { try { if ( page == null ) { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; oos . writeInt ( EMPTY_PAGE ) ; oos . close ( ) ; baos . close ( ) ; byte [ ] array = baos . toByteArray ( ) ; byte [ ] result = new byte [ pageSize ] ; System . arraycopy ( array , 0 , result , 0 , array . length ) ; return result ; } else { ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; ObjectOutputStream oos = new ObjectOutputStream ( baos ) ; oos . writeInt ( FILLED_PAGE ) ; page . writeExternal ( oos ) ; oos . close ( ) ; baos . close ( ) ; byte [ ] array = baos . toByteArray ( ) ; if ( array . length > this . pageSize ) { throw new IllegalArgumentException ( "Size of page " + page + " is greater than specified" + " pagesize: " + array . length + " > " + pageSize ) ; } else if ( array . length == this . pageSize ) { return array ; } else { byte [ ] result = new byte [ pageSize ] ; System . arraycopy ( array , 0 , result , 0 , array . length ) ; return result ; } } } catch ( IOException e ) { throw new RuntimeException ( "IOException occurred! " , e ) ; } } | Serializes an object into a byte array. |
436 | void presentDecorAnimations ( int position , float offset ) { int animMapSize = mDecorAnimations . size ( ) ; for ( int i = 0 ; i < animMapSize ; i ++ ) { Decor decor = mDecorAnimations . keyAt ( i ) ; ArrayList < Animation > animations = mDecorAnimations . get ( decor ) ; int animListSize = animations . size ( ) ; for ( int j = 0 ; j < animListSize ; j ++ ) { Animation animation = animations . get ( j ) ; if ( animation == null ) { continue ; } if ( ! animation . shouldAnimate ( position ) ) { if ( mPreviousPosition < position && animation . pageEnd < position ) { animation . animate ( decor . contentView , 1 , 0 , position ) ; } else if ( mPreviousPosition > position && animation . pageStart > position ) { animation . animate ( decor . contentView , 0 , 0 , position ) ; } continue ; } animation . animate ( decor . contentView , offset , 0 , position ) ; } } mPreviousPosition = position ; } | Run the animations based on the Decor animations saved within the presenter and the offset of the scrolling. |
437 | public static boolean deltree ( File directory ) { if ( directory == null || ! directory . exists ( ) ) { return true ; } boolean result = true ; if ( directory . isFile ( ) ) { result = directory . delete ( ) ; } else { File [ ] list = directory . listFiles ( ) ; for ( int i = list . length ; i -- > 0 ; ) { if ( ! deltree ( list [ i ] ) ) { result = false ; } } if ( ! directory . delete ( ) ) { result = false ; } } return result ; } | Deletes the given file and everything under it. |
438 | 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. |
439 | public void invalidate ( long newFileSize ) { if ( newFileSize < fileSize ) { fileSize = newFileSize ; counters . clear ( ) ; blockSize = calcBlockSize ( fileSize ) ; } else if ( newFileSize > fileSize ) compact ( newFileSize ) ; } | Check if counters and blockSize should be adjusted according to file size. |
440 | public void addCase ( SwitchCase switchCase ) { assertNotNull ( switchCase ) ; if ( cases == null ) { cases = new ArrayList < SwitchCase > ( ) ; } cases . add ( switchCase ) ; switchCase . setParent ( this ) ; } | Adds a switch case statement to the end of the list. |
441 | 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. |
442 | public void test_atomicAppendFullBlock ( ) throws IOException { final String id = "test" ; final int version = 0 ; Random r = new Random ( ) ; final byte [ ] expected = new byte [ BLOCK_SIZE ] ; r . nextBytes ( expected ) ; final long block0 = repo . appendBlock ( id , version , expected , 0 , expected . length ) ; assertEquals ( "block#" , 0L , block0 ) ; assertEquals ( "blockCount" , 1 , repo . getBlockCount ( id , version ) ) ; assertEquals ( "readBlock" , expected , repo . readBlock ( id , version , block0 ) ) ; assertEquals ( "inputStream" , expected , read ( repo . inputStream ( id , version ) ) ) ; } | Atomic append of a full block. |
443 | public static int hash ( byte [ ] data , int offset , int length , int seed ) { return hash ( ByteBuffer . wrap ( data , offset , length ) , seed ) ; } | Hashes bytes in part of an array. |
444 | protected void layoutContainer ( ) { Rectangle inBounds = p . getBounds ( ) ; Insets insets = p . getInsets ( ) ; inBounds . x += insets . left ; inBounds . width -= insets . left ; inBounds . width -= insets . right ; inBounds . y += insets . top ; inBounds . height -= insets . top ; inBounds . height -= insets . bottom ; backgroundBounds = ( Rectangle ) inBounds . clone ( ) ; occludingBounds = ( Rectangle ) inBounds . clone ( ) ; layoutCardinals ( ) ; layoutEast ( p . getEast ( ) , occludingBounds . x + occludingBounds . width , occludingBounds . y , occludingBounds . width , occludingBounds . height ) ; layoutWest ( p . getWest ( ) , occludingBounds . x , occludingBounds . y , occludingBounds . width , occludingBounds . height ) ; int southLeft = inBounds . x + getWidthAtYCardinal ( p . getWest ( ) , inBounds . y + inBounds . height - getHeightAtLeftCardinal ( p . getSouth ( ) ) ) ; int southRight = inBounds . x + inBounds . width - getWidthAtYCardinal ( p . getEast ( ) , inBounds . y + inBounds . height - getHeightAtRightCardinal ( p . getSouth ( ) ) ) ; layoutSouth ( p . getSouth ( ) , southLeft , occludingBounds . y + occludingBounds . height , southRight - southLeft , occludingBounds . height ) ; int northLeft = inBounds . x + getWidthAtYCardinal ( p . getWest ( ) , inBounds . y + getHeightAtLeftCardinal ( p . getNorth ( ) ) ) ; int northRight = inBounds . x + inBounds . width - getWidthAtYCardinal ( p . getEast ( ) , inBounds . y + getHeightAtRightCardinal ( p . getNorth ( ) ) ) ; layoutNorth ( p . getNorth ( ) , northLeft , occludingBounds . y , northRight - northLeft , occludingBounds . height ) ; layoutBackground ( ) ; } | Layout the entire container. |
445 | public static boolean isFileExist ( String filePath , FileType fileType ) throws IOException { filePath = filePath . replace ( "\\" , "/" ) ; switch ( fileType ) { case HDFS : case VIEWFS : Path path = new Path ( filePath ) ; FileSystem fs = path . getFileSystem ( configuration ) ; return fs . exists ( path ) ; case LOCAL : default : File defaultFile = new File ( filePath ) ; return defaultFile . exists ( ) ; } } | This method checks the given path exists or not and also is it file or not if the performFileCheck is true |
446 | private void informUponSimilarName ( final StringBuffer messageBuffer , final String name , final String candidate ) { if ( name . equals ( candidate ) ) { return ; } if ( name . regionMatches ( true , 0 , candidate , 0 , PKG_LEN + 5 ) ) { messageBuffer . append ( " Did you mean '" ) ; messageBuffer . append ( candidate ) ; messageBuffer . append ( "'?" ) ; } } | Appends message if the given name is similar to the candidate. |
447 | private void checkQopSupport ( byte [ ] qopInChallenge , byte [ ] ciphersInChallenge ) throws IOException { String qopOptions ; if ( qopInChallenge == null ) { qopOptions = "auth" ; } else { qopOptions = new String ( qopInChallenge , encoding ) ; } String [ ] serverQopTokens = new String [ 3 ] ; byte [ ] serverQop = parseQop ( qopOptions , serverQopTokens , true ) ; byte serverAllQop = combineMasks ( serverQop ) ; switch ( findPreferredMask ( serverAllQop , qop ) ) { case 0 : throw new SaslException ( "DIGEST-MD5: No common protection " + "layer between client and server" ) ; case NO_PROTECTION : negotiatedQop = "auth" ; break ; case INTEGRITY_ONLY_PROTECTION : negotiatedQop = "auth-int" ; integrity = true ; rawSendSize = sendMaxBufSize - 16 ; break ; case PRIVACY_PROTECTION : negotiatedQop = "auth-conf" ; privacy = integrity = true ; rawSendSize = sendMaxBufSize - 26 ; checkStrengthSupport ( ciphersInChallenge ) ; break ; } if ( logger . isLoggable ( Level . FINE ) ) { logger . log ( Level . FINE , "DIGEST61:Raw send size: {0}" , new Integer ( rawSendSize ) ) ; } } | Parses the 'qop' directive. If 'auth-conf' is specified by the client and offered as a QOP option by the server, then a check is client-side supported ciphers is performed. |
448 | public void close ( boolean pCloseUnderlying ) throws IOException { if ( closed ) { return ; } if ( pCloseUnderlying ) { closed = true ; input . close ( ) ; } else { for ( ; ; ) { int av = available ( ) ; if ( av == 0 ) { av = makeAvailable ( ) ; if ( av == 0 ) { break ; } } long skip = skip ( av ) ; if ( skip != av ) { if ( log . isDebugEnabled ( ) ) { log . debug ( skip + " bytes been skipped." ) ; } } } } closed = true ; } | Closes the input stream. |
449 | protected void addNewEvent ( Object eventKey , T event ) { if ( unwrittenEvents == null ) { unwrittenEvents = Maps . newHashMap ( ) ; } List < T > listEvents = unwrittenEvents . get ( eventKey ) ; if ( listEvents == null ) { unwrittenEvents . put ( eventKey , Lists . newArrayList ( event ) ) ; } else { listEvents . add ( event ) ; } } | Add the given event into the unwritternEvents map |
450 | public static Locale localeFromString ( final String localeAsString ) { if ( StringUtils . isBlank ( localeAsString ) ) { final List < ApiParameterError > dataValidationErrors = new ArrayList < > ( ) ; final ApiParameterError error = ApiParameterError . parameterError ( "validation.msg.invalid.locale.format" , "The parameter locale is invalid. It cannot be blank." , "locale" ) ; dataValidationErrors . add ( error ) ; throw new PlatformApiDataValidationException ( "validation.msg.validation.errors.exist" , "Validation errors exist." , dataValidationErrors ) ; } String languageCode = "" ; String countryCode = "" ; String variantCode = "" ; final String [ ] localeParts = localeAsString . split ( "_" ) ; if ( localeParts != null && localeParts . length == 1 ) { languageCode = localeParts [ 0 ] ; } if ( localeParts != null && localeParts . length == 2 ) { languageCode = localeParts [ 0 ] ; countryCode = localeParts [ 1 ] ; } if ( localeParts != null && localeParts . length == 3 ) { languageCode = localeParts [ 0 ] ; countryCode = localeParts [ 1 ] ; variantCode = localeParts [ 2 ] ; } return localeFrom ( languageCode , countryCode , variantCode ) ; } | TODO: Vishwas move all Locale related code to a separate Utils class |
451 | protected Object decodeResponse ( InputStream inputStream , String contentType ) throws IOException { Object value ; if ( contentType . startsWith ( JSON_MIME_TYPE ) ) { JSONDecoder decoder = new JSONDecoder ( ) ; value = decoder . readValue ( inputStream ) ; } else if ( contentType . startsWith ( TEXT_MIME_TYPE_PREFIX ) ) { TextDecoder decoder = new TextDecoder ( ) ; value = decoder . readValue ( inputStream ) ; } else { value = null ; } return value ; } | Decodes a response value. |
452 | protected static Pair < String , String > asrImmediate ( final long offset , final ITranslationEnvironment environment , final List < ReilInstruction > instructions , final String registerNodeValue , final String immediateNodeValue ) { long baseOffset = offset ; final String shifterOperand = environment . getNextVariableString ( ) ; final String shifterCarryOut = environment . getNextVariableString ( ) ; if ( immediateNodeValue . equals ( "0" ) ) { final String tmpVar1 = environment . getNextVariableString ( ) ; instructions . add ( ReilHelpers . createBsh ( baseOffset ++ , dWordSize , registerNodeValue , wordSize , thirtyOneSet , byteSize , tmpVar1 ) ) ; instructions . add ( ReilHelpers . createAnd ( baseOffset ++ , byteSize , tmpVar1 , byteSize , oneSet , byteSize , shifterCarryOut ) ) ; instructions . add ( ReilHelpers . createSub ( baseOffset ++ , byteSize , shifterCarryOut , byteSize , String . valueOf ( 1 ) , dWordSize , shifterOperand ) ) ; return new Pair < String , String > ( shifterOperand , shifterCarryOut ) ; } else { final String tmpVar1 = environment . getNextVariableString ( ) ; final String tmpVar2 = environment . getNextVariableString ( ) ; final String tmpVar3 = environment . getNextVariableString ( ) ; final String tmpVar4 = environment . getNextVariableString ( ) ; final String tmpVar5 = environment . getNextVariableString ( ) ; instructions . add ( ReilHelpers . createAdd ( baseOffset ++ , dWordSize , registerNodeValue , dWordSize , bitMaskHighestBitSet , qWordSize , tmpVar1 ) ) ; instructions . add ( ReilHelpers . createBsh ( baseOffset ++ , qWordSize , tmpVar1 , wordSize , "-" + immediateNodeValue , dWordSize , tmpVar2 ) ) ; instructions . add ( ReilHelpers . createBsh ( baseOffset ++ , dWordSize , bitMaskHighestBitSet , wordSize , "-" + immediateNodeValue , dWordSize , tmpVar3 ) ) ; instructions . add ( ReilHelpers . createSub ( baseOffset ++ , dWordSize , tmpVar2 , dWordSize , tmpVar3 , qWordSize , tmpVar4 ) ) ; instructions . add ( ReilHelpers . createAnd ( baseOffset ++ , qWordSize , tmpVar4 , dWordSize , bitMaskAllBitsSet , dWordSize , shifterOperand ) ) ; instructions . add ( ReilHelpers . createBsh ( baseOffset ++ , dWordSize , registerNodeValue , dWordSize , String . valueOf ( - ( Integer . decode ( immediateNodeValue ) - 1 ) ) , wordSize , tmpVar5 ) ) ; instructions . add ( ReilHelpers . createAnd ( baseOffset ++ , wordSize , tmpVar5 , byteSize , oneSet , byteSize , shifterCarryOut ) ) ; return new Pair < String , String > ( shifterOperand , shifterCarryOut ) ; } } | <Rm>, ASR #<shift_imm> Operation: if shift_imm == 0 then if Rm[31] == 0 then shifter_operand = 0 shifter_carry_out = Rm[31] else // Rm[31] == 1 / shifter_operand = 0xFFFFFFFF shifter_carry_out = Rm[31] else / shift_imm > 0 / shifter_operand = Rm Arithmetic_Shift_Right <shift_imm> shifter_carry_out = Rm[shift_imm - 1] |
453 | private boolean isIncluded ( final HttpServletRequest request ) { String uri = ( String ) request . getAttribute ( "javax.servlet.include.request_uri" ) ; boolean includeRequest = ! ( uri == null ) ; if ( includeRequest && log . isDebugEnabled ( ) ) { log . debug ( "{} resulted in an include request. This is unusable, because" + "the response will be assembled into the overrall response. Not gzipping." , request . getRequestURL ( ) ) ; } return includeRequest ; } | Checks if the request uri is an include. These cannot be gzipped. |
454 | public static void loadModule ( final JTree tree , final INaviModule module ) { Preconditions . checkNotNull ( tree , "IE01195: Tree argument can not be null" ) ; Preconditions . checkNotNull ( module , "IE01196: Module argument can not be null" ) ; loadModuleThreaded ( SwingUtilities . getWindowAncestor ( tree ) , module , tree ) ; } | Loads a module while showing a progress dialog. |
455 | public boolean evaluate ( FeatureClassInfo fci , int row ) { boolean ret = true ; StringBuffer reasoning = null ; if ( logger . isLoggable ( Level . FINE ) ) { reasoning = new StringBuffer ( ) ; } if ( exp != null ) { ret = exp . evaluate ( fci , row , reasoning ) ; } if ( reasoning != null ) { reasoning . append ( "\n--------" ) ; logger . fine ( reasoning . toString ( ) ) ; } return ret ; } | Does the feature in row of fci pass the conditions of this expression. |
456 | public void addFunctionalInstrumentation ( SpecialInstrumentationPoint functionalInstrumentation ) { if ( null == functionalInstrumentations ) { functionalInstrumentations = new HashSet < SpecialInstrumentationPoint > ( 1 ) ; } functionalInstrumentations . add ( functionalInstrumentation ) ; } | Adds functional instrumentation point. |
457 | public final List < Integer > executeIntListQuery ( String sql ) throws AdeException { return SpecialSqlQueries . executeIntListQuery ( sql , m_connection ) ; } | Executes a query that is expected to returned a column of integers. |
458 | @ ApiOperation ( value = "Uninstall SymmetricDS on the single engine" ) @ RequestMapping ( value = "engine/uninstall" , method = RequestMethod . POST ) @ ResponseStatus ( HttpStatus . NO_CONTENT ) @ ResponseBody public final void postUninstall ( ) { uninstallImpl ( getSymmetricEngine ( ) ) ; } | Uninstalls all SymmetricDS objects from the given node (database) for the single engine on the node |
459 | public boolean oneOutgoingTransitionLeavesCompositeWithExitActions ( State state ) { Set < State > sourceParentStates = new HashSet < State > ( getParentStates ( state ) ) ; for ( Transition transition : state . getOutgoingTransitions ( ) ) { Set < State > targetParentStates = getParentStates ( transition . getTarget ( ) ) ; Set < State > crossedStates = new HashSet < State > ( sourceParentStates ) ; crossedStates . removeAll ( targetParentStates ) ; for ( State crossedCompositeState : crossedStates ) { if ( hasExitAction ( crossedCompositeState ) ) return true ; } } return false ; } | Checks if at least one of the outgoing transitions of the specified state leaves a parent composite of this state which has exit actions. |
460 | public static int determineConsecutiveDigitCount ( CharSequence msg , int startpos ) { int count = 0 ; int len = msg . length ( ) ; int idx = startpos ; if ( idx < len ) { char ch = msg . charAt ( idx ) ; while ( isDigit ( ch ) && idx < len ) { count ++ ; idx ++ ; if ( idx < len ) { ch = msg . charAt ( idx ) ; } } } return count ; } | Determines the number of consecutive characters that are encodable using numeric compaction. |
461 | @ Override public int read ( ) throws IOException { int x = in . read ( ) ; if ( x != - 1 ) { check . update ( x ) ; } return x ; } | Reads one byte of data from the underlying input stream and updates the checksum with the byte data. |
462 | public static boolean removeTable ( Table t ) { try { tableList . remove ( t ) ; } catch ( Exception e ) { return false ; } return true ; } | Remove the a table. |
463 | public void addScrollingListener ( OnWheelScrollListener listener ) { scrollingListeners . add ( listener ) ; } | Adds wheel scrolling listener |
464 | public Plot add ( String label , Population population , int x , int y ) { List < Number > xs = new ArrayList < Number > ( ) ; List < Number > ys = new ArrayList < Number > ( ) ; for ( Solution solution : population ) { if ( ! solution . violatesConstraints ( ) ) { xs . add ( solution . getObjective ( x ) ) ; ys . add ( solution . getObjective ( y ) ) ; } } scatter ( label , xs , ys ) ; setLabelsIfBlank ( "Objective " + ( x + 1 ) , "Objective " + ( y + 1 ) ) ; return this ; } | Displays the solutions in the given population in a 2D scatter plot. The two given objectives will be displayed. |
465 | private void initializeNeighborhoods ( ) { List < Individual > sortedPopulation = new ArrayList < Individual > ( population ) ; for ( Individual individual : population ) { Collections . sort ( sortedPopulation , new WeightSorter ( individual ) ) ; for ( int i = 0 ; i < neighborhoodSize ; i ++ ) { individual . addNeighbor ( sortedPopulation . get ( i ) ) ; } } } | Constructs the neighborhoods for all individuals in the population based on the distances between weights. |
466 | public void print ( boolean x ) { out . print ( x ) ; out . flush ( ) ; } | Prints a boolean to this output stream and flushes this output stream. |
467 | public final boolean removeElement ( int s ) { for ( int i = 0 ; i < m_firstFree ; i ++ ) { if ( m_map [ i ] == s ) { if ( ( i + 1 ) < m_firstFree ) System . arraycopy ( m_map , i + 1 , m_map , i - 1 , m_firstFree - i ) ; else m_map [ i ] = java . lang . Integer . MIN_VALUE ; m_firstFree -- ; return true ; } } return false ; } | Removes the first occurrence of the argument from this vector. If the object is found in this vector, each component in the vector with an index greater or equal to the object's index is shifted downward to have an index one smaller than the value it had previously. |
468 | public VNXeCommandJob restoreLunGroupSnap ( String snapId , VNXeSnapRestoreParam restoreParam ) throws VNXeException { StringBuilder urlBuilder = new StringBuilder ( URL_INSTANCE ) ; urlBuilder . append ( snapId ) ; urlBuilder . append ( URL_RESTORE ) ; _url = urlBuilder . toString ( ) ; return postRequestAsync ( restoreParam ) ; } | Restore lun group snapshot |
469 | public void sortFromTo ( int from , int to ) { final int widthThreshold = 10000 ; if ( size == 0 ) return ; checkRangeFromTo ( from , to , size ) ; short min = elements [ from ] ; short max = elements [ from ] ; short [ ] theElements = elements ; for ( int i = from + 1 ; i <= to ; ) { short elem = theElements [ i ++ ] ; if ( elem > max ) max = elem ; else if ( elem < min ) min = elem ; } double N = ( double ) to - ( double ) from + 1.0 ; double quickSortEstimate = N * Math . log ( N ) / 0.6931471805599453 ; double width = ( double ) max - ( double ) min + 1.0 ; double countSortEstimate = Math . max ( width , N ) ; if ( width < widthThreshold && countSortEstimate < quickSortEstimate ) { countSortFromTo ( from , to , min , max ) ; } else { quickSortFromTo ( from , to ) ; } } | Sorts the specified range of the receiver into ascending order. The sorting algorithm is dynamically chosen according to the characteristics of the data set. Currently quicksort and countsort are considered. Countsort is not always applicable, but if applicable, it usually outperforms quicksort by a factor of 3-4. <p>Best case performance: O(N). <dt>Worst case performance: O(N^2) (a degenerated quicksort). <dt>Best case space requirements: 0 KB. <dt>Worst case space requirements: 40 KB. |
470 | public HaskellCatalog ( ) { this ( HaskellCatalog . XML_PATH ) ; } | Constructs a Haskell catalog using the default file location. |
471 | public ClassFactory ( File dir , ClassLoader parent ) { super ( parent ) ; this . output = dir ; dir . mkdirs ( ) ; } | Create a given Class Factory with the given class loader. |
472 | static boolean isSameColumn ( ConstraintWidget a , ConstraintWidget b ) { return Math . max ( a . getX ( ) , b . getX ( ) ) < Math . min ( a . getX ( ) + a . getWidth ( ) , b . getX ( ) + b . getWidth ( ) ) ; } | are the two widgets in the same vertical area |
473 | Remover add ( T listener ) ; | Registers a new listener. |
474 | public boolean isExistingCommand ( ) { return ( ! name . equals ( CommandTagHandle . CMD_UNKNOWN ) ) ; } | Check whether the present CommandTagHandle object represents a CommandTag that exists on the server. If not, the client will not be able to execute the command. Preferably, clients should check isExistingCommand() BEFORE they call the setValue() method. If the command doesn't exist, setValue() will throw a CommandTagValueException. |
475 | @ SuppressWarnings ( "deprecation" ) protected void stopClassifier ( ) { if ( m_RunThread != null ) { m_RunThread . interrupt ( ) ; m_RunThread . stop ( ) ; } } | Stops the currently running classifier (if any). |
476 | private void sleep ( long sleeptime ) { try { Thread . sleep ( sleeptime ) ; } catch ( InterruptedException e ) { } } | Make the current thread sleep. |
477 | protected void buildPanels ( ) { keyPanels . clear ( ) ; inScrollPane . removeAll ( ) ; for ( String key : order ) { String name = names . get ( key ) ; if ( name != null ) { String value = values . getProperty ( key ) ; KeyPanel keyPanel = new KeyPanel ( name , value ) ; keyPanel . setAlignmentX ( LEFT_ALIGNMENT ) ; keyPanel . setMaximumSize ( guiSize ) ; inScrollPane . add ( keyPanel ) ; keyPanels . put ( key , keyPanel ) ; } else { SpecialSetting special = specials . get ( key ) ; special . setAlignmentX ( LEFT_ALIGNMENT ) ; inScrollPane . add ( special ) ; } } } | Creates all key panels and special settings that have been registered. |
478 | public void loadDataStringFromFile ( String sFilename , boolean clearCurrentData , String sEncoding ) { try { ByteArrayOutputStream bsOut = new ByteArrayOutputStream ( ) ; FileInputStream fiIn = new FileInputStream ( sFilename ) ; int iData = 0 ; while ( ( iData = fiIn . read ( ) ) > - 1 ) bsOut . write ( iData ) ; String sDataString = bsOut . toString ( ) ; setDataString ( sDataString , SourceNGramSize , clearCurrentData ) ; } catch ( IOException ioe ) { ioe . printStackTrace ( ) ; setDataString ( "" , 1 , false ) ; } } | Loads the contents of a file as the datastring. |
479 | public final char nextChar ( CharSequence csq ) { return csq . charAt ( index ++ ) ; } | Returns the next character at this cursor position.The cursor position is incremented by one. |
480 | private long dragStartedAgo ( ) { if ( dragStarted == 0 ) { return - 1 ; } return System . currentTimeMillis ( ) - dragStarted ; } | Returns the time in milliseconds how long ago the current drag started. |
481 | protected static double regularizedIncBetaCF ( double alpha , double beta , double x ) { final double FPMIN = Double . MIN_VALUE / NUM_PRECISION ; double qab = alpha + beta ; double qap = alpha + 1.0 ; double qam = alpha - 1.0 ; double c = 1.0 ; double d = 1.0 - qab * x / qap ; if ( Math . abs ( d ) < FPMIN ) { d = FPMIN ; } d = 1.0 / d ; double h = d ; for ( int m = 1 ; m < 10000 ; m ++ ) { int m2 = 2 * m ; double aa = m * ( beta - m ) * x / ( ( qam + m2 ) * ( alpha + m2 ) ) ; d = 1.0 + aa * d ; if ( Math . abs ( d ) < FPMIN ) { d = FPMIN ; } c = 1.0 + aa / c ; if ( Math . abs ( c ) < FPMIN ) { c = FPMIN ; } d = 1.0 / d ; h *= d * c ; aa = - ( alpha + m ) * ( qab + m ) * x / ( ( alpha + m2 ) * ( qap + m2 ) ) ; d = 1.0 + aa * d ; if ( Math . abs ( d ) < FPMIN ) { d = FPMIN ; } c = 1.0 + aa / c ; if ( Math . abs ( c ) < FPMIN ) { c = FPMIN ; } d = 1.0 / d ; double del = d * c ; h *= del ; if ( Math . abs ( del - 1.0 ) <= NUM_PRECISION ) { break ; } } return h ; } | Returns the regularized incomplete beta function I_x(a, b) Includes the continued fraction way of computing, based on the book "Numerical Recipes". |
482 | public DateTimeZoneBuilder addCutover ( int year , char mode , int monthOfYear , int dayOfMonth , int dayOfWeek , boolean advanceDayOfWeek , int millisOfDay ) { if ( iRuleSets . size ( ) > 0 ) { OfYear ofYear = new OfYear ( mode , monthOfYear , dayOfMonth , dayOfWeek , advanceDayOfWeek , millisOfDay ) ; RuleSet lastRuleSet = iRuleSets . get ( iRuleSets . size ( ) - 1 ) ; lastRuleSet . setUpperLimit ( year , ofYear ) ; } iRuleSets . add ( new RuleSet ( ) ) ; return this ; } | Adds a cutover for added rules. The standard offset at the cutover defaults to 0. Call setStandardOffset afterwards to change it. |
483 | private boolean isNullSetting ( boolean makeDest , MappingType mtd , MappingType mts , StringBuilder result ) { if ( makeDest && ( mtd == ALL_FIELDS || mtd == ONLY_VALUED_FIELDS ) && mts == ONLY_NULL_FIELDS ) { result . append ( " " + stringOfSetDestination + "(null);" + newLine ) ; return true ; } return false ; } | if it is a null setting returns the null mapping |
484 | protected void findAndInit ( Iterator it ) { while ( it . hasNext ( ) ) { findAndInit ( it . next ( ) ) ; } } | Called when the MenuBar is a part of a BeanContext, and it is added to the BeanContext, or while other objects are added to the BeanContext after that. |
485 | private boolean shouldEmitTypedefByName ( JSType realType ) { return realType . isRecordType ( ) || realType . isTemplatizedType ( ) || realType . isFunctionType ( ) ; } | Whether the typedef should be emitted by name or by the type it is defining. Because, we do not access the original type signature, the replacement is done for all references of the type (through the typedef or direct). Thus it is undesirable to always emit by name. For example: |
486 | private synchronized void manageMenu ( ) { if ( ( game != null ) || ( hasBoard && ( null == client ) ) ) { fileGameNew . setEnabled ( false ) ; fileGameOpen . setEnabled ( false ) ; fileGameScenario . setEnabled ( false ) ; fileGameConnectBot . setEnabled ( false ) ; fileGameConnect . setEnabled ( false ) ; replacePlayer . setEnabled ( false ) ; if ( ( phase != IGame . Phase . PHASE_UNKNOWN ) && ( phase != IGame . Phase . PHASE_LOUNGE ) && ( phase != IGame . Phase . PHASE_SELECTION ) && ( phase != IGame . Phase . PHASE_EXCHANGE ) && ( phase != IGame . Phase . PHASE_VICTORY ) && ( phase != IGame . Phase . PHASE_STARTING_SCENARIO ) ) { fileGameSave . setEnabled ( true ) ; fileGameSaveServer . setEnabled ( true ) ; replacePlayer . setEnabled ( true ) ; } else { fileGameSave . setEnabled ( false ) ; fileGameSaveServer . setEnabled ( false ) ; replacePlayer . setEnabled ( false ) ; } } else { fileGameNew . setEnabled ( true ) ; fileGameOpen . setEnabled ( true ) ; fileGameSave . setEnabled ( false ) ; fileGameSaveServer . setEnabled ( false ) ; fileGameScenario . setEnabled ( true ) ; fileGameConnectBot . setEnabled ( true ) ; fileGameConnect . setEnabled ( true ) ; replacePlayer . setEnabled ( true ) ; } if ( game != null ) { viewGameOptions . setEnabled ( true ) ; viewPlayerSettings . setEnabled ( true ) ; } else { viewGameOptions . setEnabled ( false ) ; viewPlayerSettings . setEnabled ( false ) ; } filePrint . setEnabled ( false ) ; if ( client != null ) { fileBoardNew . setEnabled ( false ) ; fileBoardOpen . setEnabled ( false ) ; fileBoardSave . setEnabled ( false ) ; fileBoardSaveAs . setEnabled ( false ) ; fileBoardSaveAsImage . setEnabled ( false ) ; } else { fileBoardNew . setEnabled ( true ) ; fileBoardOpen . setEnabled ( true ) ; fileBoardSave . setEnabled ( false ) ; fileBoardSaveAs . setEnabled ( false ) ; fileBoardSaveAsImage . setEnabled ( false ) ; } if ( hasBoard ) { fileBoardSave . setEnabled ( true ) ; fileBoardSaveAs . setEnabled ( true ) ; fileBoardSaveAsImage . setEnabled ( true ) ; viewMiniMap . setEnabled ( true ) ; viewZoomIn . setEnabled ( true ) ; viewZoomOut . setEnabled ( true ) ; } else { fileBoardSave . setEnabled ( false ) ; fileBoardSaveAs . setEnabled ( false ) ; fileBoardSaveAsImage . setEnabled ( false ) ; viewMiniMap . setEnabled ( false ) ; viewZoomIn . setEnabled ( false ) ; viewZoomOut . setEnabled ( false ) ; } if ( hasUnitList ) { fileUnitsOpen . setEnabled ( phase == IGame . Phase . PHASE_LOUNGE ) ; fileUnitsClear . setEnabled ( phase == IGame . Phase . PHASE_LOUNGE ) ; } else { fileUnitsOpen . setEnabled ( phase == IGame . Phase . PHASE_LOUNGE ) ; fileUnitsClear . setEnabled ( false ) ; } fileUnitsReinforce . setEnabled ( phase != IGame . Phase . PHASE_LOUNGE ) ; fileUnitsReinforceRAT . setEnabled ( phase != IGame . Phase . PHASE_LOUNGE ) ; if ( entity != null ) { viewMekDisplay . setEnabled ( true ) ; } else { viewMekDisplay . setEnabled ( false ) ; } if ( ( client == null ) && hasBoard ) { viewLOSSetting . setEnabled ( false ) ; viewUnitOverview . setEnabled ( false ) ; viewPlayerList . setEnabled ( false ) ; } else if ( ( phase == IGame . Phase . PHASE_SET_ARTYAUTOHITHEXES ) || ( phase == IGame . Phase . PHASE_DEPLOY_MINEFIELDS ) || ( phase == IGame . Phase . PHASE_MOVEMENT ) || ( phase == IGame . Phase . PHASE_FIRING ) || ( phase == IGame . Phase . PHASE_PHYSICAL ) || ( phase == IGame . Phase . PHASE_OFFBOARD ) || ( phase == IGame . Phase . PHASE_TARGETING ) || ( phase == IGame . Phase . PHASE_DEPLOYMENT ) ) { viewLOSSetting . setEnabled ( true ) ; viewMiniMap . setEnabled ( true ) ; viewZoomIn . setEnabled ( true ) ; viewZoomOut . setEnabled ( true ) ; viewUnitOverview . setEnabled ( true ) ; viewPlayerList . setEnabled ( true ) ; } else { viewLOSSetting . setEnabled ( false ) ; viewMiniMap . setEnabled ( false ) ; viewZoomIn . setEnabled ( false ) ; viewZoomOut . setEnabled ( false ) ; viewUnitOverview . setEnabled ( false ) ; viewPlayerList . setEnabled ( false ) ; } if ( ( phase == IGame . Phase . PHASE_INITIATIVE ) || ( phase == IGame . Phase . PHASE_MOVEMENT ) || ( phase == IGame . Phase . PHASE_FIRING ) || ( phase == IGame . Phase . PHASE_PHYSICAL ) || ( phase == IGame . Phase . PHASE_OFFBOARD ) || ( phase == IGame . Phase . PHASE_TARGETING ) || ( phase == IGame . Phase . PHASE_END ) || ( phase == IGame . Phase . PHASE_DEPLOYMENT ) ) { viewRoundReport . setEnabled ( true ) ; } else { viewRoundReport . setEnabled ( false ) ; } viewClientSettings . setEnabled ( true ) ; if ( ( phase != IGame . Phase . PHASE_FIRING ) || ( entity == null ) ) { fireCancel . setEnabled ( false ) ; } else { fireCancel . setEnabled ( true ) ; } updateSaveWeaponOrderMenuItem ( ) ; } | A helper function that will manage the enabled states of the items in this menu, based upon the object's current state. |
487 | public static Node selectSingleNode ( Node contextNode , String str , Node namespaceNode ) throws TransformerException { NodeIterator nl = selectNodeIterator ( contextNode , str , namespaceNode ) ; return nl . nextNode ( ) ; } | Use an XPath string to select a single node. XPath namespace prefixes are resolved from the namespaceNode. |
488 | public static Array listToArrayTrim ( String list , String delimiter , int [ ] info ) { if ( delimiter . length ( ) == 1 ) return listToArrayTrim ( list , delimiter . charAt ( 0 ) , info ) ; if ( list . length ( ) == 0 ) return new ArrayImpl ( ) ; char [ ] del = delimiter . toCharArray ( ) ; char c ; outer : while ( list . length ( ) > 0 ) { c = list . charAt ( 0 ) ; for ( int i = 0 ; i < del . length ; i ++ ) { if ( c == del [ i ] ) { info [ 0 ] ++ ; list = list . substring ( 1 ) ; continue outer ; } } break ; } int len ; outer : while ( list . length ( ) > 0 ) { c = list . charAt ( list . length ( ) - 1 ) ; for ( int i = 0 ; i < del . length ; i ++ ) { if ( c == del [ i ] ) { info [ 1 ] ++ ; len = list . length ( ) ; list = list . substring ( 0 , len - 1 < 0 ? 0 : len - 1 ) ; continue outer ; } } break ; } return listToArray ( list , delimiter ) ; } | casts a list to Array object, remove all empty items at start and end of the list and store count to info |
489 | public BigInteger calculateClientEvidenceMessage ( ) throws CryptoException { if ( ( this . A == null ) || ( this . B == null ) || ( this . S == null ) ) { throw new CryptoException ( "Impossible to compute M1: " + "some data are missing from the previous operations (A,B,S)" ) ; } this . M1 = SRP6Util . calculateM1 ( digest , N , A , B , S ) ; return M1 ; } | Computes the client evidence message M1 using the previously received values. To be called after calculating the secret S. |
490 | public void testCase6 ( ) { byte aBytes [ ] = { 10 , 20 , 30 , 40 , 50 , 60 , 70 , 10 , 20 , 30 } ; byte bBytes [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 1 , 2 , 3 , 1 , 2 , 3 , 4 , 5 } ; int aSign = 1 ; int bSign = - 1 ; byte rBytes [ ] = { - 11 , - 41 , - 101 , 54 , - 97 , - 52 , - 77 , - 41 , 44 , - 86 , - 116 , - 45 , 126 , - 116 , 20 , 61 , 14 , - 86 , - 65 , 86 , 1 , 35 , 35 , 106 } ; BigInteger aNumber = new BigInteger ( aSign , aBytes ) ; BigInteger bNumber = new BigInteger ( bSign , bBytes ) ; BigInteger result = aNumber . multiply ( bNumber ) ; byte resBytes [ ] = new byte [ rBytes . length ] ; resBytes = result . toByteArray ( ) ; for ( int i = 0 ; i < resBytes . length ; i ++ ) { assertTrue ( resBytes [ i ] == rBytes [ i ] ) ; } assertEquals ( "incorrect sign" , - 1 , result . signum ( ) ) ; } | Multiply two numbers of different length and different signs. The first is positive. The second is longer. |
491 | private static Field findAccessibleField ( Class clas , String fieldName ) throws UtilEvalError , NoSuchFieldException { Field field ; try { field = clas . getField ( fieldName ) ; ReflectManager . RMSetAccessible ( field ) ; return field ; } catch ( NoSuchFieldException e ) { } while ( clas != null ) { try { field = clas . getDeclaredField ( fieldName ) ; ReflectManager . RMSetAccessible ( field ) ; return field ; } catch ( NoSuchFieldException e ) { } clas = clas . getSuperclass ( ) ; } throw new NoSuchFieldException ( fieldName ) ; } | Used when accessibility capability is available to locate an occurrence of the field in the most derived class or superclass and set its accessibility flag. Note that this method is not needed in the simple non accessible case because we don't have to hunt for fields. Note that classes may declare overlapping private fields, so the distinction about the most derived is important. Java doesn't normally allow this kind of access (super won't show private variables) so there is no real syntax for specifying which class scope to use... |
492 | public void removeArguments ( String label ) { List < PBArgument > remove = new ArrayList < > ( ) ; for ( PBArgument arg : l_arguments ) { if ( arg . isLabel ( label ) ) remove . add ( arg ) ; } l_arguments . removeAll ( remove ) ; } | Removes all argument with the specific label. |
493 | public POSMikheevFeatureExtractor ( String viewName , String json ) { this . viewName = viewName ; this . counter = POSMikheevCounter . read ( json ) ; } | Construct the feature extractor given a trained counter in JSON format. |
494 | public static boolean endsWithIgnoreCase ( String src , String subS ) { String sub = subS . toLowerCase ( ) ; int sublen = sub . length ( ) ; int j = 0 ; int i = src . length ( ) - sublen ; if ( i < 0 ) { return false ; } while ( j < sublen ) { char source = Character . toLowerCase ( src . charAt ( i ) ) ; if ( sub . charAt ( j ) != source ) { return false ; } j ++ ; i ++ ; } return true ; } | Tests if this string ends with the specified suffix. |
495 | private void prefixSearch ( String query ) { m_curNode = m_trie . find ( query ) ; if ( m_curNode != null ) { Iterator iter = trieIterator ( ) ; while ( iter . hasNext ( ) ) addInternal ( ( Tuple ) iter . next ( ) ) ; } } | Issues a prefix search and collects the results |
496 | private void sendStageProgressPatch ( com . vmware . xenon . common . TaskState . TaskStage stage ) { ServiceUtils . logInfo ( this , "sendStageProgressPatch %s" , stage ) ; TaskUtils . sendSelfPatch ( this , buildPatch ( stage , null ) ) ; } | This method sends a patch operation to the current service instance to move to a new state. |
497 | @ Nullable protected abstract Object extractParameter ( @ Nullable String cacheName , String typeName , TypeKind typeKind , String fieldName , Object obj ) throws CacheException ; | Get field value from object for use as query parameter. |
498 | public static boolean isViewableValue ( Object value ) { if ( value instanceof CompositeData || value instanceof TabularData ) { return true ; } if ( value instanceof CompositeData [ ] || value instanceof TabularData [ ] ) { return Array . getLength ( value ) > 0 ; } if ( value instanceof Collection ) { Collection < ? > c = ( Collection < ? > ) value ; if ( c . isEmpty ( ) ) { return false ; } else { return Utils . isUniformCollection ( c , CompositeData . class ) || Utils . isUniformCollection ( c , TabularData . class ) ; } } return false ; } | The supplied value is viewable iff: - it's a CompositeData/TabularData, or - it's a non-empty array of CompositeData/TabularData, or - it's a non-empty Collection of CompositeData/TabularData. |
499 | static OCSPResponse check ( List < CertId > certIds , URI responderURI , X509Certificate issuerCert , X509Certificate responderCert , Date date , List < Extension > extensions ) throws IOException , CertPathValidatorException { byte [ ] bytes = null ; OCSPRequest request = null ; try { request = new OCSPRequest ( certIds , extensions ) ; bytes = request . encodeBytes ( ) ; } catch ( IOException ioe ) { throw new CertPathValidatorException ( "Exception while encoding OCSPRequest" , ioe ) ; } InputStream in = null ; OutputStream out = null ; byte [ ] response = null ; try { URL url = responderURI . toURL ( ) ; if ( debug != null ) { debug . println ( "connecting to OCSP service at: " + url ) ; } HttpURLConnection con = ( HttpURLConnection ) url . openConnection ( ) ; con . setConnectTimeout ( CONNECT_TIMEOUT ) ; con . setReadTimeout ( CONNECT_TIMEOUT ) ; con . setDoOutput ( true ) ; con . setDoInput ( true ) ; con . setRequestMethod ( "POST" ) ; con . setRequestProperty ( "Content-type" , "application/ocsp-request" ) ; con . setRequestProperty ( "Content-length" , String . valueOf ( bytes . length ) ) ; out = con . getOutputStream ( ) ; out . write ( bytes ) ; out . flush ( ) ; if ( debug != null && con . getResponseCode ( ) != HttpURLConnection . HTTP_OK ) { debug . println ( "Received HTTP error: " + con . getResponseCode ( ) + " - " + con . getResponseMessage ( ) ) ; } in = con . getInputStream ( ) ; int contentLength = con . getContentLength ( ) ; if ( contentLength == - 1 ) { contentLength = Integer . MAX_VALUE ; } response = new byte [ contentLength > 2048 ? 2048 : contentLength ] ; int total = 0 ; while ( total < contentLength ) { int count = in . read ( response , total , response . length - total ) ; if ( count < 0 ) break ; total += count ; if ( total >= response . length && total < contentLength ) { response = Arrays . copyOf ( response , total * 2 ) ; } } response = Arrays . copyOf ( response , total ) ; } catch ( IOException ioe ) { throw new CertPathValidatorException ( "Unable to determine revocation status due to network error" , ioe , null , - 1 , BasicReason . UNDETERMINED_REVOCATION_STATUS ) ; } finally { if ( in != null ) { try { in . close ( ) ; } catch ( IOException ioe ) { throw ioe ; } } if ( out != null ) { try { out . close ( ) ; } catch ( IOException ioe ) { throw ioe ; } } } OCSPResponse ocspResponse = null ; try { ocspResponse = new OCSPResponse ( response ) ; } catch ( IOException ioe ) { throw new CertPathValidatorException ( ioe ) ; } ocspResponse . verify ( certIds , issuerCert , responderCert , date , request . getNonce ( ) ) ; return ocspResponse ; } | Checks the revocation status of a list of certificates using OCSP. |
Subsets and Splits