idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
27,800
@ ObjectiveCName ( "registerApplePushWithApnsId:withToken:" ) public void registerApplePush ( int apnsId , String token ) { modules . getPushesModule ( ) . registerApplePush ( apnsId , token ) ; }
Register apple push
27,801
@ ObjectiveCName ( "registerApplePushKitWithApnsId:withToken:" ) public void registerApplePushKit ( int apnsId , String token ) { modules . getPushesModule ( ) . registerApplePushKit ( apnsId , token ) ; }
Register apple push kit tokens
27,802
@ ObjectiveCName ( "addTrustedKey:" ) public ConfigurationBuilder addTrustedKey ( String trustedKey ) { trustedKeys . add ( new TrustedKey ( trustedKey ) ) ; return this ; }
Adding Trusted key for protocol encryption securing
27,803
@ ObjectiveCName ( "addPreferredLanguage:" ) public ConfigurationBuilder addPreferredLanguage ( String language ) { if ( ! preferredLanguages . contains ( language ) ) { preferredLanguages . add ( language ) ; } return this ; }
Adding preferred language
27,804
public synchronized void onDialogsChanged ( boolean isEmpty ) { if ( isDialogsEmpty . get ( ) != isEmpty ) { context . getPreferences ( ) . putBool ( "app.dialogs.empty" , isEmpty ) ; isDialogsEmpty . change ( isEmpty ) ; } if ( ! isEmpty ) { if ( isAppEmpty . get ( ) ) { context . getPreferences ( ) . putBool ( "app.e...
Notify from Modules about dialogs state changed
27,805
public synchronized void onContactsChanged ( boolean isEmpty ) { if ( isContactsEmpty . get ( ) != isEmpty ) { context . getPreferences ( ) . putBool ( "app.contacts.empty" , isEmpty ) ; isContactsEmpty . change ( isEmpty ) ; } if ( ! isEmpty ) { if ( isAppEmpty . get ( ) ) { context . getPreferences ( ) . putBool ( "a...
Notify from Modules about contacts state changed
27,806
public void onNewMessage ( Peer peer , int sender , long date , ContentDescription description , boolean hasCurrentUserMention , int messagesCount , int dialogsCount ) { if ( date <= getLastReadDate ( peer ) ) { return ; } boolean isEnabled = isNotificationsEnabled ( peer , hasCurrentUserMention ) ; if ( isEnabled ) { ...
Handling event about incoming notification
27,807
public void onMessagesRead ( Peer peer , long fromDate ) { if ( fromDate < getLastReadDate ( peer ) ) { return ; } getNotifications ( ) . clear ( ) ; pendingStorage . setMessagesCount ( 0 ) ; pendingStorage . setDialogsCount ( 0 ) ; allPendingNotifications . clear ( ) ; saveStorage ( ) ; updateNotification ( ) ; setLas...
Processing event about messages read
27,808
public void onConversationHidden ( Peer peer ) { if ( visiblePeer != null && visiblePeer . equals ( peer ) ) { this . visiblePeer = null ; } }
Processing Conversation hidden event
27,809
private boolean isNotificationsEnabled ( Peer peer , boolean hasMention ) { if ( ! context ( ) . getSettingsModule ( ) . isNotificationsEnabled ( ) ) { return false ; } if ( peer . getPeerType ( ) == PeerType . GROUP ) { if ( getGroup ( peer . getPeerId ( ) ) . isHidden ( ) ) { return false ; } if ( context ( ) . getSe...
Testing if notifications enabled for message
27,810
private long getLastReadDate ( Peer peer ) { if ( readStates . containsKey ( peer ) ) { return readStates . get ( peer ) ; } byte [ ] data = storage . get ( peer . getUnuqueId ( ) ) ; if ( data != null ) { try { return ReadState . fromBytes ( data ) . getSortDate ( ) ; } catch ( IOException e ) { e . printStackTrace ( ...
Getting last read sort key for peer
27,811
private void setLastReadDate ( Peer peer , long date ) { storage . put ( peer . getUnuqueId ( ) , new ReadState ( date ) . toByteArray ( ) ) ; readStates . put ( peer , date ) ; }
Setting last read date for peer
27,812
public void onBusEvent ( Event event ) { if ( event instanceof AppVisibleChanged ) { AppVisibleChanged visibleChanged = ( AppVisibleChanged ) event ; if ( visibleChanged . isVisible ( ) ) { onAppVisible ( ) ; } else { onAppHidden ( ) ; } } else if ( event instanceof PeerChatOpened ) { onConversationVisible ( ( ( PeerCh...
Receiving bus events
27,813
public void encryptBlock ( byte [ ] data , int offset , byte [ ] dest , int destOffset ) { Kuz128 x = new Kuz128 ( ) ; x . setQ ( 0 , ByteStrings . bytesToLong ( data , offset ) ) ; x . setQ ( 1 , ByteStrings . bytesToLong ( data , offset + 8 ) ) ; for ( int i = 0 ; i < 9 ; i ++ ) { x . setQ ( 0 , x . getQ ( 0 ) ^ key ...
Encrypting Block with KuznechikImpl encryption
27,814
public void decryptBlock ( byte [ ] data , int offset , byte [ ] dest , int destOffset ) { Kuz128 x = new Kuz128 ( ) ; x . setQ ( 0 , ByteStrings . bytesToLong ( data , offset ) ^ key . getK ( ) [ 9 ] . getQ ( 0 ) ) ; x . setQ ( 1 , ByteStrings . bytesToLong ( data , offset + 8 ) ^ key . getK ( ) [ 9 ] . getQ ( 1 ) ) ;...
Decrypting block with Kuznechik encryption
27,815
static KuzIntKey convertKey ( byte [ ] key ) { if ( key . length != 32 ) { throw new RuntimeException ( "Key might be 32 bytes length" ) ; } KuzIntKey kuz = new KuzIntKey ( ) ; Kuz128 c = new Kuz128 ( ) , x = new Kuz128 ( ) , y = new Kuz128 ( ) , z = new Kuz128 ( ) ; for ( int i = 0 ; i < 16 ; i ++ ) { x . getB ( ) [ i...
Converting binary representation of a key to internal format
27,816
public void waitForReady ( ) { if ( ! isLoaded ) { synchronized ( LOAD_LOCK ) { if ( ! isLoaded ) { try { long start = Runtime . getActorTime ( ) ; LOAD_LOCK . wait ( ) ; Log . d ( TAG , "Waited for startup in " + ( Runtime . getActorTime ( ) - start ) + " ms" ) ; } catch ( InterruptedException e ) { e . printStackTrac...
Waiting for Messenger Ready
27,817
public < T > T getDelegatedFragment ( ActorIntent delegatedIntent , android . support . v4 . app . Fragment baseFragment , Class < T > type ) { if ( delegatedIntent != null && delegatedIntent instanceof ActorIntentFragmentActivity && ( ( ActorIntentFragmentActivity ) delegatedIntent ) . getFragment ( ) != null && type ...
Method is used internally for getting delegated fragment
27,818
@ ObjectiveCName ( "tupleWithT1:withT2:" ) public static < T1 , T2 > Promise < Tuple2 < T1 , T2 > > tuple ( Promise < T1 > t1 , Promise < T2 > t2 ) { return PromisesArray . ofPromises ( ( Promise < Object > ) t1 , ( Promise < Object > ) t2 ) . zip ( ) . map ( src -> new Tuple2 < > ( ( T1 ) src . get ( 0 ) , ( T2 ) src ...
Combines two promises to one with different data types
27,819
@ ObjectiveCName ( "tupleWithT1:withT2:withT3:" ) public static < T1 , T2 , T3 > Promise < Tuple3 < T1 , T2 , T3 > > tuple ( Promise < T1 > t1 , Promise < T2 > t2 , Promise < T3 > t3 ) { return PromisesArray . ofPromises ( ( Promise < Object > ) t1 , ( Promise < Object > ) t2 , ( Promise < Object > ) t3 ) . zip ( ) . m...
Combines tree promises to one with different data types
27,820
public static < T > Promise traverse ( List < Supplier < Promise < T > > > queue ) { if ( queue . size ( ) == 0 ) { return Promise . success ( null ) ; } return queue . remove ( 0 ) . get ( ) . flatMap ( v -> traverse ( queue ) ) ; }
Execute promises step by step
27,821
public static final String concatGroups ( MatcherCompat matcher ) { StringBuilder b = new StringBuilder ( ) ; final int numGroups = matcher . groupCount ( ) ; for ( int i = 1 ; i <= numGroups ; i ++ ) { String s = matcher . group ( i ) ; if ( s != null ) { b . append ( s ) ; } } return b . toString ( ) ; }
Convenience method to take all of the non - null matching groups in a regex Matcher and return them as a concatenated string .
27,822
public static final String digitsAndPlusOnly ( MatcherCompat matcher ) { StringBuilder buffer = new StringBuilder ( ) ; String matchingRegion = matcher . group ( ) ; for ( int i = 0 , size = matchingRegion . length ( ) ; i < size ; i ++ ) { char character = matchingRegion . charAt ( i ) ; if ( character == '+' || Chara...
Convenience method to return only the digits and plus signs in the matching string .
27,823
private static byte [ ] writeInt ( int value ) throws IOException { byte [ ] b = new byte [ 4 ] ; b [ 0 ] = ( byte ) ( value & 0x000000FF ) ; b [ 1 ] = ( byte ) ( ( value & 0x0000FF00 ) >> 8 ) ; b [ 2 ] = ( byte ) ( ( value & 0x00FF0000 ) >> 16 ) ; b [ 3 ] = ( byte ) ( ( value & 0xFF000000 ) >> 24 ) ; return b ; }
Write integer to little - endian
27,824
public void reply ( Object message ) { if ( context . sender ( ) != null ) { context . sender ( ) . send ( message , self ( ) ) ; } }
Reply message to sender of last message
27,825
public void drop ( Object message ) { if ( system ( ) . getTraceInterface ( ) != null ) { system ( ) . getTraceInterface ( ) . onDrop ( sender ( ) , message , this ) ; } reply ( new DeadLetter ( message ) ) ; }
Dropping of message
27,826
public synchronized long exponentialWait ( ) { long maxDelayRet = minDelay + ( ( maxDelay - minDelay ) / maxFailureCount ) * currentFailureCount ; return ( long ) ( random . nextFloat ( ) * maxDelayRet ) ; }
Calculating wait duration after failure attempt
27,827
@ ObjectiveCName ( "then:" ) public synchronized Promise < T > then ( final Consumer < T > then ) { if ( isFinished ) { if ( exception == null ) { dispatcher . dispatch ( ( ) -> then . apply ( result ) ) ; } } else { callbacks . add ( new PromiseCallback < T > ( ) { public void onResult ( T t ) { then . apply ( t ) ; }...
Handling successful result
27,828
@ ObjectiveCName ( "map:" ) public < R > Promise < R > map ( final Function < T , R > res ) { final Promise < T > self = this ; return new Promise < > ( ( PromiseFunc < R > ) resolver -> { self . then ( t -> { R r ; try { r = res . apply ( t ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; resolver . tryError ( ...
Mapping result value of promise to another value
27,829
@ ObjectiveCName ( "flatMap:" ) public < R > Promise < R > flatMap ( final Function < T , Promise < R > > res ) { final Promise < T > self = this ; return new Promise < > ( ( PromiseFunc < R > ) resolver -> { self . then ( t -> { Promise < R > promise ; try { promise = res . apply ( t ) ; } catch ( Exception e ) { e . ...
Map result of promise to promise of value
27,830
public < R > Promise < T > chain ( final Function < T , Promise < R > > res ) { final Promise < T > self = this ; return new Promise < > ( resolver -> { self . then ( t -> { Promise < R > chained = res . apply ( t ) ; chained . then ( t2 -> resolver . result ( t ) ) ; chained . failure ( e -> resolver . error ( e ) ) ;...
Chaining result to next promise and returning current value as result promise
27,831
public Promise < T > after ( final ConsumerDouble < T , Exception > afterHandler ) { then ( t -> afterHandler . apply ( t , null ) ) ; failure ( e -> afterHandler . apply ( null , e ) ) ; return this ; }
Called after success or failure
27,832
@ ObjectiveCName ( "pipeTo:" ) public Promise < T > pipeTo ( PromiseResolver < T > resolver ) { then ( t -> resolver . result ( t ) ) ; failure ( e -> resolver . error ( e ) ) ; return this ; }
Pipe result to resolver
27,833
public static String hex ( byte [ ] bytes ) { char [ ] hexChars = new char [ bytes . length * 2 ] ; for ( int j = 0 ; j < bytes . length ; j ++ ) { int v = bytes [ j ] & 0xFF ; hexChars [ j * 2 ] = HEXES_SMALL [ v >>> 4 ] ; hexChars [ j * 2 + 1 ] = HEXES_SMALL [ v & 0x0F ] ; } return new String ( hexChars ) ; }
Calculating lowcase hex string
27,834
protected void onMeasure ( int widthMeasureSpec , int heightMeasureSpec ) { int topOffset = 0 ; View messageView = findMessageView ( ) ; int padding = Screen . dp ( 8 ) ; if ( showAvatar ) { padding += Screen . dp ( 48 ) ; } measureChildWithMargins ( messageView , widthMeasureSpec , padding , heightMeasureSpec , 0 ) ; ...
Small hack for avoiding listview selection
27,835
public synchronized < T extends Response > long request ( Request < T > request , RpcCallback < T > callback , long timeout ) { if ( request == null ) { throw new RuntimeException ( "Request can't be null" ) ; } long rid = NEXT_RPC_ID . incrementAndGet ( ) ; this . apiBroker . send ( new ApiBroker . PerformRequest ( ri...
Performing API request
27,836
public static byte [ ] openBox ( byte [ ] header , byte [ ] cipherText , ActorBoxKey key ) throws IntegrityException { CBCHmacBox aesCipher = new CBCHmacBox ( Crypto . createAES128 ( key . getKeyAES ( ) ) , Crypto . createSHA256 ( ) , key . getMacAES ( ) ) ; CBCHmacBox kuzCipher = new CBCHmacBox ( new KuznechikFastEngi...
Opening Encrypted box
27,837
public static byte [ ] closeBox ( byte [ ] header , byte [ ] plainText , byte [ ] random32 , ActorBoxKey key ) throws IntegrityException { CBCHmacBox aesCipher = new CBCHmacBox ( Crypto . createAES128 ( key . getKeyAES ( ) ) , Crypto . createSHA256 ( ) , key . getMacAES ( ) ) ; CBCHmacBox kuzCipher = new CBCHmacBox ( n...
Closing encrypted box
27,838
public static boolean contains ( String [ ] vals , String value ) { for ( int i = 0 ; i < vals . length ; i ++ ) { if ( vals [ i ] . equals ( value ) ) { return true ; } } return false ; }
Checking if string array contains value
27,839
public static < T > boolean equalsE ( T a , T b ) { if ( a == null && b == null ) { return true ; } if ( a != null && b == null ) { return false ; } if ( a == null ) { return false ; } return a . equals ( b ) ; }
Equals with null checking
27,840
public static < T > List < T > last ( List < T > elements , int limit ) { ArrayList < T > res = new ArrayList < T > ( ) ; for ( int i = 0 ; i < elements . size ( ) ; i ++ ) { if ( res . size ( ) >= limit ) { break ; } res . add ( elements . get ( elements . size ( ) - 1 - i ) ) ; } return res ; }
Getting last elements of list in reverse order
27,841
public static long [ ] unbox ( List < Long > list ) { long [ ] res = new long [ list . size ( ) ] ; for ( int i = 0 ; i < res . length ; i ++ ) { res [ i ] = list . get ( i ) ; } return res ; }
Unboxing long list
27,842
public synchronized void onGlobalCounterChanged ( int value ) { globalCounter . change ( value ) ; if ( ! isAppVisible . get ( ) ) { globalTempCounter . change ( value ) ; } }
Notify from Modules about global counters changed
27,843
public void addOrUpdateItem ( T item ) { synchronized ( LOCK ) { cache . onObjectUpdated ( item . getEngineId ( ) , item ) ; List < T > items = new ArrayList < T > ( ) ; items . add ( item ) ; asyncStorageInt . addOrUpdateItems ( items ) ; for ( ListEngineDisplayListener < T > l : listeners ) { l . addOrUpdate ( item )...
Main List Engine
27,844
private Promise < OwnIdentity > fetchOwnIdentity ( ) { return Promise . success ( new OwnIdentity ( ownKeys . getKeyGroupId ( ) , ownKeys . getIdentityKey ( ) ) ) ; }
Fetching Own Identity key and group id
27,845
private Promise < PrivateKey > fetchPreKey ( byte [ ] publicKey ) { try { return Promise . success ( ManagedList . of ( ownKeys . getPreKeys ( ) ) . filter ( PrivateKey . PRE_KEY_EQUALS ( publicKey ) ) . first ( ) ) ; } catch ( Exception e ) { Log . d ( TAG , "Unable to find own pre key " + Crypto . keyHash ( publicKey...
Fetching own private pre key by public key
27,846
private Promise < PrivateKey > fetchPreKey ( long keyId ) { try { return Promise . success ( ManagedList . of ( ownKeys . getPreKeys ( ) ) . filter ( PrivateKey . PRE_KEY_EQUALS_ID ( keyId ) ) . first ( ) ) ; } catch ( Exception e ) { Log . d ( TAG , "Unable to find own pre key #" + keyId ) ; throw e ; } }
Fetching own pre key by id
27,847
private Promise < UserKeys > fetchUserGroups ( final int uid ) { User user = users ( ) . getValue ( uid ) ; if ( user == null ) { throw new RuntimeException ( "Unable to find user #" + uid ) ; } final UserKeys userKeys = getCachedUserKeys ( uid ) ; if ( userKeys != null ) { return Promise . success ( userKeys ) ; } ret...
Fetching all user s key groups
27,848
private Promise < PublicKey > fetchUserPreKey ( final int uid , final int keyGroupId , final long keyId ) { User user = users ( ) . getValue ( uid ) ; if ( user == null ) { throw new RuntimeException ( "Unable to find user #" + uid ) ; } return pickUserGroup ( uid , keyGroupId ) . flatMap ( new Function < Tuple2 < User...
Fetching user s pre key by key id
27,849
private Promise < PublicKey > fetchUserPreKey ( final int uid , final int keyGroupId ) { return pickUserGroup ( uid , keyGroupId ) . flatMap ( new Function < Tuple2 < UserKeysGroup , UserKeys > , Promise < PublicKey > > ( ) { public Promise < PublicKey > apply ( final Tuple2 < UserKeysGroup , UserKeys > keyGroups ) { r...
Fetching user s random pre key
27,850
private void onPublicKeysGroupAdded ( int uid , ApiEncryptionKeyGroup keyGroup ) { UserKeys userKeys = getCachedUserKeys ( uid ) ; if ( userKeys == null ) { return ; } UserKeysGroup validatedKeysGroup = validateUserKeysGroup ( uid , keyGroup ) ; if ( validatedKeysGroup != null ) { UserKeys updatedUserKeys = userKeys . ...
Handler for adding new key group
27,851
private void onPublicKeysGroupRemoved ( int uid , int keyGroupId ) { UserKeys userKeys = getCachedUserKeys ( uid ) ; if ( userKeys == null ) { return ; } UserKeys updatedUserKeys = userKeys . removeUserKeyGroup ( keyGroupId ) ; cacheUserKeys ( updatedUserKeys ) ; context ( ) . getEncryption ( ) . getEncryptedChatManage...
Handler for removing key group
27,852
public void clearPref ( ) { try { ( ( ClcJavaPreferenceStorage ) modules . getPreferences ( ) ) . getPref ( ) . clear ( ) ; } catch ( BackingStoreException e ) { logger . error ( "Cannot clear preferences" , e ) ; } }
clear java preferences
27,853
public static Bitmap loadBitmap ( Uri uri , Context context ) throws ImageLoadException { return loadBitmap ( new UriSource ( uri , context ) ) ; }
Loading bitmap without any modifications
27,854
public static Bitmap loadBitmapOptimized ( Uri uri , Context context ) throws ImageLoadException { return loadBitmapOptimized ( uri , context , MAX_PIXELS ) ; }
Loading bitmap with optimized loaded size less than 1 . 4 MPX
27,855
public static byte [ ] save ( Bitmap src ) throws ImageSaveException { return save ( src , Bitmap . CompressFormat . JPEG , JPEG_QUALITY ) ; }
Saving image in jpeg to byte array with quality 80
27,856
public static byte [ ] saveHq ( Bitmap src ) throws ImageSaveException { return save ( src , Bitmap . CompressFormat . JPEG , JPEG_QUALITY_HQ ) ; }
Saving image in jpeg to byte array with better quality 90
27,857
public static void save ( Bitmap src , String fileName ) throws ImageSaveException { saveJpeg ( src , fileName , JPEG_QUALITY ) ; }
Saving image in jpeg to file with quality 80
27,858
public static void saveLq ( Bitmap src , String fileName ) throws ImageSaveException { saveJpeg ( src , fileName , JPEG_QUALITY_LOW ) ; }
Saving image in jpeg to file with quality 55
27,859
public static void savePng ( Bitmap src , String fileName ) throws ImageSaveException { save ( src , fileName , Bitmap . CompressFormat . PNG , 100 ) ; }
Saving image in png to file
27,860
public static void saveBmp ( Bitmap src , String fileName ) throws ImageSaveException { try { BitmapUtil . save ( src , fileName ) ; } catch ( IOException e ) { throw new ImageSaveException ( e ) ; } }
Saving image in bmp to file
27,861
public static int bitmapSize ( Bitmap bitmap ) { if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . KITKAT ) { return bitmap . getByteCount ( ) ; } else { return bitmap . getRowBytes ( ) * bitmap . getHeight ( ) ; } }
Calculating allocated memory for bitmap
27,862
private static ReuseResult loadBitmapReuseExact ( ImageSource source , Bitmap dest ) throws ImageLoadException { ImageMetadata metadata = source . getImageMetadata ( ) ; boolean tryReuse = false ; if ( dest . isMutable ( ) && dest . getWidth ( ) == metadata . getW ( ) && dest . getHeight ( ) == metadata . getH ( ) ) { ...
Loading image with reuse bitmap of same size as source
27,863
private static void save ( Bitmap src , String fileName , Bitmap . CompressFormat format , int quality ) throws ImageSaveException { FileOutputStream outputStream = null ; try { outputStream = new FileOutputStream ( fileName ) ; src . compress ( format , quality , outputStream ) ; outputStream . close ( ) ; } catch ( I...
Saving image to file
27,864
private static ILigand [ ] getLigands ( IAtom atom , IAtomContainer container , IAtom exclude ) { List < IAtom > neighbors = container . getConnectedAtomsList ( atom ) ; ILigand [ ] ligands = new ILigand [ neighbors . size ( ) - 1 ] ; int i = 0 ; for ( IAtom neighbor : neighbors ) { if ( ! neighbor . equals ( exclude )...
Obtain the ligands connected to the atom excluding exclude . This is mainly meant as a utility for double - bond labelling .
27,865
public static ILigand [ ] getLigandLigands ( ILigand ligand ) { if ( ligand instanceof TerminalLigand ) return new ILigand [ 0 ] ; IAtomContainer container = ligand . getAtomContainer ( ) ; IAtom ligandAtom = ligand . getLigandAtom ( ) ; IAtom centralAtom = ligand . getCentralAtom ( ) ; VisitedAtoms visitedAtoms = liga...
Returns a CIP - expanded array of side chains of a ligand . If the ligand atom is only connected to the chiral atom the method will return an empty list . The expansion involves the CIP rules so that a double bonded oxygen will be represented twice in the list .
27,866
private void readCoordinates ( IChemModel model ) throws CDKException , IOException { IAtomContainer container = model . getBuilder ( ) . newInstance ( IAtomContainer . class ) ; String line = input . readLine ( ) ; line = input . readLine ( ) ; line = input . readLine ( ) ; line = input . readLine ( ) ; while ( input ...
Reads a set of coordinates into ChemModel .
27,867
private void readPartialCharges ( IChemModel model ) throws CDKException , IOException { logger . info ( "Reading partial atomic charges" ) ; IAtomContainerSet moleculeSet = model . getMoleculeSet ( ) ; IAtomContainer molecule = moleculeSet . getAtomContainer ( 0 ) ; String line = input . readLine ( ) ; while ( input ....
Reads partial atomic charges and add the to the given ChemModel .
27,868
public DescriptorValue calculate ( IAtom atom , IAtomContainer container ) { int period ; String symbol = atom . getSymbol ( ) ; period = periodicTable . get ( symbol ) ; return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParameters ( ) , new IntegerResult ( period ) , NAMES ) ; }
This method calculates the period of an atom .
27,869
private int skipDigits ( ) { char ch ; int i = 0 ; while ( index < format . length ( ) ) { if ( Character . isDigit ( ch = format . charAt ( index ) ) ) { index ++ ; i = i * 10 + Character . digit ( ch , 10 ) ; } else { break ; } } return i ; }
Skip digits and return the number they form .
27,870
public Partition getAutomorphismPartition ( ) { final int n = group . getSize ( ) ; final DisjointSetForest forest = new DisjointSetForest ( n ) ; group . apply ( new PermutationGroup . Backtracker ( ) { boolean [ ] inOrbit = new boolean [ n ] ; private int inOrbitCount = 0 ; private boolean isFinished ; public boolean...
The automorphism partition is a partition of the elements of the group .
27,871
private String getHalfMatrixString ( Permutation permutation ) { StringBuilder builder = new StringBuilder ( permutation . size ( ) ) ; int size = permutation . size ( ) ; for ( int indexI = 0 ; indexI < size - 1 ; indexI ++ ) { for ( int indexJ = indexI + 1 ; indexJ < size ; indexJ ++ ) { builder . append ( getConnect...
Get the upper - half of the adjacency matrix under the permutation .
27,872
private void refine ( PermutationGroup group , Partition coarser ) { int vertexCount = getVertexCount ( ) ; Partition finer = equitableRefiner . refine ( coarser ) ; int firstNonDiscreteCell = finer . getIndexOfFirstNonDiscreteCell ( ) ; if ( firstNonDiscreteCell == - 1 ) { firstNonDiscreteCell = vertexCount ; } Permut...
Does the work of the class that refines a coarse partition into a finer one using the supplied automorphism group to prune the search .
27,873
private Result compareRowwise ( Permutation perm ) { int m = perm . size ( ) ; for ( int i = 0 ; i < m - 1 ; i ++ ) { for ( int j = i + 1 ; j < m ; j ++ ) { int x = getConnectivity ( best . get ( i ) , best . get ( j ) ) ; int y = getConnectivity ( perm . get ( i ) , perm . get ( j ) ) ; if ( x > y ) return Result . WO...
Check a permutation to see if it is better equal or worse than the current best .
27,874
public long order ( ) { long total = 1 ; for ( int i = 0 ; i < size ; i ++ ) { int sum = 0 ; for ( int j = 0 ; j < size ; j ++ ) { if ( this . permutations [ i ] [ j ] != null ) { sum ++ ; } } total *= sum ; } return total ; }
Calculates the size of the group .
27,875
public List < Permutation > transversal ( final PermutationGroup subgroup ) { final long m = this . order ( ) / subgroup . order ( ) ; final List < Permutation > results = new ArrayList < Permutation > ( ) ; Backtracker transversalBacktracker = new Backtracker ( ) { private boolean finished = false ; public void applyT...
Generate a transversal of a subgroup in this group .
27,876
public List < Permutation > all ( ) { final List < Permutation > permutations = new ArrayList < Permutation > ( ) ; Backtracker counter = new Backtracker ( ) { public void applyTo ( Permutation p ) { permutations . add ( p ) ; } public boolean isFinished ( ) { return false ; } } ; this . apply ( counter ) ; return perm...
Generate the whole group from the compact list of permutations .
27,877
public void enter ( Permutation g ) { int deg = size ; int i = test ( g ) ; if ( i == deg ) { return ; } else { permutations [ i ] [ g . get ( base . get ( i ) ) ] = new Permutation ( g ) ; } for ( int j = 0 ; j <= i ; j ++ ) { for ( int a = 0 ; a < deg ; a ++ ) { Permutation h = permutations [ j ] [ a ] ; if ( h != nu...
Enter the permutation g into this group .
27,878
public void readDictionary ( Reader reader , String name ) { name = name . toLowerCase ( ) ; logger . debug ( "Reading dictionary: " , name ) ; if ( ! dictionaries . containsKey ( name ) ) { try { Dictionary dictionary = Dictionary . unmarshal ( reader ) ; dictionaries . put ( name , dictionary ) ; logger . debug ( " ...
Reads a custom dictionary into the database .
27,879
public boolean hasEntry ( String dictName , String entryID ) { if ( hasDictionary ( dictName ) ) { Dictionary dictionary = ( Dictionary ) dictionaries . get ( dictName ) ; return dictionary . hasEntry ( entryID . toLowerCase ( ) ) ; } else { return false ; } }
Returns true if the given dictionary contains the given entry .
27,880
public void removeMonomer ( String name ) { if ( monomers . containsKey ( name ) ) { Monomer monomer = ( Monomer ) monomers . get ( name ) ; this . remove ( monomer ) ; monomers . remove ( name ) ; } }
Removes a particular monomer specified by its name .
27,881
public DescriptorValue calculate ( IAtom atom , IAtomContainer atomContainer ) { IAtomContainer clonedAtomContainer ; try { clonedAtomContainer = ( IAtomContainer ) atomContainer . clone ( ) ; } catch ( CloneNotSupportedException e ) { return new DescriptorValue ( getSpecification ( ) , getParameterNames ( ) , getParam...
The method is a proton descriptor that evaluates if a proton is joined to a conjugated system .
27,882
public boolean matches ( IAtomContainer atomContainer , boolean initializeTarget ) throws CDKException { if ( ! GeometryUtil . has3DCoordinates ( atomContainer ) ) throw new CDKException ( "Molecule must have 3D coordinates" ) ; if ( pharmacophoreQuery == null ) throw new CDKException ( "Must set the query pharmacophor...
Performs the pharmacophore matching .
27,883
public List < List < IBond > > getMatchingPharmacophoreBonds ( ) { if ( mappings == null ) return null ; List < List < IBond > > bonds = new ArrayList < > ( ) ; for ( Map < IBond , IBond > map : mappings . toBondMap ( ) ) { bonds . add ( new ArrayList < > ( map . values ( ) ) ) ; } return bonds ; }
Get the matching pharmacophore constraints .
27,884
public List < HashMap < IBond , IBond > > getTargetQueryBondMappings ( ) { if ( mappings == null ) return null ; List < HashMap < IBond , IBond > > bondMap = new ArrayList < > ( ) ; for ( Map < IBond , IBond > map : mappings . toBondMap ( ) ) { bondMap . add ( new HashMap < > ( HashBiMap . create ( map ) . inverse ( ) ...
Return a list of HashMap s that allows one to get the query constraint for a given pharmacophore bond .
27,885
public List < List < PharmacophoreAtom > > getMatchingPharmacophoreAtoms ( ) { if ( pharmacophoreMolecule == null || mappings == null ) return null ; return getPCoreAtoms ( mappings ) ; }
Get the matching pharmacophore groups .
27,886
public List < List < PharmacophoreAtom > > getUniqueMatchingPharmacophoreAtoms ( ) { if ( pharmacophoreMolecule == null || mappings == null ) return null ; return getPCoreAtoms ( mappings . uniqueAtoms ( ) ) ; }
Get the uniue matching pharmacophore groups .
27,887
public static boolean deAromatize ( IRing ring ) { boolean allaromatic = true ; for ( int i = 0 ; i < ring . getBondCount ( ) ; i ++ ) { if ( ! ring . getBond ( i ) . getFlag ( CDKConstants . ISAROMATIC ) ) allaromatic = false ; } if ( ! allaromatic ) return false ; for ( int i = 0 ; i < ring . getBondCount ( ) ; i ++ ...
Methods that takes a ring of which all bonds are aromatic and assigns single and double bonds . It does this in a non - general way by looking at the ring size and take everything as a special case .
27,888
private double calculateAngleBetweenTwoLines ( Vector3d a , Vector3d b , Vector3d c , Vector3d d ) { Vector3d firstLine = new Vector3d ( ) ; firstLine . sub ( a , b ) ; Vector3d secondLine = new Vector3d ( ) ; secondLine . sub ( c , d ) ; Vector3d firstVec = new Vector3d ( firstLine ) ; Vector3d secondVec = new Vector3...
this method calculates the angle between two bonds given coordinates of their atoms
27,889
private double calculateDistanceBetweenTwoAtoms ( IAtom atom1 , IAtom atom2 ) { double distance ; Point3d firstPoint = atom1 . getPoint3d ( ) ; Point3d secondPoint = atom2 . getPoint3d ( ) ; distance = firstPoint . distance ( secondPoint ) ; return distance ; }
generic method for calculation of distance btw 2 atoms
27,890
private double [ ] calculateDistanceBetweenAtomAndBond ( IAtom proton , IBond theBond ) { Point3d middlePoint = theBond . get3DCenter ( ) ; Point3d protonPoint = proton . getPoint3d ( ) ; double [ ] values = new double [ 4 ] ; values [ 0 ] = middlePoint . distance ( protonPoint ) ; values [ 1 ] = middlePoint . x ; valu...
and returns distance and coordinates of middle point
27,891
public Object getParameterType ( String name ) { if ( name . equals ( "checkAromaticity" ) ) return Boolean . TRUE ; return null ; }
Gets the parameterType attribute of the RDFProtonDescriptor object
27,892
public void add ( IMolecularFormulaSet formulaSet ) { for ( IMolecularFormula mf : formulaSet . molecularFormulas ( ) ) { addMolecularFormula ( mf ) ; } }
Adds all molecularFormulas in the AdductFormula to this chemObject .
27,893
public boolean contains ( IIsotope isotope ) { for ( Iterator < IIsotope > it = isotopes ( ) . iterator ( ) ; it . hasNext ( ) ; ) { IIsotope thisIsotope = it . next ( ) ; if ( isTheSame ( thisIsotope , isotope ) ) { return true ; } } return false ; }
True if the AdductFormula contains the given IIsotope object and not the instance . The method looks for other isotopes which has the same symbol natural abundance and exact mass .
27,894
public Integer getCharge ( ) { Integer charge = 0 ; Iterator < IMolecularFormula > componentIterator = components . iterator ( ) ; while ( componentIterator . hasNext ( ) ) { charge += componentIterator . next ( ) . getCharge ( ) ; } return charge ; }
Returns the partial charge of this Adduct . If the charge has not been set the return value is Double . NaN .
27,895
public int getIsotopeCount ( IIsotope isotope ) { int count = 0 ; Iterator < IMolecularFormula > componentIterator = components . iterator ( ) ; while ( componentIterator . hasNext ( ) ) { count += componentIterator . next ( ) . getIsotopeCount ( isotope ) ; } return count ; }
Checks a set of Nodes for the occurrence of the isotope in the adduct formula from a particular isotope . It returns 0 if the does not exist .
27,896
public Iterable < IIsotope > isotopes ( ) { return new Iterable < IIsotope > ( ) { public Iterator < IIsotope > iterator ( ) { return isotopesList ( ) . iterator ( ) ; } } ; }
Returns an Iterator for looping over all isotopes in this adduct formula .
27,897
private List < IIsotope > isotopesList ( ) { List < IIsotope > isotopes = new ArrayList < IIsotope > ( ) ; Iterator < IMolecularFormula > componentIterator = components . iterator ( ) ; while ( componentIterator . hasNext ( ) ) { Iterator < IIsotope > compIsotopes = componentIterator . next ( ) . isotopes ( ) . iterato...
Returns a List for looping over all isotopes in this adduct formula .
27,898
public void setParameters ( Object [ ] params ) throws CDKException { if ( params . length != 1 ) throw new CDKException ( "ChargeRule expects only one parameter" ) ; if ( ! ( params [ 0 ] instanceof Double ) ) throw new CDKException ( "The parameter must be of type Double" ) ; charge = ( Double ) params [ 0 ] ; }
Sets the parameters attribute of the ChargeRule object .
27,899
public double validate ( IMolecularFormula formula ) throws CDKException { logger . info ( "Start validation of " , formula ) ; if ( formula . getCharge ( ) == null ) { return 0.0 ; } else if ( formula . getCharge ( ) == charge ) { return 1.0 ; } else { return 0.0 ; } }
Validate the charge of this IMolecularFormula .