idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
123,500 | public Object getPreparedClassOption ( ClassOption opt ) { if ( this . classOptionNamesToPreparedObjects == null ) { this . prepareForUse ( ) ; } return this . classOptionNamesToPreparedObjects . get ( opt . getName ( ) ) ; } | Gets a prepared option of this class . |
123,501 | public boolean injectNextEvent ( ) { if ( this . getProcessor ( ) . hasNext ( ) ) { ContentEvent event = this . getProcessor ( ) . nextEvent ( ) ; this . getOutputStream ( ) . put ( event ) ; return true ; } return false ; } | If there are available events first event in the queue will be sent out on the output stream . |
123,502 | public boolean process ( ContentEvent event ) { if ( event instanceof ClusteringContentEvent ) { ClusteringContentEvent cce = ( ClusteringContentEvent ) event ; outputStream . put ( event ) ; if ( cce . isSample ( ) ) { evaluationStream . put ( new ClusteringEvaluationContentEvent ( null , new DataPoint ( cce . getInst... | Process event . |
123,503 | public double [ ] getVotesForInstance ( Instance inst ) { double [ ] votes = new double [ getNumberOfClasses ( ) ] ; for ( int classIndex = 0 ; classIndex < votes . length ; classIndex ++ ) { votes [ classIndex ] = Math . log ( getPrior ( classIndex ) ) ; for ( int index = 0 ; index < inst . numAttributes ( ) ; index +... | Predicts the class memberships for a given instance . If an instance is unclassified the returned array elements will be all zero . |
123,504 | private double getPrior ( int classIndex ) { Double currentCount = this . classInstances . get ( classIndex ) ; if ( currentCount == null || currentCount == 0 ) return 0 ; else return currentCount * 1. / this . instancesSeen ; } | Compute the prior for the given classIndex . |
123,505 | public void setStreamSource ( InstanceStream stream ) { this . streamSource = new StreamSource ( stream ) ; firstInstance = streamSource . nextInstance ( ) . getData ( ) ; } | Sets the stream source . |
123,506 | public void sendInstances ( Stream inputStream , int numberInstances , boolean isTraining , boolean isTesting ) { int numberSamples = 0 ; while ( streamSource . hasMoreInstances ( ) && numberSamples < numberInstances ) { numberSamples ++ ; numberInstancesSent ++ ; InstanceContentEvent instanceContentEvent = new Instanc... | Send instances . |
123,507 | public void sendEndEvaluationInstance ( Stream inputStream ) { InstanceContentEvent instanceContentEvent = new InstanceContentEvent ( - 1 , firstInstance , false , true ) ; inputStream . put ( instanceContentEvent ) ; } | Send end evaluation instance . |
123,508 | private void processInstanceContentEvent ( InstancesContentEvent instContentEvent ) { this . numBatches ++ ; this . contentEventList . add ( instContentEvent ) ; if ( this . numBatches == 1 || this . numBatches > 4 ) { this . processInstances ( this . contentEventList . remove ( 0 ) ) ; } if ( instContentEvent . isLast... | Helper method to process the InstanceContentEvent |
123,509 | private void trainOnInstanceImpl ( Instance inst ) { if ( this . treeRoot == null ) { this . treeRoot = newLearningNode ( this . parallelismHint ) ; this . activeLeafNodeCount = 1 ; } FoundNode foundNode = this . treeRoot . filterInstanceToLeaf ( inst , null , - 1 ) ; trainOnInstanceImpl ( foundNode , inst ) ; } | Helper method that represent training of an instance . Since it is decision tree this method routes the incoming instance into the correct leaf and then update the statistic on the found leaf . |
123,510 | private void attemptToSplit ( ActiveLearningNode activeLearningNode , FoundNode foundNode ) { this . splitId ++ ; ScheduledFuture < ? > timeOutHandler = this . executor . schedule ( new AggregationTimeOutHandler ( this . splitId , this . timedOutSplittingNodes ) , this . timeOut , TimeUnit . SECONDS ) ; this . splittin... | Helper method to represent a split attempt |
123,511 | private void continueAttemptToSplit ( ActiveLearningNode activeLearningNode , FoundNode foundNode ) { AttributeSplitSuggestion bestSuggestion = activeLearningNode . getDistributedBestSuggestion ( ) ; AttributeSplitSuggestion secondBestSuggestion = activeLearningNode . getDistributedSecondBestSuggestion ( ) ; double [ ]... | Helper method to continue the attempt to split once all local calculation results are received . |
123,512 | private void setModelContext ( InstancesHeader ih ) { if ( ( ih != null ) && ( ih . classIndex ( ) < 0 ) ) { throw new IllegalArgumentException ( "Context for a classifier must include a class to learn" ) ; } logger . trace ( "Model context: {}" , ih . toString ( ) ) ; } | Helper method to set the model context i . e . how many attributes they are and what is the class index |
123,513 | public List < MapConfig > getMapConfigsForTopology ( SamzaTopology topology ) throws Exception { List < MapConfig > configs = new ArrayList < MapConfig > ( ) ; List < Map < String , String > > maps = this . getMapsForTopology ( topology ) ; for ( Map < String , String > map : maps ) { configs . add ( new MapConfig ( ma... | Construct a list of MapConfigs for a Topology |
123,514 | private static void setValue ( Map < String , String > map , String key , String value ) { map . put ( key , value ) ; } | Set custom properties |
123,515 | public void init ( TopologyBuilder topologyBuilder , Instances dataset , int parallelism ) { this . model = new AMRRuleSetProcessor . Builder ( dataset ) . noAnomalyDetection ( noAnomalyDetectionOption . isSet ( ) ) . multivariateAnomalyProbabilityThreshold ( multivariateAnomalyProbabilityThresholdOption . getValue ( )... | private Stream resultStream ; |
123,516 | void setChild ( int index , Node child ) { if ( ( this . splitTest . maxBranches ( ) >= 0 ) && ( index >= this . splitTest . maxBranches ( ) ) ) { throw new IndexOutOfBoundsException ( ) ; } this . children . set ( index , child ) ; } | Method to set the children in a specific index of the SplitNode with the appropriate child |
123,517 | public void initTopology ( String topologyName , int delay ) { if ( this . topology != null ) { System . out . println ( "Topology has been initialized before!" ) ; return ; } this . topology = componentFactory . createTopology ( topologyName ) ; } | Initiates topology with a specific name and a delay between consecutive instances . |
123,518 | private ProcessingItem createPi ( Processor processor , int parallelism ) { ProcessingItem pi = this . componentFactory . createPi ( processor , parallelism ) ; this . topology . addProcessingItem ( pi , parallelism ) ; return pi ; } | Creates a processing item with a specific processor and paralellism level . |
123,519 | private EntranceProcessingItem createEntrancePi ( EntranceProcessor processor ) { EntranceProcessingItem epi = this . componentFactory . createEntrancePi ( processor ) ; this . topology . addEntranceProcessingItem ( epi ) ; if ( this . mapProcessorToProcessingItem == null ) this . mapProcessorToProcessingItem = new Has... | Creates a platform specific entrance processing item . |
123,520 | private Stream createStream ( IProcessingItem sourcePi ) { Stream stream = this . componentFactory . createStream ( sourcePi ) ; this . topology . addStream ( stream ) ; return stream ; } | Creates a platform specific stream . |
123,521 | public void init ( TopologyBuilder builder , Instances dataset , int parallelism ) { this . builder = builder ; this . dataset = dataset ; this . setLayout ( ) ; } | private int parallelism ; |
123,522 | public EntranceProcessingItem setOutputStream ( Stream outputStream ) { if ( this . outputStream != null && this . outputStream != outputStream ) { throw new IllegalStateException ( "Cannot overwrite output stream of EntranceProcessingItem" ) ; } else this . outputStream = outputStream ; return this ; } | Set the output stream of this EntranceProcessingItem . An EntranceProcessingItem should have only 1 single output stream and should not be re - assigned . |
123,523 | private double [ ] getVotesForInstance ( Instance instance ) { ErrorWeightedVote errorWeightedVote = newErrorWeightedVote ( ) ; int numberOfRulesCovering = 0 ; for ( ActiveRule rule : ruleSet ) { if ( rule . isCovering ( instance ) == true ) { numberOfRulesCovering ++ ; double [ ] vote = rule . getPrediction ( instance... | getVotesForInstance extension of the instance method getVotesForInstance in moa . classifier . java returns the prediction of the instance . Called in EvaluateModelRegression |
123,524 | public void finish ( ) { if ( mSuccessful ) { mDb . setTransactionSuccessful ( ) ; } mDb . endTransaction ( ) ; if ( mSuccessful ) { for ( OnTransactionCommittedListener listener : mOnTransactionCommittedListeners ) { listener . onTransactionCommitted ( ) ; } } } | Finish the transaction . This will commit or rollback the transaction depending on whether is was marked as successful or not |
123,525 | protected void onStartLoading ( ) { if ( mCursor != null ) { deliverResult ( mCursor ) ; } if ( takeContentChanged ( ) || mCursor == null ) { forceLoad ( ) ; } } | Starts an asynchronous load of the contacts list data . When the result is ready the callbacks will be called on the UI thread . If a previous load has been completed and is still valid the result may be passed to the callbacks immediately . |
123,526 | final public boolean exists ( ) { final Model m = Query . one ( getClass ( ) , String . format ( "SELECT * FROM %s WHERE %s LIMIT 1" , Utils . getTableName ( getClass ( ) ) , Utils . getWhereStatement ( this ) ) ) . get ( ) ; return m != null ; } | Check whether this model exists in the database |
123,527 | final public void delete ( ) { Transaction t = new Transaction ( ) ; try { delete ( t ) ; t . setSuccessful ( true ) ; } finally { t . finish ( ) ; } } | Delete this model |
123,528 | final public void delete ( Transaction t ) { t . delete ( Utils . getTableName ( getClass ( ) ) , Utils . getWhereStatement ( this ) ) ; t . addOnTransactionCommittedListener ( new OnTransactionCommittedListener ( ) { public void onTransactionCommitted ( ) { Sprinkles . sInstance . mContext . getContentResolver ( ) . n... | Delete this model within the given transaction |
123,529 | public static < T extends Model > ManyQuery < T > all ( Class < T > clazz ) { return many ( clazz , "SELECT * FROM " + Utils . getTableName ( clazz ) ) ; } | Start a query for the entire list of instance of type T |
123,530 | static synchronized SQLiteDatabase getDatabase ( ) { if ( sInstance == null ) { throw new SprinklesNotInitializedException ( ) ; } if ( sDatabase == null ) { DbOpenHelper dbOpenHelper = new DbOpenHelper ( sInstance . mContext , sInstance . databaseName , sInstance . initialDatabaseVersion ) ; sDatabase = dbOpenHelper .... | Throws SprinklesNotInitializedException if you try to access the database before initializing Sprinkles . |
123,531 | public Schema getXmlSchema ( CycloneDxSchema . Version schemaVersion ) throws SAXException { if ( CycloneDxSchema . Version . VERSION_10 == schemaVersion ) { return getXmlSchema10 ( ) ; } else { return getXmlSchema11 ( ) ; } } | Returns the CycloneDX XML Schema for the specified schema version . |
123,532 | private Schema getXmlSchema10 ( ) throws SAXException { final SchemaFactory schemaFactory = SchemaFactory . newInstance ( XMLConstants . W3C_XML_SCHEMA_NS_URI ) ; final Source [ ] schemaFiles = { new StreamSource ( this . getClass ( ) . getClassLoader ( ) . getResourceAsStream ( "spdx.xsd" ) ) , new StreamSource ( this... | Returns the CycloneDX XML Schema from the specifications XSD . |
123,533 | public static LicenseChoice resolve ( String licenseString ) { try { return resolveSpdxLicenseString ( licenseString ) ; } catch ( InvalidLicenseStringException e1 ) { final LicenseChoice licenseChoice = resolveViaAlternativeMapping ( licenseString ) ; if ( licenseChoice != null ) { return licenseChoice ; } try { new U... | Attempts to resolve the specified license string via SPDX license identifier and expression parsing first . If SPDX resolution is not successful the method will attempt fuzzy matching . |
123,534 | public static LicenseChoice resolveSpdxLicenseId ( String licenseId ) throws InvalidSPDXAnalysisException { final SpdxListedLicense spdxLicense = LicenseInfoFactory . getListedLicenseById ( licenseId ) ; final LicenseChoice choice = new LicenseChoice ( ) ; choice . addLicense ( createLicenseObject ( spdxLicense ) ) ; r... | Given a valid SPDX license ID this method will return a LicenseChoice object . |
123,535 | public static License parseLicenseByUrl ( String licenseUrl ) throws InvalidLicenseStringException { final String protocolExcludedUrl = licenseUrl . replace ( "http://" , "" ) . replace ( "https://" , "" ) ; final ListedLicenses ll = ListedLicenses . getListedLicenses ( ) ; License license = resolvedByUrl . get ( licen... | Given a URL this method will attempt to resolve the SPDX license . This method will not retrieve the URL rather it will interrogate it s internal list of SPDX licenses and the URLs defined for each . This method may impact performance for URLs that are not associated with an SPDX license or otherwise have not been quer... |
123,536 | private static License createLicenseObject ( SpdxListedLicense spdxListedLicense ) { final License license = new License ( ) ; license . setId ( spdxListedLicense . getLicenseId ( ) ) ; license . setName ( spdxListedLicense . getName ( ) ) ; if ( spdxListedLicense . getSeeAlso ( ) != null && spdxListedLicense . getSeeA... | Creates a License object from the specified SpdxListedLicense object . |
123,537 | private static LicenseChoice resolveViaAlternativeMapping ( String licenseString ) { if ( licenseString == null ) { return null ; } try { for ( final Map . Entry < String , List < String > > mapping : mappings . entrySet ( ) ) { final List < String > names = mapping . getValue ( ) ; if ( names != null ) { for ( final S... | Attempts to perform high - confidence license resolution with unstructured text as input . |
123,538 | public String toXmlString ( ) throws TransformerException { if ( doc == null ) { return null ; } final DOMSource domSource = new DOMSource ( doc ) ; final StringWriter writer = new StringWriter ( ) ; final StreamResult result = new StreamResult ( writer ) ; final TransformerFactory tf = TransformerFactory . newInstance... | Creates a text representation of a CycloneDX BoM Document . |
123,539 | private Bom parse ( StreamSource streamSource ) throws ParseException { try { final Schema schema = getXmlSchema ( CycloneDxSchema . Version . VERSION_11 ) ; final XmlMapper mapper = new XmlMapper ( ) ; final XMLInputFactory xif = XMLInputFactory . newFactory ( ) ; xif . setProperty ( XMLInputFactory . IS_SUPPORTING_EX... | Parses a CycloneDX BOM . |
123,540 | public List < SAXParseException > validate ( File file ) { return validate ( file , CycloneDxSchema . Version . VERSION_11 ) ; } | Verifies a CycloneDX BoM conforms to the latest version of the specification through XML validation . |
123,541 | public static List < Hash > calculateHashes ( File file ) throws IOException { if ( file == null || ! file . exists ( ) || ! file . canRead ( ) ) { return null ; } final List < Hash > hashes = new ArrayList < > ( ) ; try ( InputStream fis = Files . newInputStream ( file . toPath ( ) ) ) { hashes . add ( new Hash ( Hash... | Calculates the hashes of the specified file . |
123,542 | protected String getSortOrderStringForQuery ( MatcherPattern target , QueryParameters parameter ) { String result = "" ; if ( parameter . getSortOrder ( ) != null && parameter . getSortOrder ( ) . length ( ) >= 1 ) { result = parameter . getSortOrder ( ) ; } else { result = target . getTableInfo ( ) . getDefaultSortOrd... | This method gets the appropriate sort order . |
123,543 | public MatcherController add ( Class < ? > tableClassType , SubType subType , String pattern , int patternCode ) { this . addTableClass ( tableClassType ) ; this . addMatcherPattern ( subType , pattern , patternCode ) ; return this ; } | Register a class for table . And registers a pattern for UriMatcher . |
123,544 | public MatcherController add ( SubType subType , String pattern , int patternCode ) { this . addMatcherPattern ( subType , pattern , patternCode ) ; return this ; } | Registers a pattern for UriMatcher . It refer to the class that was last registered from add method . |
123,545 | public MatcherController add ( MatcherPattern matcherPattern ) { int patternCode = matcherPattern . getPatternCode ( ) ; if ( this . lastAddTableInfo == null ) { throw new IllegalStateException ( "There is a problem with the order of function call." ) ; } if ( findMatcherPattern ( patternCode ) != null ) { throw new Il... | Registers a pattern for UriMatcher . To register you have to create an instance of MatcherPattern . |
123,546 | public MatcherController setDefaultContentUri ( String authority , String path ) { if ( this . lastAddTableInfo == null ) { throw new IllegalStateException ( "There is a problem with the order of function call." ) ; } this . lastAddTableInfo . setDefaultContentUriInfo ( new ContentUriInfo ( authority , path ) ) ; retur... | Set the DefaultContentUri . If you did not use the DefaultContentUri annotation you must call this method . |
123,547 | public MatcherController setDefaultContentMimeTypeVnd ( String name , String type ) { if ( this . lastAddTableInfo == null ) { throw new IllegalStateException ( "There is a problem with the order of function call." ) ; } this . lastAddTableInfo . setDefaultContentMimeTypeVndInfo ( new ContentMimeTypeVndInfo ( name , ty... | Set the DefaultContentMimeTypeVnd . If you did not use the DefaultContentMimeTypeVnd annotation you must call this method . |
123,548 | public MatcherController initialize ( ) { this . lastAddTableInfo = null ; for ( Map . Entry < Class < ? > , TableInfo > entry : this . tables . entrySet ( ) ) { entry . getValue ( ) . isValid ( true ) ; } for ( MatcherPattern entry : matcherPatterns ) { entry . isValid ( true ) ; this . matcher . addURI ( entry . getT... | initialized with the contents that are registered by the add method . This method checks the registration details . |
123,549 | public MatcherPattern findMatcherPattern ( int patternCode ) { MatcherPattern result = null ; for ( MatcherPattern entry : this . matcherPatterns ) { if ( entry . getPatternCode ( ) == patternCode ) { result = entry ; break ; } } return result ; } | This will search the MatcherPattern that are registered based on the return code UriMatcher . |
123,550 | protected void onQueryCompleted ( Cursor result , Uri uri , MatcherPattern target , QueryParameters parameter ) { result . setNotificationUri ( this . getContext ( ) . getContentResolver ( ) , uri ) ; } | This method is called after the onQuery processing has been handled . If you re a need you can override this method . |
123,551 | protected void onInsertCompleted ( Uri result , Uri uri , MatcherPattern target , InsertParameters parameter ) { this . getContext ( ) . getContentResolver ( ) . notifyChange ( result , null ) ; } | This method is called after the onInsert processing has been handled . If you re a need you can override this method . |
123,552 | protected void onDeleteCompleted ( int result , Uri uri , MatcherPattern target , DeleteParameters parameter ) { this . getContext ( ) . getContentResolver ( ) . notifyChange ( uri , null ) ; } | This method is called after the onDelete processing has been handled . If you re a need you can override this method . |
123,553 | protected void onUpdateCompleted ( int result , Uri uri , MatcherPattern target , UpdateParameters parameter ) { this . getContext ( ) . getContentResolver ( ) . notifyChange ( uri , null ) ; } | This method is called after the onUpdate processing has been handled . If you re a need you can override this method . |
123,554 | public static void __gmpz_import ( mpz_t rop , int count , int order , int size , int endian , int nails , Pointer buffer ) { if ( SIZE_T_CLASS == SizeT4 . class ) { SizeT4 . __gmpz_import ( rop , count , order , size , endian , nails , buffer ) ; } else { SizeT8 . __gmpz_import ( rop , count , order , size , endian , ... | Set rop from an array of word data at op . |
123,555 | public static void __gmpz_export ( Pointer rop , Pointer countp , int order , int size , int endian , int nails , mpz_t op ) { if ( SIZE_T_CLASS == SizeT4 . class ) { SizeT4 . __gmpz_export ( rop , countp , order , size , endian , nails , op ) ; } else { SizeT8 . __gmpz_export ( rop , countp , order , size , endian , n... | Fill rop with word data from op . |
123,556 | public static void checkLoaded ( ) { if ( LOAD_ERROR != null ) { throw LOAD_ERROR ; } BigInteger two = BigInteger . valueOf ( 2 ) ; BigInteger three = BigInteger . valueOf ( 3 ) ; BigInteger four = BigInteger . valueOf ( 4 ) ; BigInteger five = BigInteger . valueOf ( 5 ) ; BigInteger answer ; answer = modPowInsecure ( ... | Verifies this library is loaded properly . |
123,557 | public static int kronecker ( BigInteger a , BigInteger p ) { return INSTANCE . get ( ) . kroneckerImpl ( a , p ) ; } | Calculate kronecker symbol a|p . Generalization of legendre and jacobi . |
123,558 | public static BigInteger modInverse ( BigInteger val , BigInteger modulus ) { if ( modulus . signum ( ) <= 0 ) { throw new ArithmeticException ( "modulus must be positive" ) ; } return INSTANCE . get ( ) . modInverseImpl ( val , modulus ) ; } | Calculate val^ - 1 % modulus . |
123,559 | public static BigInteger exactDivide ( BigInteger dividend , BigInteger divisor ) { if ( divisor . signum ( ) == 0 ) { throw new ArithmeticException ( "BigInteger divide by zero" ) ; } return INSTANCE . get ( ) . exactDivImpl ( dividend , divisor ) ; } | Divide dividend by divisor . This method only returns correct answers when the division produces no remainder . Correct answers should not be expected when the divison would result in a remainder . |
123,560 | public byte [ ] processBlock ( byte [ ] in , int inOff , int inLen ) { if ( core == null ) { throw new IllegalStateException ( "RSA engine not initialised" ) ; } return core . convertOutput ( core . processBlock ( core . convertInput ( in , inOff , inLen ) ) ) ; } | Process a single block using the basic RSA algorithm . |
123,561 | public byte [ ] transform ( byte [ ] classfileBuffer , Configuration configuration ) { InstrumentationActions instrumentationActions = calculateTransformationParameters ( classfileBuffer , configuration ) ; if ( ! instrumentationActions . includeClass ) { return classfileBuffer ; } return transform ( classfileBuffer , ... | Instrument the given class based on the configuration . |
123,562 | private InstrumentationActions calculateTransformationParameters ( byte [ ] classfileBuffer , Configuration configuration ) { DiscoveryClassVisitor discoveryClassVisitor = new DiscoveryClassVisitor ( configuration ) ; new ClassReader ( classfileBuffer ) . accept ( discoveryClassVisitor , 0 ) ; return discoveryClassVisi... | Based on the structure of the class and the supplied configuration determine the concrete instrumentation actions for the class . |
123,563 | private byte [ ] transform ( byte [ ] classfileBuffer , InstrumentationActions instrumentationActions ) { ClassReader classReader = new ClassReader ( classfileBuffer ) ; ClassWriter classWriter = new ClassWriter ( classReader , ClassWriter . COMPUTE_FRAMES ) ; ClassVisitor localVariableStateEmitterTestClassVisitor = ne... | Perform the given instrumentation actions on a class . |
123,564 | private LocalVariableScope calculateScope ( LocalVariableScopeData scope ) { final TryCatchBlockLabels enclosingTry = getEnclosingTry ( scope ) ; final Label start = scope . labels . start ; final Label end = getTryFixedEndLabel ( scope , enclosingTry ) ; int startIndex = getIndex ( start ) ; int endIndex = getIndex ( ... | Calculate the start and end line numbers for variable scopes . If the LocalVariableScope start line is 0 then it is an input parameter as it s scope start label appeared before the method body . |
123,565 | public static IBAN parse ( String input ) { if ( input == null || input . length ( ) == 0 ) { throw new IllegalArgumentException ( "Input is null or empty string." ) ; } if ( ! isLetterOrDigit ( input . charAt ( 0 ) ) || ! isLetterOrDigit ( input . charAt ( input . length ( ) - 1 ) ) ) { throw new IllegalArgumentExcept... | Parses the given string into an IBAN object and confirms the check digits . |
123,566 | public static String toPlain ( String input ) { Matcher matcher = SPACE_PATTERN . matcher ( input ) ; if ( matcher . find ( ) ) { return matcher . replaceAll ( "" ) ; } else { return input ; } } | Removes any spaces contained in the String thereby converting the input into a plain IBAN |
123,567 | private static String addSpaces ( String value ) { final int length = value . length ( ) ; final int lastPossibleBlock = length - 4 ; final StringBuilder sb = new StringBuilder ( length + ( length - 1 ) / 4 ) ; int i ; for ( i = 0 ; i < lastPossibleBlock ; i += 4 ) { sb . append ( value , i , i + 4 ) ; sb . append ( ' ... | Converts a plain to a pretty printed IBAN |
123,568 | public static int calculateCheckDigits ( CharSequence input ) { if ( input == null || input . length ( ) < 5 || input . charAt ( 2 ) != '0' || input . charAt ( 3 ) != '0' ) { throw new IllegalArgumentException ( "The input must be non-null, have a minimum length of five characters, and the characters at indices 2 and 3... | Calculates the check digits to be used in a MOD97 checked string . |
123,569 | public static int getLengthForCountryCode ( String countryCode ) { int index = indexOf ( countryCode ) ; if ( index > - 1 ) { return CountryCodes . COUNTRY_IBAN_LENGTHS [ index ] & REMOVE_SEPA_MASK ; } return - 1 ; } | Returns the IBAN length for a given country code . |
123,570 | public static boolean isSEPACountry ( String countryCode ) { int index = indexOf ( countryCode ) ; if ( index > - 1 ) { return ( CountryCodes . COUNTRY_IBAN_LENGTHS [ index ] & SEPA ) == SEPA ; } return false ; } | Returns whether the given country code is in SEPA . |
123,571 | public static boolean isKnownCountryCode ( String aCountryCode ) { if ( aCountryCode == null || aCountryCode . length ( ) != 2 ) { return false ; } return indexOf ( aCountryCode ) >= 0 ; } | Returns whether the given string is a known country code . |
123,572 | public void stop ( ) { try { if ( this . socket != null ) { this . socket . close ( ) ; } } catch ( final IOException e1 ) { GPSdEndpoint . LOG . debug ( "Close forced: " + e1 . getMessage ( ) ) ; } this . listeners . clear ( ) ; if ( this . listenThread != null ) { this . listenThread . halt ( ) ; } this . listenThrea... | Stops the endpoint . |
123,573 | void handleDisconnected ( ) throws IOException { synchronized ( this . asyncMutex ) { if ( socket != null ) { socket . close ( ) ; } this . socket = new Socket ( server , port ) ; this . in = new BufferedReader ( new InputStreamReader ( this . socket . getInputStream ( ) ) ) ; this . out = new BufferedWriter ( new Outp... | Our socket thread got disconnect and is exiting . |
123,574 | @ SuppressWarnings ( { "unchecked" , "unused" } ) protected < T extends IGPSObject > List < T > parseObjectArray ( final JSONArray array , final Class < T > type ) throws ParseException { try { if ( array == null ) { return new ArrayList < T > ( 10 ) ; } final List < T > objects = new ArrayList < T > ( 10 ) ; for ( int... | parse a whole JSONArray into a list of IGPSObjects |
123,575 | public State < T > onEvent ( T stateful , String event , Object ... args ) throws TooBusyException { int attempts = 0 ; while ( this . retryAttempts == - 1 || attempts < this . retryAttempts ) { try { State < T > current = this . getCurrentState ( stateful ) ; Transition < T > transition = this . getTransition ( event ... | Process event . Will handle all retry attempts . If attempts exceed maximum retries it will throw a TooBusyException . |
123,576 | public static Field getField ( final Class < ? > clazz , final String fieldName ) { Field field = null ; for ( Class < ? > current = clazz ; current != null && field == null ; current = current . getSuperclass ( ) ) { try { field = current . getDeclaredField ( fieldName ) ; } catch ( final NoSuchFieldException e ) { } ... | Climb the class hierarchy starting with the clazz provided looking for the field with fieldName |
123,577 | protected Annotation [ ] createParameterAnnotations ( String parmName , MethodInfo methodInfo , java . lang . annotation . Annotation [ ] annotations , ConstPool parameterConstPool ) throws IllegalArgumentException , IllegalAccessException , InvocationTargetException { List < Annotation > ctParmAnnotations = new Linked... | Clone all the parameter Annotations from the StatefulController to the Proxy |
123,578 | public void onAfterSave ( Object source , DBObject dbo ) { this . persister . onAfterSave ( source , dbo ) ; } | Pass the Save event to the MongoPersister to cascade to the StateDocument |
123,579 | private void mapControllerAndEntityClasses ( BeanDefinitionRegistry reg , Map < String , Class < ? > > controllerToEntityMapping , Map < Class < ? > , String > entityToRepositoryMapping , Map < Class < ? > , Set < String > > entityToControllerMappings ) throws ClassNotFoundException { for ( String bfName : reg . getBea... | Iterate thru all beans and fetch the StatefulControllers |
123,580 | public V getValue ( T object ) { try { if ( this . getMethod != null ) { return ( V ) this . getMethod . invoke ( object ) ; } else { return ( V ) this . field . get ( object ) ; } } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( InvocationTargetException e ) { throw new RuntimeExcept... | Return the value of the object |
123,581 | public void setValue ( T object , V value ) { try { if ( this . setMethod != null ) { this . setMethod . invoke ( object , value ) ; } else { this . field . set ( object , value ) ; } } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( InvocationTargetException e ) { throw new RuntimeExc... | Set s the value of the object |
123,582 | public static Annotation cloneAnnotation ( ConstPool constPool , java . lang . annotation . Annotation annotation ) throws IllegalArgumentException , IllegalAccessException , InvocationTargetException { Class < ? > clazz = annotation . annotationType ( ) ; Annotation annot = new Annotation ( clazz . getName ( ) , const... | Clone an annotation and all of it s methods |
123,583 | private void refitText ( ) { if ( ! mSizeToFit ) { return ; } if ( mMaxLines <= 0 ) { return ; } String text = mTextView . getText ( ) . toString ( ) ; int targetWidth = mTextView . getWidth ( ) - mTextView . getPaddingLeft ( ) - mTextView . getPaddingRight ( ) ; if ( targetWidth > 0 ) { Context context = mTextView . g... | Re size the font so the specified text fits in the text box assuming the text box is the specified width . |
123,584 | protected View onCreateView ( String name , AttributeSet attrs ) throws ClassNotFoundException { View view = null ; for ( String prefix : CLASS_PREFIX_LIST ) { try { view = createView ( name , prefix , attrs ) ; } catch ( ClassNotFoundException ignored ) { } } if ( view == null ) view = super . onCreateView ( name , at... | The LayoutInflater onCreateView is the fourth port of call for LayoutInflation . BUT only for none CustomViews . Basically if this method doesn t inflate the View nothing probably will . |
123,585 | public RECORD parse ( final String value ) throws DissectionFailure , InvalidDissectorException , MissingDissectorsException { assembleDissectors ( ) ; final Parsable < RECORD > parsable = createParsable ( ) ; if ( parsable == null ) { return null ; } parsable . setRootDissection ( rootType , value ) ; return parse ( p... | Parse the value and return a new instance of RECORD . For this method to work the RECORD class may NOT be an inner class . |
123,586 | public List < String > getPossiblePaths ( int maxDepth ) { if ( allDissectors . isEmpty ( ) ) { return Collections . emptyList ( ) ; } try { assembleDissectors ( ) ; } catch ( MissingDissectorsException | InvalidDissectorException e ) { } List < String > paths = new ArrayList < > ( ) ; Map < String , List < String > > ... | This method is for use by the developer to query the parser about the possible paths that may be extracted . |
123,587 | public static String resilientUrlDecode ( String input ) { String cookedInput = input ; if ( cookedInput . indexOf ( '%' ) > - 1 ) { cookedInput = VALID_STANDARD . matcher ( cookedInput ) . replaceAll ( "%00%$1" ) ; cookedInput = CHOPPED_STANDARD . matcher ( cookedInput ) . replaceAll ( "" ) ; if ( cookedInput . contai... | The main goal of the resilientUrlDecode is to have a UrlDecode that keeps working even if the input is seriously flawed or even uses a rejected standard . |
123,588 | public Dissector getNewInstance ( ) { try { Constructor < ? extends Dissector > co = this . getClass ( ) . getConstructor ( ) ; Dissector newInstance = co . newInstance ( ) ; initializeNewInstance ( newInstance ) ; return newInstance ; } catch ( Exception e ) { LOG . error ( "Unable to create instance of {}: {}" , this... | Create an additional instance of this dissector . This is needed because in the parse tree we may need the same dissector multiple times . In order to optimize per node we need separate instances . |
123,589 | public void declareRequestedFieldname ( String name ) { if ( name . endsWith ( ".*" ) ) { stringSetValues . put ( name , new HashMap < > ( ) ) ; stringSetPrefixes . put ( name . substring ( 0 , name . length ( ) - 1 ) , name ) ; } } | For multivalue things we need to know what the name is we are expecting . For those patterns we match the values we get against |
123,590 | public JSONAPIDocument < User > fetchUser ( Collection < User . UserField > optionalFields ) throws IOException { URIBuilder pathBuilder = new URIBuilder ( ) . setPath ( "current_user" ) . addParameter ( "include" , "pledges" ) ; if ( optionalFields != null ) { Set < User . UserField > optionalAndDefaultFields = new Ha... | Get the user object of the creator |
123,591 | public < T > T eval ( XMLResource resource , Class < T > aReturnType ) throws Exception { T retVal = ( T ) xPathExpression . evaluate ( resource . doc ( ) , getConstant ( aReturnType ) ) ; return retVal ; } | Evaluate the XPath on an XMLResource and convert the result into aReturnType . |
123,592 | protected Object unmarshal ( ) throws IOException , JSONException { json = new JSONTokener ( new InputStreamReader ( inputStream , "UTF-8" ) ) . nextValue ( ) ; inputStream . close ( ) ; return json ; } | Transforming the JSON on the fly |
123,593 | public JSONResource json ( JSONPathQuery path ) throws Exception { Object jsonValue = path . eval ( this ) ; return json ( jsonValue . toString ( ) ) ; } | Execute the given path query on the json GET the returned URI expecting JSON |
123,594 | protected void addContent ( URLConnection con ) throws IOException { con . setDoOutput ( true ) ; con . addRequestProperty ( "Content-Type" , mime ) ; con . addRequestProperty ( "Content-Length" , String . valueOf ( content . length ) ) ; OutputStream os = con . getOutputStream ( ) ; writeContent ( os ) ; os . close ( ... | Add the content to the URLConnection used . |
123,595 | public void writeHeader ( OutputStream os ) throws IOException { os . write ( ascii ( "Content-Type: " + mime + "\r\n" ) ) ; os . write ( ascii ( "Content-Length: " + String . valueOf ( content . length ) + "\r\n" ) ) ; } | Used as a mime part writing content headers |
123,596 | public static String [ ] getNames ( Object object ) { if ( object == null ) { return null ; } Class < ? extends Object > klass = object . getClass ( ) ; Field [ ] fields = klass . getFields ( ) ; int length = fields . length ; if ( length == 0 ) { return null ; } String [ ] names = new String [ length ] ; for ( int i =... | Get an array of field names from an Object . |
123,597 | public static String encodeIfNecessary ( String text , Usage usage , int usedCharacters ) { if ( hasToBeEncoded ( text , usedCharacters ) ) return encodeEncodedWord ( text , usage , usedCharacters ) ; else return text ; } | Shortcut method that encodes the specified text into an encoded - word if the text has to be encoded . |
123,598 | public static String encodeEncodedWord ( String text , Usage usage , int usedCharacters , Charset charset , Encoding encoding ) { if ( text == null ) throw new IllegalArgumentException ( ) ; if ( usedCharacters < 0 || usedCharacters > MAX_USED_CHARACTERS ) throw new IllegalArgumentException ( ) ; if ( charset == null )... | Encodes the specified text into an encoded word or a sequence of encoded words separated by space . The text is separated into a sequence of encoded words if it does not fit in a single one . |
123,599 | public static String encodeB ( byte [ ] bytes ) { StringBuilder sb = new StringBuilder ( ) ; int idx = 0 ; final int end = bytes . length ; for ( ; idx < end - 2 ; idx += 3 ) { int data = ( bytes [ idx ] & 0xff ) << 16 | ( bytes [ idx + 1 ] & 0xff ) << 8 | bytes [ idx + 2 ] & 0xff ; sb . append ( ( char ) BASE64_TABLE ... | Encodes the specified byte array using the B encoding defined in RFC 2047 . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.