idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
35,400 | protected String calculateTableForMany ( ToMany property , String sessionFactoryBeanName ) { NamingStrategy namingStrategy = getNamingStrategy ( sessionFactoryBeanName ) ; String propertyColumnName = namingStrategy . propertyToColumnName ( property . getName ( ) ) ; //fix for GRAILS-5895 PropertyConfig config = getProp... | Calculates the mapping table for a many - to - many . One side of the relationship has to own the relationship so that there is not a situation where you have two mapping tables for left_right and right_left | 498 | 45 |
35,401 | protected String getTableName ( PersistentEntity domainClass , String sessionFactoryBeanName ) { Mapping m = getMapping ( domainClass ) ; String tableName = null ; if ( m != null && m . getTableName ( ) != null ) { tableName = m . getTableName ( ) ; } if ( tableName == null ) { String shortName = domainClass . getJavaC... | Evaluates the table name for the given property | 176 | 10 |
35,402 | public void bindClass ( PersistentEntity entity , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) throws MappingException { //if (domainClass.getClazz().getSuperclass() == Object.class) { if ( entity . isRoot ( ) ) { bindRoot ( ( HibernatePersistentEntity ) entity , mappings , sessionFactoryBeanNam... | Binds a Grails domain class to the Hibernate runtime meta model | 87 | 16 |
35,403 | protected void trackCustomCascadingSaves ( Mapping mapping , Iterable < PersistentProperty > persistentProperties ) { for ( PersistentProperty property : persistentProperties ) { PropertyConfig propConf = mapping . getPropertyConfig ( property . getName ( ) ) ; if ( propConf != null && propConf . getCascade ( ) != null... | Checks for any custom cascading saves set up via the mapping DSL and records them within the persistent property . | 107 | 22 |
35,404 | protected boolean isSaveUpdateCascade ( String cascade ) { String [ ] cascades = cascade . split ( "," ) ; for ( String cascadeProp : cascades ) { String trimmedProp = cascadeProp . trim ( ) ; if ( CASCADE_SAVE_UPDATE . equals ( trimmedProp ) || CASCADE_ALL . equals ( trimmedProp ) || CASCADE_ALL_DELETE_ORPHAN . equals... | Check if a save - update cascade is defined within the Hibernate cascade properties string . | 106 | 19 |
35,405 | protected void bindClass ( PersistentEntity domainClass , PersistentClass persistentClass , InFlightMetadataCollector mappings ) { // set lazy loading for now persistentClass . setLazy ( true ) ; final String entityName = domainClass . getName ( ) ; persistentClass . setEntityName ( entityName ) ; persistentClass . set... | Binds the specified persistant class to the runtime model based on the properties defined in the domain class | 241 | 20 |
35,406 | protected void addMultiTenantFilterIfNecessary ( HibernatePersistentEntity entity , PersistentClass persistentClass , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { if ( entity . isMultiTenant ( ) ) { TenantId tenantId = entity . getTenantId ( ) ; if ( tenantId != null ) { String filterCondition... | Add a Hibernate filter for multitenancy if the persistent class is multitenant | 208 | 19 |
35,407 | protected void bindSubClasses ( HibernatePersistentEntity domainClass , PersistentClass parent , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { final java . util . Collection < PersistentEntity > subClasses = domainClass . getMappingContext ( ) . getDirectChildEntities ( domainClass ) ; for ( Pe... | Binds the sub classes of a root class using table - per - heirarchy inheritance mapping | 168 | 18 |
35,408 | protected void bindSubClass ( HibernatePersistentEntity sub , PersistentClass parent , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { evaluateMapping ( sub , defaultMapping ) ; Mapping m = getMapping ( parent . getMappedClass ( ) ) ; Subclass subClass ; boolean tablePerSubclass = m != null && ! ... | Binds a sub class . | 692 | 6 |
35,409 | protected void bindJoinedSubClass ( HibernatePersistentEntity sub , JoinedSubclass joinedSubclass , InFlightMetadataCollector mappings , Mapping gormMapping , String sessionFactoryBeanName ) { bindClass ( sub , joinedSubclass , mappings ) ; String schemaName = getSchemaName ( mappings ) ; String catalogName = getCatalo... | Binds a joined sub - class mapping using table - per - subclass | 325 | 14 |
35,410 | protected void bindSubClass ( HibernatePersistentEntity sub , Subclass subClass , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { bindClass ( sub , subClass , mappings ) ; if ( LOG . isDebugEnabled ( ) ) LOG . debug ( "Mapping subclass: " + subClass . getEntityName ( ) + " -> " + subClass . getTa... | Binds a sub - class using table - per - hierarchy inheritance mapping | 120 | 14 |
35,411 | protected void bindDiscriminatorProperty ( Table table , RootClass entity , InFlightMetadataCollector mappings ) { Mapping m = getMapping ( entity . getMappedClass ( ) ) ; SimpleValue d = new SimpleValue ( metadataBuildingContext , table ) ; entity . setDiscriminator ( d ) ; DiscriminatorConfig discriminatorConfig = m ... | Creates and binds the discriminator property used in table - per - hierarchy inheritance to discriminate between sub class instances | 439 | 22 |
35,412 | protected void bindComponent ( Component component , Embedded property , boolean isNullable , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { component . setEmbedded ( true ) ; Class < ? > type = property . getType ( ) ; String role = qualify ( type . getName ( ) , property . getName ( ) ) ; comp... | Binds a Hibernate component type using the given GrailsDomainClassProperty instance | 334 | 18 |
35,413 | @ SuppressWarnings ( "unchecked" ) protected void bindManyToOne ( Association property , ManyToOne manyToOne , String path , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { NamingStrategy namingStrategy = getNamingStrategy ( sessionFactoryBeanName ) ; bindManyToOneValues ( property , manyToOne ) ... | Binds a many - to - one relationship to the | 563 | 11 |
35,414 | private int calculateForeignKeyColumnCount ( PersistentEntity refDomainClass , String [ ] propertyNames ) { int expectedForeignKeyColumnLength = 0 ; for ( String propertyName : propertyNames ) { PersistentProperty referencedProperty = refDomainClass . getPropertyByName ( propertyName ) ; if ( referencedProperty instanc... | number of columns required for a column key we have to perform the calculation here | 161 | 15 |
35,415 | protected void bindProperty ( PersistentProperty grailsProperty , Property prop , InFlightMetadataCollector mappings ) { // set the property name prop . setName ( grailsProperty . getName ( ) ) ; if ( isBidirectionalManyToOneWithListMapping ( grailsProperty , prop ) ) { prop . setInsertable ( false ) ; prop . setUpdate... | Binds a property to Hibernate runtime meta model . Deals with cascade strategy based on the Grails domain model | 500 | 24 |
35,416 | protected void bindSimpleValue ( PersistentProperty property , PersistentProperty parentProperty , SimpleValue simpleValue , String path , InFlightMetadataCollector mappings , String sessionFactoryBeanName ) { // set type bindSimpleValue ( property , parentProperty , simpleValue , path , getPropertyConfig ( property ) ... | Binds a simple value to the Hibernate metamodel . A simple value is any type within the Hibernate type system | 74 | 30 |
35,417 | protected void bindSimpleValue ( String type , SimpleValue simpleValue , boolean nullable , String columnName , InFlightMetadataCollector mappings ) { simpleValue . setTypeName ( type ) ; Table t = simpleValue . getTable ( ) ; Column column = new Column ( ) ; column . setNullable ( nullable ) ; column . setValue ( simp... | Binds a value for the specified parameters to the meta model . | 113 | 13 |
35,418 | protected void bindStringColumnConstraints ( Column column , PersistentProperty constrainedProperty ) { final org . grails . datastore . mapping . config . Property mappedForm = constrainedProperty . getMapping ( ) . getMappedForm ( ) ; Number columnLength = mappedForm . getMaxSize ( ) ; List < ? > inListValues = mappe... | Interrogates the specified constraints looking for any constraints that would limit the length of the property s value . If such constraints exist this method adjusts the length of the column accordingly . | 133 | 35 |
35,419 | public org . grails . datastore . mapping . query . api . ProjectionList property ( String propertyName , String alias ) { final PropertyProjection propertyProjection = Projections . property ( calculatePropertyName ( propertyName ) ) ; addProjectionToList ( propertyProjection , alias ) ; return this ; } | A projection that selects a property name | 68 | 7 |
35,420 | protected void addProjectionToList ( Projection propertyProjection , String alias ) { if ( alias != null ) { projectionList . add ( propertyProjection , alias ) ; } else { projectionList . add ( propertyProjection ) ; } } | Adds a projection to the projectList for the given alias | 52 | 11 |
35,421 | public org . grails . datastore . mapping . query . api . ProjectionList distinct ( String propertyName , String alias ) { final Projection proj = Projections . distinct ( Projections . property ( calculatePropertyName ( propertyName ) ) ) ; addProjectionToList ( proj , alias ) ; return this ; } | A projection that selects a distince property name | 71 | 9 |
35,422 | public BuildableCriteria join ( String associationPath ) { criteria . setFetchMode ( calculatePropertyName ( associationPath ) , FetchMode . JOIN ) ; return this ; } | Use a join query | 39 | 4 |
35,423 | public void lock ( boolean shouldLock ) { String lastAlias = getLastAlias ( ) ; if ( shouldLock ) { if ( lastAlias != null ) { criteria . setLockMode ( lastAlias , LockMode . PESSIMISTIC_WRITE ) ; } else { criteria . setLockMode ( LockMode . PESSIMISTIC_WRITE ) ; } } else { if ( lastAlias != null ) { criteria . setLock... | Whether a pessimistic lock should be obtained . | 124 | 8 |
35,424 | public BuildableCriteria select ( String associationPath ) { criteria . setFetchMode ( calculatePropertyName ( associationPath ) , FetchMode . SELECT ) ; return this ; } | Use a select query | 38 | 4 |
35,425 | protected String calculatePropertyName ( String propertyName ) { String lastAlias = getLastAlias ( ) ; if ( lastAlias != null ) { return lastAlias + ' ' + propertyName ; } return propertyName ; } | Calculates the property name including any alias paths | 45 | 10 |
35,426 | @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) protected Object calculatePropertyValue ( Object propertyValue ) { if ( propertyValue instanceof CharSequence ) { return propertyValue . toString ( ) ; } if ( propertyValue instanceof QueryableCriteria ) { propertyValue = convertToHibernateCriteria ( ( QueryableCriter... | Calculates the property value converting GStrings if necessary | 148 | 12 |
35,427 | public void count ( String propertyName , String alias ) { final CountProjection proj = Projections . count ( calculatePropertyName ( propertyName ) ) ; addProjectionToList ( proj , alias ) ; } | Adds a projection that allows the criteria to return the property count | 46 | 12 |
35,428 | public org . grails . datastore . mapping . query . api . ProjectionList groupProperty ( String propertyName , String alias ) { final PropertyProjection proj = Projections . groupProperty ( calculatePropertyName ( propertyName ) ) ; addProjectionToList ( proj , alias ) ; return this ; } | Adds a projection that allows the criteria s result to be grouped by a property | 68 | 15 |
35,429 | public org . grails . datastore . mapping . query . api . ProjectionList min ( String propertyName , String alias ) { final AggregateProjection aggregateProjection = Projections . min ( calculatePropertyName ( propertyName ) ) ; addProjectionToList ( aggregateProjection , alias ) ; return this ; } | Adds a projection that allows the criteria to retrieve a minimum property value | 69 | 13 |
35,430 | public org . grails . datastore . mapping . query . api . ProjectionList sum ( String propertyName , String alias ) { final AggregateProjection proj = Projections . sum ( calculatePropertyName ( propertyName ) ) ; addProjectionToList ( proj , alias ) ; return this ; } | Adds a projection that allows the criteria to retrieve the sum of the results of a property | 67 | 17 |
35,431 | public void fetchMode ( String associationPath , FetchMode fetchMode ) { if ( criteria != null ) { criteria . setFetchMode ( associationPath , fetchMode ) ; } } | Sets the fetch mode of an associated path | 39 | 9 |
35,432 | public Criteria createAlias ( String associationPath , String alias ) { return criteria . createAlias ( associationPath , alias ) ; } | Join an association assigning an alias to the joined association . | 27 | 11 |
35,433 | public org . grails . datastore . mapping . query . api . Criteria geProperty ( String propertyName , String otherPropertyName ) { if ( ! validateSimpleExpression ( ) ) { throwRuntimeException ( new IllegalArgumentException ( "Call to [geProperty] with propertyName [" + propertyName + "] and other property name [" + ot... | Creates a Criterion that tests if the first property is greater than or equal to the second property | 137 | 20 |
35,434 | public org . grails . datastore . mapping . query . api . Criteria le ( String propertyName , Object propertyValue ) { if ( ! validateSimpleExpression ( ) ) { throwRuntimeException ( new IllegalArgumentException ( "Call to [le] with propertyName [" + propertyName + "] and value [" + propertyValue + "] not allowed here.... | Creates a less than or equal to Criterion based on the specified property name and value | 190 | 18 |
35,435 | @ SuppressWarnings ( "rawtypes" ) public org . grails . datastore . mapping . query . api . Criteria inList ( String propertyName , Collection values ) { return in ( propertyName , values ) ; } | Delegates to in as in is a Groovy keyword | 51 | 11 |
35,436 | public org . grails . datastore . mapping . query . api . Criteria order ( String propertyName , String direction ) { if ( criteria == null ) { throwRuntimeException ( new IllegalArgumentException ( "Call to [order] with propertyName [" + propertyName + "]not allowed here." ) ) ; } propertyName = calculatePropertyName ... | Orders by the specified property name and direction | 155 | 9 |
35,437 | public org . grails . datastore . mapping . query . api . Criteria sizeEq ( String propertyName , int size ) { if ( ! validateSimpleExpression ( ) ) { throwRuntimeException ( new IllegalArgumentException ( "Call to [sizeEq] with propertyName [" + propertyName + "] and size [" + size + "] not allowed here." ) ) ; } prop... | Creates a Criterion that contrains a collection property by size | 119 | 13 |
35,438 | public org . grails . datastore . mapping . query . api . Criteria between ( String propertyName , Object lo , Object hi ) { if ( ! validateSimpleExpression ( ) ) { throwRuntimeException ( new IllegalArgumentException ( "Call to [between] with propertyName [" + propertyName + "] not allowed here." ) ) ; } propertyName ... | Creates a between Criterion based on the property name and specified lo and hi values | 110 | 17 |
35,439 | protected Criterion addToCriteria ( Criterion c ) { if ( ! logicalExpressionStack . isEmpty ( ) ) { logicalExpressionStack . get ( logicalExpressionStack . size ( ) - 1 ) . args . add ( c ) ; } else { criteria . add ( c ) ; } return c ; } | adds and returns the given criterion to the currently active criteria set . this might be either the root criteria or a currently open LogicalExpression . | 68 | 30 |
35,440 | protected Session createSessionProxy ( Session session ) { Class < ? > [ ] sessionIfcs ; Class < ? > mainIfc = Session . class ; if ( session instanceof EventSource ) { sessionIfcs = new Class [ ] { mainIfc , EventSource . class } ; } else if ( session instanceof SessionImplementor ) { sessionIfcs = new Class [ ] { mai... | Create a close - suppressing proxy for the given Hibernate Session . The proxy also prepares returned Query and Criteria objects . | 152 | 26 |
35,441 | protected FlushMode applyFlushMode ( Session session , boolean existingTransaction ) { if ( isApplyFlushModeOnlyToNonExistingTransactions ( ) && existingTransaction ) { return null ; } if ( getFlushMode ( ) == FLUSH_NEVER ) { if ( existingTransaction ) { FlushMode previousFlushMode = session . getHibernateFlushMode ( )... | Apply the flush mode that s been specified for this accessor to the given Session . | 501 | 17 |
35,442 | public static JSONCompareResult compareJSON ( String expectedStr , String actualStr , JSONComparator comparator ) throws JSONException { Object expected = JSONParser . parseJSON ( expectedStr ) ; Object actual = JSONParser . parseJSON ( actualStr ) ; if ( ( expected instanceof JSONObject ) && ( actual instanceof JSONOb... | Compares JSON string provided to the expected JSON string using provided comparator and returns the results of the comparison . | 217 | 22 |
35,443 | public static JSONCompareResult compareJSON ( String expectedStr , String actualStr , JSONCompareMode mode ) throws JSONException { return compareJSON ( expectedStr , actualStr , getComparatorForMode ( mode ) ) ; } | Compares JSON string provided to the expected JSON string and returns the results of the comparison . | 46 | 18 |
35,444 | public boolean matches ( String prefix , Object actual , Object expected , JSONCompareResult result ) throws ValueMatcherException { if ( comparator instanceof LocationAwareValueMatcher ) { return ( ( LocationAwareValueMatcher < Object > ) comparator ) . equal ( prefix , actual , expected , result ) ; } return comparat... | Return true if actual value matches expected value using this Customization s comparator . The equal method used for comparison depends on type of comparator . | 79 | 29 |
35,445 | @ Override public void compareJSONArray ( String prefix , JSONArray expected , JSONArray actual , JSONCompareResult result ) throws JSONException { String arrayPrefix = prefix + "[]" ; if ( expected . length ( ) < 1 || expected . length ( ) > 2 ) { result . fail ( MessageFormat . format ( "{0}: invalid expectation: exp... | Expected array should consist of either 1 or 2 integer values that define maximum and minimum valid lengths of the actual array . If expected array contains a single integer value then the actual array must contain exactly that number of elements . | 516 | 44 |
35,446 | @ Override public final JSONCompareResult compareJSON ( JSONArray expected , JSONArray actual ) throws JSONException { JSONCompareResult result = new JSONCompareResult ( ) ; compareJSONArray ( "" , expected , actual , result ) ; return result ; } | Compares JSONArray provided to the expected JSONArray and returns the results of the comparison . | 52 | 18 |
35,447 | protected void recursivelyCompareJSONArray ( String key , JSONArray expected , JSONArray actual , JSONCompareResult result ) throws JSONException { Set < Integer > matched = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < expected . length ( ) ; ++ i ) { Object expectedElement = expected . get ( i ) ; boolean match... | easy way to uniquely identify each element . | 312 | 8 |
35,448 | public JSONCompareResult missing ( String field , Object expected ) { _fieldMissing . add ( new FieldComparisonFailure ( field , expected , null ) ) ; fail ( formatMissing ( field , expected ) ) ; return this ; } | Identify the missing field | 48 | 5 |
35,449 | public JSONCompareResult unexpected ( String field , Object actual ) { _fieldUnexpected . add ( new FieldComparisonFailure ( field , null , actual ) ) ; fail ( formatUnexpected ( field , actual ) ) ; return this ; } | Identify unexpected field | 50 | 4 |
35,450 | public static boolean allSimpleValues ( JSONArray array ) throws JSONException { for ( int i = 0 ; i < array . length ( ) ; ++ i ) { if ( ! isSimpleValue ( array . get ( i ) ) ) { return false ; } } return true ; } | Returns whether all of the elements in the given array are simple values . | 59 | 14 |
35,451 | private int getPressedColor ( int color ) { float [ ] hsv = new float [ 3 ] ; Color . colorToHSV ( color , hsv ) ; hsv [ 2 ] = hsv [ 2 ] * PRESSED_STATE_MULTIPLIER ; return Color . HSVToColor ( hsv ) ; } | Given a particular color adjusts its value by a multiplier . | 72 | 11 |
35,452 | public void drawPalette ( int [ ] colors , int selectedColor ) { if ( colors == null ) { return ; } this . removeAllViews ( ) ; int tableElements = 0 ; int rowElements = 0 ; int rowNumber = 0 ; // Fills the table with swatches based on the array of colors. TableRow row = createTableRow ( ) ; for ( int color : colors ) ... | Adds swatches to table in a serpentine format . | 265 | 11 |
35,453 | private ImageView createBlankSpace ( ) { ImageView view = new ImageView ( getContext ( ) ) ; TableRow . LayoutParams params = new TableRow . LayoutParams ( mSwatchLength , mSwatchLength ) ; params . setMargins ( mMarginSize , mMarginSize , mMarginSize , mMarginSize ) ; view . setLayoutParams ( params ) ; return view ; ... | Creates a blank space to fill the row . | 92 | 10 |
35,454 | private ColorPickerSwatch createColorSwatch ( int color , int selectedColor ) { ColorPickerSwatch view = new ColorPickerSwatch ( getContext ( ) , color , color == selectedColor , mOnColorSelectedListener ) ; TableRow . LayoutParams params = new TableRow . LayoutParams ( mSwatchLength , mSwatchLength ) ; params . setMar... | Creates a color swatch . | 121 | 7 |
35,455 | public CucumberITGenerator create ( final ParallelScheme parallelScheme ) throws MojoExecutionException { if ( ParallelScheme . FEATURE . equals ( parallelScheme ) ) { return createFileGeneratorByFeature ( ) ; } else { return createFileGeneratorByScenario ( ) ; } } | Create a CucumberITGenerator based on the given parallel scheme . | 67 | 15 |
35,456 | private List < String > createPluginStrings ( ) { final List < String > formatList = new ArrayList < String > ( ) ; for ( final Plugin plugin : overriddenParameters . getPlugins ( ) ) { formatList . add ( plugin . asPluginString ( fileCounter ) ) ; } return formatList ; } | Create the format string used for the output . | 68 | 9 |
35,457 | public void generateCucumberITFiles ( final File outputDirectory , final Collection < File > featureFiles ) throws MojoExecutionException { Parser < GherkinDocument > parser = new Parser < GherkinDocument > ( new AstBuilder ( ) ) ; TagPredicate tagPredicate = new TagPredicate ( overriddenParameters . getTags ( ) ) ; To... | Generates a Cucumber runner for each scenario or example in a scenario outline . | 457 | 17 |
35,458 | public String generate ( final String featureFileName ) { String fileNameWithNoExtension = FilenameUtils . removeExtension ( featureFileName ) ; fileNameWithNoExtension = fileNameWithNoExtension . replaceAll ( "_" , "-" ) ; fileNameWithNoExtension = fileNameWithNoExtension . replaceAll ( " " , "" ) ; fileNameWithNoExte... | Generate a class name based on the supplied feature file . | 181 | 12 |
35,459 | public String generate ( final String featureFileName ) { String className = pattern . replace ( "{f}" , featureFileNamingScheme . generate ( featureFileName ) ) ; int number = counter . next ( ) ; className = replaceAll ( COUNTER_PATTERN , className , number ) ; className = replaceAll ( MODULO_COUNTER_PATTERN , classN... | Generate a class name using the required pattern and feature file . | 95 | 13 |
35,460 | public void execute ( ) throws MojoExecutionException { if ( ! featuresDirectory . exists ( ) ) { throw new MojoExecutionException ( "Features directory does not exist" ) ; } final Collection < File > featureFiles = listFiles ( featuresDirectory , new String [ ] { "feature" } , true ) ; final List < File > sortedFeatur... | Called by Maven to run this mojo after parameters have been injected . | 249 | 16 |
35,461 | private OverriddenCucumberOptionsParameters overrideParametersWithCucumberOptions ( ) throws MojoExecutionException { try { final OverriddenCucumberOptionsParameters overriddenParameters = new OverriddenCucumberOptionsParameters ( ) . setTags ( tags ) . setGlue ( glue ) . setStrict ( strict ) . setPlugins ( parseFormat... | Overrides the parameters with cucumber . options if they have been specified . Plugins have somewhat limited support . | 258 | 23 |
35,462 | public void startSetup ( @ NotNull final OnIabSetupFinishedListener listener ) { if ( options != null ) { Logger . d ( "startSetup() options = " , options ) ; } //noinspection ConstantConditions if ( listener == null ) { throw new IllegalArgumentException ( "Setup listener must be not null!" ) ; } if ( setupState != SE... | Discovers all available stores and selects the best billing service . Should be called from the UI thread | 794 | 20 |
35,463 | public @ Nullable List < Appstore > discoverOpenStores ( ) { if ( Utils . uiThread ( ) ) { throw new IllegalStateException ( "Must not be called from UI thread" ) ; } final List < Appstore > openAppstores = new ArrayList < Appstore > ( ) ; final CountDownLatch countDownLatch = new CountDownLatch ( 1 ) ; discoverOpenSto... | Discovers a list of all available Open Stores . | 179 | 11 |
35,464 | public void discoverOpenStores ( @ NotNull final OpenStoresDiscoveredListener listener ) { final List < ServiceInfo > serviceInfos = queryOpenStoreServices ( ) ; final Queue < Intent > bindServiceIntents = new LinkedList < Intent > ( ) ; for ( final ServiceInfo serviceInfo : serviceInfos ) { bindServiceIntents . add ( ... | Discovers Open Stores . | 114 | 6 |
35,465 | public void queryInventoryAsync ( final boolean querySkuDetails , @ Nullable final List < String > moreItemSkus , @ Nullable final List < String > moreSubsSkus , @ NotNull final IabHelper . QueryInventoryFinishedListener listener ) { checkSetupDone ( "queryInventory" ) ; //noinspection ConstantConditions if ( listener ... | Queries the inventory . This will query all owned items from the server as well as information on additional skus if specified . This method may block or take long to execute . | 303 | 35 |
35,466 | void checkSetupDone ( String operation ) { if ( ! setupSuccessful ( ) ) { String stateToString = setupStateToString ( setupState ) ; Logger . e ( "Illegal state for operation (" , operation , "): " , stateToString ) ; throw new IllegalStateException ( stateToString + " Can't perform operation: " + operation ) ; } } | Checks that setup was done ; if not throws an exception . | 80 | 13 |
35,467 | @ Nullable public List < String > getAllStoreSkus ( @ NotNull final String appstoreName ) { if ( TextUtils . isEmpty ( appstoreName ) ) { throw SkuMappingException . newInstance ( SkuMappingException . REASON_STORE_NAME ) ; } Map < String , String > skuMap = sku2storeSkuMappings . get ( appstoreName ) ; return skuMap =... | Returns a list of SKU for a store . | 125 | 10 |
35,468 | public void onBuyGasButtonClicked ( View arg0 ) { Log . d ( TAG , "Buy gas button clicked." ) ; if ( mSubscribedToInfiniteGas ) { complain ( "No need! You're subscribed to infinite gas. Isn't that awesome?" ) ; return ; } if ( mTank >= TANK_MAX ) { complain ( "Your tank is full. Drive around a bit!" ) ; return ; } if (... | User clicked the Buy Gas button | 273 | 6 |
35,469 | public void onUpgradeAppButtonClicked ( View arg0 ) { Log . d ( TAG , "Upgrade button clicked; launching purchase flow for upgrade." ) ; if ( setupDone == null ) { complain ( "Billing Setup is not completed yet" ) ; return ; } if ( ! setupDone ) { complain ( "Billing Setup failed" ) ; return ; } setWaitScreen ( true ) ... | User clicked the Upgrade to Premium button . | 179 | 8 |
35,470 | public void onInfiniteGasButtonClicked ( View arg0 ) { if ( setupDone == null ) { complain ( "Billing Setup is not completed yet" ) ; return ; } if ( ! setupDone ) { complain ( "Billing Setup failed" ) ; return ; } if ( ! mHelper . subscriptionsSupported ( ) ) { complain ( "Subscriptions not supported on your device ye... | flow for subscription . | 226 | 4 |
35,471 | public void onDriveButtonClicked ( View arg0 ) { Log . d ( TAG , "Drive button clicked." ) ; if ( ! mSubscribedToInfiniteGas && mTank <= 0 ) alert ( R . string . out_of_gas_msg ) ; else { if ( ! mSubscribedToInfiniteGas ) -- mTank ; saveData ( ) ; alert ( R . string . spent_gas_msg ) ; updateUi ( ) ; Log . d ( TAG , "V... | Drive button clicked . Burn gas! | 120 | 7 |
35,472 | @ Override public void onDestroy ( ) { super . onDestroy ( ) ; // very important: Log . d ( TAG , "Destroying helper." ) ; if ( mHelper != null ) mHelper . dispose ( ) ; mHelper = null ; } | We re being destroyed . It s important to dispose of the helper here! | 54 | 15 |
35,473 | public void updateUi ( ) { // update the car color to reflect premium status or lack thereof ( ( ImageView ) findViewById ( R . id . free_or_premium ) ) . setImageResource ( mIsPremium ? R . drawable . premium : R . drawable . free ) ; // "Upgrade" button is only visible if the user is not premium findViewById ( R . id... | updates UI to reflect model | 290 | 6 |
35,474 | void setWaitScreen ( boolean set ) { findViewById ( R . id . screen_main ) . setVisibility ( set ? View . GONE : View . VISIBLE ) ; findViewById ( R . id . screen_wait ) . setVisibility ( set ? View . VISIBLE : View . GONE ) ; } | Enables or disables the please wait screen . | 70 | 10 |
35,475 | @ NotNull public List < String > getAllOwnedSkus ( String itemType ) { List < String > result = new ArrayList < String > ( ) ; for ( Purchase p : mPurchaseMap . values ( ) ) { if ( p . getItemType ( ) . equals ( itemType ) ) result . add ( p . getSku ( ) ) ; } return result ; } | Returns a list of all owned product IDs of a given type | 83 | 12 |
35,476 | public static boolean packageInstalled ( @ NotNull final Context context , @ NotNull final String packageName ) { final PackageManager packageManager = context . getPackageManager ( ) ; boolean result = false ; try { packageManager . getPackageInfo ( packageName , PackageManager . GET_ACTIVITIES ) ; result = true ; } c... | Checks if an application is installed . | 109 | 8 |
35,477 | public static boolean isPackageInstaller ( @ NotNull final Context context , final String packageName ) { final PackageManager packageManager = context . getPackageManager ( ) ; final String installerPackageName = packageManager . getInstallerPackageName ( context . getPackageName ( ) ) ; boolean isPackageInstaller = T... | Checks if an application with the passed name is the installer of the calling app . | 113 | 17 |
35,478 | private static boolean isNookDevice ( ) { String brand = Build . BRAND ; String manufacturer = System . getProperty ( "ro.nook.manufacturer" ) ; return ( ( brand != null && brand . equalsIgnoreCase ( "nook" ) ) || manufacturer != null && manufacturer . equalsIgnoreCase ( "nook" ) ) ; } | todo check for different devices | 77 | 6 |
35,479 | @ Override public boolean isPackageInstaller ( final String packageName ) { Logger . d ( "sPackageInstaller: packageName = " , packageName ) ; final PackageManager packageManager = context . getPackageManager ( ) ; final String installerPackageName = packageManager . getInstallerPackageName ( packageName ) ; Logger . d... | Returns true only if actual installer for specified app | 104 | 9 |
35,480 | private boolean verifyFingreprint ( ) { try { PackageInfo info = context . getPackageManager ( ) . getPackageInfo ( NOKIA_INSTALLER , PackageManager . GET_SIGNATURES ) ; if ( info . signatures . length == 1 ) { byte [ ] cert = info . signatures [ 0 ] . toByteArray ( ) ; MessageDigest digest ; digest = MessageDigest . g... | Checks SHA1 fingerprint of the enabler | 250 | 10 |
35,481 | public static void setLogTag ( final String logTag ) { Logger . logTag = TextUtils . isEmpty ( logTag ) ? LOG_TAG : logTag ; } | Sets the log tag . | 38 | 6 |
35,482 | private void startSetupIabAsync ( final String packageName , final OnIabSetupFinishedListener listener ) { new Thread ( new Runnable ( ) { @ Override public void run ( ) { try { Logger . d ( "Checking for in-app billing 3 support." ) ; // check for in-app billing v3 support int response = mService . isBillingSupported ... | Performs Iab setup with the mService object which must be properly connected before calling this method . | 445 | 20 |
35,483 | protected Intent getServiceIntent ( ) { final Intent intent = new Intent ( GooglePlay . VENDING_ACTION ) ; intent . setPackage ( GooglePlay . ANDROID_INSTALLER ) ; return intent ; } | IabHelper code is shared between OpenStore and Google Play but services has different names | 47 | 17 |
35,484 | public static String getResponseDesc ( int code ) { String [ ] iab_msgs = ( "0:OK/1:User Canceled/2:Unknown/" + "3:Billing Unavailable/4:Item unavailable/" + "5:Developer Error/6:Error/7:Item Already Owned/" + "8:Item not owned" ) . split ( "/" ) ; String [ ] iabhelper_msgs = ( "0:OK/-1001:Remote exception during initi... | Returns a human - readable description for the given response code . | 326 | 12 |
35,485 | private void processPurchaseSuccess ( final String purchaseData ) { Logger . i ( "NokiaStoreHelper.processPurchaseSuccess" ) ; Logger . d ( "purchaseData = " , purchaseData ) ; Purchase purchase ; try { final JSONObject obj = new JSONObject ( purchaseData ) ; final String sku = SkuManager . getInstance ( ) . getSku ( O... | Called if purchase has been successful | 370 | 7 |
35,486 | public static void convertCygwinFilenames ( final String [ ] names ) { if ( names == null ) { throw new NullPointerException ( "names" ) ; } final File gccDir = CUtil . getExecutableLocation ( GccCCompiler . CMD_PREFIX + "gcc.exe" ) ; if ( gccDir != null ) { final String prefix = gccDir . getAbsolutePath ( ) + "/.." ; ... | Converts absolute Cygwin file or directory names to the corresponding Win32 name . | 200 | 17 |
35,487 | public static String [ ] getSpecs ( ) { if ( specs == null ) { final File gccParent = CUtil . getExecutableLocation ( GccCCompiler . CMD_PREFIX + "gcc.exe" ) ; if ( gccParent != null ) { // // build a relative path like // ../lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs // // // resolve it relative to the location of gcc.... | Returns the contents of the gcc specs file . | 300 | 9 |
35,488 | public static void addAll ( final Vector dest , final Object [ ] src ) { if ( src == null ) { return ; } for ( final Object element : src ) { dest . addElement ( element ) ; } } | Adds the elements of the array to the given vector | 46 | 10 |
35,489 | public static int checkDirectoryArray ( final String [ ] names ) { int count = 0 ; for ( int i = 0 ; i < names . length ; i ++ ) { if ( names [ i ] != null ) { final File dir = new File ( names [ i ] ) ; if ( dir . exists ( ) && dir . isDirectory ( ) ) { count ++ ; } else { names [ i ] = null ; } } } return count ; } | Checks a array of names for non existent or non directory entries and nulls them out . | 95 | 20 |
35,490 | public static String getBasename ( final File file ) { final String path = file . getPath ( ) ; // Remove the extension String basename = file . getName ( ) ; final int pos = basename . lastIndexOf ( ' ' ) ; if ( pos != - 1 ) { basename = basename . substring ( 0 , pos ) ; } return basename ; } | Extracts the basename of a file removing the extension if present | 81 | 14 |
35,491 | public static File getExecutableLocation ( final String exeName ) { // // must add current working directory to the // from of the path from the "path" environment variable final File currentDir = new File ( System . getProperty ( "user.dir" ) ) ; if ( new File ( currentDir , exeName ) . exists ( ) ) { return currentDi... | Gets the parent directory for the executable file name using the current directory and system executable path | 144 | 18 |
35,492 | public static String getParentPath ( final String path ) { final int pos = path . lastIndexOf ( File . separator ) ; if ( pos <= 0 ) { return null ; } return path . substring ( 0 , pos ) ; } | Extracts the parent of a file | 51 | 8 |
35,493 | public static File [ ] getPathFromEnvironment ( final String envVariable , final String delim ) { // OS/4000 does not support the env command. if ( System . getProperty ( "os.name" ) . equals ( "OS/400" ) ) { return new File [ ] { } ; } final Vector osEnv = Execute . getProcEnvironment ( ) ; final String match = envVar... | Returns an array of File for each existing directory in the specified environment variable | 235 | 14 |
35,494 | public static boolean isSystemPath ( final File source ) { final String lcPath = source . getAbsolutePath ( ) . toLowerCase ( java . util . Locale . US ) ; return lcPath . contains ( "platformsdk" ) || lcPath . contains ( "windows kits" ) || lcPath . contains ( "microsoft" ) || Objects . equals ( lcPath , "/usr/include... | Determines if source file has a system path that is part of the compiler or platform . | 143 | 19 |
35,495 | public static boolean sameList ( final Object [ ] a , final Object [ ] b ) { if ( a == null || b == null || a . length != b . length ) { return false ; } for ( int i = 0 ; i < a . length ; i ++ ) { if ( ! a [ i ] . equals ( b [ i ] ) ) { return false ; } } return true ; } | Compares the contents of 2 arrays for equaliy . | 85 | 11 |
35,496 | public static boolean sameList ( final Vector v , final Object [ ] a ) { if ( v == null || a == null || v . size ( ) != a . length ) { return false ; } for ( int i = 0 ; i < a . length ; i ++ ) { final Object o = a [ i ] ; if ( ! o . equals ( v . elementAt ( i ) ) ) { return false ; } } return true ; } | Compares the contents of an array and a Vector for equality . | 94 | 13 |
35,497 | public static String [ ] toArray ( final Vector src ) { final String [ ] retval = new String [ src . size ( ) ] ; src . copyInto ( retval ) ; return retval ; } | Converts a vector to a string array . | 45 | 9 |
35,498 | public static String xmlAttribEncode ( final String attrValue ) { final StringBuffer buf = new StringBuffer ( attrValue ) ; int quotePos ; for ( quotePos = - 1 ; ( quotePos = buf . indexOf ( "\"" , quotePos + 1 ) ) >= 0 ; ) { buf . deleteCharAt ( quotePos ) ; buf . insert ( quotePos , """ ) ; quotePos += 5 ; } for... | Replaces any embedded quotes in the string so that the value can be placed in an attribute in an XML file | 225 | 22 |
35,499 | public static void serialize ( final Map propertyList , final List comments , final File file ) throws IOException , SAXException , TransformerConfigurationException { final SAXTransformerFactory sf = ( SAXTransformerFactory ) TransformerFactory . newInstance ( ) ; final TransformerHandler handler = sf . newTransformer... | Serializes a property list into a Cocoa XML Property List document . | 226 | 14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.