idx int64 0 165k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
118,300 | protected void retrieveProperties ( ) { LogManager manager = LogManager . getLogManager ( ) ; String className = SentryHandler . class . getName ( ) ; setPrintfStyle ( Boolean . valueOf ( manager . getProperty ( className + ".printfStyle" ) ) ) ; setLevel ( parseLevelOrDefault ( manager . getProperty ( className + ".le... | Retrieves the properties of the logger . |
118,301 | protected EventBuilder createEventBuilder ( LogRecord record ) { EventBuilder eventBuilder = new EventBuilder ( ) . withSdkIntegration ( "java.util.logging" ) . withLevel ( getLevel ( record . getLevel ( ) ) ) . withTimestamp ( new Date ( record . getMillis ( ) ) ) . withLogger ( record . getLoggerName ( ) ) ; String m... | Builds an EventBuilder based on the log record . |
118,302 | protected String formatMessage ( String message , Object [ ] parameters ) { String formatted ; if ( printfStyle ) { formatted = String . format ( message , parameters ) ; } else { formatted = MessageFormat . format ( message , parameters ) ; } return formatted ; } | Returns formatted Event message when provided the message template and parameters . |
118,303 | protected static PackageInfo getPackageInfo ( Context ctx ) { try { return ctx . getPackageManager ( ) . getPackageInfo ( ctx . getPackageName ( ) , 0 ) ; } catch ( PackageManager . NameNotFoundException e ) { Log . e ( TAG , "Error getting package info." , e ) ; return null ; } } | Return the Application s PackageInfo if possible or null . |
118,304 | protected static String getFamily ( ) { try { return Build . MODEL . split ( " " ) [ 0 ] ; } catch ( Exception e ) { Log . e ( TAG , "Error getting device family." , e ) ; return null ; } } | Fake the device family by using the first word in the Build . MODEL . Works well in most cases ... Nexus 6P - > Nexus Galaxy S7 - > Galaxy . |
118,305 | protected static ActivityManager . MemoryInfo getMemInfo ( Context ctx ) { try { ActivityManager actManager = ( ActivityManager ) ctx . getSystemService ( ACTIVITY_SERVICE ) ; ActivityManager . MemoryInfo memInfo = new ActivityManager . MemoryInfo ( ) ; actManager . getMemoryInfo ( memInfo ) ; return memInfo ; } catch ... | Get MemoryInfo object representing the memory state of the application . |
118,306 | protected static String getOrientation ( Context ctx ) { try { String o ; switch ( ctx . getResources ( ) . getConfiguration ( ) . orientation ) { case android . content . res . Configuration . ORIENTATION_LANDSCAPE : o = "landscape" ; break ; case android . content . res . Configuration . ORIENTATION_PORTRAIT : o = "p... | Get the device s current screen orientation . |
118,307 | protected static Boolean isCharging ( Context ctx ) { try { Intent intent = ctx . registerReceiver ( null , new IntentFilter ( Intent . ACTION_BATTERY_CHANGED ) ) ; if ( intent == null ) { return null ; } int plugged = intent . getIntExtra ( BatteryManager . EXTRA_PLUGGED , - 1 ) ; return plugged == BatteryManager . BA... | Checks whether or not the device is currently plugged in and charging or null if unknown . |
118,308 | protected static Long getUnusedInternalStorage ( ) { try { File path = Environment . getDataDirectory ( ) ; StatFs stat = new StatFs ( path . getPath ( ) ) ; long blockSize = stat . getBlockSize ( ) ; long availableBlocks = stat . getAvailableBlocks ( ) ; return availableBlocks * blockSize ; } catch ( Exception e ) { L... | Get the unused amount of internal storage in bytes . |
118,309 | protected static Long getTotalInternalStorage ( ) { try { File path = Environment . getDataDirectory ( ) ; StatFs stat = new StatFs ( path . getPath ( ) ) ; long blockSize = stat . getBlockSize ( ) ; long totalBlocks = stat . getBlockCount ( ) ; return totalBlocks * blockSize ; } catch ( Exception e ) { Log . e ( TAG ,... | Get the total amount of internal storage in bytes . |
118,310 | protected static Long getUnusedExternalStorage ( ) { try { if ( isExternalStorageMounted ( ) ) { File path = Environment . getExternalStorageDirectory ( ) ; StatFs stat = new StatFs ( path . getPath ( ) ) ; long blockSize = stat . getBlockSize ( ) ; long availableBlocks = stat . getAvailableBlocks ( ) ; return availabl... | Get the unused amount of external storage in bytes or null if no external storage is mounted . |
118,311 | protected static Long getTotalExternalStorage ( ) { try { if ( isExternalStorageMounted ( ) ) { File path = Environment . getExternalStorageDirectory ( ) ; StatFs stat = new StatFs ( path . getPath ( ) ) ; long blockSize = stat . getBlockSize ( ) ; long totalBlocks = stat . getBlockCount ( ) ; return totalBlocks * bloc... | Get the total amount of external storage in bytes or null if no external storage is mounted . |
118,312 | protected static DisplayMetrics getDisplayMetrics ( Context ctx ) { try { return ctx . getResources ( ) . getDisplayMetrics ( ) ; } catch ( Exception e ) { Log . e ( TAG , "Error getting DisplayMetrics." , e ) ; return null ; } } | Get the DisplayMetrics object for the current application . |
118,313 | protected static String getApplicationName ( Context ctx ) { try { ApplicationInfo applicationInfo = ctx . getApplicationInfo ( ) ; int stringId = applicationInfo . labelRes ; if ( stringId == 0 ) { if ( applicationInfo . nonLocalizedLabel != null ) { return applicationInfo . nonLocalizedLabel . toString ( ) ; } } else... | Get the human - facing Application name . |
118,314 | protected static boolean isConnected ( Context ctx ) { ConnectivityManager connectivityManager = ( ConnectivityManager ) ctx . getSystemService ( Context . CONNECTIVITY_SERVICE ) ; NetworkInfo activeNetworkInfo = connectivityManager . getActiveNetworkInfo ( ) ; return activeNetworkInfo != null && activeNetworkInfo . is... | Check whether the application has internet access at a point in time . |
118,315 | private boolean checkPermission ( String permission ) { int res = ctx . checkCallingOrSelfPermission ( permission ) ; return ( res == PackageManager . PERMISSION_GRANTED ) ; } | Check whether the application has been granted a certain permission . |
118,316 | public static void add ( Throwable throwable , Frame [ ] frames ) { Map < Throwable , Frame [ ] > weakMap = cache . get ( ) ; weakMap . put ( throwable , frames ) ; } | Store the per - frame local variable information for the last exception thrown on this thread . |
118,317 | public static Frame [ ] get ( Throwable throwable ) { Map < Throwable , Frame [ ] > weakMap = cache . get ( ) ; return weakMap . get ( throwable ) ; } | Retrieve the per - frame local variable information for the last exception thrown on this thread . |
118,318 | private void writeException ( JsonGenerator generator , SentryException sentryException ) throws IOException { generator . writeStartObject ( ) ; generator . writeStringField ( TYPE_PARAMETER , sentryException . getExceptionClassName ( ) ) ; generator . writeStringField ( VALUE_PARAMETER , sentryException . getExceptio... | Outputs an exception with its StackTrace on a JSon stream . |
118,319 | protected Connection createConnection ( Dsn dsn ) { String protocol = dsn . getProtocol ( ) ; Connection connection ; if ( protocol . equalsIgnoreCase ( "http" ) || protocol . equalsIgnoreCase ( "https" ) ) { logger . debug ( "Using an {} connection to Sentry." , protocol . toUpperCase ( ) ) ; connection = createHttpCo... | Creates a connection to the given DSN by determining the protocol . |
118,320 | protected Connection createHttpConnection ( Dsn dsn ) { URL sentryApiUrl = HttpConnection . getSentryApiUrl ( dsn . getUri ( ) , dsn . getProjectId ( ) ) ; String proxyHost = getProxyHost ( dsn ) ; String proxyUser = getProxyUser ( dsn ) ; String proxyPass = getProxyPass ( dsn ) ; int proxyPort = getProxyPort ( dsn ) ;... | Creates an HTTP connection to the Sentry server . |
118,321 | protected Connection createStdOutConnection ( Dsn dsn ) { OutputStreamConnection stdOutConnection = new OutputStreamConnection ( System . out ) ; stdOutConnection . setMarshaller ( createMarshaller ( dsn ) ) ; return stdOutConnection ; } | Uses stdout to send the logs . |
118,322 | protected long getBufferFlushtime ( Dsn dsn ) { return Util . parseLong ( Lookup . lookup ( BUFFER_FLUSHTIME_OPTION , dsn ) , BUFFER_FLUSHTIME_DEFAULT ) ; } | How long to wait between attempts to flush the disk buffer in milliseconds . |
118,323 | protected long getAsyncShutdownTimeout ( Dsn dsn ) { return Util . parseLong ( Lookup . lookup ( ASYNC_SHUTDOWN_TIMEOUT_OPTION , dsn ) , ASYNC_SHUTDOWN_TIMEOUT_DEFAULT ) ; } | The graceful shutdown timeout of the async executor in milliseconds . |
118,324 | protected int getAsyncQueueSize ( Dsn dsn ) { return Util . parseInteger ( Lookup . lookup ( ASYNC_QUEUE_SIZE_OPTION , dsn ) , QUEUE_SIZE_DEFAULT ) ; } | Maximum size of the async send queue . |
118,325 | protected int getAsyncPriority ( Dsn dsn ) { return Util . parseInteger ( Lookup . lookup ( ASYNC_PRIORITY_OPTION , dsn ) , Thread . MIN_PRIORITY ) ; } | Priority of threads used for the async connection . |
118,326 | protected int getAsyncThreads ( Dsn dsn ) { return Util . parseInteger ( Lookup . lookup ( ASYNC_THREADS_OPTION , dsn ) , Runtime . getRuntime ( ) . availableProcessors ( ) ) ; } | The number of threads used for the async connection . |
118,327 | protected int getProxyPort ( Dsn dsn ) { return Util . parseInteger ( Lookup . lookup ( HTTP_PROXY_PORT_OPTION , dsn ) , HTTP_PROXY_PORT_DEFAULT ) ; } | HTTP proxy port for Sentry connections . |
118,328 | protected int getMaxMessageLength ( Dsn dsn ) { return Util . parseInteger ( Lookup . lookup ( MAX_MESSAGE_LENGTH_OPTION , dsn ) , JsonMarshaller . DEFAULT_MAX_MESSAGE_LENGTH ) ; } | The maximum length of the message body in the requests to the Sentry Server . |
118,329 | protected int getTimeout ( Dsn dsn ) { return Util . parseInteger ( Lookup . lookup ( TIMEOUT_OPTION , dsn ) , TIMEOUT_DEFAULT ) ; } | Timeout for requests to the Sentry server in milliseconds . |
118,330 | protected boolean getBufferEnabled ( Dsn dsn ) { String bufferEnabled = Lookup . lookup ( BUFFER_ENABLED_OPTION , dsn ) ; if ( bufferEnabled != null ) { return Boolean . parseBoolean ( bufferEnabled ) ; } return BUFFER_ENABLED_DEFAULT ; } | Whether or not buffering is enabled . |
118,331 | protected int getBufferSize ( Dsn dsn ) { return Util . parseInteger ( Lookup . lookup ( BUFFER_SIZE_OPTION , dsn ) , BUFFER_SIZE_DEFAULT ) ; } | Get the maximum number of events to cache offline when network is down . |
118,332 | private void writeObject ( final ObjectOutputStream out ) throws IOException { out . defaultWriteObject ( ) ; out . writeInt ( size ( ) ) ; for ( final E e : this ) { out . writeObject ( e ) ; } } | Write the queue out using a custom routine . |
118,333 | @ SuppressWarnings ( "unchecked" ) private void readObject ( final ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; elements = ( E [ ] ) new Object [ maxElements ] ; final int size = in . readInt ( ) ; for ( int i = 0 ; i < size ; i ++ ) { elements [ i ] = ( E ) in . rea... | Read the queue in using a custom routine . |
118,334 | public void clear ( ) { full = false ; start = 0 ; end = 0 ; Arrays . fill ( elements , null ) ; } | Clears this queue . |
118,335 | public boolean add ( final E element ) { if ( null == element ) { throw new NullPointerException ( "Attempted to add null object to queue" ) ; } if ( isAtFullCapacity ( ) ) { remove ( ) ; } elements [ end ++ ] = element ; if ( end >= maxElements ) { end = 0 ; } if ( end == start ) { full = true ; } return true ; } | Adds the given element to this queue . If the queue is full the least recently added element is discarded so that a new element can be inserted . |
118,336 | public E get ( final int index ) { final int sz = size ( ) ; if ( index < 0 || index >= sz ) { throw new NoSuchElementException ( String . format ( "The specified index (%1$d) is outside the available range [0, %2$d)" , Integer . valueOf ( index ) , Integer . valueOf ( sz ) ) ) ; } final int idx = ( start + index ) % m... | Returns the element at the specified position in this queue . |
118,337 | public Iterator < E > iterator ( ) { return new Iterator < E > ( ) { private int index = start ; private int lastReturnedIndex = - 1 ; private boolean isFirst = full ; public boolean hasNext ( ) { return isFirst || index != end ; } public E next ( ) { if ( ! hasNext ( ) ) { throw new NoSuchElementException ( ) ; } isFi... | Returns an iterator over this queue s elements . |
118,338 | @ SuppressWarnings ( "checkstyle:magicnumber" ) private void doClose ( ) throws IOException { logger . debug ( "Gracefully shutting down Sentry async threads." ) ; closed = true ; executorService . shutdown ( ) ; try { if ( shutdownTimeout == - 1L ) { long waitBetweenLoggingMs = 5000L ; while ( true ) { if ( executorSe... | Close the connection whether it s from the shutdown hook or not . |
118,339 | private static String calculateChecksum ( String string ) { byte [ ] bytes = string . getBytes ( UTF_8 ) ; Checksum checksum = new CRC32 ( ) ; checksum . update ( bytes , 0 , bytes . length ) ; return Long . toHexString ( checksum . getValue ( ) ) . toUpperCase ( ) ; } | Calculates a checksum for a given string . |
118,340 | private void autoSetMissingValues ( ) { if ( event . getTimestamp ( ) == null ) { event . setTimestamp ( new Date ( ) ) ; } if ( event . getPlatform ( ) == null ) { event . setPlatform ( DEFAULT_PLATFORM ) ; } if ( event . getSdk ( ) == null ) { event . setSdk ( new Sdk ( SentryEnvironment . SDK_NAME , SentryEnvironmen... | Sets default values for each field that hasn t been provided manually . |
118,341 | public EventBuilder withContexts ( Map < String , Map < String , Object > > contexts ) { event . setContexts ( contexts ) ; return this ; } | Adds a map of map of context objects to the event . |
118,342 | public EventBuilder withExtra ( String extraName , Object extraValue ) { event . getExtra ( ) . put ( extraName , extraValue ) ; return this ; } | Adds an extra property to the event . |
118,343 | public EventBuilder withFingerprint ( String ... fingerprint ) { List < String > list = new ArrayList < > ( fingerprint . length ) ; Collections . addAll ( list , fingerprint ) ; event . setFingerprint ( list ) ; return this ; } | Sets event fingerprint an array of strings used to dictate the deduplicating for this event . |
118,344 | public void uncaughtException ( Thread thread , Throwable thrown ) { if ( enabled ) { logger . trace ( "Uncaught exception received." ) ; EventBuilder eventBuilder = new EventBuilder ( ) . withMessage ( thrown . getMessage ( ) ) . withLevel ( Event . Level . FATAL ) . withSentryInterface ( new ExceptionInterface ( thro... | Sends any uncaught exception to Sentry then passes the exception on to the pre - existing uncaught exception handler . |
118,345 | public static SentryUncaughtExceptionHandler setup ( ) { logger . debug ( "Configuring uncaught exception handler." ) ; Thread . UncaughtExceptionHandler currentHandler = Thread . getDefaultUncaughtExceptionHandler ( ) ; if ( currentHandler != null ) { logger . debug ( "default UncaughtExceptionHandler class='" + curre... | Configures an uncaught exception handler which sends events to Sentry then calls the preexisting uncaught exception handler . |
118,346 | private String formatLevel ( Event . Level level ) { if ( level == null ) { return null ; } switch ( level ) { case DEBUG : return "debug" ; case FATAL : return "fatal" ; case WARNING : return "warning" ; case INFO : return "info" ; case ERROR : return "error" ; default : logger . error ( "The level '{}' isn't supporte... | Formats a log level into one of the accepted string representation of a log level . |
118,347 | @ SuppressWarnings ( "checkstyle:parameternumber" ) public static SentryAppender createAppender ( @ PluginAttribute ( "name" ) final String name , @ PluginElement ( "filter" ) final Filter filter ) { if ( name == null ) { LOGGER . error ( "No name provided for SentryAppender" ) ; return null ; } return new SentryAppend... | Create a Sentry Appender . |
118,348 | public static URL getSentryApiUrl ( URI sentryUri , String projectId ) { try { String url = sentryUri . toString ( ) + "api/" + projectId + "/store/" ; return new URL ( url ) ; } catch ( MalformedURLException e ) { throw new IllegalArgumentException ( "Couldn't build a valid URL from the Sentry API." , e ) ; } } | Automatically determines the URL to the HTTP API of Sentry . |
118,349 | protected HttpURLConnection getConnection ( ) { try { HttpURLConnection connection ; if ( proxy != null ) { connection = ( HttpURLConnection ) sentryUrl . openConnection ( proxy ) ; } else { connection = ( HttpURLConnection ) sentryUrl . openConnection ( ) ; } if ( bypassSecurity && connection instanceof HttpsURLConnec... | Opens a connection to the Sentry API allowing to send new events . |
118,350 | public synchronized Map < String , String > getTags ( ) { if ( tags == null || tags . isEmpty ( ) ) { return Collections . emptyMap ( ) ; } return Collections . unmodifiableMap ( tags ) ; } | Return tags attached to this context . |
118,351 | public synchronized Map < String , Object > getExtra ( ) { if ( extra == null || extra . isEmpty ( ) ) { return Collections . emptyMap ( ) ; } return Collections . unmodifiableMap ( extra ) ; } | Return extra data attached to this context . |
118,352 | public synchronized void addExtra ( String name , Object value ) { if ( extra == null ) { extra = new HashMap < > ( ) ; } extra . put ( name , value ) ; } | Add extra data to the current context . |
118,353 | public void add ( Event event ) { if ( getNumStoredEvents ( ) >= maxEvents ) { logger . warn ( "Not adding Event because at least " + Integer . toString ( maxEvents ) + " events are already stored: " + event . getId ( ) ) ; return ; } File eventFile = new File ( bufferDir . getAbsolutePath ( ) , event . getId ( ) . toS... | Store a single event to the add directory . Java serialization is used and each event is stored in a file named by its UUID . |
118,354 | public static String dsnLookup ( ) { String dsn = Lookup . lookup ( "dsn" ) ; if ( Util . isNullOrEmpty ( dsn ) ) { dsn = Lookup . lookup ( "dns" ) ; } if ( Util . isNullOrEmpty ( dsn ) ) { logger . warn ( "*** Couldn't find a suitable DSN, Sentry operations will do nothing!" + " See documentation: https://docs.sentry.... | Looks for a DSN configuration within JNDI the System environment or Java properties . |
118,355 | public static SentryClient sentryClient ( String dsn , SentryClientFactory sentryClientFactory ) { Dsn realDsn = resolveDsn ( dsn ) ; if ( sentryClientFactory == null ) { String sentryClientFactoryName = Lookup . lookup ( "factory" , realDsn ) ; if ( Util . isNullOrEmpty ( sentryClientFactoryName ) ) { sentryClientFact... | Creates an instance of Sentry using the provided DSN and the specified factory . |
118,356 | public void setMinLevel ( String minLevel ) { this . minLevel = minLevel != null ? Level . toLevel ( minLevel ) : null ; } | Set minimum level to log . |
118,357 | public static String concernStackString ( BlockInfo blockInfo ) { String result = "" ; for ( String stackEntry : blockInfo . threadStackEntries ) { if ( Character . isLetter ( stackEntry . charAt ( 0 ) ) ) { String [ ] lines = stackEntry . split ( BlockInfo . SEPARATOR ) ; for ( String line : lines ) { String keyStackS... | Get key stack string to show as title in ui list . |
118,358 | public static int getNumCores ( ) { class CpuFilter implements FileFilter { public boolean accept ( File pathname ) { return Pattern . matches ( "cpu[0-9]" , pathname . getName ( ) ) ; } } if ( sCoreNum == 0 ) { try { File dir = new File ( "/sys/devices/system/cpu/" ) ; File [ ] files = dir . listFiles ( new CpuFilter ... | Get cpu core number |
118,359 | public List < String > provideWhiteList ( ) { LinkedList < String > whiteList = new LinkedList < > ( ) ; whiteList . add ( "org.chromium" ) ; return whiteList ; } | Provide white list entry in white list will not be shown in ui list . |
118,360 | static BlockCanaryInternals getInstance ( ) { if ( sInstance == null ) { synchronized ( BlockCanaryInternals . class ) { if ( sInstance == null ) { sInstance = new BlockCanaryInternals ( ) ; } } } return sInstance ; } | Get BlockCanaryInternals singleton |
118,361 | public static String save ( String str ) { String path ; synchronized ( SAVE_DELETE_LOCK ) { path = save ( "looper" , str ) ; } return path ; } | Save log to file |
118,362 | public static void cleanObsolete ( ) { HandlerThreadFactory . getWriteLogThreadHandler ( ) . post ( new Runnable ( ) { public void run ( ) { long now = System . currentTimeMillis ( ) ; File [ ] f = BlockCanaryInternals . getLogFiles ( ) ; if ( f != null && f . length > 0 ) { synchronized ( SAVE_DELETE_LOCK ) { for ( Fi... | Delete obsolete log files which is by default 2 days . |
118,363 | public String getCpuRateInfo ( ) { StringBuilder sb = new StringBuilder ( ) ; synchronized ( mCpuInfoEntries ) { for ( Map . Entry < Long , String > entry : mCpuInfoEntries . entrySet ( ) ) { long time = entry . getKey ( ) ; sb . append ( BlockInfo . TIME_FORMATTER . format ( time ) ) . append ( ' ' ) . append ( entry ... | Get cpu rate information |
118,364 | public void stop ( ) { if ( mMonitorStarted ) { mMonitorStarted = false ; Looper . getMainLooper ( ) . setMessageLogging ( null ) ; mBlockCanaryCore . stackSampler . stop ( ) ; mBlockCanaryCore . cpuSampler . stop ( ) ; } } | Stop monitoring . |
118,365 | public void recordStartTime ( ) { PreferenceManager . getDefaultSharedPreferences ( BlockCanaryContext . get ( ) . provideContext ( ) ) . edit ( ) . putLong ( "BlockCanary_StartTime" , System . currentTimeMillis ( ) ) . commit ( ) ; } | Record monitor start time to preference you may use it when after push which tells start BlockCanary . |
118,366 | public boolean isMonitorDurationEnd ( ) { long startTime = PreferenceManager . getDefaultSharedPreferences ( BlockCanaryContext . get ( ) . provideContext ( ) ) . getLong ( "BlockCanary_StartTime" , 0 ) ; return startTime != 0 && System . currentTimeMillis ( ) - startTime > BlockCanaryContext . get ( ) . provideMonitor... | Is monitor duration end compute from recordStartTime end provideMonitorDuration . |
118,367 | private HttpResponse directUpload ( GenericUrl initiationRequestUrl ) throws IOException { updateStateAndNotifyListener ( UploadState . MEDIA_IN_PROGRESS ) ; HttpContent content = mediaContent ; if ( metadata != null ) { content = new MultipartContent ( ) . setContentParts ( Arrays . asList ( metadata , mediaContent ) ... | Direct Uploads the media . |
118,368 | private HttpResponse resumableUpload ( GenericUrl initiationRequestUrl ) throws IOException { HttpResponse initialResponse = executeUploadInitiation ( initiationRequestUrl ) ; if ( ! initialResponse . isSuccessStatusCode ( ) ) { return initialResponse ; } GenericUrl uploadUrl ; try { uploadUrl = new GenericUrl ( initia... | Uploads the media in a resumable manner . |
118,369 | private HttpResponse executeUploadInitiation ( GenericUrl initiationRequestUrl ) throws IOException { updateStateAndNotifyListener ( UploadState . INITIATION_STARTED ) ; initiationRequestUrl . put ( "uploadType" , "resumable" ) ; HttpContent content = metadata == null ? new EmptyContent ( ) : metadata ; HttpRequest req... | This method sends a POST request with empty content to get the unique upload URL . |
118,370 | private HttpResponse executeCurrentRequestWithoutGZip ( HttpRequest request ) throws IOException { new MethodOverride ( ) . intercept ( request ) ; request . setThrowExceptionOnExecuteError ( false ) ; HttpResponse response = request . execute ( ) ; return response ; } | Executes the current request with some minimal common code . |
118,371 | private HttpResponse executeCurrentRequest ( HttpRequest request ) throws IOException { if ( ! disableGZipContent && ! ( request . getContent ( ) instanceof EmptyContent ) ) { request . setEncoding ( new GZipEncoding ( ) ) ; } HttpResponse response = executeCurrentRequestWithoutGZip ( request ) ; return response ; } | Executes the current request with some common code that includes exponential backoff and GZip encoding . |
118,372 | private ContentChunk buildContentChunk ( ) throws IOException { int blockSize ; if ( isMediaLengthKnown ( ) ) { blockSize = ( int ) Math . min ( chunkSize , getMediaContentLength ( ) - totalBytesServerReceived ) ; } else { blockSize = chunkSize ; } AbstractInputStreamContent contentChunk ; int actualBlockSize = blockSi... | Sets the HTTP media content chunk and the required headers that should be used in the upload request . |
118,373 | public MediaHttpUploader setInitiationRequestMethod ( String initiationRequestMethod ) { Preconditions . checkArgument ( initiationRequestMethod . equals ( HttpMethods . POST ) || initiationRequestMethod . equals ( HttpMethods . PUT ) || initiationRequestMethod . equals ( HttpMethods . PATCH ) ) ; this . initiationRequ... | Sets the HTTP method used for the initiation request . |
118,374 | private void updateStateAndNotifyListener ( UploadState uploadState ) throws IOException { this . uploadState = uploadState ; if ( progressListener != null ) { progressListener . progressChanged ( this ) ; } } | Sets the upload state and notifies the progress listener . |
118,375 | public static synchronized KeyStore getCertificateTrustStore ( ) throws IOException , GeneralSecurityException { if ( certTrustStore == null ) { certTrustStore = SecurityUtils . getJavaKeyStore ( ) ; InputStream keyStoreStream = GoogleUtils . class . getResourceAsStream ( "google.jks" ) ; SecurityUtils . loadKeyStore (... | Returns the key store for trusted root certificates to use for Google APIs . |
118,376 | private HttpResponse getFakeResponse ( final int statusCode , final InputStream partContent , List < String > headerNames , List < String > headerValues ) throws IOException { HttpRequest request = new FakeResponseHttpTransport ( statusCode , partContent , headerNames , headerValues ) . createRequestFactory ( ) . build... | Create a fake HTTP response object populated with the partContent and the statusCode . |
118,377 | public static GoogleAccountCredential usingOAuth2 ( Context context , Collection < String > scopes ) { Preconditions . checkArgument ( scopes != null && scopes . iterator ( ) . hasNext ( ) ) ; String scopesStr = "oauth2: " + Joiner . on ( ' ' ) . join ( scopes ) ; return new GoogleAccountCredential ( context , scopesSt... | Constructs a new instance using OAuth 2 . 0 scopes . |
118,378 | public static GoogleAccountCredential usingAudience ( Context context , String audience ) { Preconditions . checkArgument ( audience . length ( ) != 0 ) ; return new GoogleAccountCredential ( context , "audience:" + audience ) ; } | Sets the audience scope to use with Google Cloud Endpoints . |
118,379 | public final Intent newChooseAccountIntent ( ) { return AccountPicker . newChooseAccountIntent ( selectedAccount , null , new String [ ] { GoogleAccountManager . ACCOUNT_TYPE } , true , null , null , null , null ) ; } | Returns an intent to show the user to select a Google account or create a new one if there are none on the device yet . |
118,380 | public String getToken ( ) throws IOException , GoogleAuthException { if ( backOff != null ) { backOff . reset ( ) ; } while ( true ) { try { return GoogleAuthUtil . getToken ( context , accountName , scope ) ; } catch ( IOException e ) { try { if ( backOff == null || ! BackOffUtils . next ( sleeper , backOff ) ) { thr... | Returns an OAuth 2 . 0 access token . |
118,381 | public Details getDetails ( ) { Preconditions . checkArgument ( ( web == null ) != ( installed == null ) ) ; return web == null ? installed : web ; } | Returns the details for either installed or web applications . |
118,382 | private HttpResponse executeCurrentRequest ( long currentRequestLastBytePos , GenericUrl requestUrl , HttpHeaders requestHeaders , OutputStream outputStream ) throws IOException { HttpRequest request = requestFactory . buildGetRequest ( requestUrl ) ; if ( requestHeaders != null ) { request . getHeaders ( ) . putAll ( ... | Executes the current request . |
118,383 | private void updateStateAndNotifyListener ( DownloadState downloadState ) throws IOException { this . downloadState = downloadState ; if ( progressListener != null ) { progressListener . progressChanged ( this ) ; } } | Sets the download state and notifies the progress listener . |
118,384 | public void execute ( ) throws IOException { boolean retryAllowed ; Preconditions . checkState ( ! requestInfos . isEmpty ( ) ) ; HttpRequest batchRequest = requestFactory . buildPostRequest ( this . batchUrl , null ) ; HttpExecuteInterceptor originalInterceptor = batchRequest . getInterceptor ( ) ; batchRequest . setI... | Executes all queued HTTP requests in a single call parses the responses and invokes callbacks . |
118,385 | public final List < PublicKey > getPublicKeys ( ) throws GeneralSecurityException , IOException { lock . lock ( ) ; try { if ( publicKeys == null || clock . currentTimeMillis ( ) + REFRESH_SKEW_MILLIS > expirationTimeMilliseconds ) { refresh ( ) ; } return publicKeys ; } finally { lock . unlock ( ) ; } } | Returns an unmodifiable view of the public keys . |
118,386 | long getCacheTimeInSec ( HttpHeaders httpHeaders ) { long cacheTimeInSec = 0 ; if ( httpHeaders . getCacheControl ( ) != null ) { for ( String arg : httpHeaders . getCacheControl ( ) . split ( "," ) ) { Matcher m = MAX_AGE_PATTERN . matcher ( arg ) ; if ( m . matches ( ) ) { cacheTimeInSec = Long . parseLong ( m . grou... | Gets the cache time in seconds . max - age in Cache - Control header and Age header are considered . |
118,387 | public StoredChannel store ( DataStore < StoredChannel > dataStore ) throws IOException { lock . lock ( ) ; try { dataStore . set ( getId ( ) , this ) ; return this ; } finally { lock . unlock ( ) ; } } | Stores this notification channel in the given notification channel data store . |
118,388 | protected final void initializeMediaUpload ( AbstractInputStreamContent mediaContent ) { HttpRequestFactory requestFactory = abstractGoogleClient . getRequestFactory ( ) ; this . uploader = new MediaHttpUploader ( mediaContent , requestFactory . getTransport ( ) , requestFactory . getInitializer ( ) ) ; this . uploader... | Initializes the media HTTP uploader based on the media content . |
118,389 | protected final void initializeMediaDownload ( ) { HttpRequestFactory requestFactory = abstractGoogleClient . getRequestFactory ( ) ; this . downloader = new MediaHttpDownloader ( requestFactory . getTransport ( ) , requestFactory . getInitializer ( ) ) ; } | Initializes the media HTTP downloader . |
118,390 | private HttpRequest buildHttpRequest ( boolean usingHead ) throws IOException { Preconditions . checkArgument ( uploader == null ) ; Preconditions . checkArgument ( ! usingHead || requestMethod . equals ( HttpMethods . GET ) ) ; String requestMethodToUse = usingHead ? HttpMethods . HEAD : requestMethod ; final HttpRequ... | Create a request suitable for use against this service . |
118,391 | public final < E > void queue ( BatchRequest batchRequest , Class < E > errorClass , BatchCallback < T , E > callback ) throws IOException { Preconditions . checkArgument ( uploader == null , "Batching media requests is not supported" ) ; batchRequest . queue ( buildHttpRequest ( ) , getResponseClass ( ) , errorClass ,... | Queues the request into the specified batch request container using the specified error class . |
118,392 | @ SuppressWarnings ( "unchecked" ) public AbstractGoogleClientRequest < T > set ( String fieldName , Object value ) { return ( AbstractGoogleClientRequest < T > ) super . set ( fieldName , value ) ; } | for more details |
118,393 | public static GoogleJsonError parse ( JsonFactory jsonFactory , HttpResponse response ) throws IOException { JsonObjectParser jsonObjectParser = new JsonObjectParser . Builder ( jsonFactory ) . setWrapperKeys ( Collections . singleton ( "error" ) ) . build ( ) ; return jsonObjectParser . parseAndClose ( response . getC... | Parses the given error HTTP response using the given JSON factory . |
118,394 | public void initialize ( AbstractGoogleClientRequest < ? > request ) throws IOException { if ( key != null ) { request . put ( "key" , key ) ; } if ( userIp != null ) { request . put ( "userIp" , userIp ) ; } } | Subclasses should call super implementation in order to set the key and userIp . |
118,395 | public void setEntryClasses ( Class < ? > ... entryClasses ) { int numEntries = entryClasses . length ; HashMap < String , Class < ? > > kindToEntryClassMap = this . kindToEntryClassMap ; for ( int i = 0 ; i < numEntries ; i ++ ) { Class < ? > entryClass = entryClasses [ i ] ; ClassInfo typeInfo = ClassInfo . of ( entr... | Sets the entry classes to use when parsing . |
118,396 | public static < T , E > MultiKindFeedParser < T > create ( HttpResponse response , XmlNamespaceDictionary namespaceDictionary , Class < T > feedClass , Class < E > ... entryClasses ) throws IOException , XmlPullParserException { InputStream content = response . getContent ( ) ; try { Atom . checkContentType ( response ... | Parses the given HTTP response using the given feed class and entry classes . |
118,397 | protected TransactionTypeEnum getType ( byte logstate ) { switch ( ( logstate & 0x60 ) >> 5 ) { case 0 : return TransactionTypeEnum . LOADED ; case 1 : return TransactionTypeEnum . UNLOADED ; case 2 : return TransactionTypeEnum . PURCHASE ; case 3 : return TransactionTypeEnum . REFUND ; } return null ; } | Method used to get the transaction type |
118,398 | protected void extractEF_ID ( final Application pApplication ) throws CommunicationException { byte [ ] data = template . get ( ) . getProvider ( ) . transceive ( new CommandApdu ( CommandEnum . READ_RECORD , 0x01 , 0xBC , 0 ) . toBytes ( ) ) ; if ( ResponseUtils . isSucceed ( data ) ) { pApplication . setReadingStep (... | Method used to extract Ef_iD record |
118,399 | private Collection < AnnotationData > getAnnotationSet ( final Collection < TagAndLength > pTags ) { Collection < AnnotationData > ret = null ; if ( pTags != null ) { Map < ITag , AnnotationData > data = AnnotationUtils . getInstance ( ) . getMap ( ) . get ( getClass ( ) . getName ( ) ) ; ret = new ArrayList < Annotati... | Method to get the annotation set from the current class |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.