idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
15,700
public ValidationData save ( ValidationData data ) { if ( data . getParamType ( ) == null || data . getUrl ( ) == null || data . getMethod ( ) == null || data . getType ( ) == null || data . getTypeClass ( ) == null ) { throw new ValidationLibException ( "mandatory field is null " , HttpStatus . BAD_REQUEST ) ; } ValidationData existData = this . findById ( data . getId ( ) ) ; if ( existData == null ) { return this . addData ( data ) ; } else { existData . setValidationRules ( data . getValidationRules ( ) ) ; return existData ; } }
Save validation data .
15,701
public static UriBuilder fromPath ( String path ) { if ( path == null ) throw new IllegalArgumentException ( "Path cannot be null" ) ; final UriBuilder builder = newInstance ( ) ; builder . path ( path ) ; return builder ; }
Create a new instance representing a relative URI initialized from a URI path .
15,702
public static String toJson ( Object obj ) { StringWriter sw = new StringWriter ( ) ; ObjectMapper mapper = getDefaultObjectMapper ( ) ; try { JsonGenerator jg = mapper . getFactory ( ) . createGenerator ( sw ) ; mapper . writeValue ( jg , obj ) ; } catch ( JsonMappingException e ) { e . printStackTrace ( ) ; } catch ( JsonGenerationException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } return sw . toString ( ) ; }
Convert object to json . If object contains fields of type date they will be converted to strings using lightblue date format .
15,703
public boolean remove ( int element ) { if ( element < 0 ) { throw new IndexOutOfBoundsException ( "element < 0: " + element ) ; } int index = findElementOrEmpty ( element ) ; if ( index < 0 ) { return false ; } cells [ index ] = REMOVED ; modCount ++ ; size -- ; return true ; }
Removes the specified element from the set .
15,704
public void clear ( ) { size = 0 ; Arrays . fill ( cells , EMPTY ) ; freecells = cells . length ; modCount ++ ; }
Removes all of the elements from this set .
15,705
protected void rehash ( ) { int gargagecells = cells . length - ( size + freecells ) ; if ( ( double ) gargagecells / cells . length > 0.05D ) { rehash ( cells . length ) ; } else { rehash ( ( cells . length << 1 ) + 1 ) ; } }
Figures out correct size for rehashed set then does the rehash .
15,706
protected void rehash ( int newCapacity ) { HashIntSet rehashed = new HashIntSet ( newCapacity ) ; @ SuppressWarnings ( "hiding" ) int [ ] cells = rehashed . cells ; for ( int element : this . cells ) { if ( element < 0 ) { continue ; } cells [ - ( rehashed . findElementOrEmpty ( element ) + 1 ) ] = element ; } this . cells = cells ; freecells = newCapacity - size ; modCount ++ ; }
Rehashes to a bigger size .
15,707
public CheckPointHelper replaceExceptionCallback ( BasicCheckRule checkRule , ValidationInvalidCallback cb ) { this . msgChecker . replaceCallback ( checkRule , cb ) ; return this ; }
Replace the callback to be used basic exception .
15,708
public CheckPointHelper addValidationRule ( String ruleName , StandardValueType standardValueType , BaseValidationCheck validationCheck , AssistType assistType ) { ValidationRule rule = new ValidationRule ( ruleName , standardValueType , validationCheck ) ; if ( assistType == null ) { assistType = AssistType . all ( ) ; } rule . setAssistType ( assistType ) ; this . validationRuleStore . addRule ( rule ) ; return this ; }
Add the fresh user rule
15,709
private static void track ( String historyToken ) { if ( historyToken == null ) { historyToken = "historyToken_null" ; } historyToken = URL . encode ( "/WWARN-GWT-Analytics/V1.0/" + historyToken ) ; boolean hasErrored = false ; try { trackGoogleAnalytics ( historyToken ) ; } catch ( JavaScriptException e ) { hasErrored = true ; GWT . log ( "Unable to track" , e ) ; } if ( ! hasErrored ) GWT . log ( "Tracked " + historyToken ) ; }
track an event
15,710
private void addToArray ( JsonNode j ) { if ( j instanceof ArrayNode ) { for ( Iterator < JsonNode > itr = ( ( ArrayNode ) j ) . elements ( ) ; itr . hasNext ( ) ; ) { addToArray ( itr . next ( ) ) ; } } else { ( ( ArrayNode ) node ) . add ( j ) ; } }
Adds p into this array projection
15,711
public int getFeaturePosition ( AbstractFeature feature ) { AbstractFeature result = feature ; if ( ! featurePositions . containsKey ( feature ) ) { if ( feature instanceof FeatureGroup ) { FeatureGroup featureGroup = ( FeatureGroup ) feature ; List < Feature > features = featureGroup . getConcreteFeatures ( ) ; if ( ! features . isEmpty ( ) ) { Collections . sort ( features , new Comparator < Feature > ( ) { public int compare ( Feature feat1 , Feature feat2 ) { return getFeaturePosition ( feat1 ) - getFeaturePosition ( feat2 ) ; } } ) ; result = features . get ( 0 ) ; } } } return featurePositions . getOrDefault ( result , 0 ) ; }
Returns the absolute position of the feature or create if not exists
15,712
public List < Product > getSortedProducts ( ) { ArrayList < Product > result = new ArrayList < > ( pcm . getProducts ( ) ) ; Collections . sort ( result , new Comparator < Product > ( ) { public int compare ( Product o1 , Product o2 ) { Integer op1 = getProductPosition ( o1 ) ; Integer op2 = getProductPosition ( o2 ) ; return op1 . compareTo ( op2 ) ; } } ) ; return result ; }
Return the sorted products concordingly with metadata
15,713
public List < Feature > getSortedFeatures ( ) { ArrayList < Feature > result = new ArrayList < > ( pcm . getConcreteFeatures ( ) ) ; Collections . sort ( result , new Comparator < Feature > ( ) { public int compare ( Feature f1 , Feature f2 ) { Integer fp1 = getFeaturePosition ( f1 ) ; Integer fp2 = getFeaturePosition ( f2 ) ; return fp1 . compareTo ( fp2 ) ; } } ) ; return result ; }
Return the sorted features concordingly with metadata
15,714
public FacetBuilder setItemsList ( Map < String , String > items ) { ArrayList < FacetWidgetItem > facetWidgetItems = new ArrayList < FacetWidgetItem > ( ) ; for ( String key : items . keySet ( ) ) { String label = items . get ( key ) ; FacetWidgetItem facetWidgetItem = new FacetWidgetItem ( key , label ) ; facetWidgetItems . add ( facetWidgetItem ) ; } this . listItems = facetWidgetItems ; return this ; }
Takes a map of value to labels and the unique name of the list
15,715
public void updateRuleBasicInfo ( ValidationRule rule ) { this . orderIdx = rule . orderIdx ; this . parentDependency = rule . parentDependency ; this . standardValueType = rule . standardValueType ; this . validationCheck = rule . validationCheck ; this . overlapBanRuleName = rule . overlapBanRuleName ; this . assistType = rule . assistType ; }
Update rule basic info .
15,716
public boolean isUse ( ) { if ( ! this . use ) { return this . use ; } return ! ( this . standardValueType != null && ! this . standardValueType . equals ( StandardValueType . NONE ) && this . standardValue == null ) ; }
Is use boolean .
15,717
public boolean isUsedMyRule ( ValidationData item ) { List < ValidationRule > usedRules = item . getValidationRules ( ) ; if ( usedRules == null || usedRules . isEmpty ( ) ) { return false ; } return usedRules . stream ( ) . filter ( ur -> ur . getRuleName ( ) . equals ( this . ruleName ) && ur . isUse ( ) ) . findAny ( ) . orElse ( null ) != null ; }
Is used my rule boolean .
15,718
public List < ValidationData > filter ( List < ValidationData > allList ) { return allList . stream ( ) . filter ( vd -> this . isUsedMyRule ( vd ) ) . collect ( Collectors . toList ( ) ) ; }
Filter list .
15,719
public void updateMethodKey ( ) { Arrays . stream ( ParamType . values ( ) ) . forEach ( paramType -> this . syncMethodKey ( paramType ) ) ; this . validationDataRepository . flush ( ) ; this . validationStore . refresh ( ) ; log . info ( "[METHOD_KEY_SYNC] Complete" ) ; }
Update method key .
15,720
public void setSelected ( String s ) { for ( int i = 0 ; i < listBox . getItemCount ( ) ; i ++ ) { if ( listBox . getItemText ( i ) . equals ( s ) ) listBox . setSelectedIndex ( i ) ; } }
Given a string will find an item in the list box with matching text and select it .
15,721
public Panel draw ( TemplateViewNodesConfig config , RecordList recordList ) { final TemplateViewNodesConfig . TemplateNode rootTemplateNode = config . getRootTemplateNode ( ) ; if ( rootTemplateNode == null ) { throw new IllegalArgumentException ( "RootTemplate node is empty" ) ; } Panel panel = draw ( rootTemplateNode , recordList ) ; return panel ; }
call this with config to initialize the view
15,722
private VerticalPanel fixedWidthAndHeightPanel ( ) { final VerticalPanel verticalPanel = new VerticalPanel ( ) ; verticalPanel . setHeight ( "300px" ) ; verticalPanel . setWidth ( "500px" ) ; return verticalPanel ; }
Need fix width and height to ensure info widget panel is drawn correctly
15,723
protected void initNewThread ( Path monitoredFile , CountDownLatch start , CountDownLatch stop ) throws IOException { final Runnable watcher = initializeWatcherWithDirectory ( monitoredFile , start , stop ) ; final Thread thread = new Thread ( watcher ) ; thread . setDaemon ( false ) ; thread . start ( ) ; }
Added countdown latches as a synchronization aid to allow better unit testing Allows one or more threads to wait until a set of operations being performed in other threads completes
15,724
public void initSynchronous ( Path monitoredFile ) throws IOException { final Runnable watcher = initializeWatcherWithDirectory ( monitoredFile , new CountDownLatch ( 1 ) , new CountDownLatch ( 1 ) ) ; watcher . run ( ) ; }
A blocking method to start begin the monitoring of a directory only exists on thread interrupt
15,725
protected static void registerGraphiteMetricObserver ( List < MetricObserver > observers , String prefix , String host , String port ) { if ( null == host || host . trim ( ) . isEmpty ( ) ) { LOGGER . info ( "GraphiteMetricObserver not configured, missing environment variable: {}" , ENV_GRAPHITE_HOSTNAME ) ; return ; } LOGGER . debug ( "{} environment variable is: {}" , ENV_GRAPHITE_PREFIX , prefix ) ; LOGGER . debug ( "{} environment variable is: {}" , ENV_GRAPHITE_HOSTNAME , host ) ; LOGGER . debug ( "{} environment variable is: {}" , ENV_GRAPHITE_PORT , port ) ; if ( prefix == null ) { if ( System . getenv ( "OPENSHIFT_APP_NAME" ) != null ) { prefix = String . format ( "%s.%s.%s" , System . getenv ( "OPENSHIFT_APP_NAME" ) , System . getenv ( "OPENSHIFT_NAMESPACE" ) , System . getenv ( "OPENSHIFT_GEAR_DNS" ) ) ; } else { prefix = System . getenv ( "HOSTNAME" ) ; LOGGER . debug ( "using HOSTNAME as default prefix" + prefix ) ; } } int iport = - 1 ; if ( port != null && ! port . isEmpty ( ) ) { try { iport = Integer . valueOf ( port ) ; } catch ( NumberFormatException e ) { iport = - 1 ; LOGGER . warn ( "Configured port is not an integer. Falling back to default" ) ; } } if ( iport < 0 ) { iport = 2004 ; LOGGER . debug ( "Using default port: " + iport ) ; } String addr = host + ":" + iport ; LOGGER . debug ( "GraphiteMetricObserver prefix: " + prefix ) ; LOGGER . debug ( "GraphiteMetricObserver address: " + addr ) ; observers . add ( new GraphiteMetricObserver ( prefix , addr ) ) ; }
If there is sufficient configuration register a Graphite observer to publish metrics . Requires at a minimum a host . Optionally can set prefix as well as port . The prefix defaults to the host and port defaults to 2004 .
15,726
protected static void registerStatsdMetricObserver ( List < MetricObserver > observers , String prefix , String host , String port ) { if ( null == host || host . trim ( ) . isEmpty ( ) ) { LOGGER . info ( "StatdsMetricObserver not configured, missing environment variable: {}" , ENV_STATSD_HOSTNAME ) ; return ; } LOGGER . debug ( "{} environment variable is: {}" , ENV_STATSD_PREFIX , prefix ) ; LOGGER . debug ( "{} environment variable is: {}" , ENV_STATSD_HOSTNAME , host ) ; LOGGER . debug ( "{} environment variable is: {}" , ENV_STATSD_PORT , port ) ; int iport = - 1 ; if ( port != null && ! port . isEmpty ( ) ) { try { iport = Integer . valueOf ( port ) ; } catch ( NumberFormatException e ) { iport = - 1 ; LOGGER . warn ( "Configured port is not an integer. Falling back to default" ) ; } } if ( iport < 0 ) { iport = 8125 ; LOGGER . debug ( "Using default port: " + port ) ; } LOGGER . debug ( "StatsdMetricObserver prefix: " + prefix ) ; LOGGER . debug ( "StatsdMetricObserver host: " + host ) ; LOGGER . debug ( "StatsdMetricObserver port: " + iport ) ; observers . add ( new StatsdMetricObserver ( prefix , host , iport ) ) ; }
If there is sufficient configuration register a StatsD metric observer to publish metrics . Requires at a minimum a host . Optionally can set prefix as well as port . The prefix defaults to an empty string and port defaults to 8125 .
15,727
private static String findVariable ( String key ) { String value = System . getProperty ( key ) ; if ( value == null ) { return System . getenv ( key ) ; } return value ; }
Looks for the value of the key as a key firstly as a JVM argument and if not found to an environment variable . If still not found then null is returned .
15,728
public void addOverrideMap ( Map < String , String > overrideMap ) { if ( sealed ) { throw new IllegalStateException ( "Instance is sealed." ) ; } for ( Map . Entry < String , String > entry : overrideMap . entrySet ( ) ) { try { ParameterOverrideInfo info = new ParameterOverrideInfo ( entry . getKey ( ) ) ; if ( info . isOverrideSystemDefault ( ) ) { putMapIfNotExsits ( overrideSystemDefaultMap , info . getParameterName ( ) , entry . getValue ( ) ) ; } else if ( StringUtils . isNotEmpty ( info . getConfigurationId ( ) ) ) { Map < String , String > overrideForceScopeMapEntry = overrideForceScopeMap . get ( info . getConfigurationId ( ) ) ; if ( overrideForceScopeMapEntry == null ) { overrideForceScopeMapEntry = new HashMap < > ( ) ; overrideForceScopeMap . put ( info . getConfigurationId ( ) , overrideForceScopeMapEntry ) ; } putMapIfNotExsits ( overrideForceScopeMapEntry , info . getParameterName ( ) , entry . getValue ( ) ) ; if ( info . isLocked ( ) ) { Set < String > lockedParameterNamesScopeMapEntry = lockedParameterNamesScopeMap . get ( info . getConfigurationId ( ) ) ; if ( lockedParameterNamesScopeMapEntry == null ) { lockedParameterNamesScopeMapEntry = new HashSet < > ( ) ; lockedParameterNamesScopeMap . put ( info . getConfigurationId ( ) , lockedParameterNamesScopeMapEntry ) ; } putSetIfNotExsits ( lockedParameterNamesScopeMapEntry , info . getParameterName ( ) ) ; } } else { putMapIfNotExsits ( overrideForceMap , info . getParameterName ( ) , entry . getValue ( ) ) ; if ( info . isLocked ( ) ) { putSetIfNotExsits ( lockedParameterNamesSet , info . getParameterName ( ) ) ; } } } catch ( IllegalArgumentException ex ) { log . warn ( "Ignoring invalid parameter override definition:\n" + ex . getMessage ( ) ) ; } } }
Adds map containing parameter override definitions . Can be called multiple times . New calls do not override settings from previous calls only add new settings . Thus maps with highest priority should be added first .
15,729
public void seal ( ) { lockedParameterNamesSet = ImmutableSet . copyOf ( lockedParameterNamesSet ) ; lockedParameterNamesScopeMap = ImmutableMap . copyOf ( Maps . transformValues ( lockedParameterNamesScopeMap , new Function < Set < String > , Set < String > > ( ) { public Set < String > apply ( Set < String > input ) { return ImmutableSet . copyOf ( input ) ; } } ) ) ; sealed = true ; }
Make all maps and sets immutable .
15,730
public String getOverrideForce ( String configurationId , String parameterName ) { Map < String , String > overrideForceScopeMapEntry = overrideForceScopeMap . get ( configurationId ) ; if ( overrideForceScopeMapEntry != null ) { return overrideForceScopeMapEntry . get ( parameterName ) ; } return null ; }
Lookup force override for given configuration Id .
15,731
public Set < String > getLockedParameterNames ( String configurationId ) { Set < String > lockedParameterNamesScopeMapEntry = lockedParameterNamesScopeMap . get ( configurationId ) ; if ( lockedParameterNamesScopeMapEntry != null ) { return lockedParameterNamesScopeMapEntry ; } else { return ImmutableSet . of ( ) ; } }
Get locked parameter names for specific configuration Id .
15,732
@ GetMapping ( "/setting/download/api/json/all" ) public void downloadApiJsonAll ( HttpServletRequest req , HttpServletResponse res ) { this . validationSessionComponent . sessionCheck ( req ) ; List < ValidationData > list = this . msgSettingService . getAllValidationData ( ) ; ValidationFileUtil . sendFileToHttpServiceResponse ( "validation.json" , list , res ) ; }
Download api json all .
15,733
@ GetMapping ( "/setting/download/api/json" ) public void downloadApiJson ( HttpServletRequest req , @ RequestParam ( "method" ) String method , @ RequestParam ( "url" ) String url , HttpServletResponse res ) { this . validationSessionComponent . sessionCheck ( req ) ; url = new String ( Base64 . getDecoder ( ) . decode ( url ) ) ; List < ValidationData > list = this . msgSettingService . getValidationData ( method , url ) ; ValidationFileUtil . sendFileToHttpServiceResponse ( method + url . replaceAll ( "/" , "-" ) + ".json" , list , res ) ; }
Download api json .
15,734
@ GetMapping ( "/setting/download/api/excel/all" ) public void downloadApiAll ( HttpServletRequest req , HttpServletResponse res ) { this . validationSessionComponent . sessionCheck ( req ) ; PoiWorkBook workBook = this . msgExcelService . getAllExcels ( ) ; workBook . writeFile ( "ValidationApis_" + System . currentTimeMillis ( ) , res ) ; }
Download api all .
15,735
@ GetMapping ( "/setting/download/api/excel" ) public void downloadApi ( HttpServletRequest req , @ RequestParam ( "method" ) String method , @ RequestParam ( "url" ) String url , HttpServletResponse res ) { this . validationSessionComponent . sessionCheck ( req ) ; url = new String ( Base64 . getDecoder ( ) . decode ( url ) ) ; PoiWorkBook workBook = this . msgExcelService . getExcel ( method , url ) ; workBook . writeFile ( "ValidationApis_" + System . currentTimeMillis ( ) , res ) ; }
Download api .
15,736
@ PostMapping ( "/setting/upload/json" ) public void uploadSetting ( HttpServletRequest req ) { this . validationSessionComponent . sessionCheck ( req ) ; this . msgSettingService . updateValidationData ( ( MultipartHttpServletRequest ) req ) ; }
Upload setting .
15,737
@ GetMapping ( "/setting/url/list/all" ) public List < ReqUrl > reqUrlAllList ( HttpServletRequest req ) { this . validationSessionComponent . sessionCheck ( req ) ; return this . msgSettingService . getAllUrlList ( ) ; }
Req url all list list .
15,738
@ GetMapping ( "/setting/param/from/url" ) public List < ValidationData > getValidationDataLists ( HttpServletRequest req ) { this . validationSessionComponent . sessionCheck ( req ) ; ValidationData data = ParameterMapper . requestParamaterToObject ( req , ValidationData . class , "UTF-8" ) ; return this . msgSettingService . getValidationData ( data . getParamType ( ) , data . getMethod ( ) , data . getUrl ( ) ) ; }
Gets validation data lists .
15,739
private int transactionToIndex ( T t ) { Integer r = allTransactions . absoluteIndexOf ( t ) ; return r == null ? - 1 : r . intValue ( ) ; }
maps a transaction to its index and returns - 1 if not found
15,740
private int itemToIndex ( I i ) { Integer r = allItems . absoluteIndexOf ( i ) ; return r == null ? - 1 : r . intValue ( ) ; }
maps an item to its index and returns - 1 if not found
15,741
public boolean add ( T transaction , I item ) { return matrix . add ( transactionToIndex ( transaction ) , itemToIndex ( item ) ) ; }
Adds a single transaction - item pair
15,742
public boolean contains ( T transaction , I item ) { int t = transactionToIndex ( transaction ) ; if ( t < 0 ) return false ; int i = itemToIndex ( item ) ; if ( i < 0 ) return false ; return matrix . contains ( t , i ) ; }
Checks if the given transaction - item pair is contained within the set
15,743
public boolean remove ( T transaction , I item ) { return matrix . remove ( transactionToIndex ( transaction ) , itemToIndex ( item ) ) ; }
Removes a single transaction - item pair
15,744
public boolean removeAll ( Collection < T > trans , Collection < I > items ) { if ( trans == null || trans . isEmpty ( ) || items == null || items . isEmpty ( ) ) return false ; return matrix . removeAll ( allTransactions . convert ( trans ) . indices ( ) , allItems . convert ( items ) . indices ( ) ) ; }
Removes the pairs obtained from the Cartesian product of transactions and items
15,745
public boolean retainAll ( Collection < T > trans , I item ) { if ( isEmpty ( ) ) return false ; if ( trans == null || trans . isEmpty ( ) || item == null ) { clear ( ) ; return true ; } return matrix . retainAll ( allTransactions . convert ( trans ) . indices ( ) , itemToIndex ( item ) ) ; }
Retains the pairs obtained from the Cartesian product of transactions and items
15,746
public IndexedSet < I > itemsOf ( T transaction ) { IndexedSet < I > res = allItems . empty ( ) ; res . indices ( ) . addAll ( matrix . getRow ( transactionToIndex ( transaction ) ) ) ; return res ; }
Lists all items contained within a given transaction
15,747
public IndexedSet < T > transactionsOf ( I item ) { IndexedSet < T > res = allTransactions . empty ( ) ; res . indices ( ) . addAll ( matrix . getCol ( itemToIndex ( item ) ) ) ; return res ; }
Lists all transactions involved with a specified item
15,748
private List < File > unTar ( final File inputFile , final File outputDir ) throws FileNotFoundException , IOException , ArchiveException { _log . info ( String . format ( "Untaring %s to dir %s." , inputFile . getAbsolutePath ( ) , outputDir . getAbsolutePath ( ) ) ) ; final List < File > untaredFiles = new LinkedList < File > ( ) ; final InputStream is = new FileInputStream ( inputFile ) ; final TarArchiveInputStream debInputStream = ( TarArchiveInputStream ) new ArchiveStreamFactory ( ) . createArchiveInputStream ( "tar" , is ) ; TarArchiveEntry entry = null ; while ( ( entry = ( TarArchiveEntry ) debInputStream . getNextEntry ( ) ) != null ) { final File outputFile = new File ( outputDir , entry . getName ( ) ) ; if ( entry . isDirectory ( ) ) { _log . info ( String . format ( "Attempting to write output directory %s." , outputFile . getAbsolutePath ( ) ) ) ; if ( ! outputFile . exists ( ) ) { _log . info ( String . format ( "Attempting to create output directory %s." , outputFile . getAbsolutePath ( ) ) ) ; if ( ! outputFile . mkdirs ( ) ) { throw new IllegalStateException ( String . format ( "Couldn't create directory %s." , outputFile . getAbsolutePath ( ) ) ) ; } } } else { _log . info ( String . format ( "Creating output file %s." , outputFile . getAbsolutePath ( ) ) ) ; final OutputStream outputFileStream = new FileOutputStream ( outputFile ) ; IOUtils . copy ( debInputStream , outputFileStream ) ; outputFileStream . close ( ) ; } untaredFiles . add ( outputFile ) ; } debInputStream . close ( ) ; return untaredFiles ; }
Untar an input file into an output file .
15,749
private void updateLoockup ( ) { synchronized ( parameterOverrideProviders ) { ParameterOverrideInfoLookup newLookup = new ParameterOverrideInfoLookup ( ) ; for ( ParameterOverrideProvider provider : parameterOverrideProviders ) { newLookup . addOverrideMap ( provider . getOverrideMap ( ) ) ; } newLookup . seal ( ) ; lookup = newLookup ; } }
Update lookup maps with override maps from all override providers .
15,750
public static void load ( ) { if ( ! isLoaded ( ) ) { ScriptInjector . fromString ( LocalForageResources . INSTANCE . js ( ) . getText ( ) ) . setWindow ( ScriptInjector . TOP_WINDOW ) . inject ( ) ; } }
Loads the offline library . You normally never have to do this manually
15,751
public static void resetCounters ( ) { unionCount = intersectionCount = differenceCount = symmetricDifferenceCount = complementCount = unionSizeCount = intersectionSizeCount = differenceSizeCount = symmetricDifferenceSizeCount = complementSizeCount = equalsCount = hashCodeCount = containsAllCount = containsAnyCount = containsAtLeastCount = 0 ; }
Resets all counters
15,752
public void setMarkers ( List < GenericMarker > m ) { this . markers = m ; for ( GenericMarker marker : m ) { marker . setMap ( this ) ; } clusterMarkers ( ) ; }
Set markers would be a better description of this method behaviour effectively replaces the references to all markers
15,753
public static void load ( ) { if ( ! isLoaded ( ) ) { ScriptInjector . fromString ( OpenLayersV3Resources . INSTANCE . js ( ) . getText ( ) ) . setWindow ( ScriptInjector . TOP_WINDOW ) . inject ( ) ; StyleInjector . injectStylesheetAtStart ( OpenLayersV3Resources . INSTANCE . css ( ) . getText ( ) ) ; } }
Loads the offline library .
15,754
protected void display ( ) { new FilterPresenter ( new FilterViewUI ( ) ) . go ( layout ) ; resultPresenter = new ResultPresenter ( getResultView ( ) ) ; loadStatusListener . registerObserver ( resultPresenter ) ; resultPresenter . go ( layout ) ; }
Display home screen
15,755
public BaseValidationCheck getValidationChecker ( ValidationRule rule ) { ValidationRule existRule = this . rules . stream ( ) . filter ( r -> r . getRuleName ( ) . equals ( rule . getRuleName ( ) ) ) . findFirst ( ) . orElse ( null ) ; if ( existRule == null ) { throw new ValidationLibException ( "rulename : " + rule . getRuleName ( ) + "checker is notfound " , HttpStatus . INTERNAL_SERVER_ERROR ) ; } return existRule . getValidationCheck ( ) ; }
Gets validation checker .
15,756
public synchronized ValidationRuleStore addRule ( ValidationRule rule ) { rule . setOrderIdx ( this . rules . size ( ) ) ; this . rules . add ( rule ) ; this . checkHashMap . put ( rule . getRuleName ( ) , rule . getValidationCheck ( ) ) ; return this ; }
Add rule validation rule store .
15,757
private static PCM clear_ligne ( PCM pcm , PCM pcm_return ) { List < Product > pdts = pcm . getProducts ( ) ; List < Cell > cells = new ArrayList < Cell > ( ) ; for ( Product pr : pdts ) { float nbCellsEmpty = 0 ; cells = pr . getCells ( ) ; for ( Cell c : cells ) { if ( c . getContent ( ) . isEmpty ( ) ) { nbCellsEmpty ++ ; } } if ( cells . size ( ) != 0 ) { System . out . println ( "Dans les lignes -- > \n Nombre de cellule vide :" + nbCellsEmpty + "\n Nombre de cellule : " + cells . size ( ) ) ; System . out . println ( "Valeur du if : " + nbCellsEmpty / cells . size ( ) ) ; if ( ! ( ( nbCellsEmpty / cells . size ( ) ) > RATIO_EMPTY_CELL ) ) { System . out . println ( "on ajoute la ligne !" ) ; pcm_return . addProduct ( pr ) ; } } } return pcm_return ; }
Enlever les lignes inutiles
15,758
private static PCM clear_colonne ( PCM pcm , PCM pcm_return ) { List < Feature > pdts = pcm . getConcreteFeatures ( ) ; List < Cell > cells = new ArrayList < Cell > ( ) ; for ( Feature pr : pdts ) { float nbCellsEmpty = 0 ; cells = pr . getCells ( ) ; for ( Cell c : cells ) { if ( c . getContent ( ) . isEmpty ( ) ) { nbCellsEmpty ++ ; } } if ( cells . size ( ) != 0 ) { System . out . println ( "Dans les colonnes -- > \n Nombre de cellule vide :" + nbCellsEmpty + "\n Nombre de cellule : " + cells . size ( ) ) ; System . out . println ( "Valeur du if : " + nbCellsEmpty / cells . size ( ) ) ; if ( ! ( ( nbCellsEmpty / cells . size ( ) ) > RATIO_EMPTY_CELL ) ) { System . out . println ( "on ajoute la colonne !" ) ; pcm_return . addFeature ( pr ) ; ; } } } return pcm_return ; }
Enlever les colonnes inutiles
15,759
public boolean sameFeature ( JFeature f ) { return this . name . equals ( f . name ) && this . type . equals ( f . type ) ; }
Compares the name and type of the 2 features
15,760
public static void nodeWalker ( NodeList childNodes , NodeElementParser parser ) throws ParseException { for ( int i = 0 ; i < childNodes . getLength ( ) ; i ++ ) { Node item = childNodes . item ( i ) ; String node = item . getNodeName ( ) ; if ( item . getNodeType ( ) == Node . ELEMENT_NODE ) { parser . parse ( item ) ; } nodeWalker ( item . getChildNodes ( ) , parser ) ; } }
nodeWalker walker implementation simple depth first recursive implementation
15,761
protected boolean isObject ( String text ) { final String trim = text . trim ( ) ; return trim . startsWith ( "{" ) && trim . endsWith ( "}" ) ; }
Checks if the serialized content is a JSON Object .
15,762
@ SuppressWarnings ( "unchecked" ) protected < D > void evalResponse ( Request request , Deferred < D > deferred , Class < D > resolveType , Class < ? > parametrizedType , RawResponse response ) { if ( parametrizedType != null ) { processor . process ( request , response , parametrizedType , ( Class < Collection > ) resolveType , ( Deferred < Collection > ) deferred ) ; } else { processor . process ( request , response , resolveType , deferred ) ; } }
Evaluates the response and resolves the deferred . This method must be called by implementations after the response is received .
15,763
private void assertNotNull ( Object value , String message ) throws IllegalArgumentException { if ( value == null ) { throw new IllegalArgumentException ( message ) ; } }
Assert that the value is not null .
15,764
public List < ReqUrl > getUrlList ( ) { List < ReqUrl > reqUrls = new ArrayList < > ( ) ; for ( String key : this . methodAndUrlIndex . getMap ( ) . keySet ( ) ) { List < ValidationData > datas = this . methodAndUrlIndex . getMap ( ) . get ( key ) ; if ( ! datas . isEmpty ( ) ) { reqUrls . add ( new ReqUrl ( datas . get ( 0 ) . getMethod ( ) , datas . get ( 0 ) . getUrl ( ) ) ) ; } } return reqUrls ; }
Gets url list .
15,765
public ValidationData findById ( Long id ) { List < ValidationData > datas = this . idIndex . get ( ValidationIndexUtil . makeKey ( String . valueOf ( id ) ) ) ; if ( datas . isEmpty ( ) ) { return null ; } return datas . get ( 0 ) ; }
Find by id validation data .
15,766
public void addIndex ( ValidationData data ) { for ( ValidationDataIndex idx : this . idxs ) { ValidationIndexUtil . addIndexData ( data , idx ) ; } }
Add index .
15,767
public void removeIndex ( ValidationData data ) { for ( ValidationDataIndex idx : this . idxs ) { ValidationIndexUtil . removeIndexData ( data , idx ) ; } }
Remove index .
15,768
public void updateFromFile ( MultipartFile file ) { ObjectMapper objectMapper = ValidationObjUtil . getDefaultObjectMapper ( ) ; try { String jsonStr = new String ( file . getBytes ( ) , "UTF-8" ) ; List < ValidationData > list = objectMapper . readValue ( jsonStr , objectMapper . getTypeFactory ( ) . constructCollectionType ( List . class , ValidationData . class ) ) ; List < ReqUrl > reqUrls = ValidationReqUrlUtil . getUrlListFromValidationDatas ( list ) ; reqUrls . forEach ( reqUrl -> { this . deleteValidationData ( reqUrl ) ; } ) ; Map < Long , Long > idsMap = new HashMap < > ( ) ; List < ValidationData > saveList = new ArrayList < > ( ) ; list . forEach ( data -> { long oldId = data . getId ( ) ; data . setId ( null ) ; data = this . validationDataRepository . save ( data ) ; idsMap . put ( oldId , data . getId ( ) ) ; saveList . add ( data ) ; } ) ; saveList . forEach ( data -> { if ( data . getParentId ( ) != null ) { data . setParentId ( idsMap . get ( data . getParentId ( ) ) ) ; this . validationDataRepository . save ( data ) ; } } ) ; } catch ( IOException e ) { log . info ( "file io exception : " + e . getMessage ( ) ) ; } }
Update from file .
15,769
public static boolean isNotScanClass ( String className ) { String block = BASIC_PACKAGE_PREFIX_LIST . stream ( ) . filter ( prefix -> className . startsWith ( prefix ) ) . findAny ( ) . orElse ( null ) ; return block != null ; }
Is not scan class boolean .
15,770
public static boolean isObjClass ( Class < ? > type ) { if ( type . isPrimitive ( ) || type . isEnum ( ) || type . isArray ( ) ) { return false ; } String block = BASIC_PACKAGE_PREFIX_LIST . stream ( ) . filter ( prefix -> type . getName ( ) . startsWith ( prefix ) ) . findAny ( ) . orElse ( null ) ; if ( block != null ) { return false ; } return ! PRIMITIVE_CLASS_LIST . contains ( type ) ; }
Is obj class boolean .
15,771
public static boolean isListClass ( Class < ? > type ) { if ( type . isPrimitive ( ) || type . isEnum ( ) ) { return false ; } return type . equals ( List . class ) ; }
Is list class boolean .
15,772
public void initBeans ( Object [ ] beans ) { this . controllers = Arrays . stream ( beans ) . filter ( bean -> this . getController ( bean ) != null ) . map ( bean -> this . getController ( bean ) ) . collect ( Collectors . toList ( ) ) ; }
Init beans .
15,773
public List < DetailParam > getParameterFromMethodWithAnnotation ( Class < ? > parentClass , Method method , Class < ? > annotationClass ) { List < DetailParam > params = new ArrayList < > ( ) ; if ( method . getParameterCount ( ) < 1 ) { return params ; } for ( Parameter param : method . getParameters ( ) ) { Annotation [ ] annotations = param . getAnnotations ( ) ; for ( Annotation annotation : annotations ) { if ( annotation . annotationType ( ) . equals ( annotationClass ) ) { params . add ( new DetailParam ( param . getType ( ) , method , parentClass ) ) ; break ; } } } return params ; }
Gets parameter from method with annotation .
15,774
public List < DetailParam > getParameterFromClassWithAnnotation ( Class < ? > baseClass , Class < ? > annotationClass ) { List < DetailParam > params = new ArrayList < > ( ) ; Arrays . stream ( baseClass . getDeclaredMethods ( ) ) . forEach ( method -> params . addAll ( this . getParameterFromMethodWithAnnotation ( baseClass , method , annotationClass ) ) ) ; return params ; }
Gets parameter from class with annotation .
15,775
public List < DetailParam > getParameterWithAnnotation ( Class < ? > annotation ) { List < DetailParam > params = new ArrayList < > ( ) ; this . controllers . stream ( ) . forEach ( cla -> params . addAll ( this . getParameterFromClassWithAnnotation ( cla , annotation ) ) ) ; return params ; }
Gets parameter with annotation .
15,776
public Row nextRow ( int cnt ) { Row lastrow = null ; for ( int i = 0 ; i < cnt ; i ++ ) { lastrow = this . nextRow ( ) ; } return lastrow ; }
Next row row .
15,777
public List < Cell > createTitleCells ( String ... strs ) { List < Cell > cells = new ArrayList < > ( ) ; for ( String s : strs ) { Cell cell = this . createTitleCell ( s , DEFAULT_WIDTH ) ; cells . add ( cell ) ; } return cells ; }
Create title cells list .
15,778
public void createTitleCells ( double width , String ... strs ) { for ( String s : strs ) { this . createTitleCell ( s , width ) ; } }
Create title cells .
15,779
public Cell createTitleCell ( String str , double width ) { int cellCnt = this . getCellCnt ( ) ; Cell cell = this . getLastRow ( ) . createCell ( cellCnt ) ; cell . setCellValue ( str ) ; cell . setCellType ( CellType . STRING ) ; cell . setCellStyle ( this . style . getStringCs ( ) ) ; sheet . setColumnWidth ( cellCnt , ( int ) ( sheet . getColumnWidth ( cellCnt ) * width ) ) ; return cell ; }
Create title cell cell .
15,780
public void createValueCells ( Object ... values ) { for ( Object value : values ) { if ( value == null ) { this . createCell ( "" ) ; continue ; } if ( value instanceof String ) { this . createCell ( ( String ) value ) ; } else if ( value instanceof Date ) { this . createCell ( ( Date ) value ) ; } else if ( ValidationObjUtil . isIntType ( value . getClass ( ) ) ) { long longValue = Long . valueOf ( value + "" ) ; this . createCell ( longValue ) ; } else if ( ValidationObjUtil . isDoubleType ( value . getClass ( ) ) ) { double doubleValue = Double . valueOf ( value + "" ) ; this . createCell ( doubleValue ) ; } else { this . createCell ( value ) ; } } }
Create value cells .
15,781
private String printStackTrace ( Object [ ] stackTrace ) { StringBuilder output = new StringBuilder ( ) ; for ( Object line : stackTrace ) { output . append ( line ) ; output . append ( newline ) ; } return output . toString ( ) ; }
Given a stack trace turn it into a HTML formatted string - to improve its display
15,782
public IndexedSet < T > universe ( ) { IntSet allItems = indices . empty ( ) ; allItems . fill ( 0 , indexToItem . length - 1 ) ; return createFromIndices ( allItems ) ; }
Returns the collection of all possible elements
15,783
boolean expiringSoon ( TokenInfo info ) { return Double . valueOf ( info . getExpires ( ) ) < ( clock . now ( ) + TEN_MINUTES ) ; }
Returns whether or not the token will be expiring within the next ten minutes .
15,784
public DataBulkRequest insertBefore ( CRUDRequest request , CRUDRequest before ) { this . requests . add ( requests . indexOf ( before ) , request ) ; return this ; }
Inserts a request before another specified request . This guarantees that the first request parameter will be executed sequentially before the second request parameter . It does not guarantee consecutive execution .
15,785
public DataBulkRequest insertAfter ( CRUDRequest request , CRUDRequest after ) { this . requests . add ( requests . indexOf ( after ) + 1 , request ) ; return this ; }
Inserts a request after another specified request . This guarantees that the first request parameter will be executed sequentially after the second request parameter . It does not guarantee consecutive execution .
15,786
public static String readFileToString ( File file , final Charset charset ) throws IOException { String line = null ; BufferedReader reader = getBufferReader ( file , charset ) ; StringBuffer strBuffer = new StringBuffer ( ) ; while ( ( line = reader . readLine ( ) ) != null ) { strBuffer . append ( line ) ; } return strBuffer . toString ( ) ; }
Read file to string string .
15,787
public static void writeStringToFile ( File file , String content ) throws IOException { OutputStream outputStream = getOutputStream ( file ) ; outputStream . write ( content . getBytes ( ) ) ; }
Write string to file .
15,788
public static String getEncodingFileName ( String fn ) { try { return URLEncoder . encode ( fn , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new ValidationLibException ( "unSupported fiel encoding : " + e . getMessage ( ) , HttpStatus . INTERNAL_SERVER_ERROR ) ; } }
Gets encoding file name .
15,789
public static void initFileSendHeader ( HttpServletResponse res , String filename , String contentType ) { filename = getEncodingFileName ( filename ) ; if ( contentType != null ) { res . setContentType ( contentType ) ; } else { res . setContentType ( "applicaiton/download;charset=utf-8" ) ; } res . setHeader ( "Content-Disposition" , "attachment; filename=\"" + filename + "\";" ) ; res . setHeader ( "Content-Transfer-Encoding" , "binary" ) ; res . setHeader ( "file-name" , filename ) ; }
Init file send header .
15,790
public static DataError fromJson ( ObjectNode node ) { DataError error = new DataError ( ) ; JsonNode x = node . get ( "data" ) ; if ( x != null ) { error . entityData = x ; } x = node . get ( "errors" ) ; if ( x instanceof ArrayNode ) { error . errors = new ArrayList < > ( ) ; for ( Iterator < JsonNode > itr = ( ( ArrayNode ) x ) . elements ( ) ; itr . hasNext ( ) ; ) { error . errors . add ( Error . fromJson ( itr . next ( ) ) ) ; } } return error ; }
Parses a Json object node and returns the DataError corresponding to it . It is up to the client to make sure that the object node is a DataError representation . Any unrecognized elements are ignored .
15,791
public static DataError findErrorForDoc ( List < DataError > list , JsonNode node ) { for ( DataError x : list ) { if ( x . entityData == node ) { return x ; } } return null ; }
Returns the data error for the given json doc in the list
15,792
public void setMarkers ( QueryResult queryResult ) { mapWidget . clearMarkers ( ) ; RecordList recordList = queryResult . getRecordList ( ) ; List < RecordList . Record > records = recordList . getRecords ( ) ; List < GenericMarker > markers = new ArrayList < GenericMarker > ( ) ; final MarkerCoordinateSource markerCoordinateSource1 = getMarkerCoordinateSource ( ) ; final MarkerDisplayFilter markerFilter = getMarkerDisplayFilter ( ) ; markerFilter . init ( ) ; for ( final RecordList . Record record : records ) { MapMarkerBuilder markerBuilder = new MapMarkerBuilder ( ) ; final MarkerCoordinateSource . LatitudeLongitude latitudeLongitude = markerCoordinateSource1 . process ( record ) ; double lat = latitudeLongitude . getLatitude ( ) ; double lon = latitudeLongitude . getLongitude ( ) ; if ( markerFilter . filter ( record ) ) { GenericMarker < RecordList . Record > marker = markerBuilder . setMarkerLat ( lat ) . setMarkerLon ( lon ) . setMarkerIconPathBuilder ( getMarkerIconPathBuilder ( ) ) . createMarker ( record , mapWidget ) ; marker . setupMarkerHoverLabel ( getMarkerHoverLabelBuilder ( ) ) ; marker . setupMarkerClickInfoWindow ( getMarkerClickInfoWindow ( ) ) ; marker . addClickHandler ( new GenericMarker . MarkerCallBackEventHandler < GenericMarker > ( ) { public void run ( GenericMarker sourceElement ) { clientFactory . getEventBus ( ) . fireEvent ( new MarkerClickEvent ( record ) ) ; } } ) ; markers . add ( marker ) ; } } mapWidget . setMarkers ( markers ) ; }
Contain logic for getting records building marker from results Called on start and when filters are changed
15,793
public Uri getUri ( ) { if ( uri == null ) { try { uri = uriBuilder . build ( ) ; } catch ( Exception e ) { throw new IllegalStateException ( "Could not build the URI." , e ) ; } } return uri ; }
Get the URI identifying the resource .
15,794
private < T > void setupMarkerFixedNoRepeatHack ( GoogleV3Marker < T > genericMarker ) { final Marker marker1 = genericMarker . getMarker ( ) ; final LatLng [ ] initialPosition = new LatLng [ 1 ] ; marker1 . addDragStartHandler ( new DragStartMapHandler ( ) { public void onEvent ( DragStartMapEvent dragStartMapEvent ) { initialPosition [ 0 ] = marker1 . getPosition ( ) ; } } ) ; marker1 . addDragEndHandler ( new DragEndMapHandler ( ) { public void onEvent ( DragEndMapEvent dragEndMapEvent ) { marker1 . setPosition ( initialPosition [ 0 ] ) ; } } ) ; }
Prevent marker from repeating horizontally by setting marker drag and adjusting drag behaviour to reset
15,795
public void setComparator ( Column < T , ? > column , Comparator < T > comparator ) { columnSortHandler . setComparator ( column , comparator ) ; }
Sets a comparator to use when sorting the given column
15,796
String toUrl ( Auth . UrlCodex urlCodex ) { return new StringBuilder ( authUrl ) . append ( authUrl . contains ( "?" ) ? "&" : "?" ) . append ( "client_id" ) . append ( "=" ) . append ( urlCodex . encode ( clientId ) ) . append ( "&" ) . append ( "response_type" ) . append ( "=" ) . append ( "token" ) . append ( "&" ) . append ( "scope" ) . append ( "=" ) . append ( scopesToString ( urlCodex ) ) . toString ( ) ; }
Returns a URL representation of this request appending the client ID and scopes to the original authUrl .
15,797
public synchronized static < T > T get ( Class < T > cType ) { if ( map . get ( cType ) != null ) { return cType . cast ( map . get ( cType ) ) ; } try { Object obj = cType . newInstance ( ) ; log . debug ( "[CREATE INSTANCE] : " + cType . getSimpleName ( ) ) ; map . put ( cType , obj ) ; return cType . cast ( obj ) ; } catch ( InstantiationException | IllegalAccessException e ) { log . debug ( e . getMessage ( ) ) ; } return null ; }
Get t .
15,798
public WriteStreamOld openWrite ( ) { if ( _cb != null ) _cb . clear ( ) ; else _cb = CharBuffer . allocate ( ) ; if ( _ws == null ) _ws = new WriteStreamOld ( this ) ; else _ws . init ( this ) ; try { _ws . setEncoding ( "utf-8" ) ; } catch ( UnsupportedEncodingException e ) { } return _ws ; }
Opens a write stream using this StringWriter as the resulting string
15,799
public void write ( byte [ ] buf , int offset , int length , boolean isEnd ) throws IOException { int end = offset + length ; while ( offset < end ) { int ch1 = buf [ offset ++ ] & 0xff ; if ( ch1 < 0x80 ) _cb . append ( ( char ) ch1 ) ; else if ( ( ch1 & 0xe0 ) == 0xc0 ) { if ( offset >= end ) throw new EOFException ( "unexpected end of file in utf8 character" ) ; int ch2 = buf [ offset ++ ] & 0xff ; if ( ( ch2 & 0xc0 ) != 0x80 ) throw new CharConversionException ( "illegal utf8 encoding" ) ; _cb . append ( ( char ) ( ( ( ch1 & 0x1f ) << 6 ) + ( ch2 & 0x3f ) ) ) ; } else if ( ( ch1 & 0xf0 ) == 0xe0 ) { if ( offset + 1 >= end ) throw new EOFException ( "unexpected end of file in utf8 character" ) ; int ch2 = buf [ offset ++ ] & 0xff ; int ch3 = buf [ offset ++ ] & 0xff ; if ( ( ch2 & 0xc0 ) != 0x80 ) throw new CharConversionException ( "illegal utf8 encoding" ) ; if ( ( ch3 & 0xc0 ) != 0x80 ) throw new CharConversionException ( "illegal utf8 encoding" ) ; _cb . append ( ( char ) ( ( ( ch1 & 0x1f ) << 12 ) + ( ( ch2 & 0x3f ) << 6 ) + ( ch3 & 0x3f ) ) ) ; } else throw new CharConversionException ( "illegal utf8 encoding at (" + ( int ) ch1 + ")" ) ; } }
Writes a utf - 8 encoded buffer to the underlying string .