idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
27,400 | public TaxRate update ( Map < String , Object > params ) throws StripeException { return update ( params , ( RequestOptions ) null ) ; } | Updates an existing tax rate . |
27,401 | public static Dispute retrieve ( String dispute ) throws StripeException { return retrieve ( dispute , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the dispute with the given ID . |
27,402 | public Dispute close ( ) throws StripeException { return close ( ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Closing the dispute for a charge indicates that you do not have any evidence to submit and are essentially dismissing the dispute acknowledging it as lost . |
27,403 | public static IssuerFraudRecord retrieve ( String issuerFraudRecord ) throws StripeException { return retrieve ( issuerFraudRecord , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the details of an issuer fraud record that has previously been created . |
27,404 | public static WebhookEndpoint retrieve ( String webhookEndpoint ) throws StripeException { return retrieve ( webhookEndpoint , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the webhook endpoint with the given ID . |
27,405 | public static SubscriptionSchedule retrieve ( String schedule ) throws StripeException { return retrieve ( schedule , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the details of an existing subscription schedule . You only need to supply the unique subscription schedule identifier that was returned upon subscription schedule creation . |
27,406 | public static LoginLink createOnAccount ( String account , Map < String , Object > params , RequestOptions options ) throws StripeException { String url = String . format ( "%s%s" , Stripe . getApiBase ( ) , String . format ( "/v1/accounts/%s/login_links" , ApiResource . urlEncodeId ( account ) ) ) ; return request ( ApiResource . RequestMethod . POST , url , params , LoginLink . class , options ) ; } | Creates a single - use login link for an Express account to access their Stripe dashboard . |
27,407 | public static Session retrieve ( String session ) throws StripeException { return retrieve ( session , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves a Session object . |
27,408 | public static ScheduledQueryRun retrieve ( String scheduledQueryRun ) throws StripeException { return retrieve ( scheduledQueryRun , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the details of an scheduled query run . |
27,409 | public static Source retrieve ( String source ) throws StripeException { return retrieve ( source , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves an existing source object . Supply the unique source ID from a source creation request and Stripe will return the corresponding up - to - date source object information . |
27,410 | public Source verify ( Map < String , Object > params ) throws StripeException { return verify ( params , ( RequestOptions ) null ) ; } | Verify a given source . |
27,411 | public static Account retrieve ( RequestOptions options ) throws StripeException { return retrieve ( ( Map < String , Object > ) null , options ) ; } | Retrieves the details of an account . |
27,412 | public static Payout retrieve ( String payout ) throws StripeException { return retrieve ( payout , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the details of an existing payout . Supply the unique payout ID from either a payout creation request or the payout list and Stripe will return the corresponding payout information . |
27,413 | public String get ( String name ) { List < String > valuesList = values ( name ) ; String value = null ; if ( valuesList != null && valuesList . size ( ) > 0 ) { value = valuesList . get ( 0 ) ; } return value ; } | Returns the first header value for a given key . |
27,414 | public static UsageRecord createOnSubscriptionItem ( String subscriptionItem , Map < String , Object > params , RequestOptions options ) throws StripeException { String url = String . format ( "%s%s" , Stripe . getApiBase ( ) , String . format ( "/v1/subscription_items/%s/usage_records" , ApiResource . urlEncodeId ( subscriptionItem ) ) ) ; return request ( ApiResource . RequestMethod . POST , url , params , UsageRecord . class , options ) ; } | Creates a usage record for a specified subscription item and date and fills it with a quantity . |
27,415 | public TransferReversal update ( Map < String , Object > params , RequestOptions options ) throws StripeException { String url ; if ( this . getTransfer ( ) != null ) { url = String . format ( "%s%s" , Stripe . getApiBase ( ) , String . format ( "/v1/transfers/%s/reversals/%s" , ApiResource . urlEncodeId ( this . getTransfer ( ) ) , ApiResource . urlEncodeId ( this . getId ( ) ) ) ) ; } else { throw new InvalidRequestException ( "Unable to construct url because [transfer] field(s) are all null" , null , null , null , 0 , null ) ; } return request ( ApiResource . RequestMethod . POST , url , params , TransferReversal . class , options ) ; } | Updates the specified reversal by setting the values of the parameters passed . Any parameters not provided will be left unchanged . |
27,416 | public static Coupon retrieve ( String coupon , RequestOptions options ) throws StripeException { return retrieve ( coupon , ( Map < String , Object > ) null , options ) ; } | Retrieves the coupon with the given ID . |
27,417 | public static Topup create ( Map < String , Object > params ) throws StripeException { return create ( params , ( RequestOptions ) null ) ; } | Top up the balance of an account . |
27,418 | public static Topup retrieve ( String topup ) throws StripeException { return retrieve ( topup , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the details of a top - up that has previously been created . Supply the unique top - up ID that was returned from your previous request and Stripe will return the corresponding top - up information . |
27,419 | public static CountrySpec retrieve ( String country ) throws StripeException { return retrieve ( country , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Returns a Country Spec for a given Country code . |
27,420 | public static PaymentIntent retrieve ( String intent ) throws StripeException { return retrieve ( intent , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the details of a PaymentIntent that has previously been created . |
27,421 | public PaymentIntent confirm ( ) throws StripeException { return confirm ( ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Confirm that your customer intends to pay with current or provided payment method . Upon confirmation the PaymentIntent will attempt to initiate a payment . |
27,422 | public static Invoice upcoming ( ) throws StripeException { return upcoming ( ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | At any time you can preview the upcoming invoice for a customer . This will show you all the charges that are pending including subscription renewal charges invoice item charges etc . It will also show you any discount that is applicable to the customer . |
27,423 | public static Invoice retrieve ( String invoice ) throws StripeException { return retrieve ( invoice , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the invoice with the given ID . |
27,424 | public Invoice markUncollectible ( ) throws StripeException { return markUncollectible ( ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Marking an invoice as uncollectible is useful for keeping track of bad debts that can be written off for accounting purposes . |
27,425 | public static Charge retrieve ( String charge ) throws StripeException { return retrieve ( charge , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the details of a charge that has previously been created . Supply the unique charge ID that was returned from your previous request and Stripe will return the corresponding charge information . The same information is returned when creating or refunding the charge . |
27,426 | public static ExchangeRate retrieve ( String currency ) throws StripeException { return retrieve ( currency , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the exchange rates from the given currency to every supported currency . |
27,427 | public static ThreeDSecure retrieve ( String threeDSecure ) throws StripeException { return retrieve ( threeDSecure , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves a 3D Secure object . |
27,428 | public static PaymentMethod retrieve ( String paymentMethod , RequestOptions options ) throws StripeException { return retrieve ( paymentMethod , ( Map < String , Object > ) null , options ) ; } | Retrieves a PaymentMethod object . |
27,429 | public PaymentMethod attach ( Map < String , Object > params ) throws StripeException { return attach ( params , ( RequestOptions ) null ) ; } | Attaches a PaymentMethod object to a Customer . |
27,430 | public PaymentMethod detach ( RequestOptions options ) throws StripeException { return detach ( ( Map < String , Object > ) null , options ) ; } | Detaches a PaymentMethod object from a Customer . |
27,431 | public static Transfer retrieve ( String transfer ) throws StripeException { return retrieve ( transfer , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the details of an existing transfer . Supply the unique transfer ID from either a transfer creation request or the transfer list and Stripe will return the corresponding transfer information . |
27,432 | public static Subscription retrieve ( String subscriptionExposedId ) throws StripeException { return retrieve ( subscriptionExposedId , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the subscription with the given ID . |
27,433 | public static void setAppInfo ( String name , String version , String url , String partnerId ) { if ( appInfo == null ) { appInfo = new HashMap < String , String > ( ) ; } appInfo . put ( "name" , name ) ; appInfo . put ( "version" , version ) ; appInfo . put ( "url" , url ) ; appInfo . put ( "partner_id" , partnerId ) ; } | Sets information about your application . The information is passed along to Stripe . |
27,434 | public TaxIdCollection list ( TaxIdCollectionListParams params , RequestOptions options ) throws StripeException { String url = String . format ( "%s%s" , Stripe . getApiBase ( ) , this . getUrl ( ) ) ; return ApiResource . requestCollection ( url , params , TaxIdCollection . class , options ) ; } | Returns a list of tax IDs for a customer . |
27,435 | public static Token retrieve ( String token ) throws StripeException { return retrieve ( token , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the token with the given ID . |
27,436 | public static CreditNote retrieve ( String id , RequestOptions options ) throws StripeException { return retrieve ( id , ( Map < String , Object > ) null , options ) ; } | Retrieves the credit note object with the given identifier . |
27,437 | public EphemeralKey delete ( RequestOptions options ) throws StripeException { return request ( RequestMethod . DELETE , instanceUrl ( EphemeralKey . class , this . id ) , ( Map < String , Object > ) null , EphemeralKey . class , options ) ; } | Invalidates an ephemeral API key for a given resource . |
27,438 | public static String urlEncodeId ( String id ) throws InvalidRequestException { try { return urlEncode ( id ) ; } catch ( UnsupportedEncodingException e ) { throw new InvalidRequestException ( String . format ( "Unable to encode `%s` in the url to %s. " + "Please contact support@stripe.com for assistance." , id , CHARSET ) , null , null , null , 0 , e ) ; } } | URL - encode a string ID in url path formatting . |
27,439 | public static void checkNullTypedParams ( String url , ApiRequestParams params ) { if ( params == null ) { throw new IllegalArgumentException ( String . format ( "Found null params for %s. " + "Please pass empty params using param builder via `builder().build()` instead." , url ) ) ; } } | Invalidate null typed parameters . |
27,440 | public static < T extends HasId > ExpandableField < T > setExpandableFieldId ( String newId , ExpandableField < T > currentObject ) { if ( currentObject == null || ( currentObject . isExpanded ( ) && ! Objects . equals ( currentObject . getId ( ) , newId ) ) ) { return new ExpandableField < > ( newId , null ) ; } return new ExpandableField < > ( newId , currentObject . getExpanded ( ) ) ; } | When setting a String ID for an ExpandableField we need to be careful about keeping the String ID and the expanded object in sync . If they specify a new String ID that is different from the ID within the expanded object we don t keep the object . |
27,441 | public Iterable < T > autoPagingIterable ( Map < String , Object > params , RequestOptions options ) { this . setRequestOptions ( options ) ; this . setRequestParams ( params ) ; return new PagingIterable < > ( this ) ; } | Constructs an iterable that can be used to iterate across all objects across all pages . As page boundaries are encountered the next page will be fetched automatically for continued iteration . |
27,442 | public void addFileField ( String name , String fileName , InputStream inputStream ) throws IOException { writer . append ( "--" ) . append ( boundary ) . append ( LINE_BREAK ) ; writer . append ( "Content-Disposition: form-data; name=\"" ) . append ( name ) . append ( "\"; filename=\"" ) . append ( fileName ) . append ( "\"" ) . append ( LINE_BREAK ) ; String probableContentType = URLConnection . guessContentTypeFromName ( fileName ) ; writer . append ( "Content-Type: " ) . append ( probableContentType ) . append ( LINE_BREAK ) ; writer . append ( "Content-Transfer-Encoding: binary" ) . append ( LINE_BREAK ) ; writer . append ( LINE_BREAK ) ; writer . flush ( ) ; streamToOutput ( inputStream ) ; writer . append ( LINE_BREAK ) ; writer . flush ( ) ; } | Adds a file field to the multipart message but takes in an InputStream instead of just a file to read bytes from . |
27,443 | private void streamToOutput ( InputStream inputStream ) throws IOException { try { byte [ ] buffer = new byte [ 4096 ] ; int bytesRead = - 1 ; while ( ( bytesRead = inputStream . read ( buffer ) ) != - 1 ) { outputStream . write ( buffer , 0 , bytesRead ) ; } outputStream . flush ( ) ; } finally { inputStream . close ( ) ; } } | Utility method to read all the bytes from an InputStream into the outputStream . |
27,444 | public void finish ( ) throws IOException { writer . append ( "--" + boundary + "--" ) . append ( LINE_BREAK ) ; writer . flush ( ) ; writer . close ( ) ; outputStream . flush ( ) ; outputStream . close ( ) ; } | Adds the final boundary to the multipart message and closes streams . |
27,445 | public static String authorizeUrl ( Map < String , Object > params , RequestOptions options ) throws AuthenticationException , InvalidRequestException { final String base = Stripe . getConnectBase ( ) ; params . put ( "client_id" , getClientId ( params , options ) ) ; if ( params . get ( "response_type" ) == null ) { params . put ( "response_type" , "code" ) ; } String query ; try { query = LiveStripeResponseGetter . createQuery ( params ) ; } catch ( UnsupportedEncodingException e ) { throw new InvalidRequestException ( "Unable to encode parameters to " + ApiResource . CHARSET + ". Please contact support@stripe.com for assistance." , null , null , null , 0 , e ) ; } String url = base + "/oauth/authorize?" + query ; return url ; } | Generates a URL to Stripe s OAuth form . |
27,446 | public static TokenResponse token ( Map < String , Object > params , RequestOptions options ) throws StripeException { String url = Stripe . getConnectBase ( ) + "/oauth/token" ; return OAuth . stripeResponseGetter . oauthRequest ( ApiResource . RequestMethod . POST , url , params , TokenResponse . class , ApiResource . RequestType . NORMAL , options ) ; } | Uses an authorization code to connect an account to your platform and fetch the user s credentials . |
27,447 | public static DeauthorizedAccount deauthorize ( Map < String , Object > params , RequestOptions options ) throws StripeException { String url = Stripe . getConnectBase ( ) + "/oauth/deauthorize" ; params . put ( "client_id" , getClientId ( params , options ) ) ; return OAuth . stripeResponseGetter . oauthRequest ( ApiResource . RequestMethod . POST , url , params , DeauthorizedAccount . class , ApiResource . RequestType . NORMAL , options ) ; } | Disconnects an account from your platform . |
27,448 | private static String getClientId ( Map < String , Object > params , RequestOptions options ) throws AuthenticationException { String clientId = Stripe . clientId ; if ( ( options != null ) && ( options . getClientId ( ) != null ) ) { clientId = options . getClientId ( ) ; } if ( ( params != null ) && ( params . get ( "client_id" ) != null ) ) { clientId = ( String ) params . get ( "client_id" ) ; } if ( clientId == null ) { throw new AuthenticationException ( "No client_id provided. (HINT: set client_id key using 'Stripe.clientId = <CLIENT-ID>'. " + "You can find your client_ids in your Stripe dashboard at " + "https://dashboard.stripe.com/account/applications/settings, " + "after registering your account as a platform. See " + "https://stripe.com/docs/connect/standard-accounts for details, " + "or email support@stripe.com if you have any questions." , null , null , 0 ) ; } return clientId ; } | Returns the client_id to use in OAuth requests . |
27,449 | public static FileLink retrieve ( String link ) throws StripeException { return retrieve ( link , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the file link with the given ID . |
27,450 | public static InvoiceItem retrieve ( String invoiceitem ) throws StripeException { return retrieve ( invoiceitem , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the invoice item with the given ID . |
27,451 | public static ApplePayDomain retrieve ( String domain ) throws StripeException { return retrieve ( domain , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieve an apple pay domain . |
27,452 | public static Plan retrieve ( String plan ) throws StripeException { return retrieve ( plan , ( Map < String , Object > ) null , ( RequestOptions ) null ) ; } | Retrieves the plan with the given ID . |
27,453 | public void registerBeanDefinitions ( final AnnotationMetadata importingClassMetadata , final BeanDefinitionRegistry registry ) { Map < String , Object > componentScan = importingClassMetadata . getAnnotationAttributes ( RemoteApplicationEventScan . class . getName ( ) , false ) ; Set < String > basePackages = new HashSet < > ( ) ; for ( String pkg : ( String [ ] ) componentScan . get ( "value" ) ) { if ( StringUtils . hasText ( pkg ) ) { basePackages . add ( pkg ) ; } } for ( String pkg : ( String [ ] ) componentScan . get ( "basePackages" ) ) { if ( StringUtils . hasText ( pkg ) ) { basePackages . add ( pkg ) ; } } for ( Class < ? > clazz : ( Class [ ] ) componentScan . get ( "basePackageClasses" ) ) { basePackages . add ( ClassUtils . getPackageName ( clazz ) ) ; } if ( basePackages . isEmpty ( ) ) { basePackages . add ( ClassUtils . getPackageName ( importingClassMetadata . getClassName ( ) ) ) ; } BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder . genericBeanDefinition ( BusJacksonMessageConverter . class ) ; beanDefinitionBuilder . addPropertyValue ( "packagesToScan" , basePackages . toArray ( new String [ basePackages . size ( ) ] ) ) ; AbstractBeanDefinition beanDefinition = beanDefinitionBuilder . getBeanDefinition ( ) ; BeanDefinitionHolder holder = new BeanDefinitionHolder ( beanDefinition , "busJsonConverter" ) ; BeanDefinitionReaderUtils . registerBeanDefinition ( holder , registry ) ; } | patterned after Spring Integration IntegrationComponentScanRegistrar |
27,454 | @ ConditionalOnMissingBean ( name = "busJsonConverter" ) public AbstractMessageConverter busJsonConverter ( @ Autowired ( required = false ) ObjectMapper objectMapper ) { return new BusJacksonMessageConverter ( objectMapper ) ; } | otherwise RemoteApplicationEventRegistrar will register the bean |
27,455 | private void computeChartSteps ( ) { if ( chartType == GraphPanelChart . CHART_PERCENTAGE ) { minYVal = 0 ; maxYVal = 100 ; return ; } if ( maxYVal - minYVal < 0.1 ) { maxYVal = minYVal + 1 ; } double step = ( maxYVal - minYVal ) / gridLinesCount ; int pow = - 1 ; double factor = - 1 ; boolean found = false ; double testStep ; while ( ! found ) { pow ++ ; for ( double f = 0 ; f < 10 ; f ++ ) { testStep = Math . pow ( 10 , pow ) * f ; if ( testStep >= step ) { factor = f ; found = true ; break ; } } } double foundStep = Math . pow ( 10 , pow ) * factor ; minYVal = minYVal - minYVal % foundStep ; if ( minYVal + foundStep * gridLinesCount < maxYVal ) { foundStep = Math . pow ( 10 , pow ) * ( factor + ( pow > 0 ? 0.5 : 1 ) ) ; } double trim = 10 ; while ( ( minYVal - minYVal % trim ) + foundStep * gridLinesCount >= maxYVal && minYVal > 0 ) { minYVal = minYVal - minYVal % trim ; trim = trim * 10 ; } maxYVal = minYVal + foundStep * gridLinesCount ; } | compute minY and step value to have better readable charts |
27,456 | private void paintAd ( Graphics2D g ) { Font oldFont = g . getFont ( ) ; g . setFont ( g . getFont ( ) . deriveFont ( 10F ) ) ; g . setColor ( axisColor ) ; Composite oldComposite = g . getComposite ( ) ; g . setComposite ( AlphaComposite . getInstance ( AlphaComposite . SRC_OVER , 0.7f ) ) ; g . drawString ( AD_TEXT , g . getClipBounds ( ) . width - g . getFontMetrics ( ) . stringWidth ( AD_TEXT ) - spacing , g . getFontMetrics ( ) . getHeight ( ) - spacing + 1 ) ; g . setComposite ( oldComposite ) ; g . setFont ( oldFont ) ; } | Paint the add the same color of the axis but with transparency |
27,457 | private void registerPopup ( boolean allowCsvExport ) { this . setComponentPopupMenu ( popup ) ; JMenuItem itemCopy = new JMenuItem ( "Copy Image to Clipboard" ) ; itemCopy . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/kg/apc/jmeter/img/copy.png" ) ) ) ; JMenuItem itemSave = new JMenuItem ( "Save Image as..." ) ; itemSave . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/kg/apc/jmeter/img/save.png" ) ) ) ; JMenuItem itemExport = new JMenuItem ( "Export to CSV..." ) ; itemExport . setIcon ( new javax . swing . ImageIcon ( getClass ( ) . getResource ( "/kg/apc/jmeter/img/export.png" ) ) ) ; itemCopy . addActionListener ( new CopyAction ( ) ) ; itemSave . addActionListener ( new SaveAction ( ) ) ; itemExport . addActionListener ( new CsvExportAction ( ) ) ; popup . add ( itemCopy ) ; popup . add ( itemSave ) ; if ( allowCsvExport ) { popup . addSeparator ( ) ; popup . add ( itemExport ) ; } } | Thanks to stephane . hoblingre |
27,458 | public void stateChanged ( ChangeEvent e ) { log . debug ( "getting new collector" ) ; collector = ( CorrectedResultCollector ) createTestElement ( ) ; if ( collector instanceof CorrectedResultCollector ) { setUpFiltering ( ( CorrectedResultCollector ) collector ) ; } collector . loadExistingFile ( ) ; } | Invoked when the target of the listener has changed its state . This implementation assumes that the target is the FilePanel and will update the result collector for the new filename . |
27,459 | public String setValue ( String value ) { String result = this . value ; this . value = value ; calculateCompareKey ( ) ; return result ; } | Property value setter . |
27,460 | protected ListedHashTree cloneTree ( ListedHashTree tree ) { TreeCloner cloner = new TreeCloner ( true ) ; tree . traverse ( cloner ) ; ListedHashTree clonedTree = cloner . getClonedTree ( ) ; if ( ! clonedTree . isEmpty ( ) ) { Object firstElement = clonedTree . getArray ( ) [ 0 ] ; Controller samplerController = ( ( AbstractDynamicThreadGroup ) firstElement ) . getSamplerController ( ) ; if ( samplerController instanceof VirtualUserController ) { assert owner != null ; ( ( VirtualUserController ) samplerController ) . setOwner ( owner ) ; } } return clonedTree ; } | had to copy it from ThreadGroup |
27,461 | private void syncContext ( boolean isInit ) { JMeterContext current = JMeterContextService . getContext ( ) ; JMeterContext ctx = this . getThreadContext ( ) ; if ( isInit ) { current . setCurrentSampler ( ctx . getCurrentSampler ( ) ) ; current . setEngine ( ctx . getEngine ( ) ) ; current . setRestartNextLoop ( ctx . isRestartNextLoop ( ) ) ; current . setSamplingStarted ( ctx . isSamplingStarted ( ) ) ; current . setThread ( ctx . getThread ( ) ) ; current . setThreadGroup ( ctx . getThreadGroup ( ) ) ; current . setThreadNum ( ctx . getThreadNum ( ) ) ; } current . setVariables ( ctx . getVariables ( ) ) ; current . setPreviousResult ( ctx . getPreviousResult ( ) ) ; } | Update the worker thread jmeter context with the main thread one |
27,462 | public void replaceRowTab ( String tabLabel , Component object , String toolTipText ) { int index = indexOfComponent ( rowsTab ) ; remove ( index ) ; ImageIcon rowsIcon = createImageIcon ( "/kg/apc/jmeter/img/checks.png" ) ; insertTab ( tabLabel , rowsIcon , object , toolTipText , index ) ; } | Method used only for change row selector tab in Composite Chart |
27,463 | public void stop ( ) { running = false ; threadStarter . interrupt ( ) ; for ( DynamicThread thread : threads ) { thread . interrupt ( ) ; thread . interruptOSThread ( ) ; } } | Forceful stop of test calls this |
27,464 | protected double getCurrentRate ( ) { long rampUp = owner . getRampUpSeconds ( ) ; long hold = owner . getHoldSeconds ( ) ; long steps = owner . getStepsAsLong ( ) ; double throughput = owner . getTargetLevelFactored ( ) ; double timeOffset = rollingTime / 1000.0 - startTime ; if ( timeOffset >= rampUp + hold ) { return - 1 ; } if ( rampUp == 0 || timeOffset > rampUp ) { return throughput ; } else if ( steps > 0 ) { double stepSize = throughput / ( double ) steps ; double stepLen = rampUp / ( double ) steps ; return stepSize * ( Math . floor ( timeOffset / stepLen ) + 1 ) ; } else { double slope = throughput / rampUp ; return slope * Math . sqrt ( 2 * scheduledCount / slope ) ; } } | ported from Taurus PBench module |
27,465 | public static String buildHelpPageUrl ( String helpPage ) { try { if ( helpPage . matches ( "[hH][tT][tT][pP][sS]?://.*" ) ) { log . debug ( "Help page URL found, skipping building link to " + WIKI_BASE ) ; return helpPage ; } } catch ( PatternSyntaxException ex ) { log . warn ( "Invalid regex" , ex ) ; } if ( helpPage . endsWith ( "Gui" ) ) { helpPage = helpPage . substring ( 0 , helpPage . length ( ) - 3 ) ; } return WIKI_BASE + helpPage + "/?utm_source=jmeter&utm_medium=helplink&utm_campaign=" + helpPage ; } | Builds full URL from wiki page name unless a URL is already passed in . |
27,466 | public static Component addHelpLinkToPanel ( Container panel , String helpPage ) { if ( ! java . awt . Desktop . isDesktopSupported ( ) ) { return panel ; } JLabel icon = new JLabel ( ) ; icon . setIcon ( new javax . swing . ImageIcon ( JMeterPluginsUtils . class . getResource ( "vizualizers/information.png" ) ) ) ; JLabel link = new JLabel ( "Help on this plugin" ) ; link . setForeground ( Color . blue ) ; link . setFont ( link . getFont ( ) . deriveFont ( Font . PLAIN ) ) ; link . setCursor ( new Cursor ( Cursor . HAND_CURSOR ) ) ; link . addMouseListener ( new URIOpener ( buildHelpPageUrl ( helpPage ) ) ) ; Border border = BorderFactory . createMatteBorder ( 0 , 0 , 1 , 0 , java . awt . Color . blue ) ; link . setBorder ( border ) ; JLabel version = new JLabel ( "" ) ; version . setFont ( version . getFont ( ) . deriveFont ( Font . PLAIN ) . deriveFont ( 11F ) ) ; version . setForeground ( Color . GRAY ) ; Container innerPanel = findComponentWithBorder ( ( JComponent ) panel , EtchedBorder . class ) ; JPanel panelLink = new JPanel ( new GridBagLayout ( ) ) ; GridBagConstraints gridBagConstraints ; gridBagConstraints = new java . awt . GridBagConstraints ( ) ; gridBagConstraints . gridx = 0 ; gridBagConstraints . gridy = 0 ; gridBagConstraints . insets = new java . awt . Insets ( 0 , 1 , 0 , 0 ) ; panelLink . add ( icon , gridBagConstraints ) ; gridBagConstraints = new java . awt . GridBagConstraints ( ) ; gridBagConstraints . gridx = 1 ; gridBagConstraints . gridy = 0 ; gridBagConstraints . anchor = java . awt . GridBagConstraints . WEST ; gridBagConstraints . weightx = 1.0 ; gridBagConstraints . insets = new java . awt . Insets ( 0 , 2 , 3 , 0 ) ; panelLink . add ( link , gridBagConstraints ) ; gridBagConstraints = new java . awt . GridBagConstraints ( ) ; gridBagConstraints . gridx = 2 ; gridBagConstraints . gridy = 0 ; gridBagConstraints . insets = new java . awt . Insets ( 0 , 0 , 0 , 4 ) ; panelLink . add ( version , gridBagConstraints ) ; if ( innerPanel != null ) { innerPanel . add ( panelLink ) ; } else { panel . add ( panelLink ) ; } return panel ; } | Find in panel appropriate place and put hyperlink there . I know that it is stupid way . But the result is so good! |
27,467 | private static void initializeProperties ( ) { JMeterUtils . loadJMeterProperties ( JMeterUtils . getJMeterHome ( ) + File . separator + "bin" + File . separator + "jmeter.properties" ) ; JMeterUtils . initLocale ( ) ; Properties jmeterProps = JMeterUtils . getJMeterProperties ( ) ; String userProp = JMeterUtils . getPropDefault ( "user.properties" , "" ) ; if ( userProp . length ( ) > 0 ) { FileInputStream fis = null ; try { File file = JMeterUtils . findFile ( userProp ) ; if ( file . canRead ( ) ) { log . info ( "Loading user properties from: " + file . getCanonicalPath ( ) ) ; fis = new FileInputStream ( file ) ; Properties tmp = new Properties ( ) ; tmp . load ( fis ) ; jmeterProps . putAll ( tmp ) ; LoggingManager . setLoggingLevels ( jmeterProps ) ; } } catch ( IOException e ) { log . warn ( "Error loading user property file: " + userProp , e ) ; } finally { try { if ( fis != null ) { fis . close ( ) ; } } catch ( IOException ex ) { log . warn ( "There was problem closing file stream" , ex ) ; } } } String sysProp = JMeterUtils . getPropDefault ( "system.properties" , "" ) ; if ( sysProp . length ( ) > 0 ) { FileInputStream fis = null ; try { File file = JMeterUtils . findFile ( sysProp ) ; if ( file . canRead ( ) ) { log . info ( "Loading system properties from: " + file . getCanonicalPath ( ) ) ; fis = new FileInputStream ( file ) ; System . getProperties ( ) . load ( fis ) ; } } catch ( IOException e ) { log . warn ( "Error loading system property file: " + sysProp , e ) ; } finally { try { if ( fis != null ) { fis . close ( ) ; } } catch ( IOException ex ) { log . warn ( "There was problem closing file stream" , ex ) ; } } } } | Had to copy this method from JMeter class cause they provide no ways to re - use this code |
27,468 | public void scheduleThread ( JMeterThread thread ) { if ( System . currentTimeMillis ( ) - tgStartTime > TOLERANCE ) { tgStartTime = System . currentTimeMillis ( ) ; } scheduleThread ( thread , tgStartTime ) ; } | JMeter 2 . 7 compatibility |
27,469 | void checkNeedsPropertiesReloading ( long now ) { if ( CACHING_VALIDITY_MS > 0 && now - lastCachedTime > CACHING_VALIDITY_MS ) { this . rampUp = owner . getRampUpSeconds ( ) ; this . hold = owner . getHoldSeconds ( ) ; this . steps = owner . getStepsAsLong ( ) ; this . maxConcurr = owner . getTargetLevelAsDouble ( ) ; this . defaultShiftRampup = JMeterUtils . getPropDefault ( "dynamic_tg.shift_rampup_start" , 0L ) ; this . lastCachedTime = System . currentTimeMillis ( ) ; } } | Check if we need to reload properties |
27,470 | private void initGui ( ) { totalThreads . setText ( "100" ) ; initialDelay . setText ( "0" ) ; incUserCount . setText ( "10" ) ; incUserCountBurst . setText ( "0" ) ; incUserPeriod . setText ( "30" ) ; flightTime . setText ( "60" ) ; decUserCount . setText ( "5" ) ; decUserPeriod . setText ( "1" ) ; rampUp . setText ( "5" ) ; } | Initialise the gui field values |
27,471 | public void paintBorder ( Component c , Graphics g , int x , int y , int width , int height ) { float x2 = ( width - component . getWidth ( ) ) * component . getAlignmentX ( ) + x ; float y2 = ( height - component . getHeight ( ) ) * component . getAlignmentY ( ) + y ; component . setLocation ( ( int ) x2 , ( int ) y2 ) ; } | In this case a real component is to be painted . Setting the location of the component will cause it to be painted at that location . |
27,472 | private void determineInsetsAndAlignment ( ) { borderInsets = new Insets ( 0 , 0 , 0 , 0 ) ; if ( edge == Edge . TOP ) { borderInsets . top = component . getPreferredSize ( ) . height + gap ; component . setAlignmentX ( alignment ) ; component . setAlignmentY ( 0.0f ) ; } else if ( edge == Edge . BOTTOM ) { borderInsets . bottom = component . getPreferredSize ( ) . height + gap ; component . setAlignmentX ( alignment ) ; component . setAlignmentY ( 1.0f ) ; } else if ( edge == Edge . LEFT ) { borderInsets . left = component . getPreferredSize ( ) . width + gap ; component . setAlignmentX ( 0.0f ) ; component . setAlignmentY ( alignment ) ; } else if ( edge == Edge . RIGHT ) { borderInsets . right = component . getPreferredSize ( ) . width + gap ; component . setAlignmentX ( 1.0f ) ; component . setAlignmentY ( alignment ) ; } if ( adjustInsets ) { adjustBorderInsets ( ) ; } } | The insets need to be determined so they are included in the preferred size of the component the Border is attached to . |
27,473 | public void waitThreadStopped ( ) { long sleepTime = threads . isEmpty ( ) ? DEFAULT_TEMPORISATION : MIN_CHECK_TIME ; lock . lock ( ) ; try { condition . await ( sleepTime , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException e ) { log . debug ( "Interrupted" , e ) ; Thread . currentThread ( ) . interrupt ( ) ; } finally { lock . unlock ( ) ; } } | If threads is empty we wait on condition for DEFAULT_TEMPORISATION millis to be notified otherwise we wait for 1s |
27,474 | public void generateSample ( double value , String label ) { PerfMonSampleResult res = new PerfMonSampleResult ( ) ; res . setSampleLabel ( label ) ; res . setValue ( value ) ; res . setSuccessful ( true ) ; SampleEvent e = new SampleEvent ( res , PERFMON ) ; super . sampleOccurred ( e ) ; } | need floating point precision for memory and cpu |
27,475 | public void generate2Samples ( long [ ] values , String label1 , String label2 , double dividingFactor ) { if ( oldValues . containsKey ( label1 ) && oldValues . containsKey ( label2 ) ) { generateSample ( ( ( double ) ( values [ 0 ] - oldValues . get ( label1 ) ) ) / dividingFactor , label1 ) ; generateSample ( ( ( double ) ( values [ 1 ] - oldValues . get ( label2 ) ) ) / dividingFactor , label2 ) ; } oldValues . put ( label1 , values [ 0 ] ) ; oldValues . put ( label2 , values [ 1 ] ) ; } | float precision required for net io |
27,476 | public void stop ( ) { try { safeClose ( myServerSocket ) ; closeAllConnections ( ) ; myThread . join ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } | Stop the server . |
27,477 | private void compileColumns ( ) { log . debug ( "Compiling columns string: " + getColumns ( ) ) ; String [ ] chunks = JMeterPluginsUtils . replaceRNT ( getColumns ( ) ) . split ( "\\|" ) ; log . debug ( "Chunks " + chunks . length ) ; compiledFields = new int [ chunks . length ] ; compiledVars = new int [ chunks . length ] ; compiledConsts = new ByteBuffer [ chunks . length ] ; for ( int n = 0 ; n < chunks . length ; n ++ ) { int fieldID = availableFieldNames . indexOf ( chunks [ n ] ) ; if ( fieldID >= 0 ) { compiledFields [ n ] = fieldID ; } else { compiledFields [ n ] = - 1 ; compiledVars [ n ] = - 1 ; if ( chunks [ n ] . contains ( VAR_PREFIX ) ) { log . debug ( chunks [ n ] + " is sample variable" ) ; String varN = chunks [ n ] . substring ( VAR_PREFIX . length ( ) ) ; try { compiledVars [ n ] = Integer . parseInt ( varN ) ; } catch ( NumberFormatException e ) { log . error ( "Seems it is not variable spec: " + chunks [ n ] ) ; compiledConsts [ n ] = ByteBuffer . wrap ( chunks [ n ] . getBytes ( ) ) ; } } else { log . debug ( chunks [ n ] + " is const" ) ; if ( chunks [ n ] . length ( ) == 0 ) { chunks [ n ] = "|" ; } compiledConsts [ n ] = ByteBuffer . wrap ( chunks [ n ] . getBytes ( ) ) ; } } } } | making this once to be efficient and avoid manipulating strings in switch operators |
27,478 | static ObjectTableModel createObjectTableModel ( ) { return new ObjectTableModel ( COLUMNS , SamplingStatCalculator . class , new Functor [ ] { new Functor ( "getLabel" ) , new Functor ( "getCount" ) , new Functor ( "getMeanAsNumber" ) , new Functor ( "getMin" ) , new Functor ( "getMax" ) , new Functor ( "getPercentPoint" , new Object [ ] { pct1Value } ) , new Functor ( "getStandardDeviation" ) , new Functor ( "getErrorPercentage" ) , new Functor ( "getRate" ) , new Functor ( "getKBPerSecond" ) , new Functor ( "getAvgPageBytes" ) , } , new Functor [ ] { null , null , null , null , null , null , null , null , null , null , null } , new Class [ ] { String . class , Long . class , Long . class , Long . class , Long . class , Long . class , String . class , String . class , String . class , String . class , String . class } ) ; } | Creates that Table model |
27,479 | public static List < List < Object > > getAllTableData ( ObjectTableModel model , Format [ ] formats ) { List < List < Object > > data = new ArrayList < > ( ) ; if ( model . getRowCount ( ) > 0 ) { for ( int rw = 0 ; rw < model . getRowCount ( ) ; rw ++ ) { int cols = model . getColumnCount ( ) ; List < Object > column = new ArrayList < > ( ) ; data . add ( column ) ; for ( int idx = 0 ; idx < cols ; idx ++ ) { Object val = model . getValueAt ( rw , idx ) ; if ( formats [ idx ] != null ) { column . add ( formats [ idx ] . format ( val ) ) ; } else { column . add ( val ) ; } } } } return data ; } | We use this method to get the data since we are using ObjectTableModel so the calling getDataVector doesn t work as expected . |
27,480 | public static DefaultTableModel getAllDataAsTable ( ObjectTableModel model , Format [ ] formats , String [ ] columns ) { final List < List < Object > > table = getAllTableData ( model , formats ) ; final DefaultTableModel tableModel = new DefaultTableModel ( ) ; for ( String header : columns ) { tableModel . addColumn ( header ) ; } for ( List < Object > row : table ) { tableModel . addRow ( new Vector ( row ) ) ; } return tableModel ; } | Present data in javax . swing . table . DefaultTableModel form . |
27,481 | public synchronized long delay ( ) { while ( true ) { long curTimeMs = System . currentTimeMillis ( ) ; long millisSinceLastSecond = curTimeMs % 1000 ; long nowInMsRoundedAtSec = curTimeMs - millisSinceLastSecond ; checkNextSecond ( nowInMsRoundedAtSec ) ; int delayMs = getDelay ( millisSinceLastSecond ) ; if ( stopping ) { delayMs = delayMs > 0 ? 10 : 0 ; notify ( ) ; } if ( delayMs < 1 ) { notify ( ) ; break ; } cntDelayed ++ ; try { wait ( delayMs ) ; } catch ( InterruptedException ex ) { log . debug ( "Waiting thread was interrupted" , ex ) ; Thread . currentThread ( ) . interrupt ( ) ; } cntDelayed -- ; } cntSent ++ ; return 0 ; } | Internally handles that delay for caller thread |
27,482 | protected String changeCase ( String originalString , String mode ) { String targetString = originalString ; CaseFormatMode changeCaseMode = CaseFormatMode . get ( mode . toUpperCase ( ) ) ; if ( changeCaseMode != null ) { switch ( changeCaseMode ) { case LOWER_CAMEL_CASE : targetString = camelFormat ( originalString , false ) ; break ; case UPPER_CAMEL_CASE : targetString = camelFormat ( originalString , true ) ; break ; case SNAKE_CASE : case LOWER_UNDERSCORE : targetString = caseFormatWithDelimiter ( originalString , UNDERSCORE , false , true ) ; break ; case KEBAB_CASE : case LISP_CASE : case SPINAL_CASE : case LOWER_HYPHEN : targetString = caseFormatWithDelimiter ( originalString , HYPHEN_MINUS , false , true ) ; break ; case TRAIN_CASE : targetString = caseFormatWithDelimiter ( originalString , HYPHEN_MINUS , true , false ) ; break ; case UPPER_UNDERSCORE : targetString = caseFormatWithDelimiter ( originalString , UNDERSCORE , true , false ) ; break ; default : } } else { LOGGER . error ( "Unknown mode {}, returning {} unchanged" , mode , targetString ) ; } return targetString ; } | Change case options |
27,483 | private static String camelFormat ( String str , boolean isFirstCapitalized ) { StringBuilder builder = new StringBuilder ( str . length ( ) ) ; String [ ] tokens = NOT_ALPHANUMERIC_REGEX . split ( str ) ; for ( int i = 0 ; i < tokens . length ; i ++ ) { String lowerCased = StringUtils . lowerCase ( tokens [ i ] ) ; if ( i == 0 ) { builder . append ( isFirstCapitalized ? StringUtils . capitalize ( lowerCased ) : lowerCased ) ; } else { builder . append ( StringUtils . capitalize ( lowerCased ) ) ; } } return builder . toString ( ) ; } | Camel format string |
27,484 | private static String caseFormatWithDelimiter ( String str , String delimiter , boolean isAllUpper , boolean isAllLower ) { StringBuilder builder = new StringBuilder ( str . length ( ) ) ; String [ ] tokens = NOT_ALPHANUMERIC_REGEX . split ( str ) ; boolean shouldAddDelimiter = StringUtils . isNotEmpty ( delimiter ) ; for ( int i = 0 ; i < tokens . length ; i ++ ) { String currentToken = tokens [ i ] ; builder . append ( currentToken ) ; boolean hasNextToken = i + 1 != tokens . length ; if ( hasNextToken && shouldAddDelimiter ) { builder . append ( delimiter ) ; } } String outputString = builder . toString ( ) ; if ( isAllLower ) { return StringUtils . lowerCase ( outputString ) ; } else if ( isAllUpper ) { return StringUtils . upperCase ( outputString ) ; } return outputString ; } | Change case using delimiter between words |
27,485 | private final void addVariableValue ( String value , String variableName ) { if ( StringUtils . isNotEmpty ( variableName ) ) { JMeterVariables vars = getVariables ( ) ; if ( vars != null ) { vars . put ( variableName , value ) ; } } } | Store value in a variable |
27,486 | private void copyPrivateRawResourceToPubliclyAccessibleFile ( ) { InputStream inputStream = null ; FileOutputStream outputStream = null ; try { inputStream = getResources ( ) . openRawResource ( R . raw . robot ) ; outputStream = openFileOutput ( SHARED_FILE_NAME , Context . MODE_WORLD_READABLE | Context . MODE_APPEND ) ; byte [ ] buffer = new byte [ 1024 ] ; int length = 0 ; try { while ( ( length = inputStream . read ( buffer ) ) > 0 ) { outputStream . write ( buffer , 0 , length ) ; } } catch ( IOException ioe ) { } } catch ( FileNotFoundException fnfe ) { } finally { try { inputStream . close ( ) ; } catch ( IOException ioe ) { } try { outputStream . close ( ) ; } catch ( IOException ioe ) { } } } | Copies a private raw resource content to a publicly readable file such that the latter can be shared with other applications . |
27,487 | protected void addItemView ( View itemView , int childIndex ) { final ViewGroup currentParent = ( ViewGroup ) itemView . getParent ( ) ; if ( currentParent != null ) { currentParent . removeView ( itemView ) ; } ( ( ViewGroup ) mMenuView ) . addView ( itemView , childIndex ) ; } | Add an item view at the given index . |
27,488 | public MenuView . ItemView createItemView ( ViewGroup parent ) { return ( MenuView . ItemView ) mSystemInflater . inflate ( mItemLayoutRes , parent , false ) ; } | Create a new item view that can be re - bound to other item data later . |
27,489 | public View getItemView ( MenuItemImpl item , View convertView , ViewGroup parent ) { MenuView . ItemView itemView ; if ( convertView instanceof MenuView . ItemView ) { itemView = ( MenuView . ItemView ) convertView ; } else { itemView = createItemView ( parent ) ; } bindItemView ( item , itemView ) ; return ( View ) itemView ; } | Prepare an item view for use . See AdapterView for the basic idea at work here . This may require creating a new item view but well - behaved implementations will re - use the view passed as convertView if present . The returned view will be populated with data from the item parameter . |
27,490 | public boolean showOverflowMenu ( ) { if ( mReserveOverflow && ! isOverflowMenuShowing ( ) && mMenu != null && mMenuView != null && mPostedOpenRunnable == null && ! mMenu . getNonActionItems ( ) . isEmpty ( ) ) { OverflowPopup popup = new OverflowPopup ( mContext , mMenu , mOverflowButton , true ) ; mPostedOpenRunnable = new OpenOverflowRunnable ( popup ) ; ( ( View ) mMenuView ) . post ( mPostedOpenRunnable ) ; super . onSubMenuSelected ( null ) ; return true ; } return false ; } | Display the overflow menu if one is present . |
27,491 | public boolean hideOverflowMenu ( ) { if ( mPostedOpenRunnable != null && mMenuView != null ) { ( ( View ) mMenuView ) . removeCallbacks ( mPostedOpenRunnable ) ; mPostedOpenRunnable = null ; return true ; } MenuPopupHelper popup = mOverflowPopup ; if ( popup != null ) { popup . dismiss ( ) ; return true ; } return false ; } | Hide the overflow menu if it is currently showing . |
27,492 | public void changeCursor ( Cursor c ) { if ( DBG ) Log . d ( LOG_TAG , "changeCursor(" + c + ")" ) ; if ( mClosed ) { Log . w ( LOG_TAG , "Tried to change cursor after adapter was closed." ) ; if ( c != null ) c . close ( ) ; return ; } try { super . changeCursor ( c ) ; if ( c != null ) { mText1Col = c . getColumnIndex ( SearchManager . SUGGEST_COLUMN_TEXT_1 ) ; mText2Col = c . getColumnIndex ( SearchManager . SUGGEST_COLUMN_TEXT_2 ) ; mText2UrlCol = c . getColumnIndex ( SearchManager . SUGGEST_COLUMN_TEXT_2_URL ) ; mIconName1Col = c . getColumnIndex ( SearchManager . SUGGEST_COLUMN_ICON_1 ) ; mIconName2Col = c . getColumnIndex ( SearchManager . SUGGEST_COLUMN_ICON_2 ) ; mFlagsCol = c . getColumnIndex ( SearchManager . SUGGEST_COLUMN_FLAGS ) ; } } catch ( Exception e ) { Log . e ( LOG_TAG , "error changing cursor and caching columns" , e ) ; } } | Cache columns . |
27,493 | public View newView ( Context context , Cursor cursor , ViewGroup parent ) { View v = super . newView ( context , cursor , parent ) ; v . setTag ( new ChildViewCache ( v ) ) ; return v ; } | Tags the view with cached child view look - ups . |
27,494 | private void setViewDrawable ( ImageView v , Drawable drawable , int nullVisibility ) { v . setImageDrawable ( drawable ) ; if ( drawable == null ) { v . setVisibility ( nullVisibility ) ; } else { v . setVisibility ( View . VISIBLE ) ; drawable . setVisible ( false , false ) ; drawable . setVisible ( true , false ) ; } } | Sets the drawable in an image view makes sure the view is only visible if there is a drawable . |
27,495 | public View getView ( int position , View convertView , ViewGroup parent ) { try { return super . getView ( position , convertView , parent ) ; } catch ( RuntimeException e ) { Log . w ( LOG_TAG , "Search suggestions cursor threw exception." , e ) ; View v = newView ( mContext , mCursor , parent ) ; if ( v != null ) { ChildViewCache views = ( ChildViewCache ) v . getTag ( ) ; TextView tv = views . mText1 ; tv . setText ( e . toString ( ) ) ; } return v ; } } | This method is overridden purely to provide a bit of protection against flaky content providers . |
27,496 | private Drawable getDrawableFromResourceValue ( String drawableId ) { if ( drawableId == null || drawableId . length ( ) == 0 || "0" . equals ( drawableId ) ) { return null ; } try { int resourceId = Integer . parseInt ( drawableId ) ; String drawableUri = ContentResolver . SCHEME_ANDROID_RESOURCE + "://" + mProviderContext . getPackageName ( ) + "/" + resourceId ; Drawable drawable = checkIconCache ( drawableUri ) ; if ( drawable != null ) { return drawable ; } drawable = mProviderContext . getResources ( ) . getDrawable ( resourceId ) ; storeInIconCache ( drawableUri , drawable ) ; return drawable ; } catch ( NumberFormatException nfe ) { Drawable drawable = checkIconCache ( drawableId ) ; if ( drawable != null ) { return drawable ; } Uri uri = Uri . parse ( drawableId ) ; drawable = getDrawable ( uri ) ; storeInIconCache ( drawableId , drawable ) ; return drawable ; } catch ( Resources . NotFoundException nfe ) { Log . w ( LOG_TAG , "Icon resource not found: " + drawableId ) ; return null ; } } | Gets a drawable given a value provided by a suggestion provider . |
27,497 | private Drawable getActivityIconWithCache ( ComponentName component ) { String componentIconKey = component . flattenToShortString ( ) ; if ( mOutsideDrawablesCache . containsKey ( componentIconKey ) ) { Drawable . ConstantState cached = mOutsideDrawablesCache . get ( componentIconKey ) ; return cached == null ? null : cached . newDrawable ( mProviderContext . getResources ( ) ) ; } Drawable drawable = getActivityIcon ( component ) ; Drawable . ConstantState toCache = drawable == null ? null : drawable . getConstantState ( ) ; mOutsideDrawablesCache . put ( componentIconKey , toCache ) ; return drawable ; } | Gets the activity or application icon for an activity . Uses the local icon cache for fast repeated lookups . |
27,498 | private Drawable getActivityIcon ( ComponentName component ) { PackageManager pm = mContext . getPackageManager ( ) ; final ActivityInfo activityInfo ; try { activityInfo = pm . getActivityInfo ( component , PackageManager . GET_META_DATA ) ; } catch ( NameNotFoundException ex ) { Log . w ( LOG_TAG , ex . toString ( ) ) ; return null ; } int iconId = activityInfo . getIconResource ( ) ; if ( iconId == 0 ) return null ; String pkg = component . getPackageName ( ) ; Drawable drawable = pm . getDrawable ( pkg , iconId , activityInfo . applicationInfo ) ; if ( drawable == null ) { Log . w ( LOG_TAG , "Invalid icon resource " + iconId + " for " + component . flattenToShortString ( ) ) ; return null ; } return drawable ; } | Gets the activity or application icon for an activity . |
27,499 | public static String getColumnString ( Cursor cursor , String columnName ) { int col = cursor . getColumnIndex ( columnName ) ; return getStringOrNull ( cursor , col ) ; } | Gets the value of a string column by name . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.