idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
6,800 | public List < MsRun . MsInstrument > getMsInstrument ( ) { if ( msInstrument == null ) { msInstrument = new ArrayList < MsRun . MsInstrument > ( ) ; } return this . msInstrument ; } | Gets the value of the msInstrument property . |
6,801 | public List < MsRun . DataProcessing > getDataProcessing ( ) { if ( dataProcessing == null ) { dataProcessing = new ArrayList < MsRun . DataProcessing > ( ) ; } return this . dataProcessing ; } | Gets the value of the dataProcessing property . |
6,802 | public static void addCacheEntry ( final ClassLoader classLoader , final String factoryId , final String factoryClassName ) { if ( factoryClassName == null ) { CLASS_CACHE . put ( new CacheKey ( classLoader , factoryId ) , "" ) ; } else { CLASS_CACHE . put ( new CacheKey ( classLoader , factoryId ) , factoryClassName ) ; } } | Called by the container at deployment time to set the name of a given factory to remove the need for the implementation to look it up on every call . |
6,803 | public static void clearClassLoader ( final ClassLoader classLoader ) { BeanPropertiesCache . clear ( classLoader ) ; final Iterator < Map . Entry < CacheKey , String > > it = CLASS_CACHE . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final CacheKey key = it . next ( ) . getKey ( ) ; if ( key . loader == classLoader ) { it . remove ( ) ; } } } | This should be called by the container on undeploy to remove all references to the given class loader from the cache . |
6,804 | public void createValuesDictionary ( ) { tagValueDescriptions = new HashMap < String , String > ( ) ; if ( valueCodes != null && valueDescriptions != null && valueCodes . size ( ) > 0 && valueCodes . size ( ) == valueDescriptions . size ( ) ) { for ( int i = 0 ; i < valueCodes . size ( ) ; i ++ ) { tagValueDescriptions . put ( valueCodes . get ( i ) + "" , valueDescriptions . get ( i ) ) ; } } } | Creates the values dictionary . |
6,805 | public String getTextDescription ( String encodedValue ) { if ( forceDescription != null ) { return forceDescription ; } String desc = null ; if ( tagValueDescriptions . containsKey ( encodedValue ) ) { desc = tagValueDescriptions . get ( encodedValue ) ; } return desc ; } | Gets the tag value description . |
6,806 | private void checkForbiddenTag ( IfdTags metadata , String tagName , String ext ) { int tagid = TiffTags . getTagId ( tagName ) ; if ( metadata . containsTagId ( tagid ) ) { validation . addErrorLoc ( "Forbidden tag for TiffEP found " + tagName , ext ) ; } } | Check a forbidden tag is not present . |
6,807 | protected void searchStep ( ) { Move < ? super SolutionType > move = getBestMove ( getNeighbourhood ( ) . getAllMoves ( getCurrentSolution ( ) ) , true ) ; if ( move != null ) { accept ( move ) ; } else { stop ( ) ; } } | Investigates all neighbours of the current solution and adopts the best one as the new current solution if it is an improvement . If no improvement is found the search is requested to stop and no further steps will be performed . |
6,808 | public ELContext setELContext ( ELContext context ) { ELContext prev = elContext ; elContext = new StandardELContext ( context ) ; return prev ; } | Set the ELContext used for parsing and evaluating EL expressions . The supplied ELContext will not be modified except for the context object map . |
6,809 | public void mapFunction ( String prefix , String function , Method meth ) { getELContext ( ) . getFunctionMapper ( ) . mapFunction ( prefix , function , meth ) ; } | Maps a static method to an EL function . |
6,810 | public Object defineBean ( String name , Object bean ) { Object ret = getELContext ( ) . getBeans ( ) . get ( name ) ; getELContext ( ) . getBeans ( ) . put ( name , bean ) ; return ret ; } | Define a bean in the local bean repository |
6,811 | public SubsetValidation validate ( SubsetSolution solution ) { boolean validSize = solution . getNumSelectedIDs ( ) >= getMinSubsetSize ( ) && solution . getNumSelectedIDs ( ) <= getMaxSubsetSize ( ) ; if ( getMandatoryConstraints ( ) . isEmpty ( ) ) { return validSize ? UNCONSTRAINED_VALID_SIZE : UNCONSTRAINED_INVALID_SIZE ; } else { Validation constraintVal = super . validate ( solution ) ; return new SubsetValidation ( validSize , constraintVal ) ; } } | Validate a subset solution . The returned validation object separately indicates whether the solution passed general mandatory constraint validation and whether it has a valid size . |
6,812 | public void setMaxSubsetSize ( int maxSubsetSize ) { if ( maxSubsetSize < minSubsetSize ) { throw new IllegalArgumentException ( "Error while setting maximum subset size: should be >= minimum subset size." ) ; } if ( maxSubsetSize > getData ( ) . getIDs ( ) . size ( ) ) { throw new IllegalArgumentException ( "Error while setting maximum subset size: can not be larger " + "than number of items in underlying data." ) ; } this . maxSubsetSize = maxSubsetSize ; } | Set the maximum subset size . Specified size should be &ge ; the current minimum subset size and &le ; the number of items in the underlying data . |
6,813 | @ SuppressLint ( "SetTextI18n" ) public void setNotifications ( Integer notifications ) { if ( ( notifications != null ) && ( notifications > 0 ) ) { setVisibility ( VISIBLE ) ; if ( notifications > maximum ) { this . setText ( maximum + "+" ) ; } else { this . setText ( notifications . toString ( ) ) ; } } else { setVisibility ( GONE ) ; } } | Sets a notification number in the badge . |
6,814 | private void nextNeighbourhood ( ) { if ( cycleNeighbourhoods || k < getNeighbourhoods ( ) . size ( ) - 1 ) { k = ( k + 1 ) % getNeighbourhoods ( ) . size ( ) ; } else { stop ( ) ; } } | Switches to the next neighbourhood in the list if any going back to the start if cycling is enabled and all neighbourhoods have been used . |
6,815 | public static umich . ms . fileio . filetypes . mzidentml . jaxb . standard . MzIdentMLType parse ( Path path ) throws FileParsingException { try { XMLStreamReader xsr = JaxbUtils . createXmlStreamReader ( path , false ) ; umich . ms . fileio . filetypes . mzidentml . jaxb . standard . MzIdentMLType mzIdentMLType = JaxbUtils . unmarshal ( umich . ms . fileio . filetypes . mzidentml . jaxb . standard . MzIdentMLType . class , xsr ) ; return mzIdentMLType ; } catch ( JAXBException e ) { throw new FileParsingException ( String . format ( "JAXB parsing of MzIdentML file failed (%s)" , path . toAbsolutePath ( ) . toString ( ) ) , e ) ; } } | Will parse the whole file . Might be not very efficient memory - wise . |
6,816 | private void iaddWarning ( String desc , String value , String loc ) { if ( ! validate ) return ; ValidationEvent ve = new ValidationEvent ( desc , value , loc ) ; warnings . add ( ve ) ; } | Adds a warning . |
6,817 | public void addWarning ( String desc , String value , String loc ) { iaddWarning ( desc , value , loc ) ; } | Adds an warning . |
6,818 | public void add ( ValidationResult validation ) { correct &= validation . correct ; if ( ! validate ) return ; errors . addAll ( validation . errors ) ; warnings . addAll ( validation . warnings ) ; } | Adds a validation result to this . |
6,819 | public static double min ( double ... nums ) { double min = nums [ 0 ] ; for ( int i = 1 ; i < nums . length ; i ++ ) { if ( nums [ i ] > min ) { min = nums [ i ] ; } } return min ; } | Find the minimum in an array of numbers . |
6,820 | public void init ( ) throws IOException { if ( ! Files . exists ( path ) ) { throw new FileNotFoundException ( "Could not find a file under path: " + path . toAbsolutePath ( ) . toString ( ) ) ; } if ( Files . size ( path ) == 0 ) { throw new IllegalStateException ( "File size can't be zero for chunked files" ) ; } chunks = chunkFile ( ) ; chunksInUse = new ConcurrentSkipListMap < > ( ) ; chunksPreRead = new ConcurrentSkipListMap < > ( ) ; chunksScheduled = new ConcurrentSkipListMap < > ( ) ; nextChunkNum = new AtomicInteger ( - 1 ) ; if ( raf != null ) { raf . close ( ) ; } execIo = MoreExecutors . listeningDecorator ( Executors . newSingleThreadExecutor ( ) ) ; execFinalize = Executors . newSingleThreadExecutor ( ) ; } | Check if the file is still valid . |
6,821 | protected void searchStep ( ) { if ( solutionIterator . hasNext ( ) ) { SolutionType sol = solutionIterator . next ( ) ; updateBestSolution ( sol ) ; } else { stop ( ) ; } } | In every search step it is verified whether there are more solution to be generated using the solution iterator . If so the next solution is generated evaluated and presented for comparison with the current best solution . Else the search stops . |
6,822 | public boolean intersects ( Interval1D < V > other ) { if ( other . hi . compareTo ( this . lo ) < 0 ) { return false ; } if ( this . hi . compareTo ( other . lo ) < 0 ) { return false ; } return true ; } | Does this interval intersect that one? |
6,823 | public boolean selectAll ( Collection < Integer > IDs ) { boolean modified = false ; for ( int ID : IDs ) { if ( select ( ID ) ) { modified = true ; } } return modified ; } | Select all IDs contained in the given collection . Returns true if the subset solution was modified by this operation i . e . if at least one previously unselected ID has been selected . |
6,824 | public boolean deselectAll ( Collection < Integer > IDs ) { boolean modified = false ; for ( int ID : IDs ) { if ( deselect ( ID ) ) { modified = true ; } } return modified ; } | Deselect all IDs contained in the given collection . Returns true if the subset solution was modified by this operation i . e . if at least one previously selected ID has been deselected . |
6,825 | public static final void setJavolutionLogLevel ( org . slf4j . Logger log ) { if ( log . isTraceEnabled ( ) ) { javolution . context . LogContext . enter ( ) . setLevel ( LogContext . Level . DEBUG ) ; } else if ( log . isDebugEnabled ( ) ) { javolution . context . LogContext . enter ( ) . setLevel ( LogContext . Level . DEBUG ) ; } else if ( log . isInfoEnabled ( ) ) { javolution . context . LogContext . enter ( ) . setLevel ( LogContext . Level . INFO ) ; } else if ( log . isWarnEnabled ( ) ) { javolution . context . LogContext . enter ( ) . setLevel ( LogContext . Level . WARNING ) ; } else if ( log . isErrorEnabled ( ) ) { javolution . context . LogContext . enter ( ) . setLevel ( LogContext . Level . ERROR ) ; } else { javolution . context . LogContext . enter ( ) . setLevel ( LogContext . Level . FATAL ) ; } } | Set Javolution log level according to the provided logger . |
6,826 | public Map < String , String > getChildrenMap ( String parentId ) { Map < String , String > map = new HashMap < > ( ) ; List < StringEntity > children = getByField ( Column . PARENT_ID , parentId ) ; for ( StringEntity stringEntity : children ) { map . put ( stringEntity . getId ( ) , stringEntity . getValue ( ) ) ; } return map ; } | This method returns the map of children associated with given parent id . |
6,827 | public void replaceMapChildren ( Map < String , String > map , String parentId ) { ArrayList < StringEntity > entities = new ArrayList < > ( ) ; for ( String key : map . keySet ( ) ) { StringEntity entity = new StringEntity ( ) ; entity . setParentId ( parentId ) ; entity . setId ( key ) ; entity . setValue ( map . get ( key ) ) ; entities . add ( entity ) ; } replaceChildren ( entities , parentId ) ; } | This method allows to replace all children of a given parent it will remove any children which are not in the list add the new ones and update which are in the list . |
6,828 | protected void searchStep ( ) { if ( k >= getNeighbourhoods ( ) . size ( ) ) { stop ( ) ; } else { Neighbourhood < ? super SolutionType > neigh = getNeighbourhoods ( ) . get ( k ) ; Move < ? super SolutionType > move = getBestMove ( neigh . getAllMoves ( getCurrentSolution ( ) ) , true ) ; if ( move != null ) { accept ( move ) ; k = 0 ; } else { k ++ ; } } } | Investigates all neighbours of the current solution using the k - th neighbourhood and adopts the best one as the new current solution if it is an improvement . If no improvement is found k is increased . Upon each improvement k is reset to 0 and when k has reached the number of available neighbourhoods the search stops . |
6,829 | protected boolean accept ( Move < ? super SolutionType > move ) { if ( super . accept ( move ) ) { tabuMemory . registerVisitedSolution ( getCurrentSolution ( ) , move ) ; return true ; } else { return false ; } } | Overrides acceptance of a move to update the tabu memory by registering the newly visited solution . |
6,830 | public void addPenalizingValidation ( Object key , PenalizingValidation penalizingValidation ) { initMapOnce ( ) ; penalties . put ( key , penalizingValidation ) ; if ( ! penalizingValidation . passed ( ) ) { assignedPenalties = true ; double p = penalizingValidation . getPenalty ( ) ; penalizedValue += minimizing ? p : - p ; } } | Add a penalty expressed by a penalizing validation object . A key is required that can be used to retrieve the validation object later . |
6,831 | public static LCMSDataSource < ? > create ( Path path ) { path = path . toAbsolutePath ( ) ; String lowerCaseName = path . getFileName ( ) . toString ( ) . toLowerCase ( ) ; if ( lowerCaseName . endsWith ( ".mzxml" ) ) { return new MZXMLFile ( path . toString ( ) ) ; } else if ( lowerCaseName . endsWith ( ".mzml" ) ) { return new MZMLFile ( path . toString ( ) ) ; } return null ; } | Try and create a data source from a given file path . |
6,832 | public final void cacheMoveEvaluation ( Move < ? > move , Evaluation evaluation ) { evaluatedMove = move ; this . evaluation = evaluation ; } | Cache the given evaluation discarding any previously cached evaluations . |
6,833 | public final Evaluation getCachedMoveEvaluation ( Move < ? > move ) { if ( evaluatedMove == null || ! evaluatedMove . equals ( move ) ) { return null ; } else { return evaluation ; } } | Retrieve a cached evaluation if still available . If the evaluation of any other move has been cached at a later point in time the value for this move will have been overwritten . |
6,834 | public final void cacheMoveValidation ( Move < ? > move , Validation validation ) { validatedMove = move ; this . validation = validation ; } | Cache validation of the given move discarding any previously cached value . |
6,835 | public final Validation getCachedMoveValidation ( Move < ? > move ) { if ( validatedMove == null || ! validatedMove . equals ( move ) ) { return null ; } else { return validation ; } } | Retrieve a cached validation if still available . If the validation of any other move has been cached at a later point in time the value for this move will have been overwritten . |
6,836 | public final void clear ( ) { evaluatedMove = null ; evaluation = null ; validatedMove = null ; validation = null ; } | Clear all cached values . |
6,837 | protected void updateCurrentSolution ( SolutionType solution , Evaluation evaluation , Validation validation ) { super . updateCurrentSolution ( solution , evaluation , validation ) ; if ( cache != null ) { cache . clear ( ) ; } } | When updating the current solution in a neighbourhood search the evaluated move cache is cleared because it is no longer valid for the new current solution . |
6,838 | protected Evaluation evaluate ( Move < ? super SolutionType > move ) { Evaluation eval = null ; if ( cache != null ) { eval = cache . getCachedMoveEvaluation ( move ) ; } if ( eval != null ) { return eval ; } else { eval = getProblem ( ) . evaluate ( move , getCurrentSolution ( ) , getCurrentSolutionEvaluation ( ) ) ; if ( cache != null ) { cache . cacheMoveEvaluation ( move , eval ) ; } return eval ; } } | Evaluates a move to be applied to the current solution . If this move has been evaluated before and the obtained evaluation is still available in the cache the cached evaluation will be returned . Else the evaluation will be computed and offered to the cache . |
6,839 | protected Validation validate ( Move < ? super SolutionType > move ) { Validation val = null ; if ( cache != null ) { val = cache . getCachedMoveValidation ( move ) ; } if ( val != null ) { return val ; } else { val = getProblem ( ) . validate ( move , getCurrentSolution ( ) , getCurrentSolutionValidation ( ) ) ; if ( cache != null ) { cache . cacheMoveValidation ( move , val ) ; } return val ; } } | Validates a move to be applied to the current solution . If this move has been validated before and the obtained validation is still available in the cache the cached validation will be returned . Else the validation will be computed and offered to the cache . |
6,840 | public void validate ( ) { int n = 0 ; try { for ( TiffObject o : model . getImageIfds ( ) ) { IFD ifd = ( IFD ) o ; IfdTags metadata = ifd . getMetadata ( ) ; validateMetadata ( metadata ) ; checkImage ( ifd , n , metadata ) ; n ++ ; } } catch ( Exception ex ) { } } | Validates the IFD . |
6,841 | public void validateMetadata ( IfdTags metadata ) { int prevTagId = 0 ; try { TiffTags . getTiffTags ( ) ; } catch ( ReadTagsIOException e ) { } for ( TagValue ie : metadata . getTags ( ) ) { if ( ! TiffTags . tagMap . containsKey ( ie . getId ( ) ) ) { validation . addWarning ( "Ignoring undefined tag id " + ie . getId ( ) , "" , "Metadata" ) ; } else if ( ! TiffTags . tagTypes . containsKey ( ie . getType ( ) ) ) { validation . addWarning ( "Ignoring unknown tag type " + ie . getType ( ) , "" , "Metadata" ) ; } else { Tag t = TiffTags . getTag ( ie . getId ( ) ) ; String stype = TiffTags . tagTypes . get ( ie . getType ( ) ) ; if ( ie . getId ( ) == 320 ) { long bps = 0 ; if ( metadata . containsTagId ( 258 ) ) bps = metadata . get ( 258 ) . getFirstNumericValue ( ) ; long calc = 3 * ( long ) Math . pow ( 2 , bps ) ; if ( calc != ie . getCardinality ( ) ) { validation . addError ( "Invalid cardinality for tag " + TiffTags . getTag ( ie . getId ( ) ) . getName ( ) + "[" + ie . getCardinality ( ) + "]" , "Metadata" , stype ) ; } } try { int card = Integer . parseInt ( t . getCardinality ( ) ) ; if ( card != ie . getCardinality ( ) ) validation . addError ( "Cardinality for tag " + TiffTags . getTag ( ie . getId ( ) ) . getName ( ) + " must be " + card , "Metadata" , ie . getCardinality ( ) ) ; } catch ( Exception e ) { } } if ( ie . getId ( ) < prevTagId ) { if ( tagOrderTolerance > 0 ) validation . addWarning ( "Tags are not in ascending order" , "" , "Metadata" ) ; else validation . addErrorLoc ( "Tags are not in ascending order" , "Metadata" ) ; } prevTagId = ie . getId ( ) ; } } | Validates that the ifd entries have correct types and cardinalities as they are defined in the JSONs tag configuration files . |
6,842 | public void checkImage ( IFD ifd , int n , IfdTags metadata ) { CheckCommonFields ( ifd , n , metadata ) ; if ( ! metadata . containsTagId ( TiffTags . getTagId ( "PhotometricInterpretation" ) ) ) { validation . addErrorLoc ( "Missing Photometric Interpretation" , "IFD" + n ) ; } else if ( metadata . get ( TiffTags . getTagId ( "PhotometricInterpretation" ) ) . getValue ( ) . size ( ) != 1 ) { validation . addErrorLoc ( "Invalid Photometric Interpretation" , "IFD" + n ) ; } else { photometric = ( int ) metadata . get ( TiffTags . getTagId ( "PhotometricInterpretation" ) ) . getFirstNumericValue ( ) ; switch ( photometric ) { case 0 : case 1 : if ( ! metadata . containsTagId ( TiffTags . getTagId ( "BitsPerSample" ) ) || metadata . get ( TiffTags . getTagId ( "BitsPerSample" ) ) . getFirstNumericValue ( ) == 1 ) { type = ImageType . BILEVEL ; CheckBilevelImage ( metadata , n ) ; } else { type = ImageType . GRAYSCALE ; CheckGrayscaleImage ( metadata , n ) ; } break ; case 2 : type = ImageType . RGB ; CheckRGBImage ( metadata , n ) ; break ; case 3 : type = ImageType . PALETTE ; CheckPalleteImage ( metadata , n ) ; break ; case 4 : type = ImageType . TRANSPARENCY_MASK ; CheckTransparencyMask ( metadata , n ) ; break ; case 5 : type = ImageType . CMYK ; CheckCMYK ( metadata , n ) ; break ; case 6 : type = ImageType . YCbCr ; CheckYCbCr ( metadata , n ) ; break ; case 8 : case 9 : case 10 : type = ImageType . CIELab ; CheckCIELab ( metadata , n ) ; break ; default : validation . addWarning ( "Unknown Photometric Interpretation" , "" + photometric , "IFD" + n ) ; break ; } } } | Check if the tags that define the image are correct and consistent . |
6,843 | private void CheckBilevelImage ( IfdTags metadata , int n ) { long comp = metadata . get ( TiffTags . getTagId ( "Compression" ) ) . getFirstNumericValue ( ) ; if ( comp < 1 ) validation . addError ( "Invalid Compression" , "IFD" + n , comp ) ; } | Check Bilevel Image . |
6,844 | private void CheckGrayscaleImage ( IfdTags metadata , int n ) { long bps = metadata . get ( TiffTags . getTagId ( "BitsPerSample" ) ) . getFirstNumericValue ( ) ; if ( bps < 1 ) validation . addError ( "Invalid Bits per Sample" , "IFD" + n , bps ) ; long comp = metadata . get ( TiffTags . getTagId ( "Compression" ) ) . getFirstNumericValue ( ) ; if ( comp < 1 ) validation . addError ( "Invalid Compression" , "IFD" + n , comp ) ; } | Check Grayscale Image . |
6,845 | private void CheckPalleteImage ( IfdTags metadata , int nifd ) { if ( ! metadata . containsTagId ( TiffTags . getTagId ( "ColorMap" ) ) ) { validation . addErrorLoc ( "Missing Color Map" , "IFD" + nifd ) ; } else { int n = metadata . get ( TiffTags . getTagId ( "ColorMap" ) ) . getCardinality ( ) ; if ( n != 3 * ( int ) Math . pow ( 2 , metadata . get ( TiffTags . getTagId ( "BitsPerSample" ) ) . getFirstNumericValue ( ) ) ) validation . addError ( "Incorrect Color Map Cardinality" , "IFD" + nifd , metadata . get ( 320 ) . getCardinality ( ) ) ; } long bps = metadata . get ( TiffTags . getTagId ( "BitsPerSample" ) ) . getFirstNumericValue ( ) ; if ( bps != 4 && bps != 8 ) validation . addError ( "Invalid Bits per Sample" , "IFD" + nifd , bps ) ; long comp = metadata . get ( TiffTags . getTagId ( "Compression" ) ) . getFirstNumericValue ( ) ; if ( comp < 1 ) validation . addError ( "Invalid Compression" , "IFD" + nifd , comp ) ; } | Check Pallete Color Image . |
6,846 | private void CheckTransparencyMask ( IfdTags metadata , int n ) { if ( ! metadata . containsTagId ( TiffTags . getTagId ( "SamplesPerPixel" ) ) ) { validation . addErrorLoc ( "Missing Samples Per Pixel" , "IFD" + n ) ; } else { long spp = metadata . get ( TiffTags . getTagId ( "SamplesPerPixel" ) ) . getFirstNumericValue ( ) ; if ( spp != 1 ) { validation . addError ( "Invalid Samples Per Pixel" , "IFD" + n , spp ) ; } } if ( ! metadata . containsTagId ( TiffTags . getTagId ( "BitsPerSample" ) ) ) { validation . addErrorLoc ( "Missing BitsPerSample" , "IFD" + n ) ; } else { long bps = metadata . get ( TiffTags . getTagId ( "BitsPerSample" ) ) . getFirstNumericValue ( ) ; if ( bps != 1 ) { validation . addError ( "Invalid BitsPerSample" , "IFD" + n , bps ) ; } } } | Check transparency mask . |
6,847 | private void CheckCMYK ( IfdTags metadata , int n ) { if ( ! metadata . containsTagId ( TiffTags . getTagId ( "SamplesPerPixel" ) ) ) { validation . addErrorLoc ( "Missing Samples Per Pixel" , "IFD" + n ) ; } if ( ! metadata . containsTagId ( TiffTags . getTagId ( "BitsPerSample" ) ) ) { validation . addErrorLoc ( "Missing BitsPerSample" , "IFD" + n ) ; } } | Check CMYK . |
6,848 | private void CheckYCbCr ( IfdTags metadata , int n ) { if ( ! metadata . containsTagId ( TiffTags . getTagId ( "SamplesPerPixel" ) ) ) { validation . addErrorLoc ( "Missing Samples Per Pixel" , "IFD" + n ) ; } else { long spp = metadata . get ( TiffTags . getTagId ( "SamplesPerPixel" ) ) . getFirstNumericValue ( ) ; if ( spp != 3 ) { validation . addError ( "Invalid Samples Per Pixel" , "IFD" + n , spp ) ; } } if ( ! metadata . containsTagId ( TiffTags . getTagId ( "BitsPerSample" ) ) ) { validation . addErrorLoc ( "Missing BitsPerSample" , "IFD" + n ) ; } else { for ( abstractTiffType vi : metadata . get ( TiffTags . getTagId ( "BitsPerSample" ) ) . getValue ( ) ) { if ( vi . toInt ( ) != 8 ) { validation . addError ( "Invalid BitsPerSample" , "IFD" + n , vi . toInt ( ) ) ; break ; } } } } | Check YCbCr . |
6,849 | private void CheckCIELab ( IfdTags metadata , int n ) { if ( ! metadata . containsTagId ( TiffTags . getTagId ( "BitsPerSample" ) ) ) { validation . addErrorLoc ( "Missing BitsPerSample" , "IFD" + n ) ; } else { for ( abstractTiffType vi : metadata . get ( TiffTags . getTagId ( "BitsPerSample" ) ) . getValue ( ) ) { if ( vi . toInt ( ) != 8 ) { validation . addError ( "Invalid BitsPerSample" , "IFD" + n , vi . toInt ( ) ) ; break ; } } } } | Check CIELab . |
6,850 | private void CheckRGBImage ( IfdTags metadata , int n ) { long samples = metadata . get ( TiffTags . getTagId ( "SamplesPerPixel" ) ) . getFirstNumericValue ( ) ; if ( samples < 3 ) validation . addError ( "Invalid Samples per Pixel" , "IFD" + n , samples ) ; long comp = metadata . get ( TiffTags . getTagId ( "Compression" ) ) . getFirstNumericValue ( ) ; if ( comp < 1 ) validation . addError ( "Invalid Compression" , "IFD" + n , comp ) ; } | Check RGB Image . |
6,851 | private void CheckStrips ( IfdTags metadata , int n ) { long offset ; int id ; id = TiffTags . getTagId ( "StripOffsets" ) ; offset = metadata . get ( id ) . getFirstNumericValue ( ) ; int nso = metadata . get ( id ) . getCardinality ( ) ; if ( offset <= 0 ) validation . addError ( "Invalid value for field " + TiffTags . getTag ( id ) . getName ( ) , "IFD" + n , offset ) ; id = TiffTags . getTagId ( "StripBYTECount" ) ; offset = metadata . get ( id ) . getFirstNumericValue ( ) ; int nsc = metadata . get ( id ) . getCardinality ( ) ; if ( offset <= 0 ) validation . addError ( "Invalid value for field " + TiffTags . getTag ( id ) . getName ( ) , "IFD" + n , offset ) ; if ( nso != nsc ) { validation . addErrorLoc ( "Inconsistent strip lengths" , "IFD" + n ) ; } int pixelSize = 0 ; for ( int i = 0 ; i < metadata . get ( "BitsPerSample" ) . getCardinality ( ) ; i ++ ) { pixelSize += metadata . get ( "BitsPerSample" ) . getValue ( ) . get ( i ) . toInt ( ) ; } if ( metadata . get ( "Compression" ) . getFirstNumericValue ( ) == 1 && pixelSize >= 8 ) { int calculatedImageLength = 0 ; for ( int i = 0 ; i < nsc ; i ++ ) { calculatedImageLength += metadata . get ( id ) . getValue ( ) . get ( i ) . toInt ( ) ; } if ( calculatedImageLength != metadata . get ( "ImageLength" ) . getFirstNumericValue ( ) * metadata . get ( "ImageWidth" ) . getFirstNumericValue ( ) * pixelSize / 8 ) { validation . addErrorLoc ( "Calculated and declared image size do not match" , "IFD" + n ) ; } } id = TiffTags . getTagId ( "RowsPerStrip" ) ; if ( ! metadata . containsTagId ( id ) ) { if ( rowsPerStripTolerance > 0 ) validation . addWarning ( "Missing required field" , TiffTags . getTag ( id ) . getName ( ) , "IFD" + n ) ; else validation . addError ( "Missing required field" , "IFD" + n , TiffTags . getTag ( id ) . getName ( ) ) ; } else { offset = metadata . get ( id ) . getFirstNumericValue ( ) ; if ( offset <= 0 ) validation . addError ( "Invalid value for field " + TiffTags . getTag ( id ) . getName ( ) , "IFD" + n , offset ) ; } } | Check that the strips containing the image are well - formed . |
6,852 | public String loadPreference ( String key , String defaultValue ) { String value = getSharedPreferences ( ) . getString ( key , defaultValue ) ; logLoad ( key , value ) ; return value ; } | Retrieve a string value from the preferences . |
6,853 | public Boolean loadPreferenceAsBoolean ( String key , Boolean defaultValue ) { Boolean value = defaultValue ; if ( hasPreference ( key ) ) { value = getSharedPreferences ( ) . getBoolean ( key , false ) ; } logLoad ( key , value ) ; return value ; } | Retrieve a boolean value from the preferences . |
6,854 | public Long loadPreferenceAsLong ( String key , Long defaultValue ) { Long value = defaultValue ; if ( hasPreference ( key ) ) { value = getSharedPreferences ( ) . getLong ( key , 0L ) ; } logLoad ( key , value ) ; return value ; } | Retrieve a long value from the preferences . |
6,855 | public Integer loadPreferenceAsInteger ( String key , Integer defaultValue ) { Integer value = defaultValue ; if ( hasPreference ( key ) ) { value = getSharedPreferences ( ) . getInt ( key , 0 ) ; } logLoad ( key , value ) ; return value ; } | Retrieve an Integer value from the preferences . |
6,856 | public Float loadPreferenceAsFloat ( String key , Float defaultValue ) { Float value = defaultValue ; if ( hasPreference ( key ) ) { value = getSharedPreferences ( ) . getFloat ( key , 0 ) ; } logLoad ( key , value ) ; return value ; } | Retrieve a Float value from the preferences . |
6,857 | protected int mapIdRefToInternalScanNum ( CharArray id ) throws FileParsingException { String idStr = id . toString ( ) ; MZMLIndexElement byId = index . getById ( idStr ) ; if ( byId == null ) { String msg = String . format ( "Could not find a mapping from spectrum id" + " ref to an internal scan number for" + "\n\t file: %s" + "\n\t spectrum index of the spectrum in which the error occured: #%d" + "\n\t idRef searched for: %s" , source . getPath ( ) , vars . spectrumIndex , idStr ) ; throw new FileParsingException ( msg ) ; } return byId . getNumber ( ) ; } | Given a scan ID goes to the index and tries to find a mapping . |
6,858 | public static List < Long > locate ( List < byte [ ] > targets , List < POSITION > locations , InputStream is , long maxOffset ) throws IOException { if ( targets . isEmpty ( ) ) { throw new IllegalArgumentException ( "Targets argument can't be empty" ) ; } if ( locations . size ( ) != targets . size ( ) ) { throw new IllegalArgumentException ( "Targets and Locations arguments must be of equal length" ) ; } for ( byte [ ] target : targets ) { if ( target . length == 0 ) { throw new IllegalArgumentException ( "Input Targets must be non-zero length" ) ; } } if ( maxOffset <= 0 ) { maxOffset = Long . MAX_VALUE ; } long posSource = - 1 ; int iRead ; byte bRead ; List < Long > result = new ArrayList < > ( targets . size ( ) ) ; for ( int i = 0 ; i < targets . size ( ) ; i ++ ) { byte [ ] target = targets . get ( i ) ; int posTarget = 0 ; byte bTarget = target [ posTarget ] ; while ( ( iRead = is . read ( ) ) >= 0 ) { posSource ++ ; if ( posSource > maxOffset ) { return result ; } bRead = ( byte ) iRead ; if ( bRead != bTarget ) { if ( posTarget > 0 ) { posTarget = 0 ; bTarget = target [ posTarget ] ; } continue ; } else { posTarget ++ ; if ( posTarget == target . length ) { switch ( locations . get ( i ) ) { case START : result . add ( posSource - target . length + 1 ) ; break ; case END : result . add ( posSource ) ; break ; default : throw new IllegalArgumentException ( "Unsupported ELEMENT_LOCATION" ) ; } break ; } bTarget = target [ posTarget ] ; continue ; } } if ( iRead < 0 && result . size ( ) != targets . size ( ) ) { return Collections . emptyList ( ) ; } } return result ; } | Locates specific sequences of bytes in the input stream . |
6,859 | public static boolean advanceReaderToNext ( XMLStreamReader xsr , String tag ) throws javax . xml . stream . XMLStreamException { if ( tag == null ) { throw new IllegalArgumentException ( "Tag name can't be null" ) ; } if ( xsr == null ) { throw new IllegalArgumentException ( "Stream Reader can't be null" ) ; } do { if ( xsr . next ( ) == javax . xml . stream . XMLStreamConstants . END_DOCUMENT ) { return false ; } } while ( ! ( xsr . isStartElement ( ) && xsr . getLocalName ( ) . equals ( tag ) ) ) ; return true ; } | Advances the Stream Reader to the next occurrence of a user - specified tag . |
6,860 | public static String getString ( int resId , Object ... args ) { return AbstractApplication . get ( ) . getString ( resId , args ) ; } | Returns a formatted string using the localized resource as format and the supplied arguments |
6,861 | public void connect ( ) { readyState = ReadyState . CONNECTING ; try { if ( webSocketHandler == null ) { webSocketHandler = new WebSocketHandlerAdapter ( ) ; } container . connectToServer ( new SimpleWebSocketClientEndpoint ( ) , ClientEndpointConfig . Builder . create ( ) . build ( ) , websocketURI ) ; } catch ( Exception e ) { readyState = ReadyState . CLOSED ; throw new RuntimeException ( "could not establish connection" ) ; } } | Establishes the connection to the given WebSocket Server Address . |
6,862 | public void close ( ) { readyState = ReadyState . CLOSING ; try { webSocketSession . close ( new CloseReason ( CloseReason . CloseCodes . NORMAL_CLOSURE , null ) ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } | Shutting down the current connection . |
6,863 | public void add ( LCMSRange range ) { Integer msLevel = range . getMsLevel ( ) ; DoubleRange mzRange = range . getMzRange ( ) ; Range < Integer > scanRange = range . getScanRange ( ) ; if ( msLevel == null ) { anyLvlSet . add ( scanRange ) ; for ( Map . Entry < Integer , MsLevelRangeSet > lvlMapEntry : lvlMap . entrySet ( ) ) { MsLevelRangeSet msLevelRangeSet = lvlMapEntry . getValue ( ) ; msLevelRangeSet . removeFromAll ( range ) ; } return ; } TreeRangeSet < Integer > scanRangeLeft = TreeRangeSet . create ( ) ; scanRangeLeft . removeAll ( anyLvlSet ) ; if ( scanRangeLeft . isEmpty ( ) ) { return ; } MsLevelRangeSet msLvlRanges = lvlMap . get ( msLevel ) ; if ( msLvlRanges == null ) { msLvlRanges = new MsLevelRangeSet ( ) ; lvlMap . put ( msLevel , msLvlRanges ) ; } if ( mzRange == null ) { msLvlRanges . anyPrecursorSet . addAll ( scanRangeLeft ) ; msLvlRanges . removeFromSpecific ( range ) ; return ; } scanRangeLeft . removeAll ( msLvlRanges . anyPrecursorSet ) ; if ( scanRangeLeft . isEmpty ( ) ) { return ; } RangeSet < Integer > rangeSetForMzRange = msLvlRanges . rngMap . get ( mzRange ) ; if ( rangeSetForMzRange == null ) { rangeSetForMzRange = TreeRangeSet . create ( ) ; msLvlRanges . rngMap . put ( mzRange , rangeSetForMzRange ) ; } rangeSetForMzRange . addAll ( scanRangeLeft ) ; } | This add method gradually removes scan - ranges from the input range as it descends down the hierarchy . |
6,864 | public void subtract ( LCMSRangeSet other ) { anyLvlSet . removeAll ( other . anyLvlSet ) ; for ( Map . Entry < Integer , MsLevelRangeSet > lvlMapEntry : lvlMap . entrySet ( ) ) { Integer msLevel = lvlMapEntry . getKey ( ) ; MsLevelRangeSet msLevelRangeSet = lvlMapEntry . getValue ( ) ; msLevelRangeSet . anyPrecursorSet . removeAll ( other . anyLvlSet ) ; MsLevelRangeSet otherMsLevelRangeSet = other . lvlMap . get ( msLevel ) ; msLevelRangeSet . anyPrecursorSet . removeAll ( otherMsLevelRangeSet . anyPrecursorSet ) ; for ( Map . Entry < DoubleRange , RangeSet < Integer > > rngMapEntry : msLevelRangeSet . rngMap . entrySet ( ) ) { if ( rngMapEntry . getValue ( ) . isEmpty ( ) ) { continue ; } DoubleRange mzRange = rngMapEntry . getKey ( ) ; RangeSet < Integer > rangeSet = rngMapEntry . getValue ( ) ; rangeSet . removeAll ( other . anyLvlSet ) ; if ( ! rangeSet . isEmpty ( ) ) { rangeSet . removeAll ( otherMsLevelRangeSet . anyPrecursorSet ) ; } if ( ! rangeSet . isEmpty ( ) ) { RangeSet < Integer > otherRangeSetAtMsLevelForPrecursorRange = otherMsLevelRangeSet . rngMap . get ( mzRange ) ; if ( otherRangeSetAtMsLevelForPrecursorRange != null ) { rangeSet . removeAll ( otherRangeSetAtMsLevelForPrecursorRange ) ; } } } } } | Will modify the set . Intended usage - when unloading data in LCMSData create one range set for data loaded by other users then create a separate range set for the LCMSRange that you want to unload . Subtract the loaded by others from the range set you want to unload . Use this range set for unloading . |
6,865 | private int classifyTags ( IFD ifd , ArrayList < TagValue > oversized , ArrayList < TagValue > undersized ) { int tagValueSize = 4 ; int n = 0 ; for ( TagValue tag : ifd . getMetadata ( ) . getTags ( ) ) { int tagsize = getTagSize ( tag ) ; if ( tagsize > tagValueSize ) { oversized . add ( tag ) ; } else { undersized . add ( tag ) ; } n ++ ; } return n ; } | Gets the oversized tags . |
6,866 | private int getTagSize ( TagValue tag ) { int n = tag . getCardinality ( ) ; int id = tag . getId ( ) ; int type = tag . getType ( ) ; if ( id == 330 ) { n = 1000 ; } if ( id == 700 ) { if ( tag . getValue ( ) . size ( ) > 0 ) n = tag . getValue ( ) . get ( 0 ) . toString ( ) . length ( ) ; } if ( id == 33723 ) { n = tag . getReadlength ( ) ; } if ( id == 34665 ) { n = 1000 ; } if ( id == 34675 ) { n = tag . getReadlength ( ) ; } int typeSize = TiffTags . getTypeSize ( type ) ; int tagSize = typeSize * n ; return tagSize ; } | Gets the tag size . |
6,867 | private ArrayList < Integer > writeStripData ( IFD ifd ) throws IOException { ArrayList < Integer > newStripOffsets = new ArrayList < Integer > ( ) ; IfdTags metadata = ifd . getMetadata ( ) ; TagValue stripOffsets = metadata . get ( 273 ) ; TagValue stripSizes = metadata . get ( 279 ) ; for ( int i = 0 ; i < stripOffsets . getCardinality ( ) ; i ++ ) { try { int pos = ( int ) data . position ( ) ; newStripOffsets . add ( pos ) ; int start = stripOffsets . getValue ( ) . get ( i ) . toInt ( ) ; int size = stripSizes . getValue ( ) . get ( i ) . toInt ( ) ; this . input . seekOffset ( start ) ; for ( int off = start ; off < start + size ; off ++ ) { byte v = this . input . readDirectByte ( ) ; data . put ( v ) ; } if ( data . position ( ) % 2 != 0 ) { data . put ( ( byte ) 0 ) ; } } catch ( Exception ex ) { } } return newStripOffsets ; } | Write strip data . |
6,868 | private ArrayList < Integer > writeTileData ( IFD ifd ) throws IOException { ArrayList < Integer > newTileOffsets = new ArrayList < Integer > ( ) ; IfdTags metadata = ifd . getMetadata ( ) ; TagValue tileOffsets = metadata . get ( 324 ) ; TagValue tileSizes = metadata . get ( 325 ) ; for ( int i = 0 ; i < tileOffsets . getCardinality ( ) ; i ++ ) { int pos = ( int ) data . position ( ) ; if ( pos % 2 != 0 ) { data . put ( ( byte ) 0 ) ; pos = ( int ) data . position ( ) ; } newTileOffsets . add ( pos ) ; this . input . seekOffset ( tileOffsets . getValue ( ) . get ( i ) . toInt ( ) ) ; for ( int j = 0 ; j < tileSizes . getValue ( ) . get ( i ) . toInt ( ) ; j ++ ) { byte v = this . input . readDirectByte ( ) ; data . put ( v ) ; } if ( data . position ( ) % 2 != 0 ) { data . put ( ( byte ) 0 ) ; } } return newTileOffsets ; } | Write tile data . |
6,869 | public List < SubsetMove > getAllMoves ( SubsetSolution solution ) { Set < Integer > removeCandidates = getRemoveCandidates ( solution ) ; Set < Integer > addCandidates = getAddCandidates ( solution ) ; List < SubsetMove > moves = new ArrayList < > ( ) ; if ( canAdd ( solution , addCandidates ) ) { addCandidates . forEach ( add -> moves . add ( new AdditionMove ( add ) ) ) ; } if ( canRemove ( solution , removeCandidates ) ) { removeCandidates . forEach ( remove -> moves . add ( new DeletionMove ( remove ) ) ) ; } if ( canSwap ( solution , addCandidates , removeCandidates ) ) { addCandidates . forEach ( add -> { removeCandidates . forEach ( remove -> { moves . add ( new SwapMove ( add , remove ) ) ; } ) ; } ) ; } return moves ; } | Generate all valid swap deletion and addition moves that transform the given subset solution into a neighbour within the minimum and maximum allowed subset size . The returned list may be empty if no valid moves exist . If any fixed IDs have been specified these will not be considered for deletion nor addition . |
6,870 | private boolean canAdd ( SubsetSolution solution , Set < Integer > addCandidates ) { return ! addCandidates . isEmpty ( ) && isValidSubsetSize ( solution . getNumSelectedIDs ( ) + 1 ) ; } | Check if it is allowed to add one more item to the selection . |
6,871 | private boolean canRemove ( SubsetSolution solution , Set < Integer > deleteCandidates ) { return ! deleteCandidates . isEmpty ( ) && isValidSubsetSize ( solution . getNumSelectedIDs ( ) - 1 ) ; } | Check if it is allowed to remove one more item from the selection . |
6,872 | private boolean canSwap ( SubsetSolution solution , Set < Integer > addCandidates , Set < Integer > deleteCandidates ) { return ! addCandidates . isEmpty ( ) && ! deleteCandidates . isEmpty ( ) && isValidSubsetSize ( solution . getNumSelectedIDs ( ) ) ; } | Check if it is possible to swap a selected and unselected item . |
6,873 | public static final LCMSRange create ( Range < Integer > scanRange , Integer msLevel ) { return new LCMSRange ( scanRange , msLevel , null ) ; } | A range that will contain all scans with the scan number range but only at a specific MS - Level . |
6,874 | public static final LCMSRange create ( Range < Integer > scanRange , Integer msLevel , DoubleRange mzRange ) { return new LCMSRange ( scanRange , msLevel , mzRange ) ; } | A range containing all scans within the scan number range at a specific MS - Level and a specific precursor range . |
6,875 | public void addValidation ( Object key , Validation validation ) { initMapOnce ( ) ; validations . put ( key , validation ) ; passedAll = passedAll && validation . passed ( ) ; } | Add a validation object . A key is required that can be used to retrieve the validation object . |
6,876 | public static MsmsPipelineAnalysis parse ( Path path ) throws FileParsingException { try { XMLStreamReader xsr = JaxbUtils . createXmlStreamReader ( path , false ) ; MsmsPipelineAnalysis msmsPipelineAnalysis = JaxbUtils . unmarshal ( MsmsPipelineAnalysis . class , xsr ) ; return msmsPipelineAnalysis ; } catch ( JAXBException e ) { throw new FileParsingException ( String . format ( "JAXB parsing of PepXML file failed (%s)" , path . toAbsolutePath ( ) . toString ( ) ) , e ) ; } } | The simplest method to parse the whole MsmsPipelineAnalysis from a file . |
6,877 | public LCMSDataSubset merge ( LCMSDataSubset other ) { LCMSDataSubset merged = new LCMSDataSubset ( ) ; Set < Integer > msLvlsThis = getMsLvls ( ) ; Set < Integer > msLvlsThat = other . getMsLvls ( ) ; if ( msLvlsThis != null && msLvlsThat != null ) { HashSet < Integer > mergedMsLvls = new HashSet < > ( msLvlsThis ) ; mergedMsLvls . addAll ( msLvlsThat ) ; merged . setMsLvls ( mergedMsLvls ) ; } List < DoubleRange > mzRangesThis = getMzRanges ( ) ; List < DoubleRange > mzRangesThat = other . getMzRanges ( ) ; if ( mzRangesThis != null && mzRangesThat != null ) { ArrayList < DoubleRange > mergedMzRanges = new ArrayList < > ( mzRangesThis ) ; mergedMzRanges . addAll ( mzRangesThat ) ; merged . setMzRanges ( mergedMzRanges ) ; } Integer scanNumLoThis = getScanNumLo ( ) ; Integer scanNumLoThat = other . getScanNumLo ( ) ; if ( scanNumLoThis != null && scanNumLoThat != null ) { merged . setScanNumLo ( Math . min ( scanNumLoThis , scanNumLoThat ) ) ; } Integer scanNumHiThis = getScanNumHi ( ) ; Integer scanNumHiThat = other . getScanNumHi ( ) ; if ( scanNumHiThis != null && scanNumHiThat != null ) { merged . setScanNumHi ( Math . max ( scanNumHiThis , scanNumHiThat ) ) ; } return merged ; } | Doesn t modify original values always returns a new one . |
6,878 | public void addStopCriterion ( StopCriterion stopCriterion ) { synchronized ( statusLock ) { assertIdle ( "Cannot add stop criterion." ) ; stopCriterionChecker . add ( stopCriterion ) ; LOGGER . debug ( "{}: added stop criterion {}" , this , stopCriterion ) ; } } | Adds a stop criterion used to decide when the search should stop running . It is verified whether the given stop criterion is compatible with the search and if not an exception is thrown . Note that this method can only be called when the search is idle . |
6,879 | private static boolean showCheatSheet ( View view , CharSequence text ) { if ( TextUtils . isEmpty ( text ) ) { return false ; } final int [ ] screenPos = new int [ 2 ] ; final Rect displayFrame = new Rect ( ) ; view . getLocationOnScreen ( screenPos ) ; view . getWindowVisibleDisplayFrame ( displayFrame ) ; final Context context = view . getContext ( ) ; final int viewWidth = view . getWidth ( ) ; final int viewHeight = view . getHeight ( ) ; final int viewCenterX = screenPos [ 0 ] + ( viewWidth / 2 ) ; final int screenWidth = context . getResources ( ) . getDisplayMetrics ( ) . widthPixels ; final int estimatedToastHeight = ( int ) ( ESTIMATED_TOAST_HEIGHT_DPS * context . getResources ( ) . getDisplayMetrics ( ) . density ) ; Toast cheatSheet = Toast . makeText ( context , text , Toast . LENGTH_SHORT ) ; boolean showBelow = screenPos [ 1 ] < estimatedToastHeight ; if ( showBelow ) { cheatSheet . setGravity ( Gravity . TOP | Gravity . CENTER_HORIZONTAL , viewCenterX - ( screenWidth / 2 ) , ( screenPos [ 1 ] - displayFrame . top ) + viewHeight ) ; } else { cheatSheet . setGravity ( Gravity . BOTTOM | Gravity . CENTER_HORIZONTAL , viewCenterX - ( screenWidth / 2 ) , displayFrame . bottom - screenPos [ 1 ] ) ; } cheatSheet . show ( ) ; return true ; } | Internal helper method to show the cheat sheet toast . |
6,880 | @ RequiresPermission ( anyOf = { Manifest . permission . ACCESS_COARSE_LOCATION , Manifest . permission . ACCESS_FINE_LOCATION } ) public synchronized void startLocalization ( ) { if ( ! started && hasSignificantlyOlderLocation ( ) ) { started = true ; List < String > enabledProviders = locationManager . getProviders ( true ) ; boolean gpsProviderEnabled = enabledProviders != null && enabledProviders . contains ( LocationManager . GPS_PROVIDER ) ; boolean networkProviderEnabled = enabledProviders != null && enabledProviders . contains ( LocationManager . NETWORK_PROVIDER ) ; if ( gpsProviderEnabled || networkProviderEnabled ) { if ( gpsProviderEnabled ) { locationManager . requestLocationUpdates ( LocationManager . GPS_PROVIDER , LOCATION_MIN_TIME , 0 , this ) ; } if ( networkProviderEnabled ) { locationManager . requestLocationUpdates ( LocationManager . NETWORK_PROVIDER , LOCATION_MIN_TIME , 0 , this ) ; } AlarmUtils . scheduleElapsedRealtimeAlarm ( SystemClock . elapsedRealtime ( ) + LOCATION_MAX_TIME , getCancelPendingIntent ( ) ) ; LOGGER . info ( "Localization started" ) ; } else { started = false ; LOGGER . info ( "All providers disabled" ) ; } } } | Register the listener with the Location Manager to receive location updates |
6,881 | @ RequiresPermission ( anyOf = { Manifest . permission . ACCESS_COARSE_LOCATION , Manifest . permission . ACCESS_FINE_LOCATION } ) public synchronized void stopLocalization ( ) { if ( started ) { AlarmUtils . cancelAlarm ( getCancelPendingIntent ( ) ) ; locationManager . removeUpdates ( this ) ; if ( location == null ) { location = locationManager . getLastKnownLocation ( LocationManager . GPS_PROVIDER ) ; if ( location == null ) { location = locationManager . getLastKnownLocation ( LocationManager . NETWORK_PROVIDER ) ; } locationTime = DateUtils . nowMillis ( ) ; } started = false ; LOGGER . info ( "Localization stopped" ) ; } } | Remove the listener to receive location updates |
6,882 | public static boolean containsWebSocketScheme ( URI uri ) { Objects . requireNonNull ( uri , "no URI object given" ) ; final String scheme = uri . getScheme ( ) ; if ( scheme != null && ( scheme . equals ( WS_SCHEME ) || scheme . equals ( WSS_SCHEME ) ) ) { return true ; } return false ; } | Checks if the given URI is a contains a valid WebSocket scheme |
6,883 | public static LCMSRunInfo createDummyInfo ( ) { LCMSRunInfo lcmsRunInfo = new LCMSRunInfo ( ) ; lcmsRunInfo . addInstrument ( Instrument . getDummy ( ) , Instrument . ID_UNKNOWN ) ; return lcmsRunInfo ; } | Only use if you can t get real run info . |
6,884 | public void addInstrument ( Instrument instrument , String id ) { if ( instrument == null || id == null ) { throw new IllegalArgumentException ( "Instruemnt and ID must be non-null values." ) ; } if ( instruments . size ( ) == 0 ) { defaultInstrumentID = id ; } else if ( instruments . size ( ) > 0 && ! isDefaultExplicitlySet ) { unsetDefaultInstrument ( ) ; } instruments . put ( id , instrument ) ; } | If only one instrument is added it will be set as the default instrument all the scans that you add to the ScanCollection will implicitly refer to this one instrument . |
6,885 | public void setDefaultInstrumentID ( String id ) { if ( id == null ) { unsetDefaultInstrument ( ) ; return ; } if ( instruments . containsKey ( id ) ) { defaultInstrumentID = id ; isDefaultExplicitlySet = true ; } else { throw new IllegalArgumentException ( "The instrument map did not contain provided instrument ID, " + "have you added the instrument first?" ) ; } } | Call with null parameter to unset . |
6,886 | public Class < ? > getType ( ELContext context , Object base , Object property ) { if ( context == null ) { throw new NullPointerException ( ) ; } if ( base != null && base instanceof List ) { context . setPropertyResolved ( true ) ; List list = ( List ) base ; int index = toInteger ( property ) ; if ( index < 0 || index >= list . size ( ) ) { throw new PropertyNotFoundException ( ) ; } return Object . class ; } return null ; } | If the base object is a list returns the most general acceptable type for a value in this list . |
6,887 | public void undo ( SubsetSolution solution ) { solution . select ( delete ) ; solution . deselect ( add ) ; } | Undo this swap move after it has been successfully applied to the given subset solution by removing the newly added ID and re - adding the deleted ID . |
6,888 | public final void run ( ) { LOGGER . debug ( "Executing " + getClass ( ) . getSimpleName ( ) ) ; markAsInProgress ( ) ; if ( ! Lists . isNullOrEmpty ( listeners ) ) { Runnable startUseCaseRunnable = new Runnable ( ) { public void run ( ) { for ( UseCaseListener listener : listeners ) { notifyUseCaseStart ( listener ) ; } } } ; if ( handler != null ) { handler . post ( startUseCaseRunnable ) ; } else { startUseCaseRunnable . run ( ) ; } } Trace trace = null ; if ( timingTrackingEnabled ( ) ) { trace = TraceHelper . startTrace ( getClass ( ) ) ; } try { LOGGER . debug ( "Started " + getClass ( ) . getSimpleName ( ) ) ; executionTime = null ; startTime = DateUtils . nowMillis ( ) ; doExecute ( ) ; executionTime = DateUtils . nowMillis ( ) - startTime ; LOGGER . debug ( "Finished " + getClass ( ) . getSimpleName ( ) + ". Execution time: " + DateUtils . formatDuration ( executionTime ) ) ; if ( trace != null ) { trace . putAttribute ( "result" , "success" ) ; trace . incrementMetric ( "successes" , 1 ) ; } markAsSuccessful ( ) ; if ( ! Lists . isNullOrEmpty ( listeners ) ) { Runnable finishedUseCaseRunnable = new Runnable ( ) { public void run ( ) { for ( UseCaseListener listener : listeners ) { notifyFinishedUseCase ( listener ) ; } markAsNotified ( ) ; } } ; if ( handler != null ) { handler . post ( finishedUseCaseRunnable ) ; } else { finishedUseCaseRunnable . run ( ) ; } } } catch ( RuntimeException e ) { if ( trace != null ) { trace . putAttribute ( "result" , "failure" ) ; trace . incrementMetric ( "failures" , 1 ) ; } final AbstractException abstractException = wrapException ( e ) ; markAsFailed ( abstractException ) ; logHandledException ( abstractException ) ; if ( ! Lists . isNullOrEmpty ( listeners ) ) { Runnable finishedFailedUseCaseRunnable = new Runnable ( ) { public void run ( ) { for ( UseCaseListener listener : listeners ) { notifyFailedUseCase ( abstractException , listener ) ; } markAsNotified ( ) ; } } ; if ( handler != null ) { handler . post ( finishedFailedUseCaseRunnable ) ; } else { finishedFailedUseCaseRunnable . run ( ) ; } } } finally { if ( trace != null ) { trace . stop ( ) ; } } } | Executes the use case . |
6,889 | public static String encrypt ( String cleartext ) { if ( cleartext != null ) { byte [ ] result = doFinal ( Base64 . decode ( getBase64Key ( ) , Base64 . DEFAULT ) , Cipher . ENCRYPT_MODE , cleartext . getBytes ( ) ) ; return Base64 . encodeToString ( result , Base64 . DEFAULT ) ; } return null ; } | Returns the data encrypted . Avoid calling this method on the UI thread if possible since it may access to shared preferences . |
6,890 | public static String decrypt ( String base64Encrypted ) { if ( base64Encrypted != null ) { byte [ ] enc = Base64 . decode ( base64Encrypted , Base64 . DEFAULT ) ; byte [ ] result = doFinal ( Base64 . decode ( getBase64Key ( ) , Base64 . DEFAULT ) , Cipher . DECRYPT_MODE , enc ) ; return new String ( result ) ; } return null ; } | Returns the original data . Avoid calling this method on the UI thread if possible since it may access to shared preferences . |
6,891 | public static String generateShaHash ( String text ) { try { MessageDigest digest = MessageDigest . getInstance ( SHA_ALGORITHM ) ; byte [ ] bytes = text . getBytes ( UTF_8 ) ; bytes = digest . digest ( bytes ) ; return toHexEncode ( bytes ) ; } catch ( Exception e ) { throw new UnexpectedException ( e ) ; } } | Generates the SHA hash for the input string . |
6,892 | public void undo ( SubsetSolution solution ) { solution . deselectAll ( add ) ; solution . selectAll ( delete ) ; } | Undo this move after it has been successfully applied to the given subset solution by removing all added IDs and adding all removed IDs . If the subset solution has been modified since successful application of this move the result of this operation is undefined . |
6,893 | public Metadata createMetadata ( ) { Metadata metadata = new Metadata ( ) ; try { for ( DataSet ds : iimFile . getDataSets ( ) ) { Object value = "" ; try { value = ds . getValue ( ) ; } catch ( Exception ex ) { } DataSetInfo info = ds . getInfo ( ) ; metadata . add ( info . getName ( ) , new Text ( value . toString ( ) ) ) ; } } catch ( Exception ex ) { } return metadata ; } | Creates the metadata . |
6,894 | public void read ( TagValue tv , String filename ) { originalValue = tv . getValue ( ) ; File file = new File ( filename ) ; IIMReader reader = null ; SubIIMInputStream subStream = null ; try { int offset = tv . getReadOffset ( ) ; int length = tv . getReadlength ( ) ; subStream = new SubIIMInputStream ( new FileIIMInputStream ( file ) , offset , length ) ; reader = new IIMReader ( subStream , new IIMDataSetInfoFactory ( ) ) ; IIMFile iimFileReader = new IIMFile ( ) ; iimFileReader . readFrom ( reader , 0 ) ; List < DataSet > lds = new ArrayList < DataSet > ( ) ; for ( DataSet ds : iimFileReader . getDataSets ( ) ) { ds . getData ( ) ; lds . add ( ds ) ; } iimFile = new IIMFile ( ) ; iimFile . setDataSets ( lds ) ; tv . reset ( ) ; tv . add ( this ) ; reader . close ( ) ; subStream . close ( ) ; } catch ( IOException e ) { try { reader . close ( ) ; subStream . close ( ) ; } catch ( Exception ex ) { } } catch ( InvalidDataSetException e ) { try { reader . close ( ) ; subStream . close ( ) ; } catch ( Exception ex ) { } } } | Reads the IPTC . |
6,895 | public void onMessageReceived ( RemoteMessage remoteMessage ) { if ( LoggerUtils . isEnabled ( ) ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "Message received. " ) ; builder . append ( "from: " ) ; builder . append ( remoteMessage . getFrom ( ) ) ; if ( remoteMessage . getMessageType ( ) != null ) { builder . append ( ", " ) ; builder . append ( "message type: " ) ; builder . append ( remoteMessage . getMessageType ( ) ) ; } if ( remoteMessage . getData ( ) != null & ! remoteMessage . getData ( ) . isEmpty ( ) ) { builder . append ( ", " ) ; builder . append ( "data: " ) ; builder . append ( remoteMessage . getData ( ) ) ; } LOGGER . info ( builder . toString ( ) ) ; } FcmMessageResolver fcmResolver = AbstractFcmAppModule . get ( ) . getFcmMessageResolver ( ) ; if ( fcmResolver != null ) { FcmMessage fcmMessage = null ; try { fcmMessage = fcmResolver . resolve ( remoteMessage ) ; } catch ( Exception e ) { AbstractApplication . get ( ) . getExceptionHandler ( ) . logHandledException ( "Error when resolving FCM message" , e ) ; return ; } if ( fcmMessage != null ) { try { fcmMessage . handle ( remoteMessage ) ; } catch ( Exception e ) { AbstractApplication . get ( ) . getExceptionHandler ( ) . logHandledException ( "Error when handling FCM message" , e ) ; } } else { LOGGER . warn ( "The FCM message was not resolved" ) ; } } else { LOGGER . warn ( "A FCM message was received, but not resolved is configured" ) ; } for ( FcmEventsListener fcmEventsListener : FcmContext . getFcmEventsListeners ( ) ) { try { fcmEventsListener . onMessageReceived ( remoteMessage ) ; } catch ( Exception e ) { AbstractApplication . get ( ) . getExceptionHandler ( ) . logHandledException ( e ) ; } } } | Called when message is received . Since Android O have a guaranteed life cycle limited to 10 seconds for this method execution |
6,896 | public IScan getScanByNum ( int scanNum ) { IScan scan = getNum2scan ( ) . get ( scanNum ) ; if ( scan != null ) { return scan ; } return null ; } | The name says it all . |
6,897 | public IScan getScanByNumLower ( int scanNum ) { IScan scan = getNum2scan ( ) . lowerEntry ( scanNum ) . getValue ( ) ; if ( scan != null ) { return scan ; } return null ; } | Scan with closest Number STRICTLY less than the provided one is returned . |
6,898 | public IScan getScanByNumUpper ( int scanNum ) { IScan scan = getNum2scan ( ) . ceilingEntry ( scanNum ) . getValue ( ) ; if ( scan != null ) { return scan ; } return null ; } | Scan with the closest Number greater or equal to the provided one is returned . |
6,899 | public IScan getScanByNumClosest ( int scanNum ) { IScan result = null ; Map . Entry < Integer , IScan > lower = getNum2scan ( ) . lowerEntry ( scanNum ) ; Map . Entry < Integer , IScan > upper = getNum2scan ( ) . ceilingEntry ( scanNum ) ; if ( upper != null && lower != null ) { result = Integer . compare ( lower . getKey ( ) , upper . getKey ( ) ) > 0 ? lower . getValue ( ) : upper . getValue ( ) ; } else if ( upper != null ) { result = upper . getValue ( ) ; } else if ( lower != null ) { result = lower . getValue ( ) ; } return result ; } | Scan with the closest Number is returned . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.