idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
138,100 | public void run ( ) { LOGGER . debug ( "begin scan for config file changes ..." ) ; try { Date lastModified = new Date ( _xmlConfigFile . lastModified ( ) ) ; if ( _lastTimeRead == null || lastModified . after ( _lastTimeRead ) ) { LOGGER . info ( "loading config file changes ..." ) ; this . loadServiceConfigFile ( ) ; _lastTimeRead = new Date ( ) ; } } catch ( ConfigurationException e ) { e . printStackTrace ( ) ; LOGGER . error ( "Error loading configuation file: " , e ) ; } LOGGER . debug ( "finish scan for config file changes" ) ; } | When the timer goes off look for changes to the specified xml config file . For comparison we are only interested in the last time we read the file . A null value for lastTimeRead means that we never read the file before . | 150 | 46 |
138,101 | private void loadServiceConfigFile ( ) throws ConfigurationException { Properties properties = _plugin . getConfiguration ( ) ; Configuration config = ConfigurationConverter . getConfiguration ( properties ) ; String xmlConfigFilename = config . getString ( "xmlConfigFilename" ) ; _config = new ServiceListConfiguration ( xmlConfigFilename ) ; // ServicesConfiguration services = parseConfigFile(xmlConfigFilename); // ArrayList<ServiceWrapper> serviceList = constructServiceList(services); ArrayList < ServiceWrapper > serviceList = _config . getServiceList ( ) ; LOGGER . debug ( "Setting the service list in the plugin" ) ; _plugin . setServiceList ( serviceList ) ; } | actually load the xml configuration file . If anything goes wrong throws an exception . This created a list of service records . When done set the service record list in the plugin . The plugin set function should be synchronized so that it won t squash any concurrent access to the old set of services . | 144 | 57 |
138,102 | public void initialize ( ArgoClientContext context ) throws TransportConfigException { transportProps = processPropertiesFile ( config . getPropertiesFilename ( ) ) ; createProbeSenders ( context ) ; } | Initialize the actual ProbeSenders . | 44 | 8 |
138,103 | public String getDescription ( ) { StringBuffer buf = new StringBuffer ( ) ; String transportName = config . getName ( ) ; for ( ProbeSender sender : senders ) { buf . append ( transportName ) . append ( " -- " ) . append ( isEnabled ( ) ? "Enabled" : "Disabled" ) . append ( " -- " ) . append ( sender . getDescription ( ) ) ; } return buf . toString ( ) ; } | return the text description of the transport and its associated ProbeSenders . | 97 | 14 |
138,104 | public String showConfiguration ( ) { StringBuffer buf = new StringBuffer ( ) ; buf . append ( "\n Client Transport Configuration\n" ) ; buf . append ( " Name ...................... " ) . append ( config . getName ( ) ) . append ( "\n" ) ; buf . append ( " Is Enabled................. " ) . append ( isEnabled ( ) ) . append ( "\n" ) ; buf . append ( " Required Multicast ........ " ) . append ( config . requiresMulticast ( ) ) . append ( "\n" ) ; buf . append ( " Uses NI ................... " ) . append ( config . usesNetworkInterface ( ) ) . append ( "\n" ) ; buf . append ( " Classname ................. " ) . append ( config . getClassname ( ) ) . append ( "\n" ) ; buf . append ( " Properties filename ....... " ) . append ( config . getPropertiesFilename ( ) ) . append ( "\n\n" ) ; buf . append ( " Number of ProbeSenders .... " ) . append ( this . getSenders ( ) . size ( ) ) . append ( "\n" ) ; buf . append ( " ProbeSenders .............. \n" ) ; for ( ProbeSender s : getSenders ( ) ) { buf . append ( " .... " ) . append ( s . getDescription ( ) ) . append ( "\n" ) ; } buf . append ( " -------------------------------\n" ) ; return buf . toString ( ) ; } | Show the configuration for a Client Transport . | 322 | 8 |
138,105 | public void close ( ) { for ( ProbeSender sender : getSenders ( ) ) { try { sender . close ( ) ; } catch ( TransportException e ) { LOGGER . warn ( "Issue closing the ProbeSender [" + sender . getDescription ( ) + "]" , e ) ; } } } | This closes any of the underlying resources that a ProbeSender might be using such as a connection to a server somewhere . | 66 | 24 |
138,106 | private void createProbeSenders ( ArgoClientContext context ) throws TransportConfigException { senders = new ArrayList < ProbeSender > ( ) ; if ( config . usesNetworkInterface ( ) ) { try { for ( String niName : context . getAvailableNetworkInterfaces ( config . requiresMulticast ( ) ) ) { try { Transport transport = instantiateTransportClass ( config . getClassname ( ) ) ; transport . initialize ( transportProps , niName ) ; ProbeSender sender = new ProbeSender ( transport ) ; senders . add ( sender ) ; } catch ( TransportConfigException e ) { LOGGER . warn ( e . getLocalizedMessage ( ) ) ; } } } catch ( SocketException e ) { throw new TransportConfigException ( "Error getting available network interfaces" , e ) ; } } else { Transport transport = instantiateTransportClass ( config . getClassname ( ) ) ; transport . initialize ( transportProps , "" ) ; ProbeSender sender = new ProbeSender ( transport ) ; senders . add ( sender ) ; } } | Create the actual ProbeSender instances given the configuration information . If the transport depends on Network Interfaces then create a ProbeSender for each NI we can find on this machine . | 231 | 36 |
138,107 | protected List < TypeVariableName > getTypeVariables ( TypeName t ) { return match ( t ) . when ( typeOf ( TypeVariableName . class ) ) . get ( v -> { if ( v . bounds . isEmpty ( ) ) { return ImmutableList . of ( v ) ; } else { return Stream . concat ( Stream . of ( v ) , v . bounds . stream ( ) . map ( b -> getTypeVariables ( b ) ) . flatMap ( b -> b . stream ( ) ) ) . collect ( Collectors . toList ( ) ) ; } } ) . when ( typeOf ( ParameterizedTypeName . class ) ) . get ( p -> p . typeArguments . stream ( ) . map ( v -> getTypeVariables ( v ) ) . flatMap ( l -> l . stream ( ) ) . collect ( Collectors . toList ( ) ) ) . orElse ( Collections . emptyList ( ) ) . getMatch ( ) ; } | Returns a list of type variables for a given type . | 211 | 11 |
138,108 | protected List < TypeNameWithArity > createTypeArityList ( TypeName t , String extractVariableName , int maxArity ) { TypeName u = match ( t ) . when ( typeOf ( TypeVariableName . class ) ) . get ( x -> ( TypeName ) TypeVariableName . get ( "E" + x . name , x ) ) . orElse ( x -> x ) . getMatch ( ) ; List < TypeNameWithArity > typeArityList = new ArrayList <> ( ) ; //typeArityList.add(TypeNameWithArity.of(t, 0)); typeArityList . add ( TypeNameWithArity . of ( ParameterizedTypeName . get ( MATCH_EXACT , t ) , 0 ) ) ; typeArityList . add ( TypeNameWithArity . of ( ParameterizedTypeName . get ( MATCH_ANY , t ) , 1 ) ) ; //typeArityList.add(TypeNameWithArity.of(TypeName.get(MatchesAny.class), 1)); IntStream . rangeClosed ( 0 , maxArity ) . forEach ( extractArity -> { TypeName [ ] typeVariables = createTypeVariables ( u , extractVariableName , extractArity ) ; typeArityList . add ( TypeNameWithArity . of ( ParameterizedTypeName . get ( ClassName . get ( getDecomposableBuilderByArity ( extractArity ) ) , typeVariables ) , extractArity ) ) ; } ) ; return typeArityList ; } | Returns a list of pairs of types and arities up to a given max arity . | 343 | 18 |
138,109 | protected TypeName [ ] createTypeVariables ( TypeName extractedType , String extractVariableName , int extractArity ) { List < TypeName > typeVariables = new ArrayList <> ( ) ; typeVariables . add ( extractedType ) ; if ( extractArity > 0 ) { typeVariables . addAll ( IntStream . rangeClosed ( 1 , extractArity ) . mapToObj ( j -> TypeVariableName . get ( extractVariableName + j ) ) . collect ( Collectors . toList ( ) ) ) ; } return typeVariables . toArray ( new TypeName [ typeVariables . size ( ) ] ) ; } | Returns an array of type variables for a given type and arity . | 139 | 14 |
138,110 | protected static Object [ ] getMatcherStatementArgs ( int matchedCount ) { TypeName matcher = ParameterizedTypeName . get ( ClassName . get ( Matcher . class ) , TypeName . OBJECT ) ; TypeName listOfMatchers = ParameterizedTypeName . get ( ClassName . get ( List . class ) , matcher ) ; TypeName lists = TypeName . get ( Lists . class ) ; TypeName argumentMatchers = TypeName . get ( ArgumentMatchers . class ) ; return Stream . concat ( ImmutableList . of ( listOfMatchers , lists ) . stream ( ) , IntStream . range ( 0 , matchedCount ) . mapToObj ( i -> argumentMatchers ) ) . toArray ( s -> new TypeName [ s ] ) ; } | Returns the statement arguments for the match method matcher statement . | 169 | 12 |
138,111 | protected MatchType getMatchType ( TypeName m ) { return match ( m ) . when ( typeOf ( ParameterizedTypeName . class ) ) . get ( t -> { if ( isDecomposableBuilder ( t . rawType ) ) { return MatchType . DECOMPOSE ; } else if ( t . rawType . equals ( MATCH_ANY ) ) { return MatchType . ANY ; } else if ( t . rawType . equals ( MATCH_EXACT ) ) { return MatchType . EXACT ; } else { return MatchType . EXACT ; } } ) . when ( typeOf ( TypeVariableName . class ) ) . get ( t -> MatchType . EXACT ) . orElse ( MatchType . ANY ) . getMatch ( ) ; } | Returns the type of match to use for a given type . | 165 | 12 |
138,112 | protected List < TypeName > getExtractedTypes ( TypeName permutationType , TypeName paramType ) { return match ( permutationType ) . when ( typeOf ( ParameterizedTypeName . class ) ) . get ( t -> { if ( isDecomposableBuilder ( t . rawType ) ) { return t . typeArguments . subList ( 1 , t . typeArguments . size ( ) ) ; } else if ( t . rawType . equals ( MATCH_ANY ) ) { return ImmutableList . of ( paramType ) ; } else { return Collections . < TypeName > emptyList ( ) ; } } ) . when ( typeOf ( TypeVariableName . class ) ) . get ( t -> ImmutableList . of ( ) ) . when ( typeOf ( ClassName . class ) ) . get ( t -> ImmutableList . of ( paramType ) ) . orElse ( t -> ImmutableList . of ( t ) ) . getMatch ( ) ; } | Returns the extracted type parameters . | 212 | 6 |
138,113 | protected List < TypeName > getReturnStatementArgs ( MatchType matchType , TypeName paramType ) { List < TypeName > extractA ; if ( matchType == MatchType . DECOMPOSE ) { TypeName u = match ( paramType ) . when ( typeOf ( TypeVariableName . class ) ) . get ( x -> ( TypeName ) TypeVariableName . get ( "E" + x . name , x ) ) . orElse ( x -> x ) . getMatch ( ) ; extractA = ImmutableList . of ( u ) ; } else if ( matchType == MatchType . ANY ) { extractA = ImmutableList . of ( paramType ) ; } else { extractA = ImmutableList . of ( ) ; } return extractA ; } | Returns the statement arguments for the match method returns statement . | 163 | 11 |
138,114 | public static ProbeSender createMulticastProbeSender ( ) throws ProbeSenderException , TransportConfigException { Transport mcastTransport = new MulticastTransport ( "" ) ; ProbeSender gen = new ProbeSender ( mcastTransport ) ; return gen ; } | Create a Multicast ProbeSender with all the default values . The default values are the default multicast group address and port of the Argo protocol . The Network Interface is the NI associated with the localhost address . | 61 | 45 |
138,115 | public static ProbeSender createMulticastProbeSender ( String niName ) throws TransportConfigException { Transport mcastTransport = new MulticastTransport ( niName ) ; ProbeSender gen = new ProbeSender ( mcastTransport ) ; return gen ; } | Create a Multicast ProbeSender specifying the Network Interface to send on . | 60 | 16 |
138,116 | public static ProbeSender createSNSProbeSender ( String ak , String sk ) throws ProbeSenderException { Transport snsTransport = new AmazonSNSTransport ( ak , sk ) ; ProbeSender gen = new ProbeSender ( snsTransport ) ; return gen ; } | Create a AmazonSNS transport ProbeSender using the default values . | 63 | 14 |
138,117 | private void initializeHTTPClient ( ) { if ( _config . isHTTPSConfigured ( ) ) { try { KeyStore trustKeystore = getClientTruststore ( ) ; SSLContext sslContext = SSLContexts . custom ( ) . loadTrustMaterial ( trustKeystore , new TrustSelfSignedStrategy ( ) ) . build ( ) ; SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory ( sslContext , NoopHostnameVerifier . INSTANCE ) ; // Allow both HTTP and HTTPS connections Registry < ConnectionSocketFactory > r = RegistryBuilder . < ConnectionSocketFactory > create ( ) . register ( "http" , PlainConnectionSocketFactory . INSTANCE ) . register ( "https" , sslsf ) . build ( ) ; HttpClientConnectionManager cm = new PoolingHttpClientConnectionManager ( r ) ; httpClient = HttpClients . custom ( ) . setConnectionManager ( cm ) . build ( ) ; } catch ( Exception e ) { LOGGER . error ( "Issue creating HTTP client using supplied configuration. Proceeding with default non-SSL client." , e ) ; httpClient = HttpClients . createDefault ( ) ; } } else { httpClient = HttpClients . createDefault ( ) ; } } | Create HTTP Client . | 267 | 4 |
138,118 | private KeyStore getClientTruststore ( ) throws KeyStoreException , NoSuchAlgorithmException , CertificateException , IOException { KeyStore ks = null ; if ( _config . getTruststoreType ( ) != null && ! _config . getTruststoreType ( ) . isEmpty ( ) ) { try { ks = KeyStore . getInstance ( _config . getTruststoreType ( ) ) ; } catch ( KeyStoreException e ) { LOGGER . warn ( "The specified truststore type [" + _config . getTruststoreType ( ) + "] didn't work." , e ) ; throw e ; } } else { ks = KeyStore . getInstance ( KeyStore . getDefaultType ( ) ) ; } // get user password and file input stream char [ ] password = _config . getTruststorePassword ( ) . toCharArray ( ) ; java . io . FileInputStream fis = null ; try { fis = new java . io . FileInputStream ( _config . geTruststoreFilename ( ) ) ; ks . load ( fis , password ) ; } finally { if ( fis != null ) { fis . close ( ) ; } } return ks ; } | Read the KeyStore information supplied from the responder configuration file . | 257 | 13 |
138,119 | public void stopResponder ( ) { LOGGER . info ( "Force shutdown of Responder [" + _runtimeId + "]" ) ; _shutdownHook . start ( ) ; Runtime . getRuntime ( ) . removeShutdownHook ( _shutdownHook ) ; } | Close the socket and tell the processing loop to terminate . This is a forced shutdown rather then a natural shutdown . A natural shutdown happens when the shutdown hook fires when the VM exists . This method forces all that to happen . This is done to allow multiple Responders to be created and destroyed during a single VM session . Necessary for various testing and management procedures . | 60 | 73 |
138,120 | public void shutdown ( ) { LOGGER . info ( "Responder shutting down: [" + _runtimeId + "]" ) ; for ( Transport t : _transports ) { try { t . shutdown ( ) ; } catch ( TransportException e ) { LOGGER . warn ( "Error shutting down transport: [" + t . transportName ( ) + "]" , e ) ; } } } | This will shutdown the listening socket and remove the responder from the multicast group . Part of the natural life cycle . It also will end the run loop of the responder automatically - it will interrupt any read operation going on and exit the run loop . | 82 | 51 |
138,121 | public void run ( ) { // I hope that this hits you over the head with its simplicity. // That's the idea. The instances of the transports are supposed to be self // contained. Thread transportThread ; for ( Transport t : _transports ) { transportThread = new Thread ( t ) ; transportThread . setName ( t . transportName ( ) ) ; transportThread . start ( ) ; } } | This is the main run method for the Argo Responder . It starts up all the configured transports in their own thread and starts their receive loops . | 85 | 30 |
138,122 | public synchronized float probesPerSecond ( ) { Instant now = new Instant ( ) ; Instant event = null ; int events = 0 ; boolean done = false ; long timeWindow = 0 ; long oldestTime = 0 ; do { event = messages . poll ( ) ; if ( event != null ) { events ++ ; if ( events == 1 ) oldestTime = event . getMillis ( ) ; done = event . getMillis ( ) >= now . getMillis ( ) ; } else { done = true ; } } while ( ! done ) ; timeWindow = now . getMillis ( ) - oldestTime ; float mps = ( float ) events / timeWindow ; mps = ( float ) ( mps * 1000.0 ) ; return mps ; } | Calculates the number of probes per second over the last 1000 probes . | 160 | 15 |
138,123 | public static void main ( String [ ] args ) throws ResponderConfigException { Responder responder = initialize ( args ) ; if ( responder != null ) { responder . run ( ) ; } } | Main entry point for Argo Responder . | 43 | 9 |
138,124 | public static Responder initialize ( String [ ] args ) throws ResponderConfigException { readVersionProperties ( ) ; LOGGER . info ( "Starting Argo Responder daemon process. Version " + ARGO_VERSION ) ; ResponderConfiguration config = parseCommandLine ( args ) ; if ( config == null ) { LOGGER . error ( "Invalid Responder Configuration. Terminating Responder process." ) ; return null ; } Responder responder = new Responder ( config ) ; // load up the handler classes specified in the configuration parameters try { responder . loadHandlerPlugins ( config . getProbeHandlerConfigs ( ) ) ; } catch ( ProbeHandlerConfigException e ) { throw new ResponderConfigException ( "Error loading handler plugins: " , e ) ; } // load up the transport classes specified in the configuration parameters responder . loadTransportPlugins ( config . getTransportConfigs ( ) ) ; LOGGER . info ( "Responder registering shutdown hook." ) ; ResponderShutdown hook = new ResponderShutdown ( responder ) ; Runtime . getRuntime ( ) . addShutdownHook ( hook ) ; // This needs to be sent to stdout as there is no way to force the logging // of this via the LOGGER System . out . println ( "Argo " + ARGO_VERSION + " :: " + "Responder started [" + responder . _runtimeId + "] :: Responding as [" + ( config . isHTTPSConfigured ( ) ? "Secure HTTPS" : "Non-secure HTTP" ) + "]" ) ; return responder ; } | Create a new Responder given the command line arguments . | 339 | 11 |
138,125 | private void loadProperties ( String propFileName ) { if ( propFileName != null ) { loadProperties ( getClass ( ) . getResourceAsStream ( propFileName ) , propFileName ) ; } } | Load properties from a resource stream . | 47 | 7 |
138,126 | private void loadProperties ( InputStream stream , String path ) { if ( stream == null ) { return ; } try { Properties props = new Properties ( ) ; props . load ( stream ) ; Iterator < Object > keyIt = props . keySet ( ) . iterator ( ) ; while ( keyIt . hasNext ( ) ) { String key = keyIt . next ( ) . toString ( ) ; _properties . put ( key , props . get ( key ) ) ; } } catch ( Exception e ) { Console . warn ( "Unable to load properties file [" + path + "]." ) ; } finally { if ( stream != null ) { try { stream . close ( ) ; } catch ( Exception e ) { Console . warn ( "Unable to close properties file [" + path + "]." ) ; } } } } | Loads properties from the given stream . This will close the stream . | 176 | 14 |
138,127 | public Object put ( String key , Object o ) { return _properties . put ( key , o ) ; } | Add an object to the context . | 23 | 7 |
138,128 | public String getString ( String key , String defaultValue ) { Object o = getObject ( key ) ; if ( o == null ) { return defaultValue ; } if ( ! ( o instanceof String ) ) { throw new IllegalArgumentException ( "Object [" + o + "] associated with key [" + key + "] is not of type String." ) ; } return ( String ) o ; } | Get the string value or the defaultValue if not found . | 85 | 12 |
138,129 | public boolean getBoolean ( String key , boolean defaultValue ) { Object o = getObject ( key ) ; if ( o == null ) { return defaultValue ; } boolean b = defaultValue ; try { b = Boolean . parseBoolean ( o . toString ( ) ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Object [" + o + "] associated with key [" + key + "] is not of type Boolean." ) ; } return b ; } | Get the boolean value or the defaultValue if not found . | 103 | 12 |
138,130 | public int getInteger ( String key , int defaultValue ) { Object o = getObject ( key ) ; if ( o == null ) { return defaultValue ; } int val = defaultValue ; try { val = Integer . parseInt ( o . toString ( ) ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Object [" + o + "] associated with key [" + key + "] is not of type Integer." ) ; } return val ; } | Get the integer value or the defaultValue if not found . | 101 | 12 |
138,131 | public static InvocationHandler defaultMethodHandler ( ) { return ( proxy , method , args ) -> { if ( method . isDefault ( ) ) { return MethodHandles . lookup ( ) . in ( method . getDeclaringClass ( ) ) . unreflectSpecial ( method , method . getDeclaringClass ( ) ) . bindTo ( proxy ) . invokeWithArguments ( args ) ; } else { throw new IllegalArgumentException ( method . toString ( ) ) ; } } ; } | Handler for invoking interface default methods . This handler will throw an exception if the method is not a default method . | 104 | 22 |
138,132 | @ SuppressWarnings ( "unchecked" ) public < E extends T > T [ ] concat ( T [ ] oldArray , E newElement ) { T [ ] arr = ( T [ ] ) Array . newInstance ( type , oldArray . length + 1 ) ; System . arraycopy ( oldArray , 0 , arr , 0 , oldArray . length ) ; arr [ oldArray . length ] = newElement ; return arr ; } | Returns a new instance with the given element at the end . | 95 | 12 |
138,133 | @ Override @ SuppressWarnings ( "unchecked" ) protected T convert ( JsonNode data ) { // The (T) cast prevents the commandline javac from choking "no unique maximal instance" return ( T ) this . mapper . convertValue ( data , this . resultType ) ; } | Use Jackson to map from JsonNode to the type | 67 | 11 |
138,134 | @ SuppressWarnings ( "unchecked" ) public Object runKeyword ( String keyword , final Object [ ] params ) { Map attributes = new HashMap ( ) ; attributes . put ( "args" , params ) ; try { ApplicationContextHolder . set ( context ) ; startJSpringBotKeyword ( keyword , attributes ) ; Object [ ] handledParams = argumentHandlers . handlerArguments ( keyword , params ) ; Object returnedValue = ( ( Keyword ) context . getBean ( keywordToBeanMap . get ( keyword ) ) ) . execute ( handledParams ) ; attributes . put ( "status" , "PASS" ) ; return returnedValue ; } catch ( Exception e ) { attributes . put ( "exception" , e ) ; attributes . put ( "status" , "FAIL" ) ; if ( SoftAssertManager . INSTANCE . isEnable ( ) ) { LOGGER . warn ( "[SOFT ASSERT]: (" + keyword + ") -> " + e . getMessage ( ) ) ; SoftAssertManager . INSTANCE . add ( keyword , e ) ; return null ; } else { throw new IllegalStateException ( e . getMessage ( ) , e ) ; } } finally { endJSpringBotKeyword ( keyword , attributes ) ; ApplicationContextHolder . remove ( ) ; } } | Implements the Robot Framework interface method run_keyword required for dynamic libraries . | 285 | 17 |
138,135 | public static String getAppAccessToken ( String clientId , String clientSecret ) { return getAccessToken ( clientId , clientSecret , null , null ) ; } | Get the app access token from Facebook . | 34 | 8 |
138,136 | @ Override public void execute ( ) { if ( this . batches . isEmpty ( ) ) return ; // Reset the collection before making the call to eliminate callback chatter when // the batches call back to the master. List < Batch > old = this . batches ; // Reset our batches this . batches = new ArrayList < Batch > ( ) ; this . queryBatch = null ; for ( Batch batch : old ) { batch . execute ( ) ; } } | Executes all existing batches and removes them from consideration for further batching . | 98 | 15 |
138,137 | private Batch getBatchForGraph ( ) { Batch lastValidBatch = this . batches . isEmpty ( ) ? null : this . batches . get ( this . batches . size ( ) - 1 ) ; if ( lastValidBatch != null && lastValidBatch . graphSize ( ) < this . maxBatchSize ) return lastValidBatch ; else { Batch next = new Batch ( this , this . mapper , this . accessToken , this . apiVersion , this . timeout , this . retries ) ; this . batches . add ( next ) ; return next ; } } | Get an appropriate Batch for issuing a new graph call . Will construct a new one if all existing batches are full . | 129 | 24 |
138,138 | public static SmartBinder from ( Signature inbound ) { return new SmartBinder ( inbound , Binder . from ( inbound . type ( ) ) ) ; } | Create a new SmartBinder from the given Signature . | 36 | 11 |
138,139 | public static SmartBinder from ( Class < ? > retType , String [ ] names , Class < ? > ... types ) { return from ( Signature . returning ( retType ) . appendArgs ( names , types ) ) ; } | Create a new SmartBinder from the given types and argument names . | 48 | 14 |
138,140 | public static SmartBinder from ( Class < ? > retType , String name , Class < ? > type ) { return from ( Signature . returning ( retType ) . appendArg ( name , type ) ) ; } | Create a new SmartBinder with from the given types and argument name . | 45 | 15 |
138,141 | public static SmartBinder from ( Lookup lookup , Signature inbound ) { return new SmartBinder ( inbound , Binder . from ( lookup , inbound . type ( ) ) ) ; } | Create a new SmartBinder from the given Signature using the given Lookup for any handle lookups . | 42 | 21 |
138,142 | public SmartBinder foldVoid ( SmartHandle function ) { if ( Arrays . equals ( signature ( ) . argNames ( ) , function . signature ( ) . argNames ( ) ) ) { return foldVoid ( function . handle ( ) ) ; } else { return foldVoid ( signature ( ) . asFold ( void . class ) . permuteWith ( function ) . handle ( ) ) ; } } | Pass all arguments to the given function and drop any result . | 89 | 12 |
138,143 | public SmartBinder foldStatic ( String newName , Lookup lookup , Class < ? > target , String method ) { Binder newBinder = binder . foldStatic ( lookup , target , method ) ; return new SmartBinder ( this , signature ( ) . prependArg ( newName , newBinder . type ( ) . parameterType ( 0 ) ) , binder ) ; } | Acquire a static folding function from the given target class using the given name and Lookup . Pass all arguments to that function and insert the resulting value as newName into the argument list . | 83 | 38 |
138,144 | public SmartBinder foldVirtual ( String newName , Lookup lookup , String method ) { Binder newBinder = binder . foldVirtual ( lookup , method ) ; return new SmartBinder ( this , signature ( ) . prependArg ( newName , newBinder . type ( ) . parameterType ( 0 ) ) , newBinder ) ; } | Acquire a virtual folding function from the first argument s class using the given name and Lookup . Pass all arguments to that function and insert the resulting value as newName into the argument list . | 76 | 39 |
138,145 | public SmartBinder permute ( Signature target ) { return new SmartBinder ( this , target , binder . permute ( signature ( ) . to ( target ) ) ) ; } | Using the argument names and order in the target Signature permute the arguments in this SmartBinder . Arguments may be duplicated or omitted in the target Signature but all arguments in the target must be defined in this SmartBinder . | 39 | 47 |
138,146 | public SmartBinder spread ( String [ ] spreadNames , Class < ? > ... spreadTypes ) { return new SmartBinder ( this , signature ( ) . spread ( spreadNames , spreadTypes ) , binder . spread ( spreadTypes ) ) ; } | Spread a trailing array into the specified argument types . | 53 | 10 |
138,147 | public SmartBinder spread ( String baseName , int count ) { return new SmartBinder ( this , signature ( ) . spread ( baseName , count ) , binder . spread ( count ) ) ; } | Spread a trailing array into count number of arguments using the natural component type for the array . Build names for the arguments using the given baseName plus the argument s index . | 44 | 34 |
138,148 | public SmartBinder insert ( int index , String [ ] names , Class < ? > [ ] types , Object ... values ) { return new SmartBinder ( this , signature ( ) . insertArgs ( index , names , types ) , binder . insert ( index , types , values ) ) ; } | Insert arguments into the argument list at the given index with the given names and values . | 63 | 17 |
138,149 | public SmartBinder append ( String [ ] names , Class < ? > [ ] types , Object ... values ) { return new SmartBinder ( this , signature ( ) . appendArgs ( names , types ) , binder . append ( types , values ) ) ; } | Append the given arguments to the argument list assigning them the given names . | 56 | 15 |
138,150 | public SmartBinder prepend ( String [ ] names , Class < ? > [ ] types , Object ... values ) { return new SmartBinder ( this , signature ( ) . prependArgs ( names , types ) , binder . prepend ( types , values ) ) ; } | Prepend the given arguments to the argument list assigning them the given name . | 59 | 15 |
138,151 | public SmartBinder drop ( String name ) { int index = signature ( ) . argOffset ( name ) ; return new SmartBinder ( this , signature ( ) . dropArg ( index ) , binder . drop ( index ) ) ; } | Drop the argument with the given name . | 51 | 8 |
138,152 | public SmartBinder dropLast ( int count ) { return new SmartBinder ( this , signature ( ) . dropLast ( count ) , binder . dropLast ( count ) ) ; } | Drop the last N arguments . | 40 | 6 |
138,153 | public SmartBinder dropFirst ( int count ) { return new SmartBinder ( this , signature ( ) . dropFirst ( count ) , binder . dropFirst ( count ) ) ; } | Drop the first N arguments . | 40 | 6 |
138,154 | public SmartBinder collect ( String outName , String namePattern ) { int index = signature ( ) . argOffsets ( namePattern ) ; assert index >= 0 : "no arguments matching " + namePattern + " found in signature " + signature ( ) ; Signature newSignature = signature ( ) . collect ( outName , namePattern ) ; return new SmartBinder ( this , newSignature , binder . collect ( index , signature ( ) . argCount ( ) - ( newSignature . argCount ( ) - 1 ) , Array . newInstance ( signature ( ) . argType ( index ) , 0 ) . getClass ( ) ) ) ; } | Collect arguments matching namePattern into an trailing array argument named outName . | 139 | 14 |
138,155 | public SmartBinder cast ( Signature target ) { return new SmartBinder ( target , binder . cast ( target . type ( ) ) ) ; } | Cast the incoming arguments to the types in the given signature . The argument count must match but the names in the target signature are ignored . | 32 | 27 |
138,156 | public SmartBinder cast ( Class < ? > returnType , Class < ? > ... argTypes ) { return new SmartBinder ( this , new Signature ( returnType , argTypes , signature ( ) . argNames ( ) ) , binder . cast ( returnType , argTypes ) ) ; } | Cast the incoming arguments to the return and argument types given . The argument count must match . | 63 | 18 |
138,157 | public SmartBinder castVirtual ( Class < ? > returnType , Class < ? > firstArg , Class < ? > ... restArgs ) { return new SmartBinder ( this , new Signature ( returnType , firstArg , restArgs , signature ( ) . argNames ( ) ) , binder . castVirtual ( returnType , firstArg , restArgs ) ) ; } | Cast the incoming arguments to the return first argument type and remaining argument types . Provide for convenience when dealing with virtual method argument lists which frequently omit the target object . | 78 | 32 |
138,158 | public SmartBinder castArg ( String name , Class < ? > type ) { Signature newSig = signature ( ) . replaceArg ( name , name , type ) ; return new SmartBinder ( this , newSig , binder . cast ( newSig . type ( ) ) ) ; } | Cast the named argument to the given type . | 64 | 9 |
138,159 | public SmartBinder castReturn ( Class < ? > type ) { return new SmartBinder ( this , signature ( ) . changeReturn ( type ) , binder . cast ( type , binder . type ( ) . parameterArray ( ) ) ) ; } | Cast the return value to the given type . | 54 | 9 |
138,160 | public SmartHandle invokeVirtual ( Lookup lookup , String name ) throws NoSuchMethodException , IllegalAccessException { return new SmartHandle ( start , binder . invokeVirtual ( lookup , name ) ) ; } | Terminate this binder by looking up the named virtual method on the first argument s type . Perform the actual method lookup using the given Lookup object . | 43 | 31 |
138,161 | public SmartHandle invokeStatic ( Lookup lookup , Class < ? > target , String name ) throws NoSuchMethodException , IllegalAccessException { return new SmartHandle ( start , binder . invokeStatic ( lookup , target , name ) ) ; } | Terminate this binder by looking up the named static method on the given target type . Perform the actual method lookup using the given Lookup object . | 51 | 30 |
138,162 | public SmartHandle invoke ( SmartHandle target ) { return new SmartHandle ( start , binder . invoke ( target . handle ( ) ) ) ; } | Terminate this binder by invoking the given target handle . The signature of this binder is not compared to the signature of the given SmartHandle . | 31 | 30 |
138,163 | public SmartBinder filter ( String pattern , MethodHandle filter ) { String [ ] argNames = signature ( ) . argNames ( ) ; Pattern pat = Pattern . compile ( pattern ) ; Binder newBinder = binder ( ) ; Signature newSig = signature ( ) ; for ( int i = 0 ; i < argNames . length ; i ++ ) { if ( pat . matcher ( argNames [ i ] ) . matches ( ) ) { newBinder = newBinder . filter ( i , filter ) ; newSig = newSig . argType ( i , filter . type ( ) . returnType ( ) ) ; } } return new SmartBinder ( newSig , newBinder ) ; } | Filter the arguments matching the given pattern using the given filter function . | 154 | 13 |
138,164 | public static Signature from ( Class < ? > retval , Class < ? > [ ] argTypes , String ... argNames ) { assert argTypes . length == argNames . length ; return new Signature ( retval , argTypes , argNames ) ; } | Create a new signature based on the given return value argument types and argument names | 53 | 15 |
138,165 | public Signature dropArg ( String name ) { String [ ] newArgNames = new String [ argNames . length - 1 ] ; MethodType newType = methodType ; for ( int i = 0 , j = 0 ; i < argNames . length ; i ++ ) { if ( argNames [ i ] . equals ( name ) ) { newType = newType . dropParameterTypes ( j , j + 1 ) ; continue ; } newArgNames [ j ++ ] = argNames [ i ] ; } if ( newType == null ) { // arg name not found; should we error? return this ; } return new Signature ( newType , newArgNames ) ; } | Drops the first argument with the given name . | 141 | 10 |
138,166 | public Signature dropArg ( int index ) { assert index < argNames . length ; String [ ] newArgNames = new String [ argNames . length - 1 ] ; if ( index > 0 ) System . arraycopy ( argNames , 0 , newArgNames , 0 , index ) ; if ( index < argNames . length - 1 ) System . arraycopy ( argNames , index + 1 , newArgNames , index , argNames . length - ( index + 1 ) ) ; MethodType newType = methodType . dropParameterTypes ( index , index + 1 ) ; return new Signature ( newType , newArgNames ) ; } | Drops the argument at the given index . | 133 | 9 |
138,167 | public Signature dropLast ( int n ) { return new Signature ( methodType . dropParameterTypes ( methodType . parameterCount ( ) - n , methodType . parameterCount ( ) ) , Arrays . copyOfRange ( argNames , 0 , argNames . length - n ) ) ; } | Drop the specified number of last arguments from this signature . | 61 | 11 |
138,168 | public Signature dropFirst ( int n ) { return new Signature ( methodType . dropParameterTypes ( 0 , n ) , Arrays . copyOfRange ( argNames , n , argNames . length ) ) ; } | Drop the specified number of first arguments from this signature . | 45 | 11 |
138,169 | public Signature replaceArg ( String oldName , String newName , Class < ? > newType ) { int offset = argOffset ( oldName ) ; String [ ] newArgNames = argNames ; if ( ! oldName . equals ( newName ) ) { newArgNames = Arrays . copyOf ( argNames , argNames . length ) ; newArgNames [ offset ] = newName ; } Class < ? > oldType = methodType . parameterType ( offset ) ; MethodType newMethodType = methodType ; if ( ! oldType . equals ( newType ) ) newMethodType = methodType . changeParameterType ( offset , newType ) ; return new Signature ( newMethodType , newArgNames ) ; } | Replace the named argument with a new name and type . | 152 | 12 |
138,170 | public Signature collect ( String newName , String oldPattern ) { int start = - 1 ; int newCount = 0 ; int gatherCount = 0 ; Class < ? > type = null ; Pattern pattern = Pattern . compile ( oldPattern ) ; MethodType newType = type ( ) ; for ( int i = 0 ; i < argNames . length ; i ++ ) { if ( pattern . matcher ( argName ( i ) ) . matches ( ) ) { gatherCount ++ ; newType = newType . dropParameterTypes ( newCount , newCount + 1 ) ; Class < ? > argType = argType ( i ) ; if ( start == - 1 ) start = i ; if ( type == null ) { type = argType ; } else { if ( argType != type ) { throw new InvalidTransformException ( "arguments matching " + pattern + " are not all of the same type" ) ; } } } else { newCount ++ ; } } if ( start != - 1 ) { String [ ] newNames = new String [ newCount + 1 ] ; // pre System . arraycopy ( argNames , 0 , newNames , 0 , start ) ; // vararg newNames [ start ] = newName ; newType = newType . insertParameterTypes ( start , Array . newInstance ( type , 0 ) . getClass ( ) ) ; // post if ( newCount + 1 > start ) { // args not at end System . arraycopy ( argNames , start + gatherCount , newNames , start + 1 , newCount - start ) ; } return new Signature ( newType , newNames ) ; } return this ; } | Collect sequential arguments matching pattern into an array . They must have the same type . | 345 | 16 |
138,171 | public Signature argName ( int index , String name ) { String [ ] argNames = Arrays . copyOf ( argNames ( ) , argNames ( ) . length ) ; argNames [ index ] = name ; return new Signature ( type ( ) , argNames ) ; } | Set the argument name at the given index . | 58 | 9 |
138,172 | public Signature argType ( int index , Class < ? > type ) { return new Signature ( type ( ) . changeParameterType ( index , type ) , argNames ( ) ) ; } | Set the argument type at the given index . | 39 | 9 |
138,173 | public MethodHandle permuteWith ( MethodHandle target , String ... permuteArgs ) { return MethodHandles . permuteArguments ( target , methodType , to ( permute ( permuteArgs ) ) ) ; } | Produce a method handle permuting the arguments in this signature using the given permute arguments and targeting the given java . lang . invoke . MethodHandle . | 46 | 31 |
138,174 | public SmartHandle permuteWith ( SmartHandle target ) { String [ ] argNames = target . signature ( ) . argNames ( ) ; return new SmartHandle ( this , permuteWith ( target . handle ( ) , argNames ) ) ; } | Produce a new SmartHandle by permuting this Signature s arguments to the Signature of a target SmartHandle . The new SmartHandle s signature will match this one permuting those arguments and invoking the target handle . | 52 | 42 |
138,175 | public static < E > Stream < E > streamUntil ( Supplier < ? extends E > supplier , Predicate < ? super E > stop ) { Iterator < E > iterator = AltIterators . iterateUntil ( supplier , stop ) ; Spliterator < E > spliterator = Spliterators . spliterator ( iterator , Long . MAX_VALUE , Spliterator . ORDERED ) ; return StreamSupport . stream ( spliterator , false ) ; } | Consumes data from the supplier until a condition is met . Use this method where a poison pill can be supplied to stop processing . | 94 | 26 |
138,176 | public static int find ( int [ ] arr , int start , int end , int valueToFind ) { assert arr != null ; assert end >= 0 ; assert end <= arr . length ; for ( int i = start ; i < end ; i ++ ) { if ( arr [ i ] == valueToFind ) { return i ; } } return NOT_FOUND ; } | Finds a value in an int array . | 78 | 9 |
138,177 | public static int find ( Object [ ] arr , int start , int end , Object valueToFind ) { assert arr != null ; assert end >= 0 ; assert end <= arr . length ; for ( int i = start ; i < end ; i ++ ) { if ( Objects . equals ( arr [ i ] , valueToFind ) ) { return i ; } } return NOT_FOUND ; } | Finds a value in an Object array . | 83 | 9 |
138,178 | public static < T > Mutator < T > mutate ( T t ) { Objects . requireNonNull ( t ) ; return new Mutator <> ( t ) ; } | Creates a new mutate instance . | 37 | 8 |
138,179 | private HttpResponse executeOnce ( RequestSetup setup ) throws IOException { DefaultRequestDefinition req = new DefaultRequestDefinition ( ) ; setup . setup ( req ) ; HttpResponse response = req . execute ( ) ; // This will force the request to complete, causing any timeout exceptions to happen here response . getResponseCode ( ) ; return response ; } | Execute given the specified http method once throwing any exceptions as they come | 73 | 14 |
138,180 | protected static void buildClassArguments ( StringBuilder builder , Class < ? > [ ] types ) { boolean second = false ; for ( Class cls : types ) { if ( second ) builder . append ( ", " ) ; second = true ; buildClassArgument ( builder , cls ) ; } } | Build a list of argument type classes suitable for inserting into Java code . | 64 | 14 |
138,181 | protected static void buildClassArgument ( StringBuilder builder , Class cls ) { buildClass ( builder , cls ) ; builder . append ( ".class" ) ; } | Build Java code to represent a single . class reference . | 36 | 11 |
138,182 | protected static void buildClassCast ( StringBuilder builder , Class cls ) { builder . append ( ' ' ) ; buildClass ( builder , cls ) ; builder . append ( ' ' ) ; } | Build Java code to represent a cast to the given type . | 42 | 12 |
138,183 | protected static void buildPrimitiveJava ( StringBuilder builder , Object value ) { builder . append ( value . toString ( ) ) ; if ( value . getClass ( ) == Float . class ) builder . append ( ' ' ) ; if ( value . getClass ( ) == Long . class ) builder . append ( ' ' ) ; } | Build Java code to represent a literal primitive . | 71 | 9 |
138,184 | private static void buildClass ( StringBuilder builder , Class cls ) { int arrayDims = 0 ; Class tmp = cls ; while ( tmp . isArray ( ) ) { arrayDims ++ ; tmp = tmp . getComponentType ( ) ; } builder . append ( tmp . getName ( ) ) ; if ( arrayDims > 0 ) { for ( ; arrayDims > 0 ; arrayDims -- ) { builder . append ( "[]" ) ; } } } | Build Java code to represent a type reference to the given class . | 101 | 13 |
138,185 | public static String generateMethodType ( MethodType source ) { StringBuilder builder = new StringBuilder ( "MethodType.methodType(" ) ; buildClassArgument ( builder , source . returnType ( ) ) ; if ( source . parameterCount ( ) > 0 ) { builder . append ( ", " ) ; buildClassArguments ( builder , source . parameterArray ( ) ) ; } builder . append ( ")" ) ; return builder . toString ( ) ; } | Build Java code appropriate for standing up the given MethodType . | 97 | 12 |
138,186 | protected HttpResponse execute ( final HttpMethod meth , String postURL ) throws IOException { final String url = ( meth == HttpMethod . POST ) ? postURL : this . toString ( ) ; if ( log . isLoggable ( Level . FINER ) ) log . finer ( meth + "ing: " + url ) ; return RequestExecutor . instance ( ) . execute ( this . retries , new RequestSetup ( ) { public void setup ( RequestDefinition req ) throws IOException { req . init ( meth , url ) ; for ( Map . Entry < String , String > header : headers . entrySet ( ) ) req . setHeader ( header . getKey ( ) , header . getValue ( ) ) ; if ( timeout > 0 ) req . setTimeout ( timeout ) ; if ( meth == HttpMethod . POST && ! params . isEmpty ( ) ) { if ( ! hasBinaryAttachments ) { String queryString = createQueryString ( ) ; if ( log . isLoggable ( Level . FINER ) ) log . finer ( "POST data is: " + queryString ) ; // This is more efficient if we don't have any binary attachments req . setHeader ( "Content-Type" , "application/x-www-form-urlencoded; charset=utf-8" ) ; req . setContent ( queryString . getBytes ( "utf-8" ) ) ; } else { log . finer ( "POST contains binary data, sending multipart/form-data" ) ; // Binary attachments requires more complicated multipart/form-data format MultipartWriter writer = new MultipartWriter ( req ) ; writer . write ( params ) ; } } } } ) ; } | Execute given the specified http method retrying up to the allowed number of retries . | 368 | 18 |
138,187 | protected String createQueryString ( ) { assert ! this . hasBinaryAttachments ; if ( this . params . isEmpty ( ) ) return "" ; StringBuilder bld = null ; for ( Map . Entry < String , Object > param : this . params . entrySet ( ) ) { if ( bld == null ) bld = new StringBuilder ( ) ; else bld . append ( ' ' ) ; bld . append ( StringUtils . urlEncode ( param . getKey ( ) ) ) ; bld . append ( ' ' ) ; bld . append ( StringUtils . urlEncode ( param . getValue ( ) . toString ( ) ) ) ; } return bld . toString ( ) ; } | Creates a string representing the current query string or an empty string if there are no parameters . Will not work if there are binary attachments! | 156 | 28 |
138,188 | public static FacebookCookie decode ( String cookie , String appSecret ) { // Parsing and verifying signature seems to be poorly documented, but here's what I've found: // Look at parseSignedRequest() in https://github.com/facebook/php-sdk/blob/master/src/base_facebook.php // Python version: https://developers.facebook.com/docs/samples/canvas/ try { String [ ] parts = cookie . split ( "\\." ) ; byte [ ] sig = Base64 . decodeBase64 ( parts [ 0 ] ) ; byte [ ] json = Base64 . decodeBase64 ( parts [ 1 ] ) ; byte [ ] plaintext = parts [ 1 ] . getBytes ( ) ; // careful, we compute against the base64 encoded version FacebookCookie decoded = MAPPER . readValue ( json , FacebookCookie . class ) ; // "HMAC-SHA256" doesn't work, but "HMACSHA256" does. String algorithm = decoded . algorithm . replace ( "-" , "" ) ; SecretKey secret = new SecretKeySpec ( appSecret . getBytes ( ) , algorithm ) ; Mac mac = Mac . getInstance ( algorithm ) ; mac . init ( secret ) ; byte [ ] digested = mac . doFinal ( plaintext ) ; if ( ! Arrays . equals ( sig , digested ) ) throw new IllegalStateException ( "Signature failed" ) ; return decoded ; } catch ( Exception ex ) { throw new IllegalStateException ( "Unable to decode cookie" , ex ) ; } } | Decodes and validates the cookie . | 337 | 8 |
138,189 | public static Map < String , String > getKeywordMap ( ApplicationContext context ) { Map < String , String > keywordToBeanMap = new HashMap < String , String > ( ) ; // Retrieve beans implementing the Keyword interface. String [ ] beanNames = context . getBeanNamesForType ( Keyword . class ) ; for ( String beanName : beanNames ) { Object bean = context . getBean ( beanName ) ; // Retrieve keyword information KeywordInfo keywordInfo = AnnotationUtils . findAnnotation ( bean . getClass ( ) , KeywordInfo . class ) ; // Set keyword name as specified in the keyword info, or if information is not available, use bean name. String keywordName = keywordInfo != null ? keywordInfo . name ( ) : beanName ; if ( keywordToBeanMap . put ( keywordName , beanName ) != null ) { // If map already contains the keyword name, throw an exception. Keywords should be unique. throw new RuntimeException ( "Multiple definitions for keyword '" + keywordName + "' exists." ) ; } } return keywordToBeanMap ; } | Builds mapping of robot keywords to actual bean names in spring context . | 240 | 14 |
138,190 | public static String getDescription ( String keyword , ApplicationContext context , Map < String , String > beanMap ) { KeywordInfo keywordInfo = getKeywordInfo ( keyword , context , beanMap ) ; if ( keywordInfo == null ) { return "" ; } String desc = keywordInfo . description ( ) ; if ( desc . startsWith ( "classpath:" ) ) { try { ResourceEditor editor = new ResourceEditor ( ) ; editor . setAsText ( desc ) ; Resource r = ( Resource ) editor . getValue ( ) ; return IOUtils . toString ( r . getInputStream ( ) ) ; } catch ( Exception ignored ) { } } return desc ; } | Retrieves the given keyword s description . | 143 | 9 |
138,191 | public static String [ ] getParameters ( String keyword , ApplicationContext context , Map < String , String > beanMap ) { KeywordInfo keywordInfo = getKeywordInfo ( keyword , context , beanMap ) ; return keywordInfo == null ? DEFAULT_PARAMS : keywordInfo . parameters ( ) ; } | Retrieves the given keyword s parameter description . | 64 | 10 |
138,192 | public static KeywordInfo getKeywordInfo ( String keyword , ApplicationContext context , Map < String , String > beanMap ) { Object bean = context . getBean ( beanMap . get ( keyword ) ) ; return AnnotationUtils . findAnnotation ( bean . getClass ( ) , KeywordInfo . class ) ; } | Retrieves the KeywordInfo of the given keyword . | 70 | 12 |
138,193 | @ Override @ JsonIgnore protected Param [ ] getParams ( ) { Map < String , String > queries = new LinkedHashMap < String , String > ( ) ; for ( QueryRequest < ? > req : this . queryRequests ) queries . put ( req . getName ( ) , req . getFQL ( ) ) ; String json = JSONUtils . toJSON ( queries , this . mapper ) ; return new Param [ ] { new Param ( "queries" , json ) } ; } | Generate the parameters approprate to a multiquery from the registered queries | 111 | 16 |
138,194 | @ JsonProperty ( "relative_url" ) public String getRelativeURL ( ) { StringBuilder bld = new StringBuilder ( ) ; bld . append ( this . object ) ; Param [ ] params = this . getParams ( ) ; if ( params != null && params . length > 0 ) { bld . append ( ' ' ) ; boolean afterFirst = false ; for ( Param param : params ) { if ( afterFirst ) bld . append ( ' ' ) ; else afterFirst = true ; if ( param instanceof BinaryParam ) { //call.addParam(param.name, (InputStream)param.value, ((BinaryParam)param).contentType, "irrelevant"); throw new UnsupportedOperationException ( "Not quite sure what to do with BinaryParam yet" ) ; } else { String paramValue = StringUtils . stringifyValue ( param , this . mapper ) ; bld . append ( StringUtils . urlEncode ( param . name ) ) ; bld . append ( ' ' ) ; bld . append ( StringUtils . urlEncode ( paramValue ) ) ; } } } return bld . toString ( ) ; } | What Facebook uses to define the url in a batch | 254 | 10 |
138,195 | public static SmartHandle findStaticQuiet ( Lookup lookup , Class < ? > target , String name , Signature signature ) { try { return new SmartHandle ( signature , lookup . findStatic ( target , name , signature . type ( ) ) ) ; } catch ( NoSuchMethodException | IllegalAccessException e ) { throw new RuntimeException ( e ) ; } } | Create a new SmartHandle by performing a lookup on the given target class for the given method name with the given signature . | 76 | 24 |
138,196 | public SmartHandle drop ( String beforeName , String newName , Class < ? > type ) { return new SmartHandle ( signature . insertArg ( beforeName , newName , type ) , MethodHandles . dropArguments ( handle , signature . argOffset ( beforeName ) , type ) ) ; } | Drop an argument name and type from the handle at the given index returning a new SmartHandle . | 63 | 19 |
138,197 | public SmartHandle drop ( int index , String newName , Class < ? > type ) { return new SmartHandle ( signature . insertArg ( index , newName , type ) , MethodHandles . dropArguments ( handle , index , type ) ) ; } | Drop an argument from the handle at the given index returning a new SmartHandle . | 54 | 16 |
138,198 | public SmartHandle dropLast ( String newName , Class < ? > type ) { return new SmartHandle ( signature . appendArg ( newName , type ) , MethodHandles . dropArguments ( handle , signature . argOffset ( newName ) , type ) ) ; } | Drop an argument from the handle at the end returning a new SmartHandle . | 57 | 15 |
138,199 | public SmartHandle bindTo ( Object obj ) { return new SmartHandle ( signature . dropFirst ( ) , handle . bindTo ( obj ) ) ; } | Bind the first argument of this SmartHandle to the given object returning a new adapted handle . | 32 | 18 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.