idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
149,400 | public void removeCollaborator ( String appName , String collaborator ) { connection . execute ( new SharingRemove ( appName , collaborator ) , apiKey ) ; } | Remove a collaborator from an app . | 34 | 7 |
149,401 | public void updateConfig ( String appName , Map < String , String > config ) { connection . execute ( new ConfigUpdate ( appName , config ) , apiKey ) ; } | Update environment variables to an app . | 37 | 7 |
149,402 | public Map < String , String > listConfig ( String appName ) { return connection . execute ( new ConfigList ( appName ) , apiKey ) ; } | List all the environment variables for an app . | 33 | 9 |
149,403 | public void transferApp ( String appName , String to ) { connection . execute ( new SharingTransfer ( appName , to ) , apiKey ) ; } | Transfer the ownership of an application to another user . | 32 | 10 |
149,404 | public LogStreamResponse getLogs ( String appName , Boolean tail ) { return connection . execute ( new Log ( appName , tail ) , apiKey ) ; } | Get logs for an app . | 35 | 6 |
149,405 | public LogStreamResponse getLogs ( Log . LogRequestBuilder logRequest ) { return connection . execute ( new Log ( logRequest ) , apiKey ) ; } | Get logs for an app by specifying additional parameters . | 34 | 10 |
149,406 | public boolean isMaintenanceModeEnabled ( String appName ) { App app = connection . execute ( new AppInfo ( appName ) , apiKey ) ; return app . isMaintenance ( ) ; } | Checks if maintenance mode is enabled for the given app | 42 | 11 |
149,407 | public void setMaintenanceMode ( String appName , boolean enable ) { connection . execute ( new AppUpdate ( appName , enable ) , apiKey ) ; } | Sets maintenance mode for the given app | 34 | 8 |
149,408 | public Build createBuild ( String appName , Build build ) { return connection . execute ( new BuildCreate ( appName , build ) , apiKey ) ; } | Creates a build | 33 | 4 |
149,409 | public Build getBuildInfo ( String appName , String buildId ) { return connection . execute ( new BuildInfo ( appName , buildId ) , apiKey ) ; } | Gets the info for a running build | 36 | 8 |
149,410 | public Range < Dyno > listDynos ( String appName ) { return connection . execute ( new DynoList ( appName ) , apiKey ) ; } | List app dynos for an app | 35 | 7 |
149,411 | public void restartDyno ( String appName , String dynoId ) { connection . execute ( new DynoRestart ( appName , dynoId ) , apiKey ) ; } | Restarts a single dyno | 40 | 6 |
149,412 | public Formation scale ( String appName , String processType , int quantity ) { return connection . execute ( new FormationUpdate ( appName , processType , quantity ) , apiKey ) ; } | Scales a process type | 39 | 5 |
149,413 | public List < Formation > listFormation ( String appName ) { return connection . execute ( new FormationList ( appName ) , apiKey ) ; } | Lists the formation info for an app | 32 | 8 |
149,414 | public List < BuildpackInstallation > listBuildpackInstallations ( String appName ) { return connection . execute ( new BuildpackInstallationList ( appName ) , apiKey ) ; } | Lists the buildpacks installed on an app | 38 | 9 |
149,415 | public void updateBuildpackInstallations ( String appName , List < String > buildpacks ) { connection . execute ( new BuildpackInstallationUpdate ( appName , buildpacks ) , apiKey ) ; } | Update the list of buildpacks installed on an app | 42 | 10 |
149,416 | static Artifact resolveConstrained ( MavenProject project , String gav , Pattern versionRegex , ArtifactResolver resolver ) throws VersionRangeResolutionException , ArtifactResolutionException { boolean latest = gav . endsWith ( ":LATEST" ) ; if ( latest || gav . endsWith ( ":RELEASE" ) ) { Artifact a = new DefaultArtifact ( gav ) ; if ( latest ) { versionRegex = versionRegex == null ? ANY : versionRegex ; } else { versionRegex = versionRegex == null ? ANY_NON_SNAPSHOT : versionRegex ; } String upTo = project . getGroupId ( ) . equals ( a . getGroupId ( ) ) && project . getArtifactId ( ) . equals ( a . getArtifactId ( ) ) ? project . getVersion ( ) : null ; return resolver . resolveNewestMatching ( gav , upTo , versionRegex , latest , latest ) ; } else { String projectGav = getProjectArtifactCoordinates ( project , null ) ; Artifact ret = null ; if ( projectGav . equals ( gav ) ) { ret = findProjectArtifact ( project ) ; } return ret == null ? resolver . resolveArtifact ( gav ) : ret ; } } | Resolves the gav using the resolver . If the gav corresponds to the project artifact and is an unresolved version for a RELEASE or LATEST the gav is resolved such it a release not newer than the project version is found that optionally corresponds to the provided version regex if provided . | 283 | 58 |
149,417 | public static < X > ServiceTypeLoader < X > load ( Class < X > serviceType ) { return load ( serviceType , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; } | Locates the services in the context classloader of the current thread . | 43 | 14 |
149,418 | public static String stringifyJavascriptObject ( Object object ) { StringBuilder bld = new StringBuilder ( ) ; stringify ( object , bld ) ; return bld . toString ( ) ; } | Converts the provided javascript object to JSON string . | 43 | 10 |
149,419 | @ Nullable @ SuppressWarnings ( "unchecked" ) protected < T extends JavaElement > ActiveElements < T > popIfActive ( ) { return ( ActiveElements < T > ) ( ! activations . isEmpty ( ) && activations . peek ( ) . depth == depth ? activations . pop ( ) : null ) ; } | Pops the top of the stack of active elements if the current position in the call stack corresponds to the one that pushed the active elements . | 75 | 28 |
149,420 | @ Nonnull public static Builder builder ( Revapi revapi ) { List < String > knownExtensionIds = new ArrayList <> ( ) ; addExtensionIds ( revapi . getPipelineConfiguration ( ) . getApiAnalyzerTypes ( ) , knownExtensionIds ) ; addExtensionIds ( revapi . getPipelineConfiguration ( ) . getTransformTypes ( ) , knownExtensionIds ) ; addExtensionIds ( revapi . getPipelineConfiguration ( ) . getFilterTypes ( ) , knownExtensionIds ) ; addExtensionIds ( revapi . getPipelineConfiguration ( ) . getReporterTypes ( ) , knownExtensionIds ) ; return new Builder ( knownExtensionIds ) ; } | Returns a new analysis context builder that extracts the information about the available extensions from the provided Revapi instance . | 168 | 21 |
149,421 | public AnalysisContext copyWithConfiguration ( ModelNode configuration ) { return new AnalysisContext ( this . locale , configuration , this . oldApi , this . newApi , this . data ) ; } | This is generally only useful for extensions that delegate some of their functionality to other internal extensions of their own that they need to configure . | 41 | 26 |
149,422 | public static PipelineConfiguration . Builder parse ( ModelNode json ) { ModelNode analyzerIncludeNode = json . get ( "analyzers" ) . get ( "include" ) ; ModelNode analyzerExcludeNode = json . get ( "analyzers" ) . get ( "exclude" ) ; ModelNode filterIncludeNode = json . get ( "filters" ) . get ( "include" ) ; ModelNode filterExcludeNode = json . get ( "filters" ) . get ( "exclude" ) ; ModelNode transformIncludeNode = json . get ( "transforms" ) . get ( "include" ) ; ModelNode transformExcludeNode = json . get ( "transforms" ) . get ( "exclude" ) ; ModelNode reporterIncludeNode = json . get ( "reporters" ) . get ( "include" ) ; ModelNode reporterExcludeNode = json . get ( "reporters" ) . get ( "exclude" ) ; return builder ( ) . withTransformationBlocks ( json . get ( "transformBlocks" ) ) . withAnalyzerExtensionIdsInclude ( asStringList ( analyzerIncludeNode ) ) . withAnalyzerExtensionIdsExclude ( asStringList ( analyzerExcludeNode ) ) . withFilterExtensionIdsInclude ( asStringList ( filterIncludeNode ) ) . withFilterExtensionIdsExclude ( asStringList ( filterExcludeNode ) ) . withTransformExtensionIdsInclude ( asStringList ( transformIncludeNode ) ) . withTransformExtensionIdsExclude ( asStringList ( transformExcludeNode ) ) . withReporterExtensionIdsInclude ( asStringList ( reporterIncludeNode ) ) . withReporterExtensionIdsExclude ( asStringList ( reporterExcludeNode ) ) ; } | Parses the configuration node and provides a pipeline configuration without any extensions marked for loading . The configuration node is supposed to conform to the pipeline configuration JSON schema . | 401 | 32 |
149,423 | private static void firstDotConstellation ( int [ ] dollarPositions , int [ ] dotPositions , int nestingLevel ) { int i = 0 ; int unassigned = dotPositions . length - nestingLevel ; for ( ; i < unassigned ; ++ i ) { dotPositions [ i ] = - 1 ; } for ( ; i < dotPositions . length ; ++ i ) { dotPositions [ i ] = dollarPositions [ i ] ; } } | This will set the last nestingLevel elements in the dotPositions to the values present in the dollarPositions . The rest will be set to - 1 . | 102 | 32 |
149,424 | public static AnalysisResult fakeSuccess ( ) { return new AnalysisResult ( null , new Extensions ( Collections . emptyMap ( ) , Collections . emptyMap ( ) , Collections . emptyMap ( ) , Collections . emptyMap ( ) ) ) ; } | A factory method for users that need to report success without actually running any analysis . The returned result will be successful but will not contain the actual configurations of extensions . | 50 | 32 |
149,425 | static PlexusConfiguration convert ( ModelNode configuration , ModelNode jsonSchema , String extensionId , String id ) { ConversionContext ctx = new ConversionContext ( ) ; ctx . currentSchema = jsonSchema ; ctx . rootSchema = jsonSchema ; ctx . pushTag ( extensionId ) ; ctx . id = id ; return convert ( configuration , ctx ) ; } | visibility increased for testing | 84 | 5 |
149,426 | @ SuppressWarnings ( "unchecked" ) public < T extends Annotation > T getAnnotation ( Class < T > annotationType ) { for ( Annotation annotation : this . annotations ) { if ( annotation . annotationType ( ) . equals ( annotationType ) ) { return ( T ) annotation ; } } for ( Annotation metaAnn : this . annotations ) { T ann = metaAnn . annotationType ( ) . getAnnotation ( annotationType ) ; if ( ann != null ) { return ann ; } } return null ; } | Obtain the annotation associated with this type descriptor of the specified type . | 114 | 14 |
149,427 | public static String encodeScheme ( String scheme , String encoding ) throws UnsupportedEncodingException { return HierarchicalUriComponents . encodeUriComponent ( scheme , encoding , HierarchicalUriComponents . Type . SCHEME ) ; } | Encodes the given URI scheme with the given encoding . | 54 | 11 |
149,428 | public static String encodeAuthority ( String authority , String encoding ) throws UnsupportedEncodingException { return HierarchicalUriComponents . encodeUriComponent ( authority , encoding , HierarchicalUriComponents . Type . AUTHORITY ) ; } | Encodes the given URI authority with the given encoding . | 53 | 11 |
149,429 | public static String encodeUserInfo ( String userInfo , String encoding ) throws UnsupportedEncodingException { return HierarchicalUriComponents . encodeUriComponent ( userInfo , encoding , HierarchicalUriComponents . Type . USER_INFO ) ; } | Encodes the given URI user info with the given encoding . | 57 | 12 |
149,430 | public static String encodeHost ( String host , String encoding ) throws UnsupportedEncodingException { return HierarchicalUriComponents . encodeUriComponent ( host , encoding , HierarchicalUriComponents . Type . HOST_IPV4 ) ; } | Encodes the given URI host with the given encoding . | 56 | 11 |
149,431 | public static String encodePort ( String port , String encoding ) throws UnsupportedEncodingException { return HierarchicalUriComponents . encodeUriComponent ( port , encoding , HierarchicalUriComponents . Type . PORT ) ; } | Encodes the given URI port with the given encoding . | 52 | 11 |
149,432 | public static String encodePath ( String path , String encoding ) throws UnsupportedEncodingException { return HierarchicalUriComponents . encodeUriComponent ( path , encoding , HierarchicalUriComponents . Type . PATH ) ; } | Encodes the given URI path with the given encoding . | 51 | 11 |
149,433 | public static String encodePathSegment ( String segment , String encoding ) throws UnsupportedEncodingException { return HierarchicalUriComponents . encodeUriComponent ( segment , encoding , HierarchicalUriComponents . Type . PATH_SEGMENT ) ; } | Encodes the given URI path segment with the given encoding . | 57 | 12 |
149,434 | public static String encodeQuery ( String query , String encoding ) throws UnsupportedEncodingException { return HierarchicalUriComponents . encodeUriComponent ( query , encoding , HierarchicalUriComponents . Type . QUERY ) ; } | Encodes the given URI query with the given encoding . | 52 | 11 |
149,435 | public static String encodeQueryParam ( String queryParam , String encoding ) throws UnsupportedEncodingException { return HierarchicalUriComponents . encodeUriComponent ( queryParam , encoding , HierarchicalUriComponents . Type . QUERY_PARAM ) ; } | Encodes the given URI query parameter with the given encoding . | 58 | 12 |
149,436 | public static String encodeFragment ( String fragment , String encoding ) throws UnsupportedEncodingException { return HierarchicalUriComponents . encodeUriComponent ( fragment , encoding , HierarchicalUriComponents . Type . FRAGMENT ) ; } | Encodes the given URI fragment with the given encoding . | 54 | 11 |
149,437 | public void setReadTimeout ( int readTimeout ) { this . client = this . client . newBuilder ( ) . readTimeout ( readTimeout , TimeUnit . MILLISECONDS ) . build ( ) ; } | Sets the underlying read timeout in milliseconds . A value of 0 specifies an infinite timeout . | 45 | 18 |
149,438 | public void setWriteTimeout ( int writeTimeout ) { this . client = this . client . newBuilder ( ) . writeTimeout ( writeTimeout , TimeUnit . MILLISECONDS ) . build ( ) ; } | Sets the underlying write timeout in milliseconds . A value of 0 specifies an infinite timeout . | 45 | 18 |
149,439 | public void setConnectTimeout ( int connectTimeout ) { this . client = this . client . newBuilder ( ) . connectTimeout ( connectTimeout , TimeUnit . MILLISECONDS ) . build ( ) ; } | Sets the underlying connect timeout in milliseconds . A value of 0 specifies an infinite timeout . | 45 | 18 |
149,440 | public void addComparator ( Comparator < T > comparator , boolean ascending ) { this . comparators . add ( new InvertibleComparator < T > ( comparator , ascending ) ) ; } | Add a Comparator to the end of the chain using the provided sort order . | 43 | 16 |
149,441 | public static void copy ( String in , Writer out ) throws IOException { Assert . notNull ( in , "No input String specified" ) ; Assert . notNull ( out , "No Writer specified" ) ; try { out . write ( in ) ; } finally { try { out . close ( ) ; } catch ( IOException ex ) { } } } | Copy the contents of the given String to the given output Writer . Closes the writer when done . | 77 | 20 |
149,442 | public boolean matches ( String uri ) { if ( uri == null ) { return false ; } Matcher matcher = this . matchPattern . matcher ( uri ) ; return matcher . matches ( ) ; } | Indicate whether the given URI matches this template . | 47 | 10 |
149,443 | public boolean exists ( ) { // Try file existence: can we find the file in the file system? try { return getFile ( ) . exists ( ) ; } catch ( IOException ex ) { // Fall back to stream existence: can we open the stream? try { InputStream is = getInputStream ( ) ; is . close ( ) ; return true ; } catch ( Throwable isEx ) { return false ; } } } | This implementation checks whether a File can be opened falling back to whether an InputStream can be opened . This will cover both directories and content resources . | 90 | 29 |
149,444 | static String expandUriComponent ( String source , UriTemplateVariables uriVariables ) { if ( source == null ) { return null ; } if ( source . indexOf ( ' ' ) == - 1 ) { return source ; } Matcher matcher = NAMES_PATTERN . matcher ( source ) ; StringBuffer sb = new StringBuffer ( ) ; while ( matcher . find ( ) ) { String match = matcher . group ( 1 ) ; String variableName = getVariableName ( match ) ; Object variableValue = uriVariables . getValue ( variableName ) ; if ( UriTemplateVariables . SKIP_VALUE . equals ( variableValue ) ) { continue ; } String variableValueString = getVariableValueAsString ( variableValue ) ; String replacement = Matcher . quoteReplacement ( variableValueString ) ; matcher . appendReplacement ( sb , replacement ) ; } matcher . appendTail ( sb ) ; return sb . toString ( ) ; } | static expansion helpers | 214 | 3 |
149,445 | public static boolean isAssignable ( Type lhsType , Type rhsType ) { Assert . notNull ( lhsType , "Left-hand side type must not be null" ) ; Assert . notNull ( rhsType , "Right-hand side type must not be null" ) ; // all types are assignable to themselves and to class Object if ( lhsType . equals ( rhsType ) || lhsType . equals ( Object . class ) ) { return true ; } if ( lhsType instanceof Class < ? > ) { Class < ? > lhsClass = ( Class < ? > ) lhsType ; // just comparing two classes if ( rhsType instanceof Class < ? > ) { return ClassUtils . isAssignable ( lhsClass , ( Class < ? > ) rhsType ) ; } if ( rhsType instanceof ParameterizedType ) { Type rhsRaw = ( ( ParameterizedType ) rhsType ) . getRawType ( ) ; // a parameterized type is always assignable to its raw class type if ( rhsRaw instanceof Class < ? > ) { return ClassUtils . isAssignable ( lhsClass , ( Class < ? > ) rhsRaw ) ; } } else if ( lhsClass . isArray ( ) && rhsType instanceof GenericArrayType ) { Type rhsComponent = ( ( GenericArrayType ) rhsType ) . getGenericComponentType ( ) ; return isAssignable ( lhsClass . getComponentType ( ) , rhsComponent ) ; } } // parameterized types are only assignable to other parameterized types and class types if ( lhsType instanceof ParameterizedType ) { if ( rhsType instanceof Class < ? > ) { Type lhsRaw = ( ( ParameterizedType ) lhsType ) . getRawType ( ) ; if ( lhsRaw instanceof Class < ? > ) { return ClassUtils . isAssignable ( ( Class < ? > ) lhsRaw , ( Class < ? > ) rhsType ) ; } } else if ( rhsType instanceof ParameterizedType ) { return isAssignable ( ( ParameterizedType ) lhsType , ( ParameterizedType ) rhsType ) ; } } if ( lhsType instanceof GenericArrayType ) { Type lhsComponent = ( ( GenericArrayType ) lhsType ) . getGenericComponentType ( ) ; if ( rhsType instanceof Class < ? > ) { Class < ? > rhsClass = ( Class < ? > ) rhsType ; if ( rhsClass . isArray ( ) ) { return isAssignable ( lhsComponent , rhsClass . getComponentType ( ) ) ; } } else if ( rhsType instanceof GenericArrayType ) { Type rhsComponent = ( ( GenericArrayType ) rhsType ) . getGenericComponentType ( ) ; return isAssignable ( lhsComponent , rhsComponent ) ; } } if ( lhsType instanceof WildcardType ) { return isAssignable ( ( WildcardType ) lhsType , rhsType ) ; } return false ; } | Check if the right - hand side type may be assigned to the left - hand side type following the Java generics rules . | 684 | 25 |
149,446 | static String encodeUriComponent ( String source , String encoding , Type type ) throws UnsupportedEncodingException { if ( source == null ) { return null ; } Assert . hasLength ( encoding , "Encoding must not be empty" ) ; byte [ ] bytes = encodeBytes ( source . getBytes ( encoding ) , type ) ; return new String ( bytes , "US-ASCII" ) ; } | Encodes the given source into an encoded String using the rules specified by the given component and with the given options . | 86 | 23 |
149,447 | protected HttpUriRequest createHttpRequest ( HttpMethod httpMethod , URI uri ) { switch ( httpMethod ) { case GET : return new HttpGet ( uri ) ; case DELETE : return new HttpDelete ( uri ) ; case HEAD : return new HttpHead ( uri ) ; case OPTIONS : return new HttpOptions ( uri ) ; case POST : return new HttpPost ( uri ) ; case PUT : return new HttpPut ( uri ) ; case TRACE : return new HttpTrace ( uri ) ; default : throw new IllegalArgumentException ( "Invalid HTTP method: " + httpMethod ) ; } } | Create a HttpComponents HttpUriRequest object for the given HTTP method and URI specification . | 146 | 21 |
149,448 | public static void registerConverters ( Set < ? > converters , ConverterRegistry registry ) { if ( converters != null ) { for ( Object converter : converters ) { if ( converter instanceof GenericConverter ) { registry . addConverter ( ( GenericConverter ) converter ) ; } else if ( converter instanceof Converter < ? , ? > ) { registry . addConverter ( ( Converter < ? , ? > ) converter ) ; } else if ( converter instanceof ConverterFactory < ? , ? > ) { registry . addConverterFactory ( ( ConverterFactory < ? , ? > ) converter ) ; } else { throw new IllegalArgumentException ( "Each converter object must implement one of the " + "Converter, ConverterFactory, or GenericConverter interfaces" ) ; } } } } | Register the given Converter objects with the given target ConverterRegistry . | 182 | 15 |
149,449 | public static < K , V > MultiValueMap < K , V > unmodifiableMultiValueMap ( MultiValueMap < ? extends K , ? extends V > map ) { Assert . notNull ( map , "'map' must not be null" ) ; Map < K , List < V > > result = new LinkedHashMap < K , List < V > > ( map . size ( ) ) ; for ( Map . Entry < ? extends K , ? extends List < ? extends V > > entry : map . entrySet ( ) ) { List < V > values = Collections . unmodifiableList ( entry . getValue ( ) ) ; result . put ( entry . getKey ( ) , values ) ; } Map < K , List < V > > unmodifiableMap = Collections . unmodifiableMap ( result ) ; return toMultiValueMap ( unmodifiableMap ) ; } | Returns an unmodifiable view of the specified multi - value map . | 189 | 14 |
149,450 | public static String copyToString ( InputStream in , Charset charset ) throws IOException { Assert . notNull ( in , "No InputStream specified" ) ; StringBuilder out = new StringBuilder ( ) ; InputStreamReader reader = new InputStreamReader ( in , charset ) ; char [ ] buffer = new char [ BUFFER_SIZE ] ; int bytesRead = - 1 ; while ( ( bytesRead = reader . read ( buffer ) ) != - 1 ) { out . append ( buffer , 0 , bytesRead ) ; } return out . toString ( ) ; } | Copy the contents of the given InputStream into a String . Leaves the stream open when done . | 124 | 19 |
149,451 | public static void copy ( byte [ ] in , OutputStream out ) throws IOException { Assert . notNull ( in , "No input byte array specified" ) ; Assert . notNull ( out , "No OutputStream specified" ) ; out . write ( in ) ; } | Copy the contents of the given byte array to the given OutputStream . Leaves the stream open when done . | 59 | 21 |
149,452 | private int handleIOException ( IOException ex ) throws IOException { if ( AUTH_ERROR . equals ( ex . getMessage ( ) ) || AUTH_ERROR_JELLY_BEAN . equals ( ex . getMessage ( ) ) ) { return HttpStatus . UNAUTHORIZED . value ( ) ; } else if ( PROXY_AUTH_ERROR . equals ( ex . getMessage ( ) ) ) { return HttpStatus . PROXY_AUTHENTICATION_REQUIRED . value ( ) ; } else { throw ex ; } } | If credentials are incorrect or not provided for Basic Auth then Android may throw this exception when an HTTP 401 is received . A separate exception is thrown for proxy authentication errors . Checking for this response and returning the proper status . | 121 | 43 |
149,453 | public static TextEncryptor queryableText ( CharSequence password , CharSequence salt ) { return new HexEncodingTextEncryptor ( new AndroidAesBytesEncryptor ( password . toString ( ) , salt , AndroidKeyGenerators . shared ( 16 ) ) ) ; } | Creates an encryptor for queryable text strings that uses standard password - based encryption . Uses a shared or constant 16 byte initialization vector so encrypting the same data results in the same encryption result . This is done to allow encrypted data to be queried against . Encrypted text is hex - encoded . | 62 | 61 |
149,454 | public static UriComponentsBuilder fromPath ( String path ) { UriComponentsBuilder builder = new UriComponentsBuilder ( ) ; builder . path ( path ) ; return builder ; } | Returns a builder that is initialized with the given path . | 38 | 11 |
149,455 | public UriComponentsBuilder uri ( URI uri ) { Assert . notNull ( uri , "'uri' must not be null" ) ; this . scheme = uri . getScheme ( ) ; if ( uri . isOpaque ( ) ) { this . ssp = uri . getRawSchemeSpecificPart ( ) ; resetHierarchicalComponents ( ) ; } else { if ( uri . getRawUserInfo ( ) != null ) { this . userInfo = uri . getRawUserInfo ( ) ; } if ( uri . getHost ( ) != null ) { this . host = uri . getHost ( ) ; } if ( uri . getPort ( ) != - 1 ) { this . port = String . valueOf ( uri . getPort ( ) ) ; } if ( StringUtils . hasLength ( uri . getRawPath ( ) ) ) { this . pathBuilder = new CompositePathComponentBuilder ( uri . getRawPath ( ) ) ; } if ( StringUtils . hasLength ( uri . getRawQuery ( ) ) ) { this . queryParams . clear ( ) ; query ( uri . getRawQuery ( ) ) ; } resetSchemeSpecificPart ( ) ; } if ( uri . getRawFragment ( ) != null ) { this . fragment = uri . getRawFragment ( ) ; } return this ; } | Initialize all components of this URI builder with the components of the given URI . | 306 | 16 |
149,456 | public UriComponentsBuilder pathSegment ( String ... pathSegments ) throws IllegalArgumentException { Assert . notNull ( pathSegments , "'segments' must not be null" ) ; this . pathBuilder . addPathSegments ( pathSegments ) ; resetSchemeSpecificPart ( ) ; return this ; } | Append the given path segments to the existing path of this builder . Each given path segment may contain URI template variables . | 69 | 24 |
149,457 | public UriComponentsBuilder queryParams ( MultiValueMap < String , String > params ) { Assert . notNull ( params , "'params' must not be null" ) ; this . queryParams . putAll ( params ) ; return this ; } | Add the given query parameters . | 54 | 6 |
149,458 | public UriComponentsBuilder replaceQueryParam ( String name , Object ... values ) { Assert . notNull ( name , "'name' must not be null" ) ; this . queryParams . remove ( name ) ; if ( ! ObjectUtils . isEmpty ( values ) ) { queryParam ( name , values ) ; } resetSchemeSpecificPart ( ) ; return this ; } | Set the query parameter values overriding all existing query values for the same parameter . If no values are given the query parameter is removed . | 81 | 26 |
149,459 | private static void registerCommonClasses ( Class < ? > ... commonClasses ) { for ( Class < ? > clazz : commonClasses ) { commonClassCache . put ( clazz . getName ( ) , clazz ) ; } } | Register the given common classes with the ClassUtils cache . | 52 | 12 |
149,460 | public static ClassLoader overrideThreadContextClassLoader ( ClassLoader classLoaderToUse ) { Thread currentThread = Thread . currentThread ( ) ; ClassLoader threadContextClassLoader = currentThread . getContextClassLoader ( ) ; if ( classLoaderToUse != null && ! classLoaderToUse . equals ( threadContextClassLoader ) ) { currentThread . setContextClassLoader ( classLoaderToUse ) ; return threadContextClassLoader ; } else { return null ; } } | Override the thread context ClassLoader with the environment s bean ClassLoader if necessary i . e . if the bean ClassLoader is not equivalent to the thread context ClassLoader already . | 98 | 35 |
149,461 | public static boolean isCacheSafe ( Class < ? > clazz , ClassLoader classLoader ) { Assert . notNull ( clazz , "Class must not be null" ) ; try { ClassLoader target = clazz . getClassLoader ( ) ; if ( target == null ) { return true ; } ClassLoader cur = classLoader ; if ( cur == target ) { return true ; } while ( cur != null ) { cur = cur . getParent ( ) ; if ( cur == target ) { return true ; } } return false ; } catch ( SecurityException ex ) { // Probably from the system ClassLoader - let's consider it safe. return true ; } } | Check whether the given class is cache - safe in the given context i . e . whether it is loaded by the given ClassLoader or a parent of it . | 140 | 32 |
149,462 | public static String getShortName ( String className ) { Assert . hasLength ( className , "Class name must not be empty" ) ; int lastDotIndex = className . lastIndexOf ( PACKAGE_SEPARATOR ) ; int nameEndIndex = className . indexOf ( CGLIB_CLASS_SEPARATOR ) ; if ( nameEndIndex == - 1 ) { nameEndIndex = className . length ( ) ; } String shortName = className . substring ( lastDotIndex + 1 , nameEndIndex ) ; shortName = shortName . replace ( INNER_CLASS_SEPARATOR , PACKAGE_SEPARATOR ) ; return shortName ; } | Get the class name without the qualified package name . | 148 | 10 |
149,463 | public static Method getStaticMethod ( Class < ? > clazz , String methodName , Class < ? > ... args ) { Assert . notNull ( clazz , "Class must not be null" ) ; Assert . notNull ( methodName , "Method name must not be null" ) ; try { Method method = clazz . getMethod ( methodName , args ) ; return Modifier . isStatic ( method . getModifiers ( ) ) ? method : null ; } catch ( NoSuchMethodException ex ) { return null ; } } | Return a public static method of a class . | 115 | 9 |
149,464 | public static boolean isPrimitiveArray ( Class < ? > clazz ) { Assert . notNull ( clazz , "Class must not be null" ) ; return ( clazz . isArray ( ) && clazz . getComponentType ( ) . isPrimitive ( ) ) ; } | Check if the given class represents an array of primitives i . e . boolean byte char short int long float or double . | 61 | 25 |
149,465 | public static boolean isPrimitiveWrapperArray ( Class < ? > clazz ) { Assert . notNull ( clazz , "Class must not be null" ) ; return ( clazz . isArray ( ) && isPrimitiveWrapper ( clazz . getComponentType ( ) ) ) ; } | Check if the given class represents an array of primitive wrappers i . e . Boolean Byte Character Short Integer Long Float or Double . | 64 | 26 |
149,466 | public static Class < ? > resolvePrimitiveIfNecessary ( Class < ? > clazz ) { Assert . notNull ( clazz , "Class must not be null" ) ; return ( clazz . isPrimitive ( ) && clazz != void . class ? primitiveTypeToWrapperMap . get ( clazz ) : clazz ) ; } | Resolve the given class if it is a primitive class returning the corresponding primitive wrapper type instead . | 77 | 19 |
149,467 | public static Class < ? > [ ] toClassArray ( Collection < Class < ? > > collection ) { if ( collection == null ) { return null ; } return collection . toArray ( new Class < ? > [ collection . size ( ) ] ) ; } | Copy the given Collection into a Class array . The Collection must contain Class elements only . | 54 | 17 |
149,468 | public static Class < ? > determineCommonAncestor ( Class < ? > clazz1 , Class < ? > clazz2 ) { if ( clazz1 == null ) { return clazz2 ; } if ( clazz2 == null ) { return clazz1 ; } if ( clazz1 . isAssignableFrom ( clazz2 ) ) { return clazz1 ; } if ( clazz2 . isAssignableFrom ( clazz1 ) ) { return clazz2 ; } Class < ? > ancestor = clazz1 ; do { ancestor = ancestor . getSuperclass ( ) ; if ( ancestor == null || Object . class . equals ( ancestor ) ) { return null ; } } while ( ! ancestor . isAssignableFrom ( clazz2 ) ) ; return ancestor ; } | Determine the common ancestor of the given classes if any . | 171 | 13 |
149,469 | public static Class < ? > resolveReturnType ( Method method , Class < ? > clazz ) { Assert . notNull ( method , "Method must not be null" ) ; Type genericType = method . getGenericReturnType ( ) ; Assert . notNull ( clazz , "Class must not be null" ) ; Map < TypeVariable , Type > typeVariableMap = getTypeVariableMap ( clazz ) ; Type rawType = getRawType ( genericType , typeVariableMap ) ; return ( rawType instanceof Class ? ( Class < ? > ) rawType : method . getReturnType ( ) ) ; } | Determine the target type for the generic return type of the given method where formal type variables are declared on the given class . | 132 | 26 |
149,470 | public static Class < ? > resolveReturnTypeArgument ( Method method , Class < ? > genericIfc ) { Assert . notNull ( method , "method must not be null" ) ; Type returnType = method . getReturnType ( ) ; Type genericReturnType = method . getGenericReturnType ( ) ; if ( returnType . equals ( genericIfc ) ) { if ( genericReturnType instanceof ParameterizedType ) { ParameterizedType targetType = ( ParameterizedType ) genericReturnType ; Type [ ] actualTypeArguments = targetType . getActualTypeArguments ( ) ; Type typeArg = actualTypeArguments [ 0 ] ; if ( ! ( typeArg instanceof WildcardType ) ) { return ( Class < ? > ) typeArg ; } } else { return null ; } } return resolveTypeArgument ( ( Class < ? > ) returnType , genericIfc ) ; } | Resolve the single type argument of the given generic interface against the given target method which is assumed to return the given interface or an implementation of it . | 196 | 30 |
149,471 | public static Class < ? > resolveTypeArgument ( Class < ? > clazz , Class < ? > genericIfc ) { Class < ? > [ ] typeArgs = resolveTypeArguments ( clazz , genericIfc ) ; if ( typeArgs == null ) { return null ; } if ( typeArgs . length != 1 ) { throw new IllegalArgumentException ( "Expected 1 type argument on generic interface [" + genericIfc . getName ( ) + "] but found " + typeArgs . length ) ; } return typeArgs [ 0 ] ; } | Resolve the single type argument of the given generic interface against the given target class which is assumed to implement the generic interface and possibly declare a concrete type for its type variable . | 119 | 35 |
149,472 | private static Class < ? > extractClass ( Class < ? > ownerClass , Type arg ) { if ( arg instanceof ParameterizedType ) { return extractClass ( ownerClass , ( ( ParameterizedType ) arg ) . getRawType ( ) ) ; } else if ( arg instanceof GenericArrayType ) { GenericArrayType gat = ( GenericArrayType ) arg ; Type gt = gat . getGenericComponentType ( ) ; Class < ? > componentClass = extractClass ( ownerClass , gt ) ; return Array . newInstance ( componentClass , 0 ) . getClass ( ) ; } else if ( arg instanceof TypeVariable ) { TypeVariable tv = ( TypeVariable ) arg ; arg = getTypeVariableMap ( ownerClass ) . get ( tv ) ; if ( arg == null ) { arg = extractBoundForTypeVariable ( tv ) ; if ( arg instanceof ParameterizedType ) { return extractClass ( ownerClass , ( ( ParameterizedType ) arg ) . getRawType ( ) ) ; } } else { return extractClass ( ownerClass , arg ) ; } } return ( arg instanceof Class ? ( Class ) arg : Object . class ) ; } | Extract a Class from the given Type . | 252 | 9 |
149,473 | static Type getRawType ( Type genericType , Map < TypeVariable , Type > typeVariableMap ) { Type resolvedType = genericType ; if ( genericType instanceof TypeVariable ) { TypeVariable tv = ( TypeVariable ) genericType ; resolvedType = typeVariableMap . get ( tv ) ; if ( resolvedType == null ) { resolvedType = extractBoundForTypeVariable ( tv ) ; } } if ( resolvedType instanceof ParameterizedType ) { return ( ( ParameterizedType ) resolvedType ) . getRawType ( ) ; } else { return resolvedType ; } } | Determine the raw type for the given generic parameter type . | 123 | 13 |
149,474 | public static Class < ? > getMapValueFieldType ( Field mapField , int nestingLevel ) { return getGenericFieldType ( mapField , Map . class , 1 , null , nestingLevel ) ; } | Determine the generic value type of the given Map field . | 43 | 13 |
149,475 | private static Class < ? > getGenericReturnType ( Method method , Class < ? > source , int typeIndex , int nestingLevel ) { return extractType ( method . getGenericReturnType ( ) , source , typeIndex , null , null , nestingLevel , 1 ) ; } | Extract the generic return type from the given method . | 58 | 11 |
149,476 | private static Class < ? > extractTypeFromClass ( Class < ? > clazz , Class < ? > source , int typeIndex , Map < TypeVariable , Type > typeVariableMap , Map < Integer , Integer > typeIndexesPerLevel , int nestingLevel , int currentLevel ) { if ( clazz . getName ( ) . startsWith ( "java.util." ) ) { return null ; } if ( clazz . getSuperclass ( ) != null && isIntrospectionCandidate ( clazz . getSuperclass ( ) ) ) { try { return extractType ( clazz . getGenericSuperclass ( ) , source , typeIndex , typeVariableMap , typeIndexesPerLevel , nestingLevel , currentLevel ) ; } catch ( MalformedParameterizedTypeException ex ) { // from getGenericSuperclass() - ignore and continue with interface introspection } } Type [ ] ifcs = clazz . getGenericInterfaces ( ) ; if ( ifcs != null ) { for ( Type ifc : ifcs ) { Type rawType = ifc ; if ( ifc instanceof ParameterizedType ) { rawType = ( ( ParameterizedType ) ifc ) . getRawType ( ) ; } if ( rawType instanceof Class && isIntrospectionCandidate ( ( Class ) rawType ) ) { return extractType ( ifc , source , typeIndex , typeVariableMap , typeIndexesPerLevel , nestingLevel , currentLevel ) ; } } } return null ; } | Extract the generic type from the given Class object . | 316 | 11 |
149,477 | @ Override public boolean exists ( ) { try { InputStream inputStream = this . assetManager . open ( this . fileName ) ; if ( inputStream != null ) { return true ; } else { return false ; } } catch ( IOException e ) { return false ; } } | This implementation returns whether the underlying asset exists . | 60 | 9 |
149,478 | static void addHeaders ( HttpUriRequest httpRequest , HttpHeaders headers ) { for ( Map . Entry < String , List < String > > entry : headers . entrySet ( ) ) { String headerName = entry . getKey ( ) ; if ( HttpHeaders . COOKIE . equalsIgnoreCase ( headerName ) ) { // RFC 6265 String headerValue = StringUtils . collectionToDelimitedString ( entry . getValue ( ) , "; " ) ; httpRequest . addHeader ( headerName , headerValue ) ; } else if ( ! HTTP . CONTENT_LEN . equalsIgnoreCase ( headerName ) && ! HTTP . TRANSFER_ENCODING . equalsIgnoreCase ( headerName ) ) { for ( String headerValue : entry . getValue ( ) ) { httpRequest . addHeader ( headerName , headerValue ) ; } } } } | Add the given headers to the given HTTP request . | 193 | 10 |
149,479 | public boolean canBypassConvert ( TypeDescriptor sourceType , TypeDescriptor targetType ) { Assert . notNull ( targetType , "The targetType to convert to cannot be null" ) ; if ( sourceType == null ) { return true ; } GenericConverter converter = getConverter ( sourceType , targetType ) ; return ( converter == NO_OP_CONVERTER ) ; } | Returns true if conversion between the sourceType and targetType can be bypassed . More precisely this method will return true if objects of sourceType can be converted to the targetType by returning the source object unchanged . | 89 | 42 |
149,480 | protected static int calculateShift ( int minimumValue , int maximumValue ) { int shift = 0 ; int value = 1 ; while ( value < minimumValue && value < maximumValue ) { value <<= 1 ; shift ++ ; } return shift ; } | Calculate a shift value that can be used to create a power - of - two value between the specified maximum and minimum values . | 51 | 27 |
149,481 | public MediaType copyQualityValue ( MediaType mediaType ) { if ( ! mediaType . parameters . containsKey ( PARAM_QUALITY_FACTOR ) ) { return this ; } Map < String , String > params = new LinkedHashMap < String , String > ( this . parameters ) ; params . put ( PARAM_QUALITY_FACTOR , mediaType . parameters . get ( PARAM_QUALITY_FACTOR ) ) ; return new MediaType ( this , params ) ; } | Return a replica of this instance with the quality value of the given MediaType . | 111 | 16 |
149,482 | public MediaType removeQualityValue ( ) { if ( ! this . parameters . containsKey ( PARAM_QUALITY_FACTOR ) ) { return this ; } Map < String , String > params = new LinkedHashMap < String , String > ( this . parameters ) ; params . remove ( PARAM_QUALITY_FACTOR ) ; return new MediaType ( this , params ) ; } | Return a replica of this instance with its quality value removed . | 87 | 12 |
149,483 | @ Override public String getFirst ( String headerName ) { List < String > headerValues = headers . get ( headerName ) ; return headerValues != null ? headerValues . get ( 0 ) : null ; } | Return the first header value for the given header name if any . | 45 | 13 |
149,484 | @ Override public void add ( String headerName , String headerValue ) { List < String > headerValues = headers . get ( headerName ) ; if ( headerValues == null ) { headerValues = new LinkedList < String > ( ) ; this . headers . put ( headerName , headerValues ) ; } headerValues . add ( headerValue ) ; } | Add the given single header value under the given name . | 76 | 11 |
149,485 | @ Override public void set ( String headerName , String headerValue ) { List < String > headerValues = new LinkedList < String > ( ) ; headerValues . add ( headerValue ) ; headers . put ( headerName , headerValues ) ; } | Set the given single header value under the given name . | 54 | 11 |
149,486 | private void setViewPagerScroller ( ) { try { Field scrollerField = ViewPager . class . getDeclaredField ( "mScroller" ) ; scrollerField . setAccessible ( true ) ; Field interpolatorField = ViewPager . class . getDeclaredField ( "sInterpolator" ) ; interpolatorField . setAccessible ( true ) ; scroller = new CustomDurationScroller ( getContext ( ) , ( Interpolator ) interpolatorField . get ( null ) ) ; scrollerField . set ( this , scroller ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } | set ViewPager scroller to change animation duration when sliding | 141 | 12 |
149,487 | public void scrollOnce ( ) { PagerAdapter adapter = getAdapter ( ) ; int currentItem = getCurrentItem ( ) ; int totalCount ; if ( adapter == null || ( totalCount = adapter . getCount ( ) ) <= 1 ) { return ; } int nextItem = ( direction == LEFT ) ? -- currentItem : ++ currentItem ; if ( nextItem < 0 ) { if ( isCycle ) { setCurrentItem ( totalCount - 1 , isBorderAnimation ) ; } } else if ( nextItem == totalCount ) { if ( isCycle ) { setCurrentItem ( 0 , isBorderAnimation ) ; } } else { setCurrentItem ( nextItem , true ) ; } } | scroll only once | 149 | 3 |
149,488 | public void setHomeAsUpIndicator ( Drawable indicator ) { if ( ! deviceSupportMultiPane ( ) ) { pulsante . setHomeAsUpIndicator ( indicator ) ; } else { actionBar . setHomeAsUpIndicator ( indicator ) ; } } | Set the HomeAsUpIndicator that is visible when user navigate to a fragment child | 57 | 17 |
149,489 | public MaterialSection getSectionByTitle ( String title ) { for ( MaterialSection section : sectionList ) { if ( section . getTitle ( ) . equals ( title ) ) { return section ; } } for ( MaterialSection section : bottomSectionList ) { if ( section . getTitle ( ) . equals ( title ) ) return section ; } return null ; } | Get a setted section knowing his title | 75 | 8 |
149,490 | public List < MaterialSection > getSectionList ( ) { List < MaterialSection > list = new LinkedList <> ( ) ; for ( MaterialSection section : sectionList ) list . ( section ) ; for ( MaterialSection section : bottomSectionList ) list . ( section ) ; return list ; } | Get the section list | 63 | 4 |
149,491 | public MaterialAccount getAccountAtCurrentPosition ( int position ) { if ( position < 0 || position >= accountManager . size ( ) ) throw new RuntimeException ( "Account Index Overflow" ) ; return findAccountNumber ( position ) ; } | Get the account knowing his position | 50 | 6 |
149,492 | public MaterialAccount getAccountByTitle ( String title ) { for ( MaterialAccount account : accountManager ) if ( currentAccount . getTitle ( ) . equals ( title ) ) return account ; return null ; } | Get the account knowing his title | 43 | 6 |
149,493 | @ Override @ SuppressLint ( "NewApi" ) public boolean onTouch ( View v , MotionEvent event ) { if ( touchable ) { if ( event . getAction ( ) == MotionEvent . ACTION_DOWN ) { view . setBackgroundColor ( colorPressed ) ; return true ; } if ( event . getAction ( ) == MotionEvent . ACTION_CANCEL ) { if ( isSelected ) view . setBackgroundColor ( colorSelected ) ; else view . setBackgroundColor ( colorUnpressed ) ; return true ; } if ( event . getAction ( ) == MotionEvent . ACTION_UP ) { view . setBackgroundColor ( colorSelected ) ; afterClick ( ) ; return true ; } } return false ; } | touch event without ripple support | 160 | 5 |
149,494 | public void setBackgroundColor ( int color ) { colorUnpressed = color ; if ( ! isSelected ( ) ) { if ( rippleAnimationSupport ( ) ) { ripple . setRippleBackground ( colorUnpressed ) ; } else { view . setBackgroundColor ( colorUnpressed ) ; } } } | alias of setColorUnpressed | 64 | 6 |
149,495 | public List < NodeInfo > getNodes ( ) { final URI uri = uriWithPath ( "./nodes/" ) ; return Arrays . asList ( this . rt . getForObject ( uri , NodeInfo [ ] . class ) ) ; } | Retrieves state and metrics information for all nodes in the cluster . | 58 | 14 |
149,496 | public NodeInfo getNode ( String name ) { final URI uri = uriWithPath ( "./nodes/" + encodePathSegment ( name ) ) ; return this . rt . getForObject ( uri , NodeInfo . class ) ; } | Retrieves state and metrics information for individual node . | 55 | 11 |
149,497 | public List < ConnectionInfo > getConnections ( ) { final URI uri = uriWithPath ( "./connections/" ) ; return Arrays . asList ( this . rt . getForObject ( uri , ConnectionInfo [ ] . class ) ) ; } | Retrieves state and metrics information for all client connections across the cluster . | 58 | 15 |
149,498 | public ConnectionInfo getConnection ( String name ) { final URI uri = uriWithPath ( "./connections/" + encodePathSegment ( name ) ) ; return this . rt . getForObject ( uri , ConnectionInfo . class ) ; } | Retrieves state and metrics information for individual client connection . | 55 | 12 |
149,499 | public List < ChannelInfo > getChannels ( ) { final URI uri = uriWithPath ( "./channels/" ) ; return Arrays . asList ( this . rt . getForObject ( uri , ChannelInfo [ ] . class ) ) ; } | Retrieves state and metrics information for all channels across the cluster . | 58 | 14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.