idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
6,700 | private boolean tagEquals ( String tag1 , String tag2 ) { if ( caseSensitive ) { return tag1 . equals ( tag2 ) ; } return tag1 . equalsIgnoreCase ( tag2 ) ; } | Determine if the two specified tag names are equal . |
6,701 | private void onHandleIntent ( GroundyTask groundyTask ) { if ( groundyTask == null ) { return ; } boolean requiresWifi = groundyTask . keepWifiOn ( ) ; if ( requiresWifi ) { mWakeLockHelper . acquire ( ) ; } L . d ( TAG , "Executing value: " + groundyTask ) ; TaskResult taskResult ; try { taskResult = groundyTask . doInBackground ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; taskResult = new Failed ( ) ; taskResult . add ( Groundy . CRASH_MESSAGE , String . valueOf ( e . getMessage ( ) ) ) ; } if ( taskResult == null ) { throw new NullPointerException ( "Task " + groundyTask + " returned null from the doInBackground method" ) ; } if ( requiresWifi ) { mWakeLockHelper . release ( ) ; } Bundle resultData = taskResult . getResultData ( ) ; resultData . putBundle ( Groundy . ORIGINAL_PARAMS , groundyTask . getArgs ( ) ) ; resultData . putSerializable ( Groundy . TASK_IMPLEMENTATION , groundyTask . getClass ( ) ) ; switch ( taskResult . getType ( ) ) { case SUCCESS : groundyTask . send ( OnSuccess . class , resultData ) ; break ; case FAIL : groundyTask . send ( OnFailure . class , resultData ) ; break ; case CANCEL : resultData . putInt ( Groundy . CANCEL_REASON , groundyTask . getQuittingReason ( ) ) ; groundyTask . send ( OnCancel . class , resultData ) ; break ; } } | This method is invoked on the worker thread with a request to process . Only one Intent is processed at a time but the processing happens on a worker thread that runs independently from other application logic . So if this code takes a long time it will hold up other requests to the same IntentService but it will not hold up anything else . |
6,702 | public void expire ( long time ) { long calculatedSize = 0 ; Iterator < Bar > it = bars . iterator ( ) ; while ( it . hasNext ( ) ) { long barSize = it . next ( ) . expire ( time ) ; if ( barSize == 0 ) { it . remove ( ) ; } calculatedSize += barSize ; } this . size = calculatedSize ; if ( bars . isEmpty ( ) ) { bars . add ( new Bar ( barEpsilon , window ) ) ; } } | Expire old events from all buckets . |
6,703 | @ SuppressWarnings ( "rawtypes" ) public boolean useReferences ( Class type ) { return ! Util . isWrapperClass ( type ) && ! type . equals ( String . class ) && ! type . equals ( Date . class ) && ! type . equals ( BigDecimal . class ) && ! type . equals ( BigInteger . class ) ; } | Returns false for all primitive wrappers . |
6,704 | public static EbInterfaceWriter < Ebi30InvoiceType > ebInterface30 ( ) { final EbInterfaceWriter < Ebi30InvoiceType > ret = EbInterfaceWriter . create ( Ebi30InvoiceType . class ) ; ret . setNamespaceContext ( EbInterface30NamespaceContext . getInstance ( ) ) ; return ret ; } | Create a writer builder for Ebi30InvoiceType . |
6,705 | public static EbInterfaceWriter < Ebi302InvoiceType > ebInterface302 ( ) { final EbInterfaceWriter < Ebi302InvoiceType > ret = EbInterfaceWriter . create ( Ebi302InvoiceType . class ) ; ret . setNamespaceContext ( EbInterface302NamespaceContext . getInstance ( ) ) ; return ret ; } | Create a writer builder for Ebi302InvoiceType . |
6,706 | public static EbInterfaceWriter < Ebi40InvoiceType > ebInterface40 ( ) { final EbInterfaceWriter < Ebi40InvoiceType > ret = EbInterfaceWriter . create ( Ebi40InvoiceType . class ) ; ret . setNamespaceContext ( EbInterface40NamespaceContext . getInstance ( ) ) ; return ret ; } | Create a writer builder for Ebi40InvoiceType . |
6,707 | public static EbInterfaceWriter < Ebi41InvoiceType > ebInterface41 ( ) { final EbInterfaceWriter < Ebi41InvoiceType > ret = EbInterfaceWriter . create ( Ebi41InvoiceType . class ) ; ret . setNamespaceContext ( EbInterface41NamespaceContext . getInstance ( ) ) ; return ret ; } | Create a writer builder for Ebi41InvoiceType . |
6,708 | public static EbInterfaceWriter < Ebi42InvoiceType > ebInterface42 ( ) { final EbInterfaceWriter < Ebi42InvoiceType > ret = EbInterfaceWriter . create ( Ebi42InvoiceType . class ) ; ret . setNamespaceContext ( EbInterface42NamespaceContext . getInstance ( ) ) ; return ret ; } | Create a writer builder for Ebi42InvoiceType . |
6,709 | public static EbInterfaceWriter < Ebi43InvoiceType > ebInterface43 ( ) { final EbInterfaceWriter < Ebi43InvoiceType > ret = EbInterfaceWriter . create ( Ebi43InvoiceType . class ) ; ret . setNamespaceContext ( EbInterface43NamespaceContext . getInstance ( ) ) ; return ret ; } | Create a writer builder for Ebi43InvoiceType . |
6,710 | public static EbInterfaceWriter < Ebi50InvoiceType > ebInterface50 ( ) { final EbInterfaceWriter < Ebi50InvoiceType > ret = EbInterfaceWriter . create ( Ebi50InvoiceType . class ) ; ret . setNamespaceContext ( EbInterface50NamespaceContext . getInstance ( ) ) ; return ret ; } | Create a writer builder for Ebi50InvoiceType . |
6,711 | public static CallbacksManager init ( Bundle bundle , Object ... callbackHandlers ) { if ( bundle == null ) { return new CallbacksManager ( ) ; } CallbacksManager callbacksManager = new CallbacksManager ( ) ; ArrayList < TaskHandler > taskProxies = bundle . getParcelableArrayList ( TASK_PROXY_LIST ) ; if ( taskProxies != null ) { callbacksManager . proxyTasks . addAll ( taskProxies ) ; } if ( callbackHandlers != null ) { for ( TaskHandler proxyTask : new ArrayList < TaskHandler > ( callbacksManager . proxyTasks ) ) { proxyTask . clearCallbacks ( ) ; proxyTask . appendCallbacks ( callbackHandlers ) ; } } return callbacksManager ; } | Call from within your activity or fragment onCreate method . |
6,712 | public void linkCallbacks ( Object ... callbackHandlers ) { if ( callbackHandlers != null ) { for ( TaskHandler proxyTask : new ArrayList < TaskHandler > ( proxyTasks ) ) { proxyTask . clearCallbacks ( ) ; proxyTask . appendCallbacks ( callbackHandlers ) ; } } } | Links the specified callback handlers to their respective tasks . |
6,713 | public void onSaveInstanceState ( Bundle bundle ) { bundle . putParcelableArrayList ( TASK_PROXY_LIST , proxyTasks ) ; for ( TaskHandler proxyTask : proxyTasks ) { bundle . putParcelable ( GROUNDY_PROXY_KEY_PREFIX + proxyTask . getTaskId ( ) , proxyTask ) ; } } | Saves the current callback handlers information in order to restore them after the configuration change . |
6,714 | public void addFields ( List < ModelFieldBean > modelFields ) { Assert . notNull ( modelFields , "modelFields must not be null" ) ; for ( ModelFieldBean bean : modelFields ) { this . fields . put ( bean . getName ( ) , bean ) ; } } | Add all provided fields to the collection of fields |
6,715 | public static void d ( String tag , String msg ) { if ( logEnabled ) { Log . d ( tag , msg ) ; } } | Sends a debug message to the log . |
6,716 | public Groundy service ( Class < ? extends GroundyService > groundyClass ) { if ( groundyClass == GroundyService . class ) { throw new IllegalStateException ( "This method is meant to set a different GroundyService implementation. " + "You cannot use GroundyService.class, http://i.imgur.com/IR23PAe.png" ) ; } checkAlreadyProcessed ( ) ; mGroundyClass = groundyClass ; return this ; } | This allows you to use a different GroundyService implementation . |
6,717 | static GroundyTask get ( Class < ? extends GroundyTask > taskClass , Context context ) { if ( CACHE . containsKey ( taskClass ) ) { return CACHE . get ( taskClass ) ; } GroundyTask groundyTask = null ; try { L . d ( TAG , "Instantiating " + taskClass ) ; Constructor ctc = taskClass . getConstructor ( ) ; groundyTask = ( GroundyTask ) ctc . newInstance ( ) ; if ( groundyTask . canBeCached ( ) ) { CACHE . put ( taskClass , groundyTask ) ; } else if ( CACHE . containsKey ( taskClass ) ) { CACHE . remove ( taskClass ) ; } groundyTask . setContext ( context ) ; groundyTask . onCreate ( ) ; return groundyTask ; } catch ( Exception e ) { L . e ( TAG , "Unable to create value for call " + taskClass , e ) ; } return groundyTask ; } | Builds a GroundyTask based on call . |
6,718 | public boolean hasOnlyName ( OutputConfig outputConfig ) { if ( StringUtils . hasText ( this . name ) && ! StringUtils . hasText ( this . type ) && this . defaultValue == null && ! StringUtils . hasText ( this . dateFormat ) && ! StringUtils . hasText ( this . mapping ) && this . persist == null && ! StringUtils . hasText ( this . convert ) ) { if ( outputConfig . getOutputFormat ( ) == OutputFormat . EXTJS4 ) { return this . useNull == null ; } else if ( outputConfig . getOutputFormat ( ) == OutputFormat . TOUCH2 ) { return this . allowNull == null ; } else if ( outputConfig . getOutputFormat ( ) == OutputFormat . EXTJS5 ) { return this . allowNull == null && this . critical == null && ! StringUtils . hasText ( this . calculate ) && ( this . validators == null || this . validators . isEmpty ( ) ) && ( this . depends == null || this . depends . isEmpty ( ) ) && this . reference == null && this . allowBlank == null && this . unique == null ; } } return false ; } | Returns true if only the name property is set |
6,719 | public void merge ( ExponentialHistogram b ) { if ( b . mergeThreshold != mergeThreshold ) { throw new IllegalArgumentException ( ) ; } merge ( b . boxes , b . total ) ; } | Merge the supplied ExponentialHistogram in to this one . |
6,720 | public long expire ( long time ) { for ( int logSize = ( Long . SIZE - 1 ) - numberOfLeadingZeros ( last ) ; logSize >= 0 ; logSize -- ) { boolean live = false ; for ( int i = min_l ( logSize ) ; i < max_l ( logSize ) ; i ++ ) { long end = boxes [ i ] ; if ( end != MIN_VALUE ) { if ( ( time - end ) >= window ) { total -= 1L << logSize ; boxes [ i ] = MIN_VALUE ; } else { live = true ; } } } if ( live ) { last = 1L << logSize ; return count ( ) ; } } last = 0 ; return 0 ; } | Expire old events . |
6,721 | @ Consumes ( "application/json" ) public void putJson ( IncomingMessage msg ) { chatBean . addMessage ( msg . nick , msg . content ) ; } | PUT method for updating or creating an instance of ChatService |
6,722 | protected void callback ( String name , Bundle resultData ) { if ( resultData == null ) resultData = new Bundle ( ) ; resultData . putString ( Groundy . KEY_CALLBACK_NAME , name ) ; resultData . putSerializable ( Groundy . TASK_IMPLEMENTATION , getClass ( ) ) ; send ( OnCallback . class , resultData ) ; } | Sends this data to the callback methods annotated with the specified name . |
6,723 | private void mergeProxiesWithClassHierarchy ( ) { for ( Map . Entry < HandlerAndTask , Set < ProxyImplContent > > elementSetEntry : implMap . entrySet ( ) ) { final HandlerAndTask handlerAndTask = elementSetEntry . getKey ( ) ; final Set < Element > superTasks = getSuperClasses ( handlerAndTask . task ) ; for ( Element superTask : superTasks ) { final HandlerAndTask handlerAndSuperTask = new HandlerAndTask ( handlerAndTask . handler , superTask ) ; if ( implMap . containsKey ( handlerAndSuperTask ) ) { appendNonExistentCallbacks ( handlerAndSuperTask , handlerAndTask ) ; } } final Set < Element > superHandlers = getSuperClasses ( handlerAndTask . handler ) ; for ( Element superHandler : superHandlers ) { final HandlerAndTask superHandlerAndTask = new HandlerAndTask ( superHandler , handlerAndTask . task ) ; if ( implMap . containsKey ( superHandlerAndTask ) ) { appendNonExistentCallbacks ( superHandlerAndTask , handlerAndTask ) ; } for ( Element superTask : superTasks ) { final HandlerAndTask superHandlerAndSuperTask = new HandlerAndTask ( superHandler , superTask ) ; if ( implMap . containsKey ( superHandlerAndSuperTask ) ) { appendNonExistentCallbacks ( superHandlerAndSuperTask , handlerAndTask ) ; } } } } } | Merges callbacks implementations taking into account the supper types of the handlers and the tasks . 1 . It will look for callbacks of the super classes of the tasks in the same handler . 2 . It will look for callbacks of the super classes of the handler that use the same task . 3 . It will look for callbacks of the super classes of the handler that use super classes of the task . |
6,724 | private void appendNonExistentCallbacks ( HandlerAndTask from , HandlerAndTask to ) { final Set < ProxyImplContent > proxyImplContentsTo = implMap . get ( to ) ; if ( proxyImplContentsTo == null ) { return ; } final Set < ProxyImplContent > proxyImplContentsFrom = implMap . get ( from ) ; if ( proxyImplContentsFrom == null ) { return ; } for ( ProxyImplContent proxyImplContentFrom : proxyImplContentsFrom ) { boolean exists = false ; for ( ProxyImplContent proxyImplContentTo : proxyImplContentsTo ) { if ( proxyImplContentTo . annotation . equals ( proxyImplContentFrom . annotation ) ) { exists = true ; break ; } } if ( ! exists ) { proxyImplContentsTo . add ( proxyImplContentFrom ) ; } } } | Copy all callbacks implementations from - > to the specified set . It makes sure to copy the callbacks that don t exist already on the destination set . |
6,725 | private static List < NameAndType > getParamNames ( Element callbackMethod ) { Element parentClass = callbackMethod . getEnclosingElement ( ) ; String methodFullInfo = parentClass + "#" + callbackMethod ; ExecutableElement method = ( ExecutableElement ) callbackMethod ; if ( ! method . getModifiers ( ) . contains ( Modifier . PUBLIC ) ) { LOGGER . info ( methodFullInfo + " must be public." ) ; System . exit ( - 1 ) ; } if ( method . getReturnType ( ) . getKind ( ) != TypeKind . VOID ) { LOGGER . info ( methodFullInfo + " must return void." ) ; System . exit ( - 1 ) ; } List < NameAndType > paramNames = new ArrayList < NameAndType > ( ) ; for ( VariableElement param : method . getParameters ( ) ) { Param paramAnnotation = param . getAnnotation ( Param . class ) ; if ( paramAnnotation == null ) { LOGGER . info ( methodFullInfo + ": all parameters must be annotated with the @" + Param . class . getName ( ) ) ; System . exit ( - 1 ) ; } paramNames . add ( new NameAndType ( paramAnnotation . value ( ) , param . asType ( ) . toString ( ) ) ) ; } return paramNames ; } | Makes sure method is public returns void and all its parameters are annotated too . |
6,726 | public boolean hasAnyProperties ( ) { return StringUtils . hasText ( this . type ) || StringUtils . hasText ( this . association ) || StringUtils . hasText ( this . child ) || StringUtils . hasText ( this . parent ) || StringUtils . hasText ( this . role ) || StringUtils . hasText ( this . inverse ) ; } | Tests if something is set . |
6,727 | private boolean hasSlf4jBinding ( File file ) throws MojoExecutionException { try ( JarFile jarFile = new JarFile ( file ) ) { return jarFile . getEntry ( "org/slf4j/impl/StaticLoggerBinder.class" ) != null ; } catch ( IOException e ) { throw new MojoExecutionException ( e . getMessage ( ) , e ) ; } } | Returns true if the given jar file contains an SLF4J binding |
6,728 | public static Templates getXSLTTemplates ( final EEbInterfaceVersion eVersion ) { final String sNamespaceURI = eVersion . getNamespaceURI ( ) ; final Templates ret = s_aRWLock . readLocked ( ( ) -> s_aTemplates . get ( sNamespaceURI ) ) ; if ( ret != null ) return ret ; return s_aRWLock . writeLocked ( ( ) -> { Templates ret2 = s_aTemplates . get ( sNamespaceURI ) ; if ( ret2 == null ) { final IReadableResource aXSLTRes = eVersion . getXSLTResource ( ) ; ret2 = XMLTransformerFactory . newTemplates ( aXSLTRes ) ; if ( ret2 == null ) LOGGER . error ( "Failed to parse XSLT template " + aXSLTRes ) ; else if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Compiled XSLT template " + aXSLTRes ) ; s_aTemplates . put ( sNamespaceURI , ret2 ) ; } return ret2 ; } ) ; } | Get the precompiled XSLT template to be used . It is lazily initialized upon first call . |
6,729 | public static ESuccess visualize ( final EEbInterfaceVersion eVersion , final Source aSource , final Result aResult ) { ValueEnforcer . notNull ( eVersion , "version" ) ; final Templates aTemplates = getXSLTTemplates ( eVersion ) ; if ( aTemplates == null ) return ESuccess . FAILURE ; try { final Transformer aTransformer = aTemplates . newTransformer ( ) ; aTransformer . transform ( aSource , aResult ) ; return ESuccess . SUCCESS ; } catch ( final TransformerException ex ) { LOGGER . error ( "Failed to apply transformation for ebInterface " + eVersion + " invoice" , ex ) ; return ESuccess . FAILURE ; } } | Visualize a source to a result for a certain ebInterface version using XSLT . This is the most generic method . |
6,730 | public static DownloadProgressListener getDownloadListenerForTask ( final GroundyTask groundyTask ) { return new DownloadProgressListener ( ) { public void onProgress ( String url , int progress ) { groundyTask . updateProgress ( progress ) ; } } ; } | Returns a progress listener that will post progress to the specified groundyTask . |
6,731 | public static Matcher < Class < ? > > subclassOf ( final Class < ? > klazz ) { return new Matcher < Class < ? > > ( ) { protected boolean matchesSafely ( Class < ? > t ) { return klazz . isAssignableFrom ( t ) ; } public String toString ( ) { return "a subtype of " + klazz ; } } ; } | Returns a matcher that matches classes that are sub - types of the supplied class . |
6,732 | public static Matcher < Map < String , Object > > hasAttribute ( final String key , final Object value ) { return new Matcher < Map < String , Object > > ( ) { protected boolean matchesSafely ( Map < String , Object > object ) { return object . containsKey ( key ) && value . equals ( object . get ( key ) ) ; } } ; } | Returns a matcher that matches attribute maps that include the given attribute entry . |
6,733 | public Object getValue ( String expression , Class < ? > expectedType ) { ValueExpression exp = factory . createValueExpression ( elManager . getELContext ( ) , bracket ( expression ) , expectedType ) ; return exp . getValue ( elManager . getELContext ( ) ) ; } | Evaluates an EL expression and coerces the result to the specified type . |
6,734 | public void defineFunction ( String prefix , String function , Method method ) throws NoSuchMethodException { if ( prefix == null || function == null || method == null ) { throw new NullPointerException ( "Null argument for defineFunction" ) ; } if ( ! Modifier . isStatic ( method . getModifiers ( ) ) ) { throw new NoSuchMethodException ( "The method specified in defineFunction must be static: " + method ) ; } if ( function . equals ( "" ) ) { function = method . getName ( ) ; } elManager . mapFunction ( prefix , function , method ) ; } | Define an EL function in the local function mapper . |
6,735 | public String getText ( String indentation , char indentationChar ) { newCode = FormatterHelper . indent ( newNode . getPrettySource ( indentationChar , indentationLevel , indentationSize , acceptedComments ) , indentation , indentationChar , indentationLevel , indentationSize , requiresExtraIndentationOnFirstLine ( ) ) ; return newCode ; } | Returns the new text to insert with the appropriate indentation and comments |
6,736 | public Object getContext ( Class key ) { if ( key == null ) { throw new NullPointerException ( ) ; } return map . get ( key ) ; } | Returns the context object associated with the given key . |
6,737 | public void addEvaluationListener ( EvaluationListener listener ) { if ( listeners == null ) { listeners = new ArrayList < EvaluationListener > ( ) ; } listeners . add ( listener ) ; } | Registers an evaluation listener to the ELContext . |
6,738 | public void notifyBeforeEvaluation ( String expr ) { if ( getEvaluationListeners ( ) == null ) return ; for ( EvaluationListener listener : getEvaluationListeners ( ) ) { listener . beforeEvaluation ( this , expr ) ; } } | Notifies the listeners before an EL expression is evaluated |
6,739 | public void notifyAfterEvaluation ( String expr ) { if ( getEvaluationListeners ( ) == null ) return ; for ( EvaluationListener listener : getEvaluationListeners ( ) ) { listener . afterEvaluation ( this , expr ) ; } } | Notifies the listeners after an EL expression is evaluated |
6,740 | public boolean isLambdaArgument ( String arg ) { if ( lambdaArgs == null ) { return false ; } for ( int i = lambdaArgs . size ( ) - 1 ; i >= 0 ; i -- ) { Map < String , Object > lmap = lambdaArgs . elementAt ( i ) ; if ( lmap . containsKey ( arg ) ) { return true ; } } return false ; } | Inquires if the name is a LambdaArgument |
6,741 | public Object getLambdaArgument ( String arg ) { if ( lambdaArgs == null ) { return null ; } for ( int i = lambdaArgs . size ( ) - 1 ; i >= 0 ; i -- ) { Map < String , Object > lmap = lambdaArgs . elementAt ( i ) ; Object v = lmap . get ( arg ) ; if ( v != null ) { return v ; } } return null ; } | Retrieves the Lambda argument associated with a formal parameter . If the Lambda expression is nested within other Lambda expressions the arguments for the current Lambda expression is first searched and if not found the arguments for the immediate nesting Lambda expression then searched and so on . |
6,742 | public void enterLambdaScope ( Map < String , Object > args ) { if ( lambdaArgs == null ) { lambdaArgs = new Stack < Map < String , Object > > ( ) ; } lambdaArgs . push ( args ) ; } | Installs a Lambda argument map in preparation for the evaluation of a Lambda expression . The arguments in the map will be in scope during the evaluation of the Lambda expression . |
6,743 | public void setPackage ( PackageDeclaration pakage ) { if ( this . pakage != null ) { updateReferences ( this . pakage ) ; } this . pakage = pakage ; setAsParentNodeOf ( pakage ) ; } | Sets or clear the package declarations of this compilation unit . |
6,744 | public List < SubsetMove > getAllMoves ( SubsetSolution solution ) { Set < Integer > removeCandidates = getRemoveCandidates ( solution ) ; Set < Integer > addCandidates = getAddCandidates ( solution ) ; if ( removeCandidates . isEmpty ( ) || addCandidates . isEmpty ( ) ) { return Collections . emptyList ( ) ; } return addCandidates . stream ( ) . flatMap ( add -> removeCandidates . stream ( ) . map ( remove -> new SwapMove ( add , remove ) ) ) . collect ( Collectors . toList ( ) ) ; } | Generates a list of all possible swap moves that transform the given subset solution by removing a single ID from the current selection and replacing it with a new ID which is currently not selected . Possible fixed IDs are not considered to be swapped . May return an empty list if no swap moves can be generated . |
6,745 | public void setName ( NameExpr name ) { if ( this . name != null ) { updateReferences ( this . name ) ; } this . name = name ; setAsParentNodeOf ( name ) ; } | Sets the name of this package declaration . |
6,746 | protected void searchStep ( ) { for ( int i = 0 ; i < replicas . size ( ) ; i ++ ) { futures . add ( pool . submit ( replicas . get ( i ) , i ) ) ; } while ( ! futures . isEmpty ( ) ) { try { int i = futures . poll ( ) . get ( ) ; incNumAcceptedMoves ( replicas . get ( i ) . getNumAcceptedMoves ( ) ) ; incNumRejectedMoves ( replicas . get ( i ) . getNumRejectedMoves ( ) ) ; } catch ( InterruptedException | ExecutionException ex ) { throw new SearchException ( "An error occured during concurrent execution of Metropolis replicas " + "in the parallel tempering algorithm." , ex ) ; } } for ( int i = swapBase ; i < replicas . size ( ) - 1 ; i += 2 ) { MetropolisSearch < SolutionType > r1 = replicas . get ( i ) ; MetropolisSearch < SolutionType > r2 = replicas . get ( i + 1 ) ; double delta = computeDelta ( r2 . getCurrentSolutionEvaluation ( ) , r1 . getCurrentSolutionEvaluation ( ) ) ; boolean swap = false ; if ( delta >= 0 ) { swap = true ; } else { double b1 = 1.0 / ( r1 . getTemperature ( ) ) ; double b2 = 1.0 / ( r2 . getTemperature ( ) ) ; double diffb = b1 - b2 ; double p = Math . exp ( diffb * delta ) ; double r = getRandom ( ) . nextDouble ( ) ; if ( r < p ) { swap = true ; } } if ( swap ) { SolutionType r1Sol = r1 . getCurrentSolution ( ) ; Evaluation r1Eval = r1 . getCurrentSolutionEvaluation ( ) ; Validation r1Val = r1 . getCurrentSolutionValidation ( ) ; r1 . setCurrentSolution ( r2 . getCurrentSolution ( ) , r2 . getCurrentSolutionEvaluation ( ) , r2 . getCurrentSolutionValidation ( ) ) ; r2 . setCurrentSolution ( r1Sol , r1Eval , r1Val ) ; } } swapBase = 1 - swapBase ; } | In each search step every replica performs several steps after which solutions of adjacent replicas may be swapped . |
6,747 | protected void searchDisposed ( ) { replicas . forEach ( r -> r . dispose ( ) ) ; pool . shutdown ( ) ; super . searchDisposed ( ) ; } | When disposing a parallel tempering search it will dispose each contained Metropolis replica and will shut down the thread pool used for concurrent execution of replicas . |
6,748 | public int getIfdCount ( ) { int c = 0 ; if ( metadata != null && metadata . contains ( "IFD" ) ) c = getMetadataList ( "IFD" ) . size ( ) ; return c ; } | Gets the ifd count . |
6,749 | public int getMainImagesCount ( ) { int count = 0 ; List < TiffObject > list = new ArrayList < > ( ) ; list . addAll ( getMetadataList ( "IFD" ) ) ; list . addAll ( getMetadataList ( "SubIFDs" ) ) ; for ( TiffObject to : list ) { if ( to instanceof IFD ) { IFD ifd = ( IFD ) to ; if ( ifd . isImage ( ) && ! ifd . isThumbnail ( ) ) count ++ ; } } return count ; } | Gets the main images count . |
6,750 | public int getSubIfdCount ( ) { int c = 0 ; if ( metadata != null && metadata . contains ( "SubIFDs" ) ) c = getMetadataList ( "SubIFDs" ) . size ( ) ; return c ; } | Gets the Subifd count . |
6,751 | public List < TiffObject > getIfds ( ) { List < TiffObject > l = new ArrayList < TiffObject > ( ) ; if ( metadata != null && metadata . contains ( "IFD" ) ) l = getMetadataList ( "IFD" ) ; return l ; } | Returns a list of ifds including exifds . |
6,752 | public List < TiffObject > getImageIfds ( ) { List < TiffObject > l = new ArrayList < TiffObject > ( ) ; IFD oifd = this . firstIFD ; while ( oifd != null ) { if ( oifd . isImage ( ) ) { if ( oifd . hasSubIFD ( ) ) { try { long length = oifd . getMetadata ( ) . get ( "ImageLength" ) . getFirstNumericValue ( ) ; long width = oifd . getMetadata ( ) . get ( "ImageWidth" ) . getFirstNumericValue ( ) ; long sublength = oifd . getsubIFD ( ) . getMetadata ( ) . get ( "ImageLength" ) . getFirstNumericValue ( ) ; long subwidth = oifd . getsubIFD ( ) . getMetadata ( ) . get ( "ImageWidth" ) . getFirstNumericValue ( ) ; if ( sublength > length && subwidth > width ) { l . add ( oifd . getsubIFD ( ) ) ; } else { l . add ( oifd ) ; } } catch ( Exception ex ) { l . add ( oifd ) ; } } else { l . add ( oifd ) ; } } oifd = oifd . getNextIFD ( ) ; } return l ; } | Returns a list of ifds representing Images . |
6,753 | public List < TiffObject > getIfdsAndSubIfds ( ) { List < TiffObject > all = new ArrayList < TiffObject > ( ) ; all . addAll ( getMetadataList ( "IFD" ) ) ; all . addAll ( getMetadataList ( "SubIFDs" ) ) ; return all ; } | Returns a list of subifds . |
6,754 | public List < TiffObject > getMetadataList ( String name ) { List < TiffObject > l = new ArrayList < TiffObject > ( ) ; if ( metadata == null ) createMetadataDictionary ( ) ; if ( metadata . contains ( name ) ) l = metadata . getList ( name ) ; return l ; } | Gets the metadata ok a given class name . |
6,755 | private void addMetadataFromIFD ( IFD ifd , String key , boolean exif ) { metadata . add ( key , ifd ) ; for ( TagValue tag : ifd . getMetadata ( ) . getTags ( ) ) { if ( tag . getCardinality ( ) == 1 ) { abstractTiffType t = tag . getValue ( ) . get ( 0 ) ; if ( t . isIFD ( ) ) { addMetadataFromIFD ( ( IFD ) t , key , true ) ; } else if ( t . containsMetadata ( ) ) { try { Metadata meta = t . createMetadata ( ) ; metadata . addMetadata ( meta ) ; } catch ( Exception ex ) { } } else { if ( exif ) t . setContainer ( "EXIF" ) ; metadata . add ( tag . getName ( ) , t ) ; } } else { if ( exif ) tag . setContainer ( "EXIF" ) ; metadata . add ( tag . getName ( ) , tag ) ; } } if ( ifd . hasNextIFD ( ) ) { addMetadataFromIFD ( ifd . getNextIFD ( ) , key , false ) ; } } | Adds the metadata from ifd . |
6,756 | public void printMetadata ( ) { if ( metadata == null ) createMetadataDictionary ( ) ; System . out . println ( "METADATA" ) ; for ( String name : metadata . keySet ( ) ) { String mult = "" ; if ( getMetadataList ( name ) . size ( ) > 1 ) mult = "(x" + getMetadataList ( name ) . size ( ) + ")" ; if ( metadata . getMetadataObject ( name ) . isDublinCore ( ) ) System . out . println ( "[DC]" ) ; System . out . println ( name + mult + ": " + getMetadataSingleString ( name ) ) ; } } | Prints the metadata . |
6,757 | public boolean isTabu ( Move < ? super SolutionType > move , SolutionType currentSolution ) { move . apply ( currentSolution ) ; boolean tabu = memory . contains ( currentSolution ) ; move . undo ( currentSolution ) ; return tabu ; } | Verifies whether the given move is tabu by applying it to the current solution and checking if the obtained neighbour is currently contained in the tabu memory . If not the move is allowed . Before returning the move is undone to restore the original state of the current solution . |
6,758 | public void registerVisitedSolution ( SolutionType visitedSolution , Move < ? super SolutionType > appliedMove ) { memory . add ( Solution . checkedCopy ( visitedSolution ) ) ; } | A newly visited solution is registered by storing a deep copy of this solution in the full tabu memory . |
6,759 | public List < SubsetMove > getAllMoves ( SubsetSolution solution ) { if ( maxSizeReached ( solution ) ) { return Collections . emptyList ( ) ; } Set < Integer > addCandidates = getAddCandidates ( solution ) ; if ( addCandidates . isEmpty ( ) ) { return Collections . emptyList ( ) ; } return addCandidates . stream ( ) . map ( add -> new AdditionMove ( add ) ) . collect ( Collectors . toList ( ) ) ; } | Generates a list of all possible addition moves that add a single ID to the selection of a given subset solution . Possible fixed IDs are not considered to be added and the maximum subset size is taken into account . May return an empty list if no addition moves can be generated . |
6,760 | public boolean searchShouldStop ( Search < ? > search ) { return search . getMinDelta ( ) != JamesConstants . INVALID_DELTA && search . getMinDelta ( ) < minDelta ; } | Checks whether the minimum delta observed during the current run of the given search is still above the required minimum . |
6,761 | protected void generateTagRules ( ) throws ReadTagsIOException { try { PrintWriter writer = new PrintWriter ( "typecheck.xml" , "UTF-8" ) ; for ( int tagId : tagMap . keySet ( ) ) { Tag tag = tagMap . get ( tagId ) ; writer . println ( " <rule context=\"tag[id=" + tag . getId ( ) + "]\">" ) ; String typeRule = "" ; for ( String tagType : tag . getType ( ) ) { if ( typeRule . length ( ) > 0 ) typeRule += " || " ; typeRule += "{type=='" + tagType + "'}" ; } writer . println ( " <assert test=\"" + typeRule + "\">Tag type does not match</assert>" ) ; writer . println ( " </rule>" ) ; } writer . close ( ) ; writer = new PrintWriter ( "cardinalitycheck.xml" , "UTF-8" ) ; for ( int tagId : tagMap . keySet ( ) ) { Tag tag = tagMap . get ( tagId ) ; if ( tag . getCardinality ( ) . length ( ) > 0 && ! tag . getCardinality ( ) . equals ( "N" ) ) { try { int card = Integer . parseInt ( tag . getCardinality ( ) ) ; writer . println ( " <rule context=\"tag[id=" + tag . getId ( ) + "]\">" ) ; String typeRule = "{cardinality==" + card + "}" ; writer . println ( " <assert test=\"" + typeRule + "\">Tag cardinality does not match</assert>" ) ; writer . println ( " </rule>" ) ; } catch ( Exception ex ) { System . err . println ( "Formula in tag " + tag . getName ( ) + ": " + tag . getCardinality ( ) ) ; } } } writer . close ( ) ; } catch ( Exception ex ) { throw new ReadTagsIOException ( ) ; } } | Generate tag rules . |
6,762 | public static int getTagId ( String name ) { int id = - 1 ; try { if ( instance == null ) getTiffTags ( ) ; } catch ( ReadTagsIOException e ) { } if ( tagNames . containsKey ( name ) ) id = tagNames . get ( name ) . getId ( ) ; return id ; } | Gets the tag id . |
6,763 | public TiffObject get ( String name ) { TiffObject result = null ; String container = null ; ArrayList < TiffObject > found = new ArrayList < > ( ) ; if ( contains ( name ) ) { if ( metadata . get ( name ) . getObjectList ( ) . size ( ) == 1 ) { found . add ( getFirst ( name ) ) ; } else { for ( TiffObject to : metadata . get ( name ) . getObjectList ( ) ) { found . add ( to ) ; } } } else { for ( String key : metadata . keySet ( ) ) { boolean similar = key . toLowerCase ( ) . equals ( name . toLowerCase ( ) ) ; if ( ! similar ) similar = name . toLowerCase ( ) . equals ( "date" ) && key . toLowerCase ( ) . equals ( "datetime" ) ; if ( ! similar ) similar = name . toLowerCase ( ) . equals ( "date" ) && key . toLowerCase ( ) . equals ( "creatordate" ) ; if ( ! similar ) similar = name . toLowerCase ( ) . equals ( "description" ) && key . toLowerCase ( ) . equals ( "imagedescription" ) ; if ( ! similar ) similar = name . toLowerCase ( ) . equals ( "creator" ) && key . toLowerCase ( ) . equals ( "artist" ) ; if ( ! similar ) similar = name . toLowerCase ( ) . equals ( "creator" ) && key . toLowerCase ( ) . equals ( "creatortool" ) ; if ( similar ) { for ( TiffObject to : metadata . get ( key ) . getObjectList ( ) ) { found . add ( to ) ; } } } } if ( found . size ( ) == 1 ) { result = found . get ( 0 ) ; } else { for ( TiffObject to : found ) { if ( result == null ) { result = to ; container = to . getContainer ( ) ; } else if ( to . getContainer ( ) != null ) { if ( container == null || to . getContainer ( ) . equals ( "EXIF" ) || ( to . getContainer ( ) . equals ( "XMP" ) && container . equals ( "IPTC" ) ) ) { result = to ; container = to . getContainer ( ) ; } } } } return result ; } | Gets a metadata value returning the appropriate value when multiple are found . |
6,764 | public void addMetadata ( Metadata meta ) { for ( String k : meta . keySet ( ) ) { for ( TiffObject to : meta . getList ( k ) ) { add ( k , to , meta . getMetadataObject ( k ) . isDublinCore ( ) , meta . getMetadataObject ( k ) . getPath ( ) ) ; } } } | Adds a complete dictionary to the current one . |
6,765 | public int readFile ( String filename , boolean validate ) { int result = 0 ; try { if ( Files . exists ( Paths . get ( filename ) ) ) { data = new TiffInputStream ( new File ( filename ) ) ; tiffModel = new TiffDocument ( ) ; validation = new ValidationResult ( validate ) ; tiffModel . setSize ( data . size ( ) ) ; boolean correctHeader = readHeader ( ) ; if ( correctHeader ) { if ( tiffModel . getMagicNumber ( ) < 42 ) { validation . addError ( "Incorrect tiff magic number" , "Header" , tiffModel . getMagicNumber ( ) ) ; } else if ( tiffModel . getMagicNumber ( ) == 43 ) { validation . addErrorLoc ( "Big tiff file not yet supported" , "Header" ) ; } else if ( validation . isCorrect ( ) ) { readIFDs ( ) ; if ( validate ) { BaselineProfile bp = new BaselineProfile ( tiffModel ) ; bp . validate ( ) ; getBaselineValidation ( ) . add ( bp . getValidation ( ) ) ; } } } if ( getBaselineValidation ( ) . getFatalError ( ) ) { tiffModel . setFatalError ( true , getBaselineValidation ( ) . getFatalErrorMessage ( ) ) ; } data . close ( ) ; } else { result = - 1 ; tiffModel . setFatalError ( true , "File not found" ) ; } } catch ( Exception ex ) { result = - 2 ; tiffModel . setFatalError ( true , "IO Exception" ) ; } return result ; } | Parses a Tiff File and create an internal model representation . |
6,766 | private boolean readHeader ( ) { boolean correct = true ; ByteOrder byteOrder = ByteOrder . LITTLE_ENDIAN ; int c1 = 0 ; int c2 = 0 ; try { c1 = data . readByte ( ) . toInt ( ) ; c2 = data . readByte ( ) . toInt ( ) ; } catch ( Exception ex ) { validation . addErrorLoc ( "Header IO Exception" , "Header" ) ; } if ( c1 == 'I' && c2 == 'I' ) { byteOrder = ByteOrder . LITTLE_ENDIAN ; } else if ( c1 == 'M' && c2 == 'M' ) { byteOrder = ByteOrder . BIG_ENDIAN ; } else if ( byteOrderErrorTolerance > 0 && c1 == 'i' && c2 == 'i' ) { validation . addWarning ( "Byte Order in lower case" , "" + c1 + c2 , "Header" ) ; byteOrder = ByteOrder . LITTLE_ENDIAN ; } else if ( byteOrderErrorTolerance > 0 && c1 == 'm' && c2 == 'm' ) { validation . addWarning ( "Byte Order in lower case" , "" + c1 + c2 , "Header" ) ; byteOrder = ByteOrder . BIG_ENDIAN ; } else if ( byteOrderErrorTolerance > 1 ) { validation . addWarning ( "Non-sense Byte Order. Trying Little Endian." , "" + c1 + c2 , "Header" ) ; byteOrder = ByteOrder . LITTLE_ENDIAN ; } else { validation . addErrorLoc ( "Invalid Byte Order " + c1 + c2 , "Header" ) ; correct = false ; } if ( correct ) { tiffModel . setByteOrder ( byteOrder ) ; data . setByteOrder ( byteOrder ) ; try { int magic = data . readShort ( ) . toInt ( ) ; tiffModel . setMagicNumber ( magic ) ; } catch ( Exception ex ) { validation . addErrorLoc ( "Magic number parsing error" , "Header" ) ; correct = false ; } } return correct ; } | Reads the Tiff header . |
6,767 | private void readIFDs ( ) { int offset0 = 0 ; try { offset0 = data . readLong ( 4 ) . toInt ( ) ; tiffModel . setFirstIFDOffset ( offset0 ) ; if ( offset0 == 0 ) validation . addErrorLoc ( "There is no first IFD" , "Header" ) ; else if ( offset0 > data . size ( ) ) validation . addErrorLoc ( "Incorrect offset" , "Header" ) ; } catch ( Exception ex ) { validation . addErrorLoc ( "IO exception" , "Header" ) ; } if ( validation . isCorrect ( ) ) { int nifd = 1 ; try { IfdReader ifd0 = readIFD ( offset0 , true , 0 ) ; HashSet < Integer > usedOffsets = new HashSet < Integer > ( ) ; usedOffsets . add ( offset0 ) ; if ( ifd0 . getIfd ( ) == null ) { validation . addErrorLoc ( "Parsing error in first IFD" , "IFD" + 0 ) ; } else { IFD iifd = ifd0 . getIfd ( ) ; iifd . setNextOffset ( ifd0 . getNextIfdOffset ( ) ) ; tiffModel . addIfd0 ( iifd ) ; IfdReader current_ifd = ifd0 ; boolean stop = false ; while ( current_ifd . getNextIfdOffset ( ) > 0 && ! stop ) { if ( usedOffsets . contains ( current_ifd . getNextIfdOffset ( ) ) ) { validation . addErrorLoc ( "IFD offset already used" , "IFD" + nifd ) ; stop = true ; } else if ( current_ifd . getNextIfdOffset ( ) > data . size ( ) ) { validation . addErrorLoc ( "Incorrect offset" , "IFD" + nifd ) ; stop = true ; } else { usedOffsets . add ( current_ifd . getNextIfdOffset ( ) ) ; IfdReader next_ifd = readIFD ( current_ifd . getNextIfdOffset ( ) , true , nifd ) ; if ( next_ifd == null ) { validation . addErrorLoc ( "Parsing error in IFD " + nifd , "IFD" + nifd ) ; stop = true ; } else { iifd = next_ifd . getIfd ( ) ; iifd . setNextOffset ( next_ifd . getNextIfdOffset ( ) ) ; current_ifd . getIfd ( ) . setNextIFD ( iifd ) ; current_ifd = next_ifd ; } nifd ++ ; } } } } catch ( Exception ex ) { validation . addErrorLoc ( "IFD parsing error" , "IFD" + nifd ) ; } try { tiffModel . createMetadataDictionary ( ) ; } catch ( Exception ex ) { } } } | Read the IFDs contained in the Tiff file . |
6,768 | private boolean checkType ( int tagid , int tagType , int n ) { if ( TiffTags . hasTag ( tagid ) && ! TiffTags . getTag ( tagid ) . getName ( ) . equals ( "IPTC" ) ) { boolean found = false ; String stagType = TiffTags . getTagTypeName ( tagType ) ; if ( stagType != null ) { if ( stagType . equals ( "SUBIFD" ) ) stagType = "IFD" ; if ( stagType . equals ( "UNDEFINED" ) ) stagType = "BYTE" ; for ( String vType : TiffTags . getTag ( tagid ) . getType ( ) ) { String vType2 = vType ; if ( vType2 . equals ( "UNDEFINED" ) ) vType2 = "BYTE" ; if ( vType2 . equals ( stagType ) ) { found = true ; } } } if ( ! found ) { validation . addError ( "Incorrect type for tag " + TiffTags . getTag ( tagid ) . getName ( ) , "IFD" + n , stagType ) ; return false ; } return true ; } return false ; } | Check tag type . |
6,769 | public void addTag ( TagValue tag ) { tags . add ( tag ) ; if ( ! hashTagsId . containsKey ( tag . getId ( ) ) ) { hashTagsId . put ( tag . getId ( ) , tag ) ; } Tag t = TiffTags . getTag ( tag . getId ( ) ) ; if ( t != null ) { if ( hashTagsName . containsKey ( t . getName ( ) ) ) { hashTagsName . put ( t . getName ( ) , tag ) ; } } } | Adds a tag to the set . |
6,770 | public void startChecking ( ) { synchronized ( runningTaskLock ) { if ( runningTask == null ) { if ( ! stopCriteria . isEmpty ( ) ) { runningTask = new StopCriterionCheckTask ( ) ; runningTaskFuture = SCHEDULER . scheduleWithFixedDelay ( runningTask , period , period , periodTimeUnit ) ; LOGGER . debug ( "Stop criterion checker for search {} activated" , search ) ; } } else { LOGGER . warn ( "Attempted to activate already active stop criterion checker for search {}" , search ) ; } } } | Start checking the stop criteria in a separate background thread . If the stop criterion checker is already active or if no stop criteria have been added calling this method does not have any effect . |
6,771 | public void stopChecking ( ) { synchronized ( runningTaskLock ) { if ( runningTask != null ) { runningTaskFuture . cancel ( false ) ; LOGGER . debug ( "Stop criterion checker for search {} deactivated" , search ) ; runningTask = null ; runningTaskFuture = null ; } } } | Instructs the stop criterion checker to stop checking . In case the checker is not active calling this method does not have any effect . |
6,772 | public boolean stopCriterionSatisfied ( ) { int i = 0 ; while ( i < stopCriteria . size ( ) && ! stopCriteria . get ( i ) . searchShouldStop ( search ) ) { i ++ ; } return i < stopCriteria . size ( ) ; } | Check whether at least one stop criterion is satisfied . |
6,773 | public static String encode ( String string , String enc ) throws UnsupportedEncodingException { return new String ( encode ( string . getBytes ( enc ) ) , enc ) ; } | Encode a String in Base64 . No line breaks or other white space are inserted into the encoded data . |
6,774 | public static void encode ( InputStream in , OutputStream out ) throws IOException { encode ( in , out , true ) ; } | Encode data from the InputStream to the OutputStream in Base64 . Line breaks are inserted every 76 characters in the output . |
6,775 | public static void encode ( InputStream in , OutputStream out , boolean lineBreaks ) throws IOException { int [ ] inBuffer = new int [ 3 ] ; int lineCount = 0 ; boolean done = false ; while ( ! done && ( inBuffer [ 0 ] = in . read ( ) ) != END_OF_INPUT ) { inBuffer [ 1 ] = in . read ( ) ; inBuffer [ 2 ] = in . read ( ) ; out . write ( base64Chars [ inBuffer [ 0 ] >> 2 ] ) ; if ( inBuffer [ 1 ] != END_OF_INPUT ) { out . write ( base64Chars [ ( ( inBuffer [ 0 ] << 4 ) & 0x30 ) | ( inBuffer [ 1 ] >> 4 ) ] ) ; if ( inBuffer [ 2 ] != END_OF_INPUT ) { out . write ( base64Chars [ ( ( inBuffer [ 1 ] << 2 ) & 0x3c ) | ( inBuffer [ 2 ] >> 6 ) ] ) ; out . write ( base64Chars [ inBuffer [ 2 ] & 0x3F ] ) ; } else { out . write ( base64Chars [ ( ( inBuffer [ 1 ] << 2 ) & 0x3c ) ] ) ; out . write ( '=' ) ; done = true ; } } else { out . write ( base64Chars [ ( ( inBuffer [ 0 ] << 4 ) & 0x30 ) ] ) ; out . write ( '=' ) ; out . write ( '=' ) ; done = true ; } lineCount += 4 ; if ( lineBreaks && lineCount >= 76 ) { out . write ( '\n' ) ; lineCount = 0 ; } } if ( lineBreaks && lineCount >= 1 ) { out . write ( '\n' ) ; lineCount = 0 ; } out . flush ( ) ; } | Encode data from the InputStream to the OutputStream in Base64 . |
6,776 | public static void decode ( byte [ ] bytes , OutputStream out ) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream ( bytes ) ; decode ( in , out , false ) ; } | Decode Base64 encoded bytes to the an OutputStream . Characters that are not part of the Base64 alphabet are ignored in the input . |
6,777 | public static byte [ ] decodeToBytes ( InputStream in ) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; decode ( in , out , false ) ; return out . toByteArray ( ) ; } | Decode Base64 encoded data from the InputStream to a byte array . Characters that are not part of the Base64 alphabet are ignored in the input . |
6,778 | public static String decodeToString ( InputStream in , String enc ) throws IOException { return new String ( decodeToBytes ( in ) , enc ) ; } | Decode Base64 encoded data from the InputStream to a String . Characters that are not part of the Base64 alphabet are ignored in the input . |
6,779 | private static void reportResults ( TiffReader tiffReader , int result , String filename , String output_file ) { TiffDocument to = tiffReader . getModel ( ) ; if ( output_file != null ) { } else { switch ( result ) { case - 1 : System . out . println ( "File '" + filename + "' does not exist" ) ; break ; case - 2 : System . out . println ( "IO Exception in file '" + filename + "'" ) ; break ; case 0 : if ( tiffReader . getBaselineValidation ( ) . correct ) { System . out . println ( "Everything ok in file '" + filename + "'" ) ; System . out . println ( "IFDs: " + to . getIfdCount ( ) ) ; System . out . println ( "SubIFDs: " + to . getSubIfdCount ( ) ) ; to . printMetadata ( ) ; TiffEPProfile bpep = new TiffEPProfile ( to ) ; bpep . validate ( ) ; bpep . getValidation ( ) . printErrors ( ) ; TiffITProfile bpit = new TiffITProfile ( to , 0 ) ; bpit . validate ( ) ; bpit . getValidation ( ) . printErrors ( ) ; int nifd = 1 ; for ( TiffObject o : to . getImageIfds ( ) ) { IFD ifd = ( IFD ) o ; if ( ifd != null ) { System . out . println ( "IFD " + nifd ++ + " TAGS:" ) ; ifd . printTags ( ) ; } } } else { System . out . println ( "Errors in file '" + filename + "'" ) ; if ( to != null ) { System . out . println ( "IFDs: " + to . getIfdCount ( ) ) ; System . out . println ( "SubIFDs: " + to . getSubIfdCount ( ) ) ; to . printMetadata ( ) ; } tiffReader . getBaselineValidation ( ) . printErrors ( ) ; } tiffReader . getBaselineValidation ( ) . printWarnings ( ) ; break ; default : System . out . println ( "Unknown result (" + result + ") in file '" + filename + "'" ) ; break ; } } } | Report the results of the reading process to the console . |
6,780 | public synchronized void unload ( LCMSDataSubset subset , Object user , Set < LCMSDataSubset > exclude ) { if ( ! isLoaded ( subset ) ) { throw new IllegalStateException ( "LCMSData load/unload methods only" + " work for subsets loaded/unloaded using LCMSData API. The" + " subset you requested to unload wasn't loaded. If you've" + " loaded data into ScanCollection manually, then use" + " IScanCollection's API for unloading data manually as" + " well." ) ; } Set < LCMSDataSubset > userSubsets = cache . getIfPresent ( user ) ; if ( userSubsets == null ) { throw new IllegalStateException ( "The user was not present in cache," + " which means it either has never been there, or has already" + " been reclaimed by GC." ) ; } if ( ! userSubsets . contains ( subset ) ) { throw new IllegalArgumentException ( "This user has not loaded the subset" + " in the first place. The user must load the subset using" + " LCMSData API first. Unloading a subset that a user has not" + " loaded itself is illegal." ) ; } userSubsets . remove ( subset ) ; ConcurrentMap < Object , Set < LCMSDataSubset > > otherUserMaps = cache . asMap ( ) ; HashSet < LCMSDataSubset > otherUsersSubsetsCombined = new HashSet < > ( ) ; for ( Map . Entry < Object , Set < LCMSDataSubset > > entry : otherUserMaps . entrySet ( ) ) { Object otherUser = entry . getKey ( ) ; if ( otherUser != user ) { Set < LCMSDataSubset > otherUserSubsets = entry . getValue ( ) ; otherUsersSubsetsCombined . addAll ( otherUserSubsets ) ; } } if ( exclude != null ) { otherUsersSubsetsCombined . addAll ( exclude ) ; } if ( otherUsersSubsetsCombined . isEmpty ( ) ) { scans . unloadData ( subset ) ; } else { scans . unloadData ( subset , otherUsersSubsetsCombined ) ; } } | Unloads spectra matched by this subset . |
6,781 | private void unsafeUnload ( LCMSDataSubset subset ) { ConcurrentMap < Object , Set < LCMSDataSubset > > otherUserMaps = cache . asMap ( ) ; HashSet < LCMSDataSubset > otherUsersSubsetsCombined = new HashSet < > ( ) ; for ( Map . Entry < Object , Set < LCMSDataSubset > > entry : otherUserMaps . entrySet ( ) ) { Set < LCMSDataSubset > otherUserSubsets = entry . getValue ( ) ; otherUsersSubsetsCombined . addAll ( otherUserSubsets ) ; } if ( otherUsersSubsetsCombined . isEmpty ( ) ) { scans . unloadData ( subset ) ; } else { scans . unloadData ( subset , otherUsersSubsetsCombined ) ; } } | Unloads the subset without checking the user . It s required by our user - tracking automatic cleanup if a user was GCed and it hasn t unloaded its subsets we detect the GC automatically and unload all the subsets used by this killed user . It will still check for other users using scans from this subset . |
6,782 | public SubsetSolution next ( ) { Set < Integer > subset = subsetIterator . next ( ) ; return new SubsetSolution ( IDs , subset ) ; } | Generate the next subset solution . The returned subset will either have the same size as the previously generated solution if any or it will be a larger subset . |
6,783 | public void printError ( ) { System . out . print ( description ) ; if ( value != null ) System . out . print ( " (" + value + ")" ) ; System . out . println ( ) ; } | Prints the error in the console . |
6,784 | public void printWarning ( ) { System . out . print ( "Warning: " ) ; System . out . print ( description ) ; if ( value != null ) System . out . print ( " (" + value + ")" ) ; System . out . println ( ) ; } | Prints the warning in the console . |
6,785 | private int numSwaps ( Set < Integer > addCandidates , Set < Integer > deleteCandidates ) { return Math . min ( addCandidates . size ( ) , Math . min ( deleteCandidates . size ( ) , numSwaps ) ) ; } | Infer the number of swaps that will be performed taking into account the fixed number of desired swaps as specified at construction and the maximum number of possible swaps for the given subset solution . |
6,786 | public List < abstractTiffType > getDescriptiveValueObject ( ) { Tag tag = TiffTags . getTag ( id ) ; if ( tag != null ) { if ( tag . hasReadableDescription ( ) ) { String desc = this . toString ( ) ; String tagDescription = tag . getTextDescription ( toString ( ) ) ; if ( tagDescription != null ) { desc = tagDescription ; } return Arrays . asList ( new Text ( desc ) ) ; } else { return getValue ( ) ; } } return null ; } | Gets the descriptive value . |
6,787 | public long getFirstNumericValue ( ) { String val = ( value != null ) ? value . get ( 0 ) . toString ( ) : readValue . get ( 0 ) . toString ( ) ; if ( isInteger ( val ) ) { return Long . parseLong ( val ) ; } else { return 0 ; } } | Gets the first value of the list parsed as a number . |
6,788 | public String getName ( ) { String name = "" + id ; if ( TiffTags . hasTag ( id ) ) name = TiffTags . getTag ( id ) . getName ( ) ; return name ; } | Gets the name of the tag . |
6,789 | public void startSetup ( ) { try { LOGGER . debug ( "Starting in-app billing setup." ) ; billingClient = BillingClient . newBuilder ( AbstractApplication . get ( ) ) . setListener ( this ) . build ( ) ; Runnable runnable = new Runnable ( ) { public void run ( ) { LOGGER . debug ( "In-app billing setup successful." ) ; for ( ProductType productType : InAppBillingAppModule . get ( ) . getInAppBillingContext ( ) . getManagedProductTypes ( ) ) { inventory . addProduct ( new Product ( productType ) ) ; } if ( isSubscriptionsSupported ( ) ) { for ( ProductType productType : InAppBillingAppModule . get ( ) . getInAppBillingContext ( ) . getSubscriptionsProductTypes ( ) ) { inventory . addProduct ( new Product ( productType ) ) ; } } if ( listener != null ) { listener . onSetupFinished ( ) ; } } } ; if ( isServiceConnected ) { runnable . run ( ) ; } else { startServiceConnection ( runnable ) ; } } catch ( Exception e ) { AbstractApplication . get ( ) . getExceptionHandler ( ) . logHandledException ( e ) ; if ( listener != null ) { listener . onSetupFailed ( new UnexpectedException ( e ) ) ; } } } | Starts the setup process . This will start up the setup process asynchronously . You will be notified through the listener when the setup process is complete . |
6,790 | private void launchPurchaseFlow ( Activity activity , Product product , ItemType itemType , String oldProductId ) { executeServiceRequest ( new Runnable ( ) { public void run ( ) { if ( itemType . equals ( ItemType . SUBSCRIPTION ) && ! isSubscriptionsSupported ( ) ) { LOGGER . debug ( "Failed in-app purchase flow for product id " + product . getId ( ) + ", item type: " + itemType + ". Subscriptions not supported." ) ; if ( listener != null ) { listener . onPurchaseFailed ( InAppBillingErrorCode . SUBSCRIPTIONS_NOT_AVAILABLE . newErrorCodeException ( ) ) ; } } else { LOGGER . debug ( "Launching in-app purchase flow for product id " + product . getId ( ) + ", item type: " + itemType ) ; String productIdToBuy = InAppBillingAppModule . get ( ) . getInAppBillingContext ( ) . isStaticResponsesEnabled ( ) ? product . getProductType ( ) . getTestProductId ( ) : product . getId ( ) ; BillingFlowParams purchaseParams = BillingFlowParams . newBuilder ( ) . setSku ( productIdToBuy ) . setType ( itemType . getType ( ) ) . setOldSku ( oldProductId ) . build ( ) ; int responseCode = billingClient . launchBillingFlow ( activity , purchaseParams ) ; InAppBillingErrorCode inAppBillingErrorCode = InAppBillingErrorCode . findByErrorResponseCode ( responseCode ) ; if ( inAppBillingErrorCode != null ) { if ( listener != null ) { AbstractApplication . get ( ) . getExceptionHandler ( ) . logHandledException ( inAppBillingErrorCode . newErrorCodeException ( ) ) ; listener . onPurchaseFailed ( inAppBillingErrorCode . newErrorCodeException ( ) ) ; } } } } } ) ; } | Initiate the UI flow for an in - app purchase . Call this method to initiate an in - app purchase which will involve bringing up the Google Play screen . The calling activity will be paused while the user interacts with Google Play This method MUST be called from the UI thread of the Activity . |
6,791 | private int fillBuffer ( ) throws IOException { int n = super . read ( buffer , 0 , BUF_SIZE ) ; if ( n >= 0 ) { real_pos += n ; buf_end = n ; buf_pos = 0 ; } return n ; } | Reads the next BUF_SIZE bytes into the internal buffer . |
6,792 | public int read ( byte b [ ] , int off , int len ) throws IOException { int leftover = buf_end - buf_pos ; if ( len <= leftover ) { System . arraycopy ( buffer , buf_pos , b , off , len ) ; buf_pos += len ; return len ; } for ( int i = 0 ; i < len ; i ++ ) { int c = this . read ( ) ; if ( c != - 1 ) { b [ off + i ] = ( byte ) c ; } else { return i ; } } return len ; } | Reads the set number of bytes into the passed buffer . |
6,793 | protected void searchStep ( ) { pipeline . stream ( ) . forEachOrdered ( l -> { l . addSearchListener ( pipelineListener ) ; l . setCurrentSolution ( Solution . checkedCopy ( getCurrentSolution ( ) ) ) ; l . start ( ) ; SolutionType bestSol = l . getBestSolution ( ) ; Evaluation bestSolEvaluation = l . getBestSolutionEvaluation ( ) ; Validation bestSolValidation = l . getBestSolutionValidation ( ) ; if ( bestSol != null && ! bestSol . equals ( getCurrentSolution ( ) ) ) { updateCurrentAndBestSolution ( bestSol , bestSolEvaluation , bestSolValidation ) ; } l . removeSearchListener ( pipelineListener ) ; } ) ; stop ( ) ; } | Executes all local searches in the pipeline where the best solution of the previous search is used as initial solution for the next search . When the entire pipeline has been executed the search step is complete and the search terminates . |
6,794 | private void readVersion ( TagValue tv ) { int maj = tv . getBytesBigEndian ( 8 , 1 ) ; int min = ( tv . getBytesBigEndian ( 9 , 1 ) & 0xF0 ) >> 4 ; version = maj + "." + min ; } | Read version . |
6,795 | private void readClass ( TagValue tv ) { int profileClass = tv . getBytesBigEndian ( 12 , 4 ) ; String hex = Integer . toHexString ( profileClass ) ; if ( hex . equals ( "73636e72" ) ) { this . profileClass = ProfileClass . Input ; } else if ( hex . equals ( "6d6e7472" ) ) { this . profileClass = ProfileClass . Display ; } else if ( hex . equals ( "70727472" ) ) { this . profileClass = ProfileClass . Output ; } else if ( hex . equals ( "6C696e6b" ) ) { this . profileClass = ProfileClass . DeviceLink ; } else if ( hex . equals ( "73706163" ) ) { this . profileClass = ProfileClass . ColorSpace ; } else if ( hex . equals ( "61627374" ) ) { this . profileClass = ProfileClass . Abstract ; } else if ( hex . equals ( "6e6d636c" ) ) { this . profileClass = ProfileClass . NamedColor ; } else { this . profileClass = ProfileClass . Unknown ; } } | Read class . |
6,796 | private void readCreator ( TagValue tv ) { int creatorSignature = tv . getBytesBigEndian ( 4 , 4 ) ; creator = IccProfileCreators . getIccProfile ( creatorSignature ) ; } | Read creator . |
6,797 | private void readDescription ( TagValue tv ) throws NumberFormatException , IOException { int index = 128 ; int tagCount = tv . getBytesBigEndian ( index , 4 ) ; index += 4 ; for ( int i = 0 ; i < tagCount ; i ++ ) { int signature = tv . getBytesBigEndian ( index , 4 ) ; int tagOffset = tv . getBytesBigEndian ( index + 4 , 4 ) ; if ( Integer . toHexString ( signature ) . equals ( "64657363" ) ) { String typedesc = Integer . toHexString ( tv . getBytesBigEndian ( tagOffset , 4 ) ) ; if ( typedesc . equals ( "64657363" ) ) { int size = tv . getBytesBigEndian ( tagOffset + 8 , 4 ) - 1 ; String s = "" ; int j = 0 ; int begin = tagOffset + 12 ; while ( begin + j < begin + size ) { int unicode_char = tv . getBytesBigEndian ( begin + j , 1 ) ; s += Character . toString ( ( char ) unicode_char ) ; j ++ ; } description = s ; } else { description = "" ; } } index += 12 ; } } | Read description . |
6,798 | public void read ( TagValue tv ) { readClass ( tv ) ; readVersion ( tv ) ; readCreator ( tv ) ; readEmbedded ( tv ) ; try { readDescription ( tv ) ; } catch ( NumberFormatException | IOException e ) { e . printStackTrace ( ) ; } tv . clear ( ) ; tv . add ( this ) ; } | Reads the desired values of the ICCProfile . |
6,799 | public List < MsRun . ParentFile > getParentFile ( ) { if ( parentFile == null ) { parentFile = new ArrayList < MsRun . ParentFile > ( ) ; } return this . parentFile ; } | Gets the value of the parentFile property . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.