idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
6,500 | public static boolean isClientAbortException ( IOException e ) { String exceptionClassName = e . getClass ( ) . getName ( ) ; return exceptionClassName . endsWith ( ".EofException" ) || exceptionClassName . endsWith ( ".ClientAbortException" ) ; } | Checks if the exception is a client abort exception |
6,501 | @ SuppressWarnings ( "unchecked" ) private void insertPair ( ReflectedHandle < K , V > handle1 , ReflectedHandle < K , V > handle2 ) { int c ; if ( comparator == null ) { c = ( ( Comparable < ? super K > ) handle1 . key ) . compareTo ( handle2 . key ) ; } else { c = comparator . compare ( handle1 . key , handle2 . key ) ; } AddressableHeap . Handle < K , HandleMap < K , V > > innerHandle1 ; AddressableHeap . Handle < K , HandleMap < K , V > > innerHandle2 ; if ( c <= 0 ) { innerHandle1 = minHeap . insert ( handle1 . key ) ; handle1 . minNotMax = true ; innerHandle2 = maxHeap . insert ( handle2 . key ) ; handle2 . minNotMax = false ; } else { innerHandle1 = maxHeap . insert ( handle1 . key ) ; handle1 . minNotMax = false ; innerHandle2 = minHeap . insert ( handle2 . key ) ; handle2 . minNotMax = true ; } handle1 . inner = innerHandle1 ; handle2 . inner = innerHandle2 ; innerHandle1 . setValue ( new HandleMap < K , V > ( handle1 , innerHandle2 ) ) ; innerHandle2 . setValue ( new HandleMap < K , V > ( handle2 , innerHandle1 ) ) ; } | Insert a pair of elements one in the min heap and one in the max heap . |
6,502 | private void delete ( ReflectedHandle < K , V > n ) { if ( n . inner == null && free != n ) { throw new IllegalArgumentException ( "Invalid handle!" ) ; } if ( free == n ) { free = null ; } else { AddressableHeap . Handle < K , HandleMap < K , V > > nInner = n . inner ; ReflectedHandle < K , V > nOuter = nInner . getValue ( ) . outer ; nInner . delete ( ) ; nOuter . inner = null ; nOuter . minNotMax = false ; AddressableHeap . Handle < K , HandleMap < K , V > > otherInner = nInner . getValue ( ) . otherInner ; ReflectedHandle < K , V > otherOuter = otherInner . getValue ( ) . outer ; otherInner . delete ( ) ; otherOuter . inner = null ; otherOuter . minNotMax = false ; if ( free == null ) { free = otherOuter ; } else { insertPair ( otherOuter , free ) ; free = null ; } } size -- ; } | Delete an element |
6,503 | @ SuppressWarnings ( "unchecked" ) private void decreaseKey ( ReflectedHandle < K , V > n , K newKey ) { if ( n . inner == null && free != n ) { throw new IllegalArgumentException ( "Invalid handle!" ) ; } int c ; if ( comparator == null ) { c = ( ( Comparable < ? super K > ) newKey ) . compareTo ( n . key ) ; } else { c = comparator . compare ( newKey , n . key ) ; } if ( c > 0 ) { throw new IllegalArgumentException ( "Keys can only be decreased!" ) ; } n . key = newKey ; if ( c == 0 || free == n ) { return ; } AddressableHeap . Handle < K , HandleMap < K , V > > nInner = n . inner ; if ( n . minNotMax ) { n . inner . decreaseKey ( newKey ) ; } else { nInner . delete ( ) ; ReflectedHandle < K , V > nOuter = nInner . getValue ( ) . outer ; nOuter . inner = null ; nOuter . minNotMax = false ; AddressableHeap . Handle < K , HandleMap < K , V > > minInner = nInner . getValue ( ) . otherInner ; ReflectedHandle < K , V > minOuter = minInner . getValue ( ) . outer ; minInner . delete ( ) ; minOuter . inner = null ; minOuter . minNotMax = false ; nOuter . key = newKey ; insertPair ( nOuter , minOuter ) ; } } | Decrease the key of an element . |
6,504 | public void send ( Context context , byte [ ] data , ResponseListener listener ) { setContext ( context ) ; super . send ( data , listener ) ; } | Send this resource request asynchronously with the given byte array as the request body . This method does not set any Content - Type header ; if such a header is required it must be set before calling this method . |
6,505 | public void upload ( Context context , final File file , final ProgressListener progressListener , ResponseListener responseListener ) { setContext ( context ) ; super . upload ( file , progressListener , responseListener ) ; } | Upload a file asynchronously . This method does not set any Content - Type header ; if such a header is required it must be set before calling this method . |
6,506 | protected String getImgSrcToRender ( ) throws JspException { BinaryResourcesHandler binaryRsHandler = ( BinaryResourcesHandler ) pageContext . getServletContext ( ) . getAttribute ( JawrConstant . BINARY_CONTEXT_ATTRIBUTE ) ; if ( null == binaryRsHandler ) throw new JspException ( "You are using a Jawr image tag while the Jawr Binary servlet has not been initialized. Initialization of Jawr Image servlet either failed or never occurred." ) ; HttpServletResponse response = ( HttpServletResponse ) pageContext . getResponse ( ) ; HttpServletRequest request = ( HttpServletRequest ) pageContext . getRequest ( ) ; return ImageTagUtils . getImageUrl ( src , base64 , binaryRsHandler , request , response ) ; } | Returns the image source to render |
6,507 | public static String rewriteGeneratedBinaryResourceDebugUrl ( String requestPath , String content , String binaryServletMapping ) { if ( binaryServletMapping == null ) { binaryServletMapping = "" ; } String relativeRootUrlPath = PathNormalizer . getRootRelativePath ( requestPath ) ; String replacementPattern = PathNormalizer . normalizePath ( "$1" + relativeRootUrlPath + binaryServletMapping + "/$5_cbDebug/$7$8" ) ; Matcher matcher = GENERATED_BINARY_RESOURCE_PATTERN . matcher ( content ) ; StringBuffer result = new StringBuffer ( ) ; while ( matcher . find ( ) ) { matcher . appendReplacement ( result , replacementPattern ) ; } matcher . appendTail ( result ) ; return result . toString ( ) ; } | Rewrites the generated binary resource URL for debug mode |
6,508 | private void performInitializations ( ) { try { BMSClient . getInstance ( ) . initialize ( getApplicationContext ( ) , backendURL , backendGUID , BMSClient . REGION_US_SOUTH ) ; } catch ( MalformedURLException e ) { e . printStackTrace ( ) ; } MCAAuthorizationManager mcaAuthorizationManager = MCAAuthorizationManager . createInstance ( this . getApplicationContext ( ) ) ; mcaAuthorizationManager . registerAuthenticationListener ( customRealm , new MyChallengeHandler ( ) ) ; mcaAuthorizationManager . clearAuthorizationData ( ) ; BMSClient . getInstance ( ) . setAuthorizationManager ( mcaAuthorizationManager ) ; Logger . setLogLevel ( Logger . LEVEL . DEBUG ) ; Logger . setSDKDebugLoggingEnabled ( true ) ; } | Initialize BMSClient and set the authorization manager |
6,509 | private void getNetworkInfo ( ) { NetworkConnectionListener listener = new NetworkConnectionListener ( ) { public void networkChanged ( NetworkConnectionType newConnection ) { Log . i ( "BMSCore" , "New network connection: " + newConnection . toString ( ) ) ; } } ; this . networkMonitor = new NetworkMonitor ( getApplicationContext ( ) , listener ) ; networkMonitor . startMonitoringNetworkChanges ( ) ; Log . i ( "BMSCore" , "Is connected to the internet: " + networkMonitor . isInternetAccessAvailable ( ) ) ; Log . i ( "BMSCore" , "Connection type: " + networkMonitor . getCurrentConnectionType ( ) . toString ( ) ) ; int networkPermission = ContextCompat . checkSelfPermission ( this , Manifest . permission . READ_PHONE_STATE ) ; if ( networkPermission == PackageManager . PERMISSION_GRANTED ) { Log . i ( "BMSCore" , "Mobile network type: " + networkMonitor . getMobileNetworkType ( ) ) ; } else { Log . i ( "BMSCore" , "Obtaining permission to read phone state" ) ; if ( ActivityCompat . shouldShowRequestPermissionRationale ( this , Manifest . permission . READ_PHONE_STATE ) ) { } else { ActivityCompat . requestPermissions ( this , new String [ ] { Manifest . permission . READ_PHONE_STATE } , MY_PERMISSIONS_READ_PHONE_STATE ) ; } } } | Exercise the NetworkMonitor API |
6,510 | private void sendSomeRequests ( ) { ResponseListener responseListener = new MyResponseListener ( ) ; sendCustomUrlRequest ( responseListener ) ; sendAutoRetryRequest ( responseListener ) ; downloadImage ( responseListener ) ; uploadData ( responseListener ) ; uploadFile ( responseListener ) ; uploadText ( responseListener ) ; } | Exercise the Request and Response APIs |
6,511 | public void startAuthorizationProcess ( final Context context , ResponseListener listener ) { authorizationQueue . add ( listener ) ; if ( authorizationQueue . size ( ) == 1 ) { try { if ( preferences . clientId . get ( ) == null ) { logger . info ( "starting registration process" ) ; invokeInstanceRegistrationRequest ( context ) ; } else { logger . info ( "starting authorization process" ) ; invokeAuthorizationRequest ( context ) ; } } catch ( Throwable t ) { handleAuthorizationFailure ( t ) ; } } else { logger . info ( "authorization process already running, adding response listener to the queue" ) ; logger . debug ( String . format ( "authorization process currently handling %d requests" , authorizationQueue . size ( ) ) ) ; } } | Main method to start authorization process |
6,512 | private void invokeInstanceRegistrationRequest ( final Context context ) { AuthorizationRequestManager . RequestOptions options = new AuthorizationRequestManager . RequestOptions ( ) ; options . parameters = createRegistrationParams ( ) ; options . headers = createRegistrationHeaders ( ) ; options . requestMethod = Request . POST ; InnerAuthorizationResponseListener listener = new InnerAuthorizationResponseListener ( ) { public void handleAuthorizationSuccessResponse ( Response response ) throws Exception { saveCertificateFromResponse ( response ) ; invokeAuthorizationRequest ( context ) ; } } ; authorizationRequestSend ( null , "clients/instance" , options , listener ) ; } | Invoke request for registration the result of the request should contain ClientId . |
6,513 | private HashMap < String , String > createRegistrationParams ( ) { registrationKeyPair = KeyPairUtility . generateRandomKeyPair ( ) ; JSONObject csrJSON = new JSONObject ( ) ; HashMap < String , String > params ; try { DeviceIdentity deviceData = new BaseDeviceIdentity ( preferences . deviceIdentity . getAsMap ( ) ) ; AppIdentity applicationData = new BaseAppIdentity ( preferences . appIdentity . getAsMap ( ) ) ; csrJSON . put ( "deviceId" , deviceData . getId ( ) ) ; csrJSON . put ( "deviceOs" , "" + deviceData . getOS ( ) ) ; csrJSON . put ( "deviceModel" , deviceData . getModel ( ) ) ; csrJSON . put ( "applicationId" , applicationData . getId ( ) ) ; csrJSON . put ( "applicationVersion" , applicationData . getVersion ( ) ) ; csrJSON . put ( "environment" , "android" ) ; String csrValue = jsonSigner . sign ( registrationKeyPair , csrJSON ) ; params = new HashMap < > ( 1 ) ; params . put ( "CSR" , csrValue ) ; return params ; } catch ( Exception e ) { throw new RuntimeException ( "Failed to create registration params" , e ) ; } } | Generate the params that will be used during the registration phase |
6,514 | private HashMap < String , String > createRegistrationHeaders ( ) { HashMap < String , String > headers = new HashMap < > ( ) ; addSessionIdHeader ( headers ) ; return headers ; } | Generate the headers that will be used during the registration phase |
6,515 | private HashMap < String , String > createTokenRequestParams ( String grantCode ) { HashMap < String , String > params = new HashMap < > ( ) ; params . put ( "code" , grantCode ) ; params . put ( "client_id" , preferences . clientId . get ( ) ) ; params . put ( "grant_type" , "authorization_code" ) ; params . put ( "redirect_uri" , HTTP_LOCALHOST ) ; return params ; } | Generate the params that will be used during the token request phase |
6,516 | private void saveCertificateFromResponse ( Response response ) { try { String responseBody = response . getResponseText ( ) ; JSONObject jsonResponse = new JSONObject ( responseBody ) ; String certificateString = jsonResponse . getString ( "certificate" ) ; X509Certificate certificate = CertificatesUtility . base64StringToCertificate ( certificateString ) ; CertificatesUtility . checkValidityWithPublicKey ( certificate , registrationKeyPair . getPublic ( ) ) ; certificateStore . saveCertificate ( registrationKeyPair , certificate ) ; preferences . clientId . set ( jsonResponse . getString ( "clientId" ) ) ; } catch ( Exception e ) { throw new RuntimeException ( "Failed to save certificate from response" , e ) ; } logger . debug ( "certificate successfully saved" ) ; } | Extract the certificate data from response and save it on local storage |
6,517 | private void invokeAuthorizationRequest ( Context context ) { AuthorizationRequestManager . RequestOptions options = new AuthorizationRequestManager . RequestOptions ( ) ; options . parameters = createAuthorizationParams ( ) ; options . headers = new HashMap < > ( 1 ) ; addSessionIdHeader ( options . headers ) ; options . requestMethod = Request . GET ; InnerAuthorizationResponseListener listener = new InnerAuthorizationResponseListener ( ) { public void handleAuthorizationSuccessResponse ( Response response ) throws Exception { String location = extractLocationHeader ( response ) ; String grantCode = extractGrantCode ( location ) ; invokeTokenRequest ( grantCode ) ; } } ; authorizationRequestSend ( context , "authorization" , options , listener ) ; } | Invoke the authorization request the result of the request should be a grant code |
6,518 | private HashMap < String , String > createAuthorizationParams ( ) { HashMap < String , String > params = new HashMap < > ( 3 ) ; params . put ( "response_type" , "code" ) ; params . put ( "client_id" , preferences . clientId . get ( ) ) ; params . put ( "redirect_uri" , HTTP_LOCALHOST ) ; return params ; } | Generate the params that will be used during the authorization phase |
6,519 | private String extractGrantCode ( String urlString ) throws MalformedURLException { URL url = new URL ( urlString ) ; String code = Utils . getParameterValueFromQuery ( url . getQuery ( ) , "code" ) ; if ( code == null ) { throw new RuntimeException ( "Failed to extract grant code from url" ) ; } logger . debug ( "Grant code extracted successfully" ) ; return code ; } | Extract grant code from url string |
6,520 | private void invokeTokenRequest ( String grantCode ) { AuthorizationRequestManager . RequestOptions options = new AuthorizationRequestManager . RequestOptions ( ) ; options . parameters = createTokenRequestParams ( grantCode ) ; options . headers = createTokenRequestHeaders ( grantCode ) ; addSessionIdHeader ( options . headers ) ; options . requestMethod = Request . POST ; InnerAuthorizationResponseListener listener = new InnerAuthorizationResponseListener ( ) { public void handleAuthorizationSuccessResponse ( Response response ) throws Exception { saveTokenFromResponse ( response ) ; handleAuthorizationSuccess ( response ) ; } } ; authorizationRequestSend ( null , "token" , options , listener ) ; } | Invoke request to get token the result of the response should be a valid token |
6,521 | private HashMap < String , String > createTokenRequestHeaders ( String grantCode ) { JSONObject payload = new JSONObject ( ) ; HashMap < String , String > headers ; try { payload . put ( "code" , grantCode ) ; KeyPair keyPair = certificateStore . getStoredKeyPair ( ) ; String jws = jsonSigner . sign ( keyPair , payload ) ; headers = new HashMap < > ( 1 ) ; headers . put ( "X-WL-Authenticate" , jws ) ; } catch ( Exception e ) { throw new RuntimeException ( "Failed to create token request headers" , e ) ; } return headers ; } | Generate the headers that will be used during the token request phase |
6,522 | private void saveTokenFromResponse ( Response response ) { try { JSONObject responseJSON = ( ( ResponseImpl ) response ) . getResponseJSON ( ) ; String accessToken = responseJSON . getString ( "access_token" ) ; String idToken = responseJSON . getString ( "id_token" ) ; preferences . accessToken . set ( accessToken ) ; preferences . idToken . set ( idToken ) ; String [ ] idTokenData = idToken . split ( "\\." ) ; byte [ ] decodedIdTokenData = Base64 . decode ( idTokenData [ 1 ] , Base64 . DEFAULT ) ; String decodedIdTokenString = new String ( decodedIdTokenData ) ; JSONObject idTokenJSON = new JSONObject ( decodedIdTokenString ) ; if ( idTokenJSON . has ( "imf.user" ) ) { preferences . userIdentity . set ( idTokenJSON . getJSONObject ( "imf.user" ) ) ; } logger . debug ( "token successfully saved" ) ; } catch ( Exception e ) { throw new RuntimeException ( "Failed to save token from response" , e ) ; } } | Extract token from response and save it locally |
6,523 | private void authorizationRequestSend ( final Context context , String path , AuthorizationRequestManager . RequestOptions options , ResponseListener listener ) { try { AuthorizationRequestManager authorizationRequestManager = new AuthorizationRequestManager ( ) ; authorizationRequestManager . initialize ( context , listener ) ; authorizationRequestManager . sendRequest ( path , options ) ; } catch ( Exception e ) { throw new RuntimeException ( "Failed to send authorization request" , e ) ; } } | Use authorization request agent for sending the request |
6,524 | private void handleAuthorizationFailure ( Response response , Throwable t , JSONObject extendedInfo ) { logger . error ( "authorization process failed" ) ; if ( t != null ) { t . printStackTrace ( ) ; } Iterator < ResponseListener > iterator = authorizationQueue . iterator ( ) ; while ( iterator . hasNext ( ) ) { ResponseListener next = iterator . next ( ) ; next . onFailure ( response , t , extendedInfo ) ; iterator . remove ( ) ; } } | Handle failure in the authorization process . All the response listeners will be updated with failure |
6,525 | private void handleAuthorizationSuccess ( Response response ) { Iterator < ResponseListener > iterator = authorizationQueue . iterator ( ) ; while ( iterator . hasNext ( ) ) { ResponseListener next = iterator . next ( ) ; next . onSuccess ( response ) ; iterator . remove ( ) ; } } | Handle success in the authorization process . All the response listeners will be updated with success |
6,526 | public void setProxy ( Proxy proxy ) { if ( proxy != null ) { java . net . Proxy p = new java . net . Proxy ( java . net . Proxy . Type . HTTP , new InetSocketAddress ( proxy . getHost ( ) , proxy . getPort ( ) ) ) ; client . setProxy ( p ) ; } else client . setProxy ( java . net . Proxy . NO_PROXY ) ; } | Set the proxy configuration to use for this client . |
6,527 | public void setKeepAliveConfiguration ( KeepAliveConfiguration keepAliveConfiguration ) { if ( keepAliveConfiguration != null ) client . setConnectionPool ( new ConnectionPool ( keepAliveConfiguration . getMaxIdleConnections ( ) , keepAliveConfiguration . getKeepAliveDurationMs ( ) ) ) ; } | Set the keep alive configuration to use for this client . |
6,528 | public void setLogger ( String logger ) { if ( logger != null && logger . trim ( ) . length ( ) > 0 ) this . logger = LoggerFactory . getLogger ( logger ) ; } | Set an alternate logger for this client to use for log statements . This can be used to direct client logs to different destinations . The default value is com . dottydingo . hyperion . client . HyperionClient |
6,529 | protected com . squareup . okhttp . Request buildHttpRequest ( Request request ) { RequestBody requestBody = null ; if ( request . getRequestMethod ( ) . isBodyRequest ( ) ) requestBody = RequestBody . create ( JSON , serializeBody ( request ) ) ; return new com . squareup . okhttp . Request . Builder ( ) . url ( buildUrl ( request ) ) . headers ( getHeaders ( request ) ) . method ( request . getRequestMethod ( ) . name ( ) , requestBody ) . build ( ) ; } | Build the actual http request |
6,530 | protected < T > T readResponse ( Response response , JavaType javaType ) { try { return objectMapper . readValue ( response . body ( ) . byteStream ( ) , javaType ) ; } catch ( IOException e ) { throw new ClientMarshallingException ( "Error reading results." , e ) ; } } | Read the response and unmarshall into the expected type |
6,531 | protected String serializeBody ( Request request ) { try { return objectMapper . writeValueAsString ( request . getRequestBody ( ) ) ; } catch ( JsonProcessingException e ) { throw new ClientMarshallingException ( "Error writing request." , e ) ; } } | Serialize the request body |
6,532 | protected HyperionException readException ( Response response ) throws IOException { ErrorResponse errorResponse = null ; try { errorResponse = objectMapper . readValue ( response . body ( ) . byteStream ( ) , ErrorResponse . class ) ; } catch ( Exception ignore ) { } HyperionException resolvedException = null ; if ( errorResponse != null ) { try { Class exceptionClass = Class . forName ( errorResponse . getType ( ) ) ; resolvedException = ( HyperionException ) exceptionClass . getConstructor ( String . class ) . newInstance ( errorResponse . getMessage ( ) ) ; } catch ( Throwable ignore ) { } if ( resolvedException == null ) { resolvedException = new HyperionException ( errorResponse . getStatusCode ( ) , errorResponse . getMessage ( ) ) ; } resolvedException . setErrorDetails ( errorResponse . getErrorDetails ( ) ) ; resolvedException . setErrorTime ( errorResponse . getErrorTime ( ) ) ; resolvedException . setRequestId ( errorResponse . getRequestId ( ) ) ; } if ( resolvedException == null ) { resolvedException = new HyperionException ( response . code ( ) , response . message ( ) ) ; } return resolvedException ; } | Create the proper exception for the error response |
6,533 | protected String buildUrl ( Request request ) { StringBuilder sb = new StringBuilder ( 512 ) ; sb . append ( baseUrl ) . append ( request . getEntityName ( ) ) . append ( "/" ) ; if ( request . getPath ( ) != null ) sb . append ( request . getPath ( ) ) ; String queryString = buildQueryString ( request ) ; if ( queryString . length ( ) > 0 ) { sb . append ( "?" ) . append ( queryString ) ; } return sb . toString ( ) ; } | Build the URL for the specified request |
6,534 | protected String buildQueryString ( Request request ) { MultiMap resolvedParameters = null ; if ( parameterFactory != null ) { resolvedParameters = parameterFactory . getParameters ( ) ; } if ( hasEntries ( resolvedParameters ) ) resolvedParameters = resolvedParameters . merge ( request . getParameters ( ) ) ; else resolvedParameters = request . getParameters ( ) ; if ( authorizationFactory != null ) { MultiMap authEntries = authorizationFactory . getParameters ( ) ; if ( hasEntries ( authEntries ) ) resolvedParameters = resolvedParameters . merge ( authEntries ) ; } int ct = 0 ; StringBuilder sb = new StringBuilder ( 512 ) ; for ( Map . Entry < String , List < String > > entry : resolvedParameters . entries ( ) ) { for ( String value : entry . getValue ( ) ) { if ( ct ++ > 0 ) sb . append ( "&" ) ; sb . append ( encode ( entry . getKey ( ) ) ) . append ( "=" ) . append ( encode ( value ) ) ; } } return sb . toString ( ) ; } | Build the query string for the specified request |
6,535 | protected Headers getHeaders ( Request request ) { Headers . Builder headers = new Headers . Builder ( ) ; MultiMap resolvedHeaders = null ; if ( headerFactory != null ) resolvedHeaders = headerFactory . getHeaders ( ) ; if ( hasEntries ( resolvedHeaders ) ) resolvedHeaders = resolvedHeaders . merge ( request . getHeaders ( ) ) ; else resolvedHeaders = request . getHeaders ( ) ; if ( authorizationFactory != null ) { MultiMap authEntries = authorizationFactory . getHeaders ( ) ; if ( hasEntries ( authEntries ) ) resolvedHeaders = resolvedHeaders . merge ( authEntries ) ; } if ( resolvedHeaders . getFirst ( "user-agent" ) == null ) headers . add ( "user-agent" , userAgent ) ; if ( resolvedHeaders . getFirst ( CLIENT_VERSION_HEADER_NAME ) == null ) headers . add ( CLIENT_VERSION_HEADER_NAME , getClientVersion ( ) ) ; for ( Map . Entry < String , List < String > > entry : resolvedHeaders . entries ( ) ) { for ( String value : entry . getValue ( ) ) { headers . add ( entry . getKey ( ) , value ) ; } } return headers . build ( ) ; } | Return the headers for the supplied request |
6,536 | protected String encode ( String value ) { try { return URLEncoder . encode ( value , "UTF-8" ) ; } catch ( UnsupportedEncodingException e ) { throw new ClientException ( 500 , "Error encoding parameter." , e ) ; } } | Encode the supplied string |
6,537 | IntIterator keyIterator ( ) { return new IntIterator ( ) { final IntIterator setitr = set . keyIterator ( ) ; public boolean hasNext ( ) { return setitr . hasNext ( ) ; } public int next ( ) { return setitr . next ( ) ; } } ; } | Returns an iterator over the keys of this map . The keys are returned in no particular order . |
6,538 | public static String getContextPath ( ServletContext servletContext ) { String contextPath = DEFAULT_CONTEXT_PATH ; if ( servletContext != null ) { contextPath = servletContext . getContextPath ( ) ; if ( StringUtils . isEmpty ( contextPath ) ) { contextPath = DEFAULT_CONTEXT_PATH ; } } return contextPath ; } | Returns the context path associated to the servlet context |
6,539 | protected void processCollectionRequest ( HyperionContext hyperionContext ) { EndpointRequest request = hyperionContext . getEndpointRequest ( ) ; EndpointResponse response = hyperionContext . getEndpointResponse ( ) ; ApiVersionPlugin < ApiObject < Serializable > , PersistentObject < Serializable > , Serializable > apiVersionPlugin = hyperionContext . getVersionPlugin ( ) ; EntityPlugin plugin = hyperionContext . getEntityPlugin ( ) ; List < ApiObject < Serializable > > clientObjects = null ; try { clientObjects = marshaller . unmarshallCollection ( request . getInputStream ( ) , apiVersionPlugin . getApiClass ( ) ) ; } catch ( WriteLimitException e ) { throw new BadRequestException ( messageSource . getErrorMessage ( ERROR_WRITE_LIMIT , hyperionContext . getLocale ( ) , e . getWriteLimit ( ) ) , e ) ; } catch ( MarshallingException e ) { throw new BadRequestException ( messageSource . getErrorMessage ( ERROR_READING_REQUEST , hyperionContext . getLocale ( ) , e . getMessage ( ) ) , e ) ; } PersistenceContext persistenceContext = buildPersistenceContext ( hyperionContext ) ; Set < String > fieldSet = persistenceContext . getRequestedFields ( ) ; if ( fieldSet != null ) fieldSet . add ( "id" ) ; List < ApiObject > saved = plugin . getPersistenceOperations ( ) . createOrUpdateItems ( clientObjects , persistenceContext ) ; processChangeEvents ( hyperionContext , persistenceContext ) ; response . setResponseCode ( 200 ) ; EntityList < ApiObject > entityResponse = new EntityList < > ( ) ; entityResponse . setEntries ( saved ) ; hyperionContext . setResult ( entityResponse ) ; } | Process a multi - item request |
6,540 | void store ( int A , int r , int B ) { getB ( A , r ) . add ( B ) ; getA ( B , r ) . add ( A ) ; } | Record A [ r . B |
6,541 | public void subtract ( R1 relationships ) { if ( null == base ) { throw new AssertionError ( "" ) ; } for ( int i = 0 ; i < base . length ; i ++ ) { if ( null == base [ i ] ) { continue ; } final IConceptSet set = data [ i ] = new SparseConceptHashSet ( ) ; set . addAll ( base [ i ] ) ; if ( null != relationships . data [ i ] ) { set . removeAll ( relationships . data [ i ] ) ; } } } | This should only ever be called when the relationships wrap an initial state and no other methods have been called . |
6,542 | public Iterator < AddressableHeap . Handle < K , V > > handlesIterator ( ) { return new Iterator < AddressableHeap . Handle < K , V > > ( ) { private int pos = 1 ; public boolean hasNext ( ) { return pos <= size ; } public AddressableHeap . Handle < K , V > next ( ) { return array [ pos ++ ] ; } public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ; } | Get an iterator for all handles currently in the heap . |
6,543 | public String getFullPath ( String path ) { if ( StringUtils . isEmpty ( pathPrefix ) ) { return path ; } return PathNormalizer . asPath ( pathPrefix + path ) ; } | Returns the full path for the specified resource |
6,544 | @ SuppressWarnings ( "unchecked" ) private void updateSuffixMin ( RootListNode < K , V > t ) { if ( comparator == null ) { while ( t != null ) { if ( t . next == null ) { t . suffixMin = t ; } else { RootListNode < K , V > nextSuffixMin = t . next . suffixMin ; if ( ( ( Comparable < ? super K > ) t . root . cKey ) . compareTo ( nextSuffixMin . root . cKey ) <= 0 ) { t . suffixMin = t ; } else { t . suffixMin = nextSuffixMin ; } } t = t . prev ; } } else { while ( t != null ) { if ( t . next == null ) { t . suffixMin = t ; } else { RootListNode < K , V > nextSuffixMin = t . next . suffixMin ; if ( comparator . compare ( t . root . cKey , nextSuffixMin . root . cKey ) <= 0 ) { t . suffixMin = t ; } else { t . suffixMin = nextSuffixMin ; } } t = t . prev ; } } } | Update all suffix minimum pointers for a node and all its predecessors in the root list . |
6,545 | private void delete ( RootListNode < K , V > n ) { RootListNode < K , V > nPrev = n . prev ; if ( nPrev != null ) { nPrev . next = n . next ; } else { rootList . head = n . next ; } if ( n . next != null ) { n . next . prev = nPrev ; } else { rootList . tail = nPrev ; } n . prev = null ; n . next = null ; } | Delete a node from the root list . |
6,546 | @ SuppressWarnings ( "unchecked" ) private void delete ( SoftHandle < K , V > n ) { if ( n . tree == null ) { throw new IllegalArgumentException ( "Invalid handle!" ) ; } TreeNode < K , V > tree = n . tree ; if ( tree . cHead != n ) { if ( n . next != null ) { n . next . prev = n . prev ; } n . prev . next = n . next ; } else { SoftHandle < K , V > nNext = n . next ; tree . cHead = nNext ; if ( nNext != null ) { nNext . prev = null ; nNext . tree = tree ; } else { sift ( tree ) ; if ( tree . cHead == null ) { if ( tree . parent instanceof TreeNode ) { TreeNode < K , V > p = ( TreeNode < K , V > ) tree . parent ; if ( p . left == tree ) { p . left = null ; } else { p . right = null ; } } else { delete ( ( RootListNode < K , V > ) tree . parent ) ; } } } } n . tree = null ; n . prev = null ; n . next = null ; size -- ; } | Delete an element . |
6,547 | public QueryExpression eq ( String propertyName , String value ) { return new SimpleQueryExpression ( propertyName , ComparisonOperator . EQUAL , wrap ( value ) ) ; } | Create an equals expression |
6,548 | public QueryExpression ne ( String propertyName , String value ) { return new SimpleQueryExpression ( propertyName , ComparisonOperator . NOT_EQUAL , wrap ( value ) ) ; } | Create a not equals expression |
6,549 | public QueryExpression gt ( String propertyName , String value ) { return new SimpleQueryExpression ( propertyName , ComparisonOperator . GREATER_THAN , wrap ( value ) ) ; } | Create a greater than expression |
6,550 | public QueryExpression lt ( String propertyName , String value ) { return new SimpleQueryExpression ( propertyName , ComparisonOperator . LESS_THAN , wrap ( value ) ) ; } | Create a less than expression |
6,551 | public QueryExpression ge ( String propertyName , String value ) { return new SimpleQueryExpression ( propertyName , ComparisonOperator . GREATER_THAN_OR_EQUAL , wrap ( value ) ) ; } | Create a greater than or equals expression |
6,552 | public QueryExpression le ( String propertyName , String value ) { return new SimpleQueryExpression ( propertyName , ComparisonOperator . LESS_THAN_OR_EQUAL , wrap ( value ) ) ; } | Create a less than or equals expression |
6,553 | public QueryExpression in ( String propertyName , String ... values ) { return new MultiValueQueryExpression ( propertyName , ComparisonOperator . IN , wrap ( values ) ) ; } | Create an in expression |
6,554 | public QueryExpression notIn ( String propertyName , String ... values ) { return new MultiValueQueryExpression ( propertyName , ComparisonOperator . NOT_IN , wrap ( values ) ) ; } | Create a not in expression |
6,555 | @ SuppressWarnings ( "unchecked" ) private void decreaseKey ( Node < K , V > n , K newKey ) { int c ; if ( comparator == null ) { c = ( ( Comparable < ? super K > ) newKey ) . compareTo ( n . key ) ; } else { c = comparator . compare ( newKey , n . key ) ; } if ( c > 0 ) { throw new IllegalArgumentException ( "Keys can only be decreased!" ) ; } n . key = newKey ; if ( c == 0 || root == n ) { return ; } if ( n . o_s == null ) { throw new IllegalArgumentException ( "Invalid handle!" ) ; } if ( n . y_s != null ) { n . y_s . o_s = n . o_s ; } if ( n . o_s . o_c == n ) { n . o_s . o_c = n . y_s ; } else { n . o_s . y_s = n . y_s ; } n . y_s = null ; n . o_s = null ; if ( comparator == null ) { root = link ( root , n ) ; } else { root = linkWithComparator ( root , n ) ; } } | Decrease the key of a node . |
6,556 | private Node < K , V > cutChildren ( Node < K , V > n ) { Node < K , V > child = n . o_c ; n . o_c = null ; if ( child != null ) { child . o_s = null ; } return child ; } | Cut the children of a node and return the list . |
6,557 | protected Literal transformLiteralToModel ( AbstractLiteral al ) { if ( al instanceof BigIntegerLiteral ) { return new au . csiro . ontology . model . BigIntegerLiteral ( ( ( BigIntegerLiteral ) al ) . getValue ( ) ) ; } else if ( al instanceof DateLiteral ) { return new au . csiro . ontology . model . DateLiteral ( ( ( DateLiteral ) al ) . getValue ( ) ) ; } else if ( al instanceof DecimalLiteral ) { return new au . csiro . ontology . model . DecimalLiteral ( ( ( DecimalLiteral ) al ) . getValue ( ) ) ; } else if ( al instanceof FloatLiteral ) { return new au . csiro . ontology . model . FloatLiteral ( ( ( FloatLiteral ) al ) . getValue ( ) ) ; } else if ( al instanceof IntegerLiteral ) { return new au . csiro . ontology . model . IntegerLiteral ( ( ( IntegerLiteral ) al ) . getValue ( ) ) ; } else if ( al instanceof StringLiteral ) { return new au . csiro . ontology . model . StringLiteral ( ( ( StringLiteral ) al ) . getValue ( ) ) ; } else { throw new RuntimeException ( "Unexpected abstract literal " + al ) ; } } | Transforms literal from the internal representation to the canonical representation . |
6,558 | private IConceptSet filterEquivalents ( final IConceptSet concepts ) { int [ ] cArray = concepts . toArray ( ) ; boolean [ ] toExclude = new boolean [ cArray . length ] ; for ( int i = 0 ; i < cArray . length ; i ++ ) { if ( toExclude [ i ] ) continue ; final IConceptSet iAncestors = IConceptSet . FACTORY . createConceptSet ( getAncestors ( no , cArray [ i ] ) ) ; for ( int j = i + 1 ; j < cArray . length ; j ++ ) { if ( iAncestors . contains ( cArray [ j ] ) ) { final IConceptSet jAncestors = IConceptSet . FACTORY . createConceptSet ( getAncestors ( no , cArray [ j ] ) ) ; if ( jAncestors . contains ( cArray [ i ] ) ) { toExclude [ j ] = true ; } } } } IConceptSet res = IConceptSet . FACTORY . createConceptSet ( ) ; for ( int i = 0 ; i < cArray . length ; i ++ ) { if ( ! toExclude [ i ] ) { res . add ( cArray [ i ] ) ; } } return res ; } | Identifies any equivalent concepts and retains only one of them . |
6,559 | private IConceptSet getLeaves ( final IConceptSet concepts ) { final IConceptSet filtered = filterEquivalents ( concepts ) ; final IConceptSet leafBs = IConceptSet . FACTORY . createConceptSet ( filtered ) ; final IConceptSet set = IConceptSet . FACTORY . createConceptSet ( leafBs ) ; for ( final IntIterator bItr = set . iterator ( ) ; bItr . hasNext ( ) ; ) { final int b = bItr . next ( ) ; final IConceptSet ancestors = IConceptSet . FACTORY . createConceptSet ( getAncestors ( no , b ) ) ; ancestors . remove ( b ) ; leafBs . removeAll ( ancestors ) ; } return leafBs ; } | Given a set of concepts computes the subset such that no member of the subset is subsumed by another member . |
6,560 | protected String printConcept ( int id ) { Object oid = factory . lookupConceptId ( id ) ; if ( factory . isVirtualConcept ( id ) ) { if ( oid instanceof AbstractConcept ) { return printAbstractConcept ( ( AbstractConcept ) oid ) ; } else { return oid . toString ( ) ; } } else { return ( String ) oid ; } } | Prints a concept given its internal id . Useful for debugging . |
6,561 | private String printAbstractConcept ( AbstractConcept ac ) { if ( ac instanceof au . csiro . snorocket . core . model . Concept ) { au . csiro . snorocket . core . model . Concept c = ( au . csiro . snorocket . core . model . Concept ) ac ; Object o = factory . lookupConceptId ( c . hashCode ( ) ) ; if ( o instanceof String ) { return ( String ) o ; } else { return printAbstractConcept ( ( AbstractConcept ) o ) ; } } else if ( ac instanceof au . csiro . snorocket . core . model . Conjunction ) { au . csiro . snorocket . core . model . Conjunction c = ( au . csiro . snorocket . core . model . Conjunction ) ac ; AbstractConcept [ ] acs = c . getConcepts ( ) ; StringBuilder sb = new StringBuilder ( ) ; if ( acs != null && acs . length > 0 ) { sb . append ( printAbstractConcept ( acs [ 0 ] ) ) ; for ( int i = 1 ; i < acs . length ; i ++ ) { sb . append ( " + " ) ; sb . append ( printAbstractConcept ( acs [ i ] ) ) ; } } return sb . toString ( ) ; } else if ( ac instanceof au . csiro . snorocket . core . model . Existential ) { au . csiro . snorocket . core . model . Existential e = ( au . csiro . snorocket . core . model . Existential ) ac ; return "E" + factory . lookupRoleId ( e . getRole ( ) ) . toString ( ) + "." + printAbstractConcept ( e . getConcept ( ) ) ; } else if ( ac instanceof au . csiro . snorocket . core . model . Datatype ) { au . csiro . snorocket . core . model . Datatype d = ( au . csiro . snorocket . core . model . Datatype ) ac ; return "F" + factory . lookupFeatureId ( d . getFeature ( ) ) + ".(" + d . getOperator ( ) + ", " + d . getLiteral ( ) + ")" ; } else { throw new RuntimeException ( "Unexpected concept: " + ac ) ; } } | Prints an abstract concept . Useful for debugging . |
6,562 | public static String getParameterValueFromQuery ( String query , String paramName ) { String [ ] components = query . split ( "&" ) ; for ( String keyValuePair : components ) { String [ ] pairComponents = keyValuePair . split ( "=" ) ; if ( pairComponents . length == 2 ) { try { String key = URLDecoder . decode ( pairComponents [ 0 ] , "utf-8" ) ; if ( key . compareTo ( paramName ) == 0 ) { return URLDecoder . decode ( pairComponents [ 1 ] , "utf-8" ) ; } } catch ( UnsupportedEncodingException e ) { logger . error ( "getParameterValueFromQuery failed with exception: " + e . getLocalizedMessage ( ) , e ) ; } } } return null ; } | Obtains a parameter with specified name from from query string . The query should be in format param = value¶m = value ... |
6,563 | public static JSONObject extractSecureJson ( Response response ) { try { String responseText = response . getResponseText ( ) ; if ( ! responseText . startsWith ( SECURE_PATTERN_START ) || ! responseText . endsWith ( SECURE_PATTERN_END ) ) { return null ; } int startIndex = responseText . indexOf ( SECURE_PATTERN_START ) ; int endIndex = responseText . indexOf ( SECURE_PATTERN_END , responseText . length ( ) - SECURE_PATTERN_END . length ( ) - 1 ) ; String jsonString = responseText . substring ( startIndex + SECURE_PATTERN_START . length ( ) , endIndex ) ; return new JSONObject ( jsonString ) ; } catch ( Throwable t ) { logger . error ( "extractSecureJson failed with exception: " + t . getLocalizedMessage ( ) , t ) ; return null ; } } | Extracts a JSON object from server response with secured string . |
6,564 | public static String buildRewriteDomain ( String backendRoute , String subzone ) throws MalformedURLException { if ( backendRoute == null || backendRoute . isEmpty ( ) ) { logger . error ( "Backend route can't be null." ) ; return null ; } String applicationRoute = backendRoute ; if ( ! applicationRoute . startsWith ( BMSClient . HTTP_SCHEME ) ) { applicationRoute = String . format ( "%s://%s" , BMSClient . HTTPS_SCHEME , applicationRoute ) ; } else if ( ! applicationRoute . startsWith ( BMSClient . HTTPS_SCHEME ) && applicationRoute . contains ( BLUEMIX_NAME ) ) { applicationRoute = applicationRoute . replace ( BMSClient . HTTP_SCHEME , BMSClient . HTTPS_SCHEME ) ; } URL url = new URL ( applicationRoute ) ; String host = url . getHost ( ) ; String rewriteDomain ; String regionInDomain = "ng" ; int port = url . getPort ( ) ; String serviceUrl = String . format ( "%s://%s" , url . getProtocol ( ) , host ) ; if ( port != 0 ) { serviceUrl += ":" + String . valueOf ( port ) ; } String [ ] hostElements = host . split ( "\\." ) ; if ( ! serviceUrl . contains ( STAGE1_NAME ) ) { if ( hostElements . length == 4 ) { regionInDomain = hostElements [ hostElements . length - 3 ] ; } rewriteDomain = String . format ( "%s.%s" , regionInDomain , BLUEMIX_DOMAIN ) ; } else { if ( hostElements . length == 5 ) { regionInDomain = hostElements [ hostElements . length - 3 ] ; } if ( subzone != null && ! subzone . isEmpty ( ) ) { rewriteDomain = String . format ( "%s-%s.%s.%s" , STAGE1_NAME , subzone , regionInDomain , BLUEMIX_DOMAIN ) ; } else { rewriteDomain = String . format ( "%s.%s.%s" , STAGE1_NAME , regionInDomain , BLUEMIX_DOMAIN ) ; } } return rewriteDomain ; } | Builds rewrite domain from backend route url . |
6,565 | public static String concatenateUrls ( String rootUrl , String path ) { if ( rootUrl == null || rootUrl . isEmpty ( ) ) { return path ; } if ( path == null || path . isEmpty ( ) ) { return rootUrl ; } String finalUrl ; if ( rootUrl . charAt ( rootUrl . length ( ) - 1 ) == '/' && path . charAt ( 0 ) == '/' ) { finalUrl = rootUrl . substring ( 0 , rootUrl . length ( ) - 2 ) + path ; } else if ( rootUrl . charAt ( rootUrl . length ( ) - 1 ) != '/' && path . charAt ( 0 ) != '/' ) { finalUrl = rootUrl + "/" + path ; } else { finalUrl = rootUrl + path ; } return finalUrl ; } | Concatenates two URLs . The function checks for trailing and preceding slashes in rootUrl and path . |
6,566 | private void init ( NormalisedOntology ont ) { parentTodo = ont . getTodo ( ) ; contextIndex = ont . getContextIndex ( ) ; ontologyNF1 = ont . getOntologyNF1 ( ) ; ontologyNF2 = ont . getOntologyNF2 ( ) ; ontologyNF3 = ont . getOntologyNF3 ( ) ; ontologyNF4 = ont . getOntologyNF4 ( ) ; ontologyNF5 = ont . getOntologyNF5 ( ) ; reflexiveRoles = ont . getReflexiveRoles ( ) ; ontologyNF7 = ont . getOntologyNF7 ( ) ; ontologyNF8 = ont . getOntologyNF8 ( ) ; functionalFeatures = ont . getFunctionalFeatures ( ) ; roleClosureCache = ont . getRoleClosureCache ( ) ; factory = ont . getFactory ( ) ; affectedContexts = ont . getAffectedContexts ( ) ; } | Initialises the shared variables . |
6,567 | public void primeQueuesIncremental ( MonotonicCollection < IConjunctionQueueEntry > conceptEntries , MonotonicCollection < IRoleQueueEntry > roleEntries , MonotonicCollection < IFeatureQueueEntry > featureEntries ) { if ( conceptEntries != null ) addToConceptQueue ( conceptEntries ) ; if ( roleEntries != null ) roleQueue . addAll ( roleEntries ) ; if ( featureEntries != null ) featureQueue . addAll ( featureEntries ) ; } | Adds queue entries for this concept based on the new axioms added in an incremental classification . |
6,568 | public void deactivate ( ) { active . set ( false ) ; if ( ! ( conceptQueue . isEmpty ( ) && roleQueue . isEmpty ( ) && featureQueue . isEmpty ( ) ) ) { if ( activate ( ) ) { parentTodo . add ( this ) ; } } } | Deactivates the context . Returns true if the context was active and was deactivated by this method call or false otherwise . |
6,569 | public int doEndTag ( ) throws JspException { try { BinaryResourcesHandler rsHandler = null ; if ( ( rsHandler = ( BinaryResourcesHandler ) pageContext . getServletContext ( ) . getAttribute ( JawrConstant . BINARY_CONTEXT_ATTRIBUTE ) ) == null ) throw new IllegalStateException ( "Binary ResourceBundlesHandler not present in servlet context. Initialization of Jawr either failed or never occurred." ) ; JawrConfig jawrConfig = rsHandler . getConfig ( ) ; this . renderer = RendererFactory . getImgRenderer ( jawrConfig , isPlainImage ( ) ) ; this . renderer . renderImage ( getImgSrcToRender ( ) , getAttributeMap ( ) , pageContext . getOut ( ) ) ; } catch ( IOException e ) { throw new JspException ( e ) ; } finally { ThreadLocalJawrContext . reset ( ) ; } return ( EVAL_PAGE ) ; } | Render the IMG tag . |
6,570 | protected boolean isBulkInsertionBufferFull ( ) { if ( insertionBufferSize >= insertionBuffer . length ) { return true ; } double sizeAsDouble = size + insertionBufferSize ; return Math . getExponent ( sizeAsDouble ) + 3 >= insertionBuffer . length ; } | Check if the bulk insertion buffer is full . |
6,571 | protected void initCommonGenerators ( ) { commonGenerators . put ( new PrefixedPathResolver ( MESSAGE_BUNDLE_PREFIX ) , ResourceBundleMessagesGenerator . class ) ; Class < ? > classPathGeneratorClass = null ; Class < ? > webJarsGeneratorClass = null ; boolean isWebJarsLocatorPresent = ClassLoaderResourceUtils . isClassPresent ( WEBJARS_LOCATOR_CLASSNAME ) ; if ( resourceType . equals ( JawrConstant . JS_TYPE ) ) { classPathGeneratorClass = ClasspathJSGenerator . class ; if ( isWebJarsLocatorPresent ) { webJarsGeneratorClass = WebJarsLocatorJSGenerator . class ; } else { webJarsGeneratorClass = WebJarsJSGenerator . class ; } } else if ( resourceType . equals ( JawrConstant . CSS_TYPE ) ) { classPathGeneratorClass = ClassPathCSSGenerator . class ; if ( isWebJarsLocatorPresent ) { webJarsGeneratorClass = WebJarsLocatorCssGenerator . class ; } else { webJarsGeneratorClass = WebJarsCssGenerator . class ; } } else { classPathGeneratorClass = ClassPathBinaryResourceGenerator . class ; if ( isWebJarsLocatorPresent ) { webJarsGeneratorClass = WebJarsLocatorBinaryResourceGenerator . class ; } else { webJarsGeneratorClass = WebJarsBinaryResourceGenerator . class ; } } commonGenerators . put ( new PrefixedPathResolver ( CLASSPATH_RESOURCE_BUNDLE_PREFIX ) , classPathGeneratorClass ) ; commonGenerators . put ( new PrefixedPathResolver ( WEBJARS_GENERATOR_PREFIX ) , webJarsGeneratorClass ) ; if ( resourceType . equals ( JawrConstant . JS_TYPE ) ) { commonGenerators . put ( new PrefixedPathResolver ( COMMONS_VALIDATOR_PREFIX ) , CommonsValidatorGenerator . class ) ; commonGenerators . put ( new PrefixedPathResolver ( SKIN_SWTICHER_GENERATOR_PREFIX ) , SkinSwitcherJsGenerator . class ) ; commonGenerators . put ( new SuffixedPathResolver ( COFEESCRIPT_GENERATOR_SUFFIX ) , CoffeeScriptGenerator . class ) ; } if ( resourceType . equals ( JawrConstant . CSS_TYPE ) ) { commonGenerators . put ( new PrefixedPathResolver ( IE_CSS_GENERATOR_PREFIX ) , IECssBundleGenerator . class ) ; commonGenerators . put ( new PrefixedPathResolver ( SKIN_GENERATOR_PREFIX ) , CssSkinGenerator . class ) ; commonGenerators . put ( new SuffixedPathResolver ( LESS_GENERATOR_SUFFIX ) , LessCssGenerator . class ) ; String sassGenerator = config . getProperty ( SASS_GENERATOR_TYPE , SASS_GENERATOR_VAADIN ) ; if ( ! sassGenerator . equals ( SASS_GENERATOR_VAADIN ) && ! sassGenerator . equals ( SASS_GENERATOR_RUBY ) ) { throw new BundlingProcessException ( "The value '" + sassGenerator + "' is not allowed for property '" + SASS_GENERATOR_TYPE + "'. Please check your configuration." ) ; } if ( sassGenerator . equals ( SASS_GENERATOR_VAADIN ) ) { commonGenerators . put ( new SuffixedPathResolver ( SASS_GENERATOR_SUFFIX ) , SassVaadinGenerator . class ) ; } else { commonGenerators . put ( new SuffixedPathResolver ( SASS_GENERATOR_SUFFIX ) , SassRubyGenerator . class ) ; } } if ( ( resourceType . equals ( JawrConstant . CSS_TYPE ) || resourceType . equals ( JawrConstant . BINARY_TYPE ) ) ) { commonGenerators . put ( new PrefixedPathResolver ( SPRITE_GENERATOR_PREFIX ) , SpriteGenerator . class ) ; } } | Initialize the common generators |
6,572 | public static Map < Object , Object > getSupportedProperties ( Object ref ) { if ( null == supportedMIMETypes ) { synchronized ( MIMETypesSupport . class ) { if ( null == supportedMIMETypes ) { try ( InputStream is = ClassLoaderResourceUtils . getResourceAsStream ( MIME_PROPS_LOCATION , ref ) ) { supportedMIMETypes = new Properties ( ) ; supportedMIMETypes . load ( is ) ; } catch ( FileNotFoundException e ) { throw new BundlingProcessException ( "Error retrieving " + MIME_PROPS_LOCATION + ". Please check your classloader settings" ) ; } catch ( IOException e ) { throw new BundlingProcessException ( "Error retrieving " + MIME_PROPS_LOCATION + ". Please check your classloader settings" ) ; } } } } return supportedMIMETypes ; } | Returns a Map object containing all the supported media extensions paired to their MIME type . |
6,573 | public CreateSingleRequestBuilder < T , ID > create ( T item ) { return new CreateSingleRequestBuilder < > ( version , type , entityName , item ) ; } | Create a request builder for a create operation for a single item |
6,574 | public QueryRequestBuilder < T , ID > query ( QueryExpression query ) { return new QueryRequestBuilder < T , ID > ( version , type , entityName , query . build ( ) ) ; } | Create a request builder for a query operation using the specified query expression |
6,575 | public QueryRequestBuilder < T , ID > query ( ) { return new QueryRequestBuilder < T , ID > ( version , type , entityName ) ; } | Create a request builder for a query operation using the specified no query |
6,576 | public GetRequestBuilder < T , ID > find ( ID ... ids ) { return new GetRequestBuilder < T , ID > ( version , type , entityName , ids ) ; } | Create a request builder for a find operation using the specified IDs |
6,577 | public UpdateSingleRequestBuilder < T , ID > update ( T item ) { return new UpdateSingleRequestBuilder < > ( version , type , entityName , item ) ; } | Create a request builder for an update operation for a single item |
6,578 | private void initCompositeBundleMap ( List < JoinableResourceBundle > bundles ) { for ( JoinableResourceBundle bundle : bundles ) { if ( bundle . isComposite ( ) ) { List < JoinableResourceBundle > childBundles = ( ( CompositeResourceBundle ) bundle ) . getChildBundles ( ) ; for ( JoinableResourceBundle childBundle : childBundles ) { List < JoinableResourceBundle > associatedBundles = compositeResourceBundleMap . get ( childBundle . getId ( ) ) ; if ( associatedBundles == null ) { associatedBundles = new ArrayList < > ( ) ; } associatedBundles . add ( bundle ) ; compositeResourceBundleMap . put ( childBundle . getId ( ) , associatedBundles ) ; } } } } | Initialize the composite bundle map |
6,579 | private List < JoinableResourceBundle > getBundlesToRebuild ( ) { List < JoinableResourceBundle > bundlesToRebuild = new ArrayList < > ( ) ; if ( config . getUseSmartBundling ( ) ) { for ( JoinableResourceBundle bundle : globalBundles ) { if ( bundle . isDirty ( ) ) { bundlesToRebuild . add ( bundle ) ; } } for ( JoinableResourceBundle bundle : contextBundles ) { if ( bundle . isDirty ( ) ) { bundlesToRebuild . add ( bundle ) ; } } } return bundlesToRebuild ; } | Returns the bundles which needs to be rebuild |
6,580 | private void initModulesArgs ( Map < String , String > resultBundlePathMapping , List < String > args , List < JoinableResourceBundle > bundles , Map < String , JoinableResourceBundle > bundleMap , String modules , List < String > depModulesArgs , List < String > globalBundleDependencies ) { args . add ( JS_ARG ) ; args . add ( JAWR_ROOT_MODULE_JS ) ; args . add ( MODULE_ARG ) ; args . add ( JAWR_ROOT_MODULE_NAME + ":1:" ) ; resultBundlePathMapping . put ( JAWR_ROOT_MODULE_NAME , JAWR_ROOT_MODULE_JS ) ; if ( StringUtils . isNotEmpty ( modules ) ) { String [ ] moduleSpecs = modules . split ( ";" ) ; for ( String moduleSpec : moduleSpecs ) { int moduleNameSeparatorIdx = moduleSpec . indexOf ( ":" ) ; if ( moduleNameSeparatorIdx < 0 ) { throw new BundlingProcessException ( "The property 'jawr.js.closure.modules' is not properly defined. Please check your configuration." ) ; } String bundleName = moduleSpec . substring ( 0 , moduleNameSeparatorIdx ) ; checkBundleName ( bundleName , bundleMap ) ; JoinableResourceBundle bundle = bundleMap . get ( bundleName ) ; List < String > dependencies = Arrays . asList ( moduleSpec . substring ( moduleNameSeparatorIdx + 1 ) . split ( MODULE_DEPENDENCIES_SEPARATOR ) ) ; dependencies . addAll ( 0 , globalBundleDependencies ) ; generateBundleModuleArgs ( depModulesArgs , bundleMap , resultBundlePathMapping , bundle , dependencies ) ; bundles . remove ( bundle ) ; } } } | Initialize the modules arguments |
6,581 | public int [ ] getRoles ( ) { List < Integer > roles = new ArrayList < Integer > ( ) ; for ( int i = 0 ; i < data . length ; i ++ ) { if ( data [ i ] != null ) { roles . add ( i ) ; } } int [ ] res = new int [ roles . size ( ) ] ; for ( int i = 0 ; i < res . length ; i ++ ) { res [ i ] = roles . get ( i ) ; } return res ; } | Returns the roles stored in this data structure . |
6,582 | public long getContentLength ( ) { try { return getInternalResponse ( ) . body ( ) . contentLength ( ) ; } catch ( NullPointerException e ) { logger . error ( "Failed to get the response content length from " + getRequestURL ( ) + ". Error: " + e . getMessage ( ) ) ; return 0 ; } } | This method gets the Content - Length of the response body . |
6,583 | public Map < String , List < String > > getHeaders ( ) { if ( headers == null ) { return null ; } return headers . toMultimap ( ) ; } | Get the HTTP headers from the response . |
6,584 | public List < String > getHeader ( String name ) { if ( headers == null ) { return null ; } return headers . values ( name ) ; } | Get the header values for the given header name if it exists . There can be more than one value for a given header name . |
6,585 | public String getFirstHeader ( String name ) { List < String > headerValues = getHeader ( name ) ; if ( headerValues == null || headerValues . size ( ) == 0 ) { return null ; } return headerValues . get ( 0 ) ; } | Get the first header value for the given header name if it exists . |
6,586 | @ SuppressWarnings ( "unchecked" ) private void sift ( TreeNode < K > x ) { Deque < TreeNode < K > > stack = new ArrayDeque < TreeNode < K > > ( ) ; stack . push ( x ) ; while ( ! stack . isEmpty ( ) ) { x = stack . peek ( ) ; TreeNode < K > xLeft = x . left ; TreeNode < K > xRight = x . right ; if ( xLeft == null && xRight == null || x . cSize >= targetSize ( x . rank ) ) { stack . pop ( ) ; continue ; } if ( xLeft == null || xRight != null && ( ( comparator == null && ( ( Comparable < ? super K > ) xLeft . cKey ) . compareTo ( xRight . cKey ) > 0 ) || ( comparator != null && comparator . compare ( xLeft . cKey , xRight . cKey ) > 0 ) ) ) { x . left = xRight ; x . right = xLeft ; xLeft = x . left ; xRight = x . right ; } xLeft . cTail . next = x . cHead ; x . cHead = xLeft . cHead ; if ( x . cTail == null ) { x . cTail = xLeft . cTail ; } x . cSize += xLeft . cSize ; x . cKey = xLeft . cKey ; xLeft . cKey = null ; xLeft . cHead = null ; xLeft . cTail = null ; xLeft . cSize = 0 ; if ( xLeft . left != null || xLeft . right != null ) { stack . push ( xLeft ) ; } else { x . left = null ; } } } | Sift elements from children nodes until the current node has enough elements in its list . |
6,587 | private TreeNode < K > combine ( TreeNode < K > x , TreeNode < K > y ) { TreeNode < K > z = new TreeNode < K > ( ) ; z . left = x ; z . right = y ; z . rank = x . rank + 1 ; sift ( z ) ; return z ; } | Combine two trees into a new tree . |
6,588 | protected int computeBucket ( K key , K minKey ) { return 1 + Math . min ( msd ( key , minKey ) , buckets . length - 2 ) ; } | Compute the bucket of a key based on a minimum key . |
6,589 | protected void delete ( Node < K , V > n ) { if ( n == root ) { deleteMin ( ) ; return ; } if ( n . y_s == null ) { throw new IllegalArgumentException ( "Invalid handle!" ) ; } Node < K , V > childTree = unlinkAndUnionChildren ( n ) ; Node < K , V > p = getParent ( n ) ; if ( childTree == null ) { if ( p . o_c == n ) { if ( n . y_s == p ) { p . o_c = null ; } else { p . o_c = n . y_s ; } } else { p . o_c . y_s = p ; } } else { if ( p . o_c == n ) { childTree . y_s = n . y_s ; p . o_c = childTree ; } else { p . o_c . y_s = childTree ; childTree . y_s = p ; } } size -- ; n . o_c = null ; n . y_s = null ; } | Delete a node from the heap . |
6,590 | protected Node < K , V > unlinkAndUnionChildren ( Node < K , V > n ) { Node < K , V > child1 = n . o_c ; if ( child1 == null ) { return null ; } n . o_c = null ; Node < K , V > child2 = child1 . y_s ; if ( child2 == n ) { child2 = null ; } else { child2 . y_s = null ; } child1 . y_s = null ; if ( comparator == null ) { return union ( child1 , child2 ) ; } else { return unionWithComparator ( child1 , child2 ) ; } } | Unlink the two children of a node and union them forming a new tree . |
6,591 | protected Node < K , V > unlinkRightChild ( Node < K , V > n ) { Node < K , V > left = n . o_c ; if ( left == null || left . y_s == n ) { return null ; } Node < K , V > right = left . y_s ; left . y_s = n ; right . y_s = null ; return right ; } | Unlink the right child of a node . |
6,592 | @ SuppressWarnings ( "unchecked" ) protected Node < K , V > union ( Node < K , V > root1 , Node < K , V > root2 ) { if ( root1 == null ) { return root2 ; } else if ( root2 == null ) { return root1 ; } Node < K , V > newRoot ; Node < K , V > cur ; int c = ( ( Comparable < ? super K > ) root1 . key ) . compareTo ( root2 . key ) ; if ( c <= 0 ) { newRoot = root1 ; root1 = unlinkRightChild ( root1 ) ; } else { newRoot = root2 ; root2 = unlinkRightChild ( root2 ) ; } cur = newRoot ; while ( root1 != null && root2 != null ) { c = ( ( Comparable < ? super K > ) root1 . key ) . compareTo ( root2 . key ) ; if ( c <= 0 ) { if ( cur . o_c == null ) { root1 . y_s = cur ; } else { root1 . y_s = cur . o_c ; } cur . o_c = root1 ; cur = root1 ; root1 = unlinkRightChild ( root1 ) ; } else { if ( cur . o_c == null ) { root2 . y_s = cur ; } else { root2 . y_s = cur . o_c ; } cur . o_c = root2 ; cur = root2 ; root2 = unlinkRightChild ( root2 ) ; } } while ( root1 != null ) { if ( cur . o_c == null ) { root1 . y_s = cur ; } else { root1 . y_s = cur . o_c ; } cur . o_c = root1 ; cur = root1 ; root1 = unlinkRightChild ( root1 ) ; } while ( root2 != null ) { if ( cur . o_c == null ) { root2 . y_s = cur ; } else { root2 . y_s = cur . o_c ; } cur . o_c = root2 ; cur = root2 ; root2 = unlinkRightChild ( root2 ) ; } return newRoot ; } | Top - down union of two skew heaps . |
6,593 | protected Node < K , V > unionWithComparator ( Node < K , V > root1 , Node < K , V > root2 ) { if ( root1 == null ) { return root2 ; } else if ( root2 == null ) { return root1 ; } Node < K , V > newRoot ; Node < K , V > cur ; int c = comparator . compare ( root1 . key , root2 . key ) ; if ( c <= 0 ) { newRoot = root1 ; root1 = unlinkRightChild ( root1 ) ; } else { newRoot = root2 ; root2 = unlinkRightChild ( root2 ) ; } cur = newRoot ; while ( root1 != null && root2 != null ) { c = comparator . compare ( root1 . key , root2 . key ) ; if ( c <= 0 ) { if ( cur . o_c == null ) { root1 . y_s = cur ; } else { root1 . y_s = cur . o_c ; } cur . o_c = root1 ; cur = root1 ; root1 = unlinkRightChild ( root1 ) ; } else { if ( cur . o_c == null ) { root2 . y_s = cur ; } else { root2 . y_s = cur . o_c ; } cur . o_c = root2 ; cur = root2 ; root2 = unlinkRightChild ( root2 ) ; } } while ( root1 != null ) { if ( cur . o_c == null ) { root1 . y_s = cur ; } else { root1 . y_s = cur . o_c ; } cur . o_c = root1 ; cur = root1 ; root1 = unlinkRightChild ( root1 ) ; } while ( root2 != null ) { if ( cur . o_c == null ) { root2 . y_s = cur ; } else { root2 . y_s = cur . o_c ; } cur . o_c = root2 ; cur = root2 ; root2 = unlinkRightChild ( root2 ) ; } return newRoot ; } | Top - down union of two skew heaps with comparator . |
6,594 | public List < String > get ( String key ) { if ( key == null ) throw new IllegalArgumentException ( "Null keys not allowed." ) ; return map . get ( key ) ; } | Return the values stored for the supplied key |
6,595 | public String getFirst ( String key ) { if ( key == null ) throw new IllegalArgumentException ( "Null keys not allowed." ) ; List < String > vals = map . get ( key ) ; if ( vals == null || vals . size ( ) == 0 ) return null ; return vals . get ( 0 ) ; } | Return the first value stored for the supplied key |
6,596 | public void set ( String key , String value ) { if ( key == null ) throw new IllegalArgumentException ( "Null keys not allowed." ) ; if ( value == null ) throw new IllegalArgumentException ( "Null values not allowed." ) ; ArrayList < String > vals = new ArrayList < String > ( ) ; vals . add ( value ) ; map . put ( key , vals ) ; } | Set a value for the supplied key . This will overwrite any values that are currently stored for this key . |
6,597 | public void add ( String key , String value ) { if ( key == null ) throw new IllegalArgumentException ( "Null keys not allowed." ) ; if ( value == null ) throw new IllegalArgumentException ( "Null values not allowed." ) ; List < String > vals = map . get ( key ) ; if ( vals == null ) { vals = new ArrayList < String > ( ) ; map . put ( key , vals ) ; } vals . add ( value ) ; } | Add a value for the supplied key . This will add the value to any existing values stored for this key . |
6,598 | public MultiMap merge ( MultiMap multiMap ) { MultiMap result = new MultiMap ( ) ; result . map . putAll ( this . map ) ; result . map . putAll ( multiMap . map ) ; return result ; } | Merge the values in the specified map with the values in this map and return the results in a new map . |
6,599 | public RequestBuilder < T , ID > addParameter ( String name , String value ) { parameters . add ( name , value ) ; return this ; } | Add a parameter to the request . Adds this value to any existing values for this name . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.