idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
40,800 | @ Override public HttpService addingService ( final ServiceReference < HttpService > serviceReference ) { LOG . debug ( "HttpService available {}" , serviceReference ) ; lock . lock ( ) ; HttpService addedHttpService = null ; try { if ( httpService != null ) { return super . addingService ( serviceReference ) ; } httpS... | Gets the service if one is not already available and notify listeners . | 149 | 14 |
40,801 | @ Override public void removedService ( final ServiceReference < HttpService > serviceReference , final HttpService service ) { LOG . debug ( "HttpService removed {}" , serviceReference ) ; lock . lock ( ) ; HttpService removedHttpService = null ; try { if ( context != null ) { super . removedService ( serviceReference... | Notify listeners that the http service became unavailable . Then looks for another one and if available notifies listeners . | 120 | 22 |
40,802 | private static void printAttribute ( final PrintWriter writer , final HttpServletRequest request , final String attribute ) { writer . println ( "<tr><td>" + attribute + "</td><td>" + ( request . getAttribute ( attribute ) != null ? request . getAttribute ( attribute ) : "" ) + "</td></tr>" ) ; } | Prints an error request attribute . | 74 | 7 |
40,803 | @ Override public Enumeration < URL > getResources ( String name ) throws IOException { return bundleClassLoader . getResources ( name ) ; } | Delegate to bundle class loader . | 32 | 7 |
40,804 | public List < URL > scanBundlesInClassSpace ( String directory , String filePattern , boolean recursive ) { Set < Bundle > bundlesInClassSpace = ClassPathUtil . getBundlesInClassSpace ( bundleClassLoader . getBundle ( ) , new HashSet <> ( ) ) ; List < URL > matching = new ArrayList <> ( ) ; for ( Bundle bundle : bundle... | Scans the imported and required bundles for matching resources . Can be used to obtain references to TLD files XML definition files etc . | 169 | 26 |
40,805 | public BindingInfo bindingInfo ( String socketBindingName ) { SocketBinding sb = socketBinding ( socketBindingName ) ; if ( sb == null ) { throw new IllegalArgumentException ( "Can't find socket binding with name \"" + socketBindingName + "\"" ) ; } Interface iface = interfaceRef ( sb . getInterfaceRef ( ) ) ; if ( ifa... | Returns valid information about interfaces + port to listen on | 183 | 10 |
40,806 | public void configureWelcomeFiles ( List < String > welcomePages ) { this . welcomePages = welcomePages ; ( ( ResourceHandler ) handler ) . setWelcomeFiles ( ) ; ( ( ResourceHandler ) handler ) . addWelcomeFiles ( welcomePages . toArray ( new String [ welcomePages . size ( ) ] ) ) ; } | Reconfigures default welcome pages with ones provided externally | 68 | 11 |
40,807 | public static String getStringProperty ( final ServiceReference < ? > serviceReference , final String key ) { NullArgumentException . validateNotNull ( serviceReference , "Service reference" ) ; NullArgumentException . validateNotEmpty ( key , true , "Property key" ) ; Object value = serviceReference . getProperty ( ke... | Returns a property as String . | 116 | 6 |
40,808 | public static Integer getIntegerProperty ( final ServiceReference < ? > serviceReference , final String key ) { NullArgumentException . validateNotNull ( serviceReference , "Service reference" ) ; NullArgumentException . validateNotEmpty ( key , true , "Property key" ) ; final Object value = serviceReference . getPrope... | Returns a property as Integer . | 175 | 6 |
40,809 | public static Map < String , Object > getSubsetStartingWith ( final ServiceReference < ? > serviceReference , final String prefix ) { final Map < String , Object > subset = new HashMap <> ( ) ; for ( String key : serviceReference . getPropertyKeys ( ) ) { if ( key != null && key . startsWith ( prefix ) && key . trim ( ... | Returns the subset of properties that start with the prefix . The returned dictionary will have as keys the original key without the prefix . | 137 | 25 |
40,810 | public static String extractHttpContextId ( final ServiceReference < ? > serviceReference ) { String httpContextId = getStringProperty ( serviceReference , ExtenderConstants . PROPERTY_HTTP_CONTEXT_ID ) ; //TODO: Make sure the current HttpContextSelect works together with R6 if ( httpContextId == null ) { String httpCo... | Utility method to extract the httpContextID from the service reference . This can either be included with the old Pax - Web style or the new OSGi R6 Whiteboard style . | 212 | 37 |
40,811 | public static Boolean extractSharedHttpContext ( final ServiceReference < ? > serviceReference ) { Boolean sharedHttpContext = Boolean . parseBoolean ( ( String ) serviceReference . getProperty ( ExtenderConstants . PROPERTY_HTTP_CONTEXT_SHARED ) ) ; if ( serviceReference . getProperty ( HttpWhiteboardConstants . HTTP_... | Utility method to extract the shared state of the HttpContext | 103 | 13 |
40,812 | public void addInitParam ( final WebAppInitParam param ) { NullArgumentException . validateNotNull ( param , "Init param" ) ; NullArgumentException . validateNotNull ( param . getParamName ( ) , "Init param name" ) ; NullArgumentException . validateNotNull ( param . getParamValue ( ) , "Init param value" ) ; initParams... | Add a init param for filter . | 89 | 7 |
40,813 | public Extension createExtension ( final Bundle bundle ) { NullArgumentException . validateNotNull ( bundle , "Bundle" ) ; if ( bundle . getState ( ) != Bundle . ACTIVE ) { LOG . debug ( "Bundle is not in ACTIVE state, ignore it!" ) ; return null ; } // Check compatibility Boolean canSeeServletClass = canSeeClass ( bun... | Parse the web app and create the extension that will be managed by the extender . | 748 | 18 |
40,814 | public static String normalizeResourcePath ( final String path ) { if ( path == null ) { return null ; } String normalizedPath = replaceSlashes ( path . trim ( ) ) ; if ( normalizedPath . startsWith ( "/" ) && normalizedPath . length ( ) > 1 ) { normalizedPath = normalizedPath . substring ( 1 ) ; } return normalizedPat... | Normalize the path for accesing a resource meaning that will replace consecutive slashes and will remove a leading slash if present . | 79 | 26 |
40,815 | public static String [ ] normalizePatterns ( final String [ ] urlPatterns ) { String [ ] normalized = null ; if ( urlPatterns != null ) { normalized = new String [ urlPatterns . length ] ; for ( int i = 0 ; i < urlPatterns . length ; i ++ ) { normalized [ i ] = normalizePattern ( urlPatterns [ i ] ) ; } } return normal... | Normalize an array of patterns . | 89 | 7 |
40,816 | public static URL [ ] getClassPathJars ( final Bundle bundle ) { final List < URL > urls = new ArrayList <> ( ) ; final String bundleClasspath = ( String ) bundle . getHeaders ( ) . get ( "Bundle-ClassPath" ) ; if ( bundleClasspath != null ) { String [ ] segments = bundleClasspath . split ( "," ) ; for ( String segment... | Returns a list of urls to jars that composes the Bundle - ClassPath . | 278 | 17 |
40,817 | public static Set < Bundle > getBundlesInClassSpace ( Bundle bundle , Set < Bundle > bundleSet ) { return getBundlesInClassSpace ( bundle . getBundleContext ( ) , bundle , bundleSet ) ; } | Gets a list of bundles that are imported or required by this bundle . | 50 | 15 |
40,818 | public void addServletModel ( final ServletModel model ) throws NamespaceException , ServletException { servletLock . writeLock ( ) . lock ( ) ; try { associateBundle ( model . getContextModel ( ) . getVirtualHosts ( ) , model . getContextModel ( ) . getBundle ( ) ) ; for ( String virtualHost : resolveVirtualHosts ( mo... | Registers a servlet model . | 468 | 7 |
40,819 | public void removeServletModel ( final ServletModel model ) { servletLock . writeLock ( ) . lock ( ) ; try { deassociateBundle ( model . getContextModel ( ) . getVirtualHosts ( ) , model . getContextModel ( ) . getBundle ( ) ) ; for ( String virtualHost : resolveVirtualHosts ( model ) ) { if ( model . getAlias ( ) != n... | Unregisters a servlet model . | 242 | 8 |
40,820 | public void addFilterModel ( final FilterModel model ) { if ( model . getUrlPatterns ( ) != null ) { try { filterLock . writeLock ( ) . lock ( ) ; associateBundle ( model . getContextModel ( ) . getVirtualHosts ( ) , model . getContextModel ( ) . getBundle ( ) ) ; for ( String virtualHost : resolveVirtualHosts ( model ... | Registers a filter model . | 405 | 6 |
40,821 | public void removeFilterModel ( final FilterModel model ) { if ( model . getUrlPatterns ( ) != null ) { try { deassociateBundle ( model . getContextModel ( ) . getVirtualHosts ( ) , model . getContextModel ( ) . getBundle ( ) ) ; filterLock . writeLock ( ) . lock ( ) ; for ( String virtualHost : resolveVirtualHosts ( m... | Unregister a filter model . | 271 | 6 |
40,822 | public void associateHttpContext ( final WebContainerContext httpContext , final Bundle bundle , final boolean allowReAsssociation ) { List < String > virtualHosts = resolveVirtualHosts ( bundle ) ; for ( String virtualHost : virtualHosts ) { ConcurrentMap < WebContainerContext , Bundle > virtualHostHttpContexts = http... | Associates a http context with a bundle if the http service is not already associated to another bundle . This is done in order to prevent sharing http context between bundles . The implementation is not 100% correct as it can be that at a certain moment in time when this method is called another thread is processing a... | 200 | 141 |
40,823 | protected final ServiceTracker < T , W > create ( String filter ) { try { return new ServiceTracker <> ( bundleContext , bundleContext . createFilter ( filter ) , this ) ; } catch ( InvalidSyntaxException e ) { throw new IllegalArgumentException ( "Unexpected InvalidSyntaxException: " + e . getMessage ( ) ) ; } } | Creates a new tracker that tracks services by generic filter | 76 | 11 |
40,824 | public void visit ( final WebApp webApp ) { NullArgumentException . validateNotNull ( webApp , "Web app" ) ; bundleClassLoader = new BundleClassLoader ( webApp . getBundle ( ) ) ; httpContext = new WebAppHttpContext ( httpService . createDefaultHttpContext ( ) , webApp . getRootPath ( ) , webApp . getBundle ( ) , webAp... | Creates a default context that will be used for all following registrations and registers a resource for root of war . | 174 | 22 |
40,825 | public void visit ( final WebAppServlet webAppServlet ) { NullArgumentException . validateNotNull ( webAppServlet , "Web app servlet" ) ; final String [ ] aliases = webAppServlet . getAliases ( ) ; if ( aliases != null && aliases . length > 0 ) { for ( final String alias : aliases ) { try { final Servlet servlet = newI... | Registers servlets with http context . | 215 | 8 |
40,826 | public static < T > T newInstance ( final Class < T > clazz , final ClassLoader classLoader , final String className ) throws ClassNotFoundException , IllegalAccessException , InstantiationException { return loadClass ( clazz , classLoader , className ) . newInstance ( ) ; } | Creates an instance of a class from class name . | 62 | 11 |
40,827 | @ SuppressWarnings ( "unchecked" ) public static < T > Class < ? extends T > loadClass ( final Class < T > clazz , final ClassLoader classLoader , final String className ) throws ClassNotFoundException , IllegalAccessException { NullArgumentException . validateNotNull ( clazz , "Class" ) ; NullArgumentException . valid... | Load a class from class name . | 129 | 7 |
40,828 | public static Dictionary < String , String > convertInitParams ( final WebAppInitParam [ ] initParams ) { if ( initParams == null || initParams . length == 0 ) { return null ; } Hashtable < String , String > dictionary = new Hashtable <> ( ) ; for ( WebAppInitParam initParam : initParams ) { dictionary . put ( initPara... | Converts an array of init params to a Dictionary . | 105 | 11 |
40,829 | private void createManagedService ( final BundleContext context ) { ManagedService service = this :: scheduleUpdateConfig ; final Dictionary < String , String > props = new Hashtable <> ( ) ; props . put ( Constants . SERVICE_PID , org . ops4j . pax . web . service . WebContainerConstants . PID ) ; context . registerSe... | Registers a managed service to listen on configuration updates . | 187 | 11 |
40,830 | private static String validateAlias ( final String alias ) { NullArgumentException . validateNotNull ( alias , "Alias" ) ; if ( ! alias . startsWith ( "/" ) ) { throw new IllegalArgumentException ( "Alias does not start with slash (/)" ) ; } // "/" must be allowed if ( alias . length ( ) > 1 && alias . endsWith ( "/" )... | Validates that aan alias conforms to OSGi specs requirements . See OSGi R4 Http Service specs for details about alias validation . | 106 | 29 |
40,831 | private static String aliasAsUrlPattern ( final String alias ) { String urlPattern = alias ; if ( urlPattern != null && ! urlPattern . equals ( "/" ) && ! urlPattern . contains ( "*" ) ) { if ( urlPattern . endsWith ( "/" ) ) { urlPattern = urlPattern + "*" ; } else { urlPattern = urlPattern + "/*" ; } } return urlPatt... | Transforms an alias into a url pattern . | 91 | 9 |
40,832 | @ Override public void registerServlet ( Class < ? extends Servlet > servletClass , String [ ] urlPatterns , Dictionary < String , ? > initParams , HttpContext httpContext ) throws ServletException { LOG . warn ( "Http service has already been stopped" ) ; } | Does nothing . | 63 | 3 |
40,833 | private String createResourceIdentifier ( final String localePrefix , final String resourceName , final String resourceVersion , final String libraryName , final String libraryVersion ) { final StringBuilder sb = new StringBuilder ( ) ; if ( StringUtils . isNotBlank ( localePrefix ) ) { sb . append ( localePrefix ) . a... | Creates an ResourceIdentifier according to chapter 2 . 6 . 1 . 3 from the JSF 2 . 2 specification | 216 | 24 |
40,834 | public static String [ ] extractNameVersionType ( String url ) { Matcher m = ARTIFACT_MATCHER . matcher ( url ) ; if ( ! m . matches ( ) ) { return new String [ ] { url . split ( "\\." ) [ 0 ] , DEFAULT_VERSION } ; } else { //CHECKSTYLE:OFF StringBuilder v = new StringBuilder ( ) ; String d1 = m . group ( 1 ) ; String ... | Heuristic to compute the name and version of a file given it s name on disk | 335 | 17 |
40,835 | public void visit ( final WebAppServlet webAppServlet ) { //CHECKSTYLE:OFF NullArgumentException . validateNotNull ( webAppServlet , "Web app servlet" ) ; final String [ ] aliases = webAppServlet . getAliases ( ) ; if ( aliases != null && aliases . length > 0 ) { for ( String alias : aliases ) { try { httpService . unr... | Unregisters servlet from http context . | 158 | 9 |
40,836 | public void addServletMapping ( final WebAppServletMapping servletMapping ) { NullArgumentException . validateNotNull ( servletMapping , "Servlet mapping" ) ; NullArgumentException . validateNotNull ( servletMapping . getServletName ( ) , "Servlet name" ) ; NullArgumentException . validateNotNull ( servletMapping . get... | Add a servlet mapping . | 268 | 6 |
40,837 | public List < WebAppServletMapping > getServletMappings ( final String servletName ) { final Set < WebAppServletMapping > webAppServletMappings = servletMappings . get ( servletName ) ; if ( webAppServletMappings == null ) { return new ArrayList <> ( ) ; } return new ArrayList <> ( webAppServletMappings ) ; } | Returns a servlet mapping by servlet name . | 90 | 10 |
40,838 | public void addFilter ( final WebAppFilter filter ) { NullArgumentException . validateNotNull ( filter , "Filter" ) ; NullArgumentException . validateNotNull ( filter . getFilterName ( ) , "Filter name" ) ; NullArgumentException . validateNotNull ( filter . getFilterClass ( ) , "Filter class" ) ; filters . put ( filter... | Add a filter . | 229 | 4 |
40,839 | public void addFilterMapping ( final WebAppFilterMapping filterMapping ) { NullArgumentException . validateNotNull ( filterMapping , "Filter mapping" ) ; NullArgumentException . validateNotNull ( filterMapping . getFilterName ( ) , "Filter name" ) ; final String filterName = filterMapping . getFilterName ( ) ; if ( ! o... | Add a filter mapping . | 395 | 5 |
40,840 | public List < WebAppFilterMapping > getFilterMappings ( final String filterName ) { final Set < WebAppFilterMapping > webAppFilterMappings = filterMappings . get ( filterName ) ; if ( webAppFilterMappings == null ) { return new ArrayList <> ( ) ; } return new ArrayList <> ( webAppFilterMappings ) ; } | Returns filter mappings by filter name . | 81 | 8 |
40,841 | public void addErrorPage ( final WebAppErrorPage errorPage ) { NullArgumentException . validateNotNull ( errorPage , "Error page" ) ; if ( errorPage . getErrorCode ( ) == null && errorPage . getExceptionType ( ) == null ) { throw new NullPointerException ( "At least one of error type or exception code must be set" ) ; ... | Add an error page . | 92 | 5 |
40,842 | public void addContextParam ( final WebAppInitParam contextParam ) { NullArgumentException . validateNotNull ( contextParam , "Context param" ) ; NullArgumentException . validateNotNull ( contextParam . getParamName ( ) , "Context param name" ) ; NullArgumentException . validateNotNull ( contextParam . getParamValue ( ... | Add a context param . | 94 | 5 |
40,843 | public void addMimeMapping ( final WebAppMimeMapping mimeMapping ) { NullArgumentException . validateNotNull ( mimeMapping , "Mime mapping" ) ; NullArgumentException . validateNotNull ( mimeMapping . getExtension ( ) , "Mime mapping extension" ) ; NullArgumentException . validateNotNull ( mimeMapping . getMimeType ( ) ... | Add a mime mapping . | 113 | 6 |
40,844 | public void addLoginConfig ( final WebAppLoginConfig webApploginConfig ) { NullArgumentException . validateNotNull ( webApploginConfig , "Login Config" ) ; NullArgumentException . validateNotNull ( webApploginConfig . getAuthMethod ( ) , "Login Config Authorization Method" ) ; // NullArgumentException.validateNotNull(l... | Adds a login config | 103 | 4 |
40,845 | public void accept ( final WebAppVisitor visitor ) { visitor . visit ( this ) ; // First do everything else for ( WebAppListener listener : listeners ) { visitor . visit ( listener ) ; } if ( ! filters . isEmpty ( ) ) { // first visit the filters with a filter mapping in mapping order final List < WebAppFilter > remain... | Accepts a visitor for inner elements . | 288 | 8 |
40,846 | private void configureSecurity ( ServletContextHandler context , String realmName , String authMethod , String formLoginPage , String formErrorPage ) { final SecurityHandler securityHandler = context . getSecurityHandler ( ) ; Authenticator authenticator = null ; if ( authMethod == null ) { LOG . warn ( "UNKNOWN AUTH M... | Sets the security authentication method and the realm name on the security handler . This has to be done before the context is started . | 327 | 26 |
40,847 | public void validate ( KeyStore keyStore ) throws CertificateException { try { Enumeration < String > aliases = keyStore . aliases ( ) ; for ( ; aliases . hasMoreElements ( ) ; ) { String alias = aliases . nextElement ( ) ; validate ( keyStore , alias ) ; } } catch ( KeyStoreException kse ) { throw new CertificateExcep... | validates all aliases inside of a given keystore | 95 | 10 |
40,848 | public void visit ( final WebAppServlet webAppServlet ) { NullArgumentException . validateNotNull ( webAppServlet , "Web app servlet" ) ; Class < ? extends Servlet > servletClass = webAppServlet . getServletClass ( ) ; if ( servletClass == null && webAppServlet . getServletClassName ( ) != null ) { try { servletClass =... | Unregisters servlet from web container . | 234 | 9 |
40,849 | public void visit ( final WebAppFilter webAppFilter ) { NullArgumentException . validateNotNull ( webAppFilter , "Web app filter" ) ; String filterName = webAppFilter . getFilterName ( ) ; if ( filterName != null ) { //CHECKSTYLE:OFF try { webContainer . unregisterFilter ( filterName ) ; } catch ( Exception ignore ) { ... | Unregisters filter from web container . | 109 | 8 |
40,850 | public void visit ( final WebAppListener webAppListener ) { NullArgumentException . validateNotNull ( webAppListener , "Web app listener" ) ; final EventListener listener = webAppListener . getListener ( ) ; if ( listener != null ) { //CHECKSTYLE:OFF try { webContainer . unregisterEventListener ( listener ) ; } catch (... | Unregisters listeners from web container . | 108 | 8 |
40,851 | public void visit ( final WebAppErrorPage webAppErrorPage ) { NullArgumentException . validateNotNull ( webAppErrorPage , "Web app error page" ) ; //CHECKSTYLE:OFF try { webContainer . unregisterErrorPage ( webAppErrorPage . getError ( ) , httpContext ) ; } catch ( Exception ignore ) { LOG . warn ( "Unregistration exce... | Unregisters error pages from web container . | 101 | 9 |
40,852 | @ Override public void addEventListener ( final EventListener listener ) { super . addEventListener ( listener ) ; if ( ( listener instanceof HttpSessionActivationListener ) || ( listener instanceof HttpSessionAttributeListener ) || ( listener instanceof HttpSessionBindingListener ) || ( listener instanceof HttpSession... | If the listener is a servlet context listener and the context is already started notify the servlet context listener about the fact that context is started . This has to be done separately as the listener could be added after the context is already started case when servlet context listeners are not notified anymore . | 95 | 58 |
40,853 | public URL getResource ( final String name ) { final String normalizedName = Path . normalizeResourcePath ( rootPath + ( name . startsWith ( "/" ) ? "" : "/" ) + name ) . trim ( ) ; log . debug ( "Searching bundle " + bundle + " for resource [{}], normalized to [{}]" , name , normalizedName ) ; URL url = resourceCache ... | Searches for the resource in the bundle that published the service . | 377 | 14 |
40,854 | public String getMimeType ( final String name ) { String mimeType = null ; if ( name != null && name . length ( ) > 0 && name . contains ( "." ) ) { final String [ ] segments = name . split ( "\\." ) ; mimeType = mimeMappings . get ( segments [ segments . length - 1 ] ) ; } if ( mimeType == null ) { mimeType = httpCont... | Find the mime type in the mime mappings . If not found delegate to wrapped http context . | 110 | 21 |
40,855 | public void publish ( final WebApp webApp ) { NullArgumentException . validateNotNull ( webApp , "Web app" ) ; LOG . debug ( "Publishing web application [{}]" , webApp ) ; final BundleContext webAppBundleContext = BundleUtils . getBundleContext ( webApp . getBundle ( ) ) ; if ( webAppBundleContext != null ) { try { Fil... | Publish a web application . | 318 | 6 |
40,856 | public void unpublish ( final WebApp webApp ) { NullArgumentException . validateNotNull ( webApp , "Web app" ) ; LOG . debug ( "Unpublishing web application [{}]" , webApp ) ; final ServiceTracker < WebAppDependencyHolder , WebAppDependencyHolder > tracker = webApps . remove ( webApp ) ; if ( tracker != null ) { tracke... | Unpublish a web application . | 96 | 7 |
40,857 | @ Override public void registerServlet ( final String alias , final Servlet servlet , @ SuppressWarnings ( "rawtypes" ) final Dictionary initParams , final HttpContext httpContext ) throws ServletException , NamespaceException { synchronized ( lock ) { this . registerServlet ( alias , servlet , initParams , null , null... | From Http Service - cannot fix generics until underlying Http Service is corrected | 83 | 16 |
40,858 | private < T > T withWhiteboardDtoService ( Function < WhiteboardDtoService , T > function ) { final BundleContext bundleContext = serviceBundle . getBundleContext ( ) ; ServiceReference < WhiteboardDtoService > ref = bundleContext . getServiceReference ( WhiteboardDtoService . class ) ; if ( ref != null ) { WhiteboardD... | WhiteboardDtoService is registered as DS component . Should be removed if this class gets full DS support | 163 | 21 |
40,859 | protected void preDestroy ( Object instance , final Class < ? > clazz ) throws IllegalAccessException , InvocationTargetException { Class < ? > superClass = clazz . getSuperclass ( ) ; if ( superClass != Object . class ) { preDestroy ( instance , superClass ) ; } // At the end the postconstruct annotated // method is i... | Call preDestroy method on the specified instance recursively from deepest superclass to actual class . | 218 | 19 |
40,860 | protected void populateAnnotationsCache ( Class < ? > clazz , Map < String , String > injections ) throws IllegalAccessException , InvocationTargetException { while ( clazz != null ) { List < AnnotationCacheEntry > annotations = null ; synchronized ( annotationCache ) { annotations = annotationCache . get ( clazz ) ; }... | Make sure that the annotations cache has been populated for the provided class . | 542 | 14 |
40,861 | public static int pipeBytes ( InputStream in , OutputStream out , byte [ ] buffer ) throws IOException { int count = 0 ; int length ; while ( ( length = ( in . read ( buffer ) ) ) >= 0 ) { out . write ( buffer , 0 , length ) ; count += length ; } return count ; } | Reads the specified input stream into the provided byte array storage and writes it to the output stream . | 69 | 20 |
40,862 | private List < Deployment > managedDeployments ( List < Deployment > deployments ) { List < Deployment > managed = new ArrayList < Deployment > ( ) ; for ( Deployment deployment : deployments ) { if ( deployment . getDescription ( ) . managed ( ) ) { managed . add ( deployment ) ; } } return managed ; } | Filters the List of Deployments and returns the ones that are Managed deployments . | 71 | 17 |
40,863 | private List < Deployment > defaultDeployments ( List < Deployment > deployments ) { List < Deployment > defaults = new ArrayList < Deployment > ( ) ; for ( Deployment deployment : deployments ) { if ( deployment . getDescription ( ) . getName ( ) . equals ( DeploymentTargetDescription . DEFAULT . getName ( ) ) ) { def... | Filters the List of Deployments and returns the ones that are DEFAULT deployments . | 88 | 17 |
40,864 | private List < Deployment > archiveDeployments ( List < Deployment > deployments ) { List < Deployment > archives = new ArrayList < Deployment > ( ) ; for ( Deployment deployment : deployments ) { if ( deployment . getDescription ( ) . isArchiveDeployment ( ) ) { archives . add ( deployment ) ; } } return archives ; } | Filters the List of Deployments and returns the ones that are Archive deployments . | 75 | 16 |
40,865 | private Deployment findMatchingDeployment ( DeploymentTargetDescription target ) { List < Deployment > matching = findMatchingDeployments ( target ) ; if ( matching . size ( ) == 0 ) { return null ; } if ( matching . size ( ) == 1 ) { return matching . get ( 0 ) ; } // if multiple Deployment of different Type, we get t... | Validation names except DEFAULT should be unique . See constructor | 96 | 12 |
40,866 | private void validateNotSameNameAndTypeOfDeployment ( DeploymentDescription deployment ) { for ( Deployment existing : deployments ) { if ( existing . getDescription ( ) . getName ( ) . equals ( deployment . getName ( ) ) ) { if ( ( existing . getDescription ( ) . isArchiveDeployment ( ) && deployment . isArchiveDeploy... | Validate that a deployment of same type is not already added | 155 | 12 |
40,867 | private void validateNotSameArchiveAndSameTarget ( DeploymentDescription deployment ) { if ( ! deployment . isArchiveDeployment ( ) ) { return ; } for ( Deployment existing : archiveDeployments ( deployments ) ) { if ( existing . getDescription ( ) . getArchive ( ) . getName ( ) . equals ( deployment . getArchive ( ) .... | Validate that a deployment with a archive of the same name does not have the same taget | 170 | 19 |
40,868 | private List < Object > getRuleInstances ( Object testInstance ) throws Exception { List < Object > ruleInstances = new ArrayList < Object > ( ) ; List < Field > fieldsWithRuleAnnotation = SecurityActions . getFieldsWithAnnotation ( testInstance . getClass ( ) , Rule . class ) ; if ( fieldsWithRuleAnnotation . isEmpty ... | Retrieves instances of the TestRule and MethodRule classes | 248 | 12 |
40,869 | public static void notNull ( final Object obj , final String message ) throws IllegalArgumentException { if ( obj == null ) { throw new IllegalArgumentException ( message ) ; } } | Checks that object is not null throws exception if it is . | 39 | 13 |
40,870 | public static void notNullOrEmpty ( final String string , final String message ) throws IllegalArgumentException { if ( string == null || string . length ( ) == 0 ) { throw new IllegalArgumentException ( message ) ; } } | Checks that the specified String is not null or empty throws exception if it is . | 49 | 17 |
40,871 | public static void stateNotNull ( final Object obj , final String message ) throws IllegalStateException { if ( obj == null ) { throw new IllegalStateException ( message ) ; } } | Checks that obj is not null throws exception if it is . | 38 | 13 |
40,872 | public static void configurationDirectoryExists ( final String string , final String message ) throws ConfigurationException { if ( string == null || string . length ( ) == 0 || new File ( string ) . isDirectory ( ) == false ) { throw new ConfigurationException ( message ) ; } } | Checks that string is not null and not empty and it represents a path to a valid directory | 58 | 19 |
40,873 | private static Object convert ( Class < ? > clazz , String value ) { /* TODO create a new Converter class and move this method there for reuse */ if ( Integer . class . equals ( clazz ) || int . class . equals ( clazz ) ) { return Integer . valueOf ( value ) ; } else if ( Double . class . equals ( clazz ) || double . c... | Converts a String value to the specified class . | 172 | 10 |
40,874 | private Object [ ] resolveArguments ( Manager manager , Object event ) { final Class < ? > [ ] argumentTypes = getMethod ( ) . getParameterTypes ( ) ; int numberOfArguments = argumentTypes . length ; // we know that the first Argument is always the Event, and it will be there else this wouldn't be a Observer method Obj... | Resolve all Observer method arguments . Unresolved argument types wil be null . | 238 | 16 |
40,875 | private boolean containsNull ( Object [ ] arguments ) { for ( Object argument : arguments ) { if ( argument == null ) { return true ; } } return false ; } | Check that all arguments were resolved . Do not invoke if not . | 35 | 13 |
40,876 | private void validateConfiguration ( ArquillianDescriptor desc ) { Object defaultConfig = null ; // verify only one container is marked as default for ( ContainerDef container : desc . getContainers ( ) ) { if ( container . isDefault ( ) ) { if ( defaultConfig != null ) { throw new IllegalStateException ( "Multiple Con... | Validate that the Configuration given is sane | 331 | 8 |
40,877 | public static String fileAsString ( String filename ) { File classpathFile = getClasspathFile ( filename ) ; return fileAsString ( classpathFile ) ; } | Returns the content of a file with specified filename | 35 | 9 |
40,878 | public static InputStream fileAsStream ( String filename ) { File classpathFile = getClasspathFile ( filename ) ; return fileAsStream ( classpathFile ) ; } | Returns the input stream of a file with specified filename | 36 | 10 |
40,879 | public static InputStream fileAsStream ( File file ) { try { return new BufferedInputStream ( new FileInputStream ( file ) ) ; } catch ( FileNotFoundException e ) { throw LOG . fileNotFoundException ( file . getAbsolutePath ( ) , e ) ; } } | Returns the input stream of a file . | 62 | 8 |
40,880 | public static String join ( String delimiter , String ... parts ) { if ( parts == null ) { return null ; } if ( delimiter == null ) { delimiter = "" ; } StringBuilder stringBuilder = new StringBuilder ( ) ; for ( int i = 0 ; i < parts . length ; i ++ ) { if ( i > 0 ) { stringBuilder . append ( delimiter ) ; } stringBui... | Joins a list of Strings to a single one . | 106 | 12 |
40,881 | protected void logDebug ( String id , String messageTemplate , Object ... parameters ) { if ( delegateLogger . isDebugEnabled ( ) ) { String msg = formatMessageTemplate ( id , messageTemplate ) ; delegateLogger . debug ( msg , parameters ) ; } } | Logs a DEBUG message | 56 | 5 |
40,882 | protected void logInfo ( String id , String messageTemplate , Object ... parameters ) { if ( delegateLogger . isInfoEnabled ( ) ) { String msg = formatMessageTemplate ( id , messageTemplate ) ; delegateLogger . info ( msg , parameters ) ; } } | Logs an INFO message | 56 | 5 |
40,883 | protected void logWarn ( String id , String messageTemplate , Object ... parameters ) { if ( delegateLogger . isWarnEnabled ( ) ) { String msg = formatMessageTemplate ( id , messageTemplate ) ; delegateLogger . warn ( msg , parameters ) ; } } | Logs an WARN message | 58 | 5 |
40,884 | protected void logError ( String id , String messageTemplate , Object ... parameters ) { if ( delegateLogger . isErrorEnabled ( ) ) { String msg = formatMessageTemplate ( id , messageTemplate ) ; delegateLogger . error ( msg , parameters ) ; } } | Logs an ERROR message | 56 | 5 |
40,885 | protected String formatMessageTemplate ( String id , String messageTemplate ) { return projectCode + "-" + componentId + id + " " + messageTemplate ; } | Formats a message template | 33 | 5 |
40,886 | protected String exceptionMessage ( String id , String messageTemplate , Object ... parameters ) { String formattedTemplate = formatMessageTemplate ( id , messageTemplate ) ; if ( parameters == null || parameters . length == 0 ) { return formattedTemplate ; } else { return MessageFormatter . arrayFormat ( formattedTemp... | Prepares an exception message | 72 | 5 |
40,887 | public static void ensureNotNull ( String parameterName , Object value ) { if ( value == null ) { throw LOG . parameterIsNullException ( parameterName ) ; } } | Ensures that the parameter is not null . | 36 | 10 |
40,888 | @ SuppressWarnings ( "unchecked" ) public static < T > T ensureParamInstanceOf ( String objectName , Object object , Class < T > type ) { if ( type . isAssignableFrom ( object . getClass ( ) ) ) { return ( T ) object ; } else { throw LOG . unsupportedParameterType ( objectName , object , type ) ; } } | Ensure the object is of a given type and return the casted object | 82 | 15 |
40,889 | private static int [ ] getFactors ( int _value , int _max ) { final int factors [ ] = new int [ MAX_GROUP_SIZE ] ; int factorIdx = 0 ; for ( int possibleFactor = 1 ; possibleFactor <= _max ; possibleFactor ++ ) { if ( ( _value % possibleFactor ) == 0 ) { factors [ factorIdx ++ ] = possibleFactor ; } } return ( Arrays .... | Determine the set of factors for a given value . | 103 | 12 |
40,890 | public int getNumGroups ( int _dim ) { return ( _dim == 0 ? ( globalSize_0 / localSize_0 ) : ( _dim == 1 ? ( globalSize_1 / localSize_1 ) : ( globalSize_2 / localSize_2 ) ) ) ; } | Get the number of groups for the given dimension . | 64 | 10 |
40,891 | public double getElapsedTimeCurrentThread ( int stage ) { if ( stage == ProfilingEvent . START . ordinal ( ) ) { return 0 ; } Accumulator acc = getAccForThread ( ) ; return acc == null ? Double . NaN : ( acc . currentTimes [ stage ] - acc . currentTimes [ stage - 1 ] ) / MILLION ; } | Elapsed time for a single event only and for the current thread i . e . since the previous stage rather than from the start . | 79 | 27 |
40,892 | public double getCumulativeElapsedTimeCurrrentThread ( ProfilingEvent stage ) { Accumulator acc = getAccForThread ( ) ; return acc == null ? Double . NaN : acc . accumulatedTimes [ stage . ordinal ( ) ] / MILLION ; } | Elapsed time for a single event only i . e . since the previous stage rather than from the start summed over all executions for the current thread if it has executed the kernel on the device assigned to this KernelDeviceProfile instance . | 59 | 46 |
40,893 | public double getCumulativeElapsedTimeAllCurrentThread ( ) { double sum = 0 ; Accumulator acc = getAccForThread ( ) ; if ( acc == null ) { return sum ; } for ( int i = 1 ; i <= ProfilingEvent . EXECUTED . ordinal ( ) ; ++ i ) { sum += acc . accumulatedTimes [ i ] ; } return sum ; } | Elapsed time of entire execution summed over all executions for the current thread if it has executed the kernel on the device assigned to this KernelDeviceProfile instance . | 85 | 31 |
40,894 | public double getElapsedTimeLastThread ( int stage ) { if ( stage == ProfilingEvent . START . ordinal ( ) ) { return 0 ; } Accumulator acc = lastAccumulator . get ( ) ; return acc == null ? Double . NaN : ( acc . currentTimes [ stage ] - acc . currentTimes [ stage - 1 ] ) / MILLION ; } | Elapsed time for a single event only and for the last thread that finished executing a kernel i . e . single event only - since the previous stage rather than from the start . | 81 | 36 |
40,895 | public double getCumulativeElapsedTimeGlobal ( ProfilingEvent stage ) { final long [ ] accumulatedTimesHolder = new long [ NUM_EVENTS ] ; globalAcc . consultAccumulatedTimes ( accumulatedTimesHolder ) ; return accumulatedTimesHolder [ stage . ordinal ( ) ] / MILLION ; } | Elapsed time for a single event only i . e . since the previous stage rather than from the start summed over all executions for the last thread that executed this KernelDeviceProfile instance respective kernel and device . | 68 | 41 |
40,896 | public double getCumulativeElapsedTimeAllGlobal ( ) { final long [ ] accumulatedTimesHolder = new long [ NUM_EVENTS ] ; globalAcc . consultAccumulatedTimes ( accumulatedTimesHolder ) ; double sum = 0 ; for ( int i = 1 ; i <= ProfilingEvent . EXECUTED . ordinal ( ) ; ++ i ) { sum += accumulatedTimesHolder [ i ] ; } retu... | Elapsed time of entire execution summed over all executions for all the threads that executed the kernel on this device . | 94 | 22 |
40,897 | public boolean isSuperClass ( String otherClassName ) { if ( getClassWeAreModelling ( ) . getName ( ) . equals ( otherClassName ) ) { return true ; } else if ( superClazz != null ) { return superClazz . isSuperClass ( otherClassName ) ; } else { return false ; } } | Determine if this is the superclass of some other named class . | 72 | 15 |
40,898 | public boolean isSuperClass ( Class < ? > other ) { Class < ? > s = other . getSuperclass ( ) ; while ( s != null ) { if ( ( getClassWeAreModelling ( ) == s ) || ( getClassWeAreModelling ( ) . getName ( ) . equals ( s . getName ( ) ) ) ) { return true ; } s = s . getSuperclass ( ) ; } return false ; } | Determine if this is the superclass of some other class . | 95 | 14 |
40,899 | public Integer getPrivateMemorySize ( String fieldName ) throws ClassParseException { if ( CacheEnabler . areCachesEnabled ( ) ) return privateMemorySizes . computeIfAbsent ( fieldName ) ; return computePrivateMemorySize ( fieldName ) ; } | If a field does not satisfy the private memory conditions null otherwise the size of private memory required . | 57 | 19 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.