idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
150,000 | public static void initialize ( BeanManagerImpl deploymentManager , ServiceRegistry deploymentServices ) { Container instance = new Container ( RegistrySingletonProvider . STATIC_INSTANCE , deploymentManager , deploymentServices ) ; Container . instance . set ( RegistrySingletonProvider . STATIC_INSTANCE , instance ) ; } | Initialize the container for the current application deployment | 63 | 9 |
150,001 | public void cleanup ( ) { managers . clear ( ) ; for ( BeanManagerImpl beanManager : beanDeploymentArchives . values ( ) ) { beanManager . cleanup ( ) ; } beanDeploymentArchives . clear ( ) ; deploymentServices . cleanup ( ) ; deploymentManager . cleanup ( ) ; instance . clear ( contextId ) ; } | Cause the container to be cleaned up including all registered bean managers and all deployment services | 72 | 16 |
150,002 | public void putBeanDeployments ( BeanDeploymentArchiveMapping bdaMapping ) { for ( Entry < BeanDeploymentArchive , BeanManagerImpl > entry : bdaMapping . getBdaToBeanManagerMap ( ) . entrySet ( ) ) { beanDeploymentArchives . put ( entry . getKey ( ) , entry . getValue ( ) ) ; addBeanManager ( entry . getValue ( ) ) ; } } | Add sub - deployment units to the container | 97 | 8 |
150,003 | private < Y > void checkObserverMethod ( EnhancedAnnotatedMethod < T , Y > annotated ) { // Make sure exactly one and only one parameter is annotated with Observes or ObservesAsync List < EnhancedAnnotatedParameter < ? , Y > > eventObjects = annotated . getEnhancedParameters ( Observes . class ) ; eventObjects . addAll ( annotated . getEnhancedParameters ( ObservesAsync . class ) ) ; if ( this . reception . equals ( Reception . IF_EXISTS ) && declaringBean . getScope ( ) . equals ( Dependent . class ) ) { throw EventLogger . LOG . invalidScopedConditionalObserver ( this , Formats . formatAsStackTraceElement ( annotated . getJavaMember ( ) ) ) ; } if ( eventObjects . size ( ) > 1 ) { throw EventLogger . LOG . multipleEventParameters ( this , Formats . formatAsStackTraceElement ( annotated . getJavaMember ( ) ) ) ; } EnhancedAnnotatedParameter < ? , Y > eventParameter = eventObjects . iterator ( ) . next ( ) ; checkRequiredTypeAnnotations ( eventParameter ) ; // Check for parameters annotated with @Disposes List < ? > disposeParams = annotated . getEnhancedParameters ( Disposes . class ) ; if ( disposeParams . size ( ) > 0 ) { throw EventLogger . LOG . invalidDisposesParameter ( this , Formats . formatAsStackTraceElement ( annotated . getJavaMember ( ) ) ) ; } // Check annotations on the method to make sure this is not a producer // method, initializer method, or destructor method. if ( this . observerMethod . getAnnotated ( ) . isAnnotationPresent ( Produces . class ) ) { throw EventLogger . LOG . invalidProducer ( this , Formats . formatAsStackTraceElement ( annotated . getJavaMember ( ) ) ) ; } if ( this . observerMethod . getAnnotated ( ) . isAnnotationPresent ( Inject . class ) ) { throw EventLogger . LOG . invalidInitializer ( this , Formats . formatAsStackTraceElement ( annotated . getJavaMember ( ) ) ) ; } boolean containerLifecycleObserverMethod = Observers . isContainerLifecycleObserverMethod ( this ) ; for ( EnhancedAnnotatedParameter < ? , ? > parameter : annotated . getEnhancedParameters ( ) ) { // if this is an observer method for container lifecycle event, it must not inject anything besides BeanManager if ( containerLifecycleObserverMethod && ! parameter . isAnnotationPresent ( Observes . class ) && ! parameter . isAnnotationPresent ( ObservesAsync . class ) && ! BeanManager . class . equals ( parameter . getBaseType ( ) ) ) { throw EventLogger . LOG . invalidInjectionPoint ( this , Formats . formatAsStackTraceElement ( annotated . getJavaMember ( ) ) ) ; } } } | Performs validation of the observer method for compliance with the specifications . | 646 | 13 |
150,004 | protected void sendEvent ( final T event ) { if ( isStatic ) { sendEvent ( event , null , null ) ; } else { CreationalContext < X > creationalContext = null ; try { Object receiver = getReceiverIfExists ( null ) ; if ( receiver == null && reception != Reception . IF_EXISTS ) { // creational context is created only if we need it for obtaining receiver // ObserverInvocationStrategy takes care of creating CC for parameters, if needed creationalContext = beanManager . createCreationalContext ( declaringBean ) ; receiver = getReceiverIfExists ( creationalContext ) ; } if ( receiver != null ) { sendEvent ( event , receiver , creationalContext ) ; } } finally { if ( creationalContext != null ) { creationalContext . release ( ) ; } } } } | Invokes the observer method immediately passing the event . | 180 | 10 |
150,005 | public static void endRequest ( ) { final List < RequestScopedItem > result = CACHE . get ( ) ; if ( result != null ) { CACHE . remove ( ) ; for ( final RequestScopedItem item : result ) { item . invalidate ( ) ; } } } | ends the request and clears the cache . This can be called before the request is over in which case the cache will be unavailable for the rest of the request . | 63 | 32 |
150,006 | public < X > X invokeOnInstance ( Object instance , Object ... parameters ) throws IllegalArgumentException , SecurityException , IllegalAccessException , InvocationTargetException , NoSuchMethodException { final Map < Class < ? > , Method > methods = this . methods ; Method method = methods . get ( instance . getClass ( ) ) ; if ( method == null ) { // the same method may be written to the map twice, but that is ok // lookupMethod is very slow Method delegate = annotatedMethod . getJavaMember ( ) ; method = SecurityActions . lookupMethod ( instance . getClass ( ) , delegate . getName ( ) , delegate . getParameterTypes ( ) ) ; SecurityActions . ensureAccessible ( method ) ; synchronized ( this ) { final Map < Class < ? > , Method > newMethods = new HashMap < Class < ? > , Method > ( methods ) ; newMethods . put ( instance . getClass ( ) , method ) ; this . methods = WeldCollections . immutableMapView ( newMethods ) ; } } return cast ( method . invoke ( instance , parameters ) ) ; } | Invokes the method on the class of the passed instance not the declaring class . Useful with proxies | 235 | 19 |
150,007 | @ SuppressWarnings ( "unchecked" ) protected Class < ? extends Annotation > annotationTypeForName ( String name ) { try { return ( Class < ? extends Annotation > ) resourceLoader . classForName ( name ) ; } catch ( ResourceLoadingException cnfe ) { return DUMMY_ANNOTATION ; } } | Initializes an annotation class | 73 | 5 |
150,008 | protected Class < ? > classForName ( String name ) { try { return resourceLoader . classForName ( name ) ; } catch ( ResourceLoadingException cnfe ) { return DUMMY_CLASS ; } } | Initializes a type | 46 | 4 |
150,009 | public void addInterface ( Class < ? > newInterface ) { if ( ! newInterface . isInterface ( ) ) { throw new IllegalArgumentException ( newInterface + " is not an interface" ) ; } additionalInterfaces . add ( newInterface ) ; } | Adds an additional interface that the proxy should implement . The default implementation will be to forward invocations to the bean instance . | 55 | 24 |
150,010 | public T create ( BeanInstance beanInstance ) { final T proxy = ( System . getSecurityManager ( ) == null ) ? run ( ) : AccessController . doPrivileged ( this ) ; ( ( ProxyObject ) proxy ) . weld_setHandler ( new ProxyMethodHandler ( contextId , beanInstance , bean ) ) ; return proxy ; } | Method to create a new proxy that wraps the bean instance . | 72 | 12 |
150,011 | public Class < T > getProxyClass ( ) { String suffix = "_$$_Weld" + getProxyNameSuffix ( ) ; String proxyClassName = getBaseProxyName ( ) ; if ( ! proxyClassName . endsWith ( suffix ) ) { proxyClassName = proxyClassName + suffix ; } if ( proxyClassName . startsWith ( JAVA ) ) { proxyClassName = proxyClassName . replaceFirst ( JAVA , "org.jboss.weld" ) ; } Class < T > proxyClass = null ; Class < ? > originalClass = bean != null ? bean . getBeanClass ( ) : proxiedBeanType ; BeanLogger . LOG . generatingProxyClass ( proxyClassName ) ; try { // First check to see if we already have this proxy class proxyClass = cast ( classLoader == null ? proxyServices . loadClass ( originalClass , proxyClassName ) : classLoader . loadClass ( proxyClassName ) ) ; } catch ( ClassNotFoundException e ) { // Create the proxy class for this instance try { proxyClass = createProxyClass ( originalClass , proxyClassName ) ; } catch ( Throwable e1 ) { //attempt to load the class again, just in case another thread //defined it between the check and the create method try { proxyClass = cast ( classLoader == null ? proxyServices . loadClass ( originalClass , proxyClassName ) : classLoader . loadClass ( proxyClassName ) ) ; } catch ( ClassNotFoundException e2 ) { BeanLogger . LOG . catchingDebug ( e1 ) ; throw BeanLogger . LOG . unableToLoadProxyClass ( bean , proxiedBeanType , e1 ) ; } } } return proxyClass ; } | Produces or returns the existing proxy class . The operation is thread - safe . | 372 | 16 |
150,012 | public static < T > void setBeanInstance ( String contextId , T proxy , BeanInstance beanInstance , Bean < ? > bean ) { if ( proxy instanceof ProxyObject ) { ProxyObject proxyView = ( ProxyObject ) proxy ; proxyView . weld_setHandler ( new ProxyMethodHandler ( contextId , beanInstance , bean ) ) ; } } | Convenience method to set the underlying bean instance for a proxy . | 75 | 14 |
150,013 | protected void addConstructors ( ClassFile proxyClassType , List < DeferredBytecode > initialValueBytecode ) { try { if ( getBeanType ( ) . isInterface ( ) ) { ConstructorUtils . addDefaultConstructor ( proxyClassType , initialValueBytecode , ! useConstructedFlag ( ) ) ; } else { boolean constructorFound = false ; for ( Constructor < ? > constructor : AccessController . doPrivileged ( new GetDeclaredConstructorsAction ( getBeanType ( ) ) ) ) { if ( ( constructor . getModifiers ( ) & Modifier . PRIVATE ) == 0 ) { constructorFound = true ; String [ ] exceptions = new String [ constructor . getExceptionTypes ( ) . length ] ; for ( int i = 0 ; i < exceptions . length ; ++ i ) { exceptions [ i ] = constructor . getExceptionTypes ( ) [ i ] . getName ( ) ; } ConstructorUtils . addConstructor ( BytecodeUtils . VOID_CLASS_DESCRIPTOR , DescriptorUtils . parameterDescriptors ( constructor . getParameterTypes ( ) ) , exceptions , proxyClassType , initialValueBytecode , ! useConstructedFlag ( ) ) ; } } if ( ! constructorFound ) { // the bean only has private constructors, we need to generate // two fake constructors that call each other addConstructorsForBeanWithPrivateConstructors ( proxyClassType ) ; } } } catch ( Exception e ) { throw new WeldException ( e ) ; } } | Adds a constructor for the proxy for each constructor declared by the base bean type . | 325 | 16 |
150,014 | public static ClassLoader resolveClassLoaderForBeanProxy ( String contextId , Class < ? > proxiedType , TypeInfo typeInfo , ProxyServices proxyServices ) { Class < ? > superClass = typeInfo . getSuperClass ( ) ; if ( superClass . getName ( ) . startsWith ( JAVA ) ) { ClassLoader cl = proxyServices . getClassLoader ( proxiedType ) ; if ( cl == null ) { cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; } return cl ; } return Container . instance ( contextId ) . services ( ) . get ( ProxyServices . class ) . getClassLoader ( superClass ) ; } | Figures out the correct class loader to use for a proxy for a given bean | 144 | 16 |
150,015 | public void fetchUninitializedAttributes ( ) { for ( String prefixedId : getPrefixedAttributeNames ( ) ) { BeanIdentifier id = getNamingScheme ( ) . deprefix ( prefixedId ) ; if ( ! beanStore . contains ( id ) ) { ContextualInstance < ? > instance = ( ContextualInstance < ? > ) getAttribute ( prefixedId ) ; beanStore . put ( id , instance ) ; ContextLogger . LOG . addingDetachedContextualUnderId ( instance , id ) ; } } } | Fetch all relevant attributes from the backing store and copy instances which are not present in the local bean store . | 115 | 22 |
150,016 | static void merge ( Map < ConfigurationKey , Object > original , Map < ConfigurationKey , Object > toMerge , String mergedSourceDescription ) { for ( Entry < ConfigurationKey , Object > entry : toMerge . entrySet ( ) ) { Object existing = original . get ( entry . getKey ( ) ) ; if ( existing != null ) { ConfigurationLogger . LOG . configurationKeyAlreadySet ( entry . getKey ( ) . get ( ) , existing , entry . getValue ( ) , mergedSourceDescription ) ; } else { original . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } } } | Merge two maps of configuration properties . If the original contains a mapping for the same key the new mapping is ignored . | 134 | 24 |
150,017 | private Map < ConfigurationKey , Object > getObsoleteSystemProperties ( ) { Map < ConfigurationKey , Object > found = new EnumMap < ConfigurationKey , Object > ( ConfigurationKey . class ) ; String concurrentDeployment = getSystemProperty ( "org.jboss.weld.bootstrap.properties.concurrentDeployment" ) ; if ( concurrentDeployment != null ) { processKeyValue ( found , ConfigurationKey . CONCURRENT_DEPLOYMENT , concurrentDeployment ) ; found . put ( ConfigurationKey . CONCURRENT_DEPLOYMENT , ConfigurationKey . CONCURRENT_DEPLOYMENT . convertValue ( concurrentDeployment ) ) ; } String preloaderThreadPoolSize = getSystemProperty ( "org.jboss.weld.bootstrap.properties.preloaderThreadPoolSize" ) ; if ( preloaderThreadPoolSize != null ) { found . put ( ConfigurationKey . PRELOADER_THREAD_POOL_SIZE , ConfigurationKey . PRELOADER_THREAD_POOL_SIZE . convertValue ( preloaderThreadPoolSize ) ) ; } return found ; } | Try to get a system property for obsolete keys . The value is automatically converted - a runtime exception may be thrown during conversion . | 236 | 25 |
150,018 | @ SuppressFBWarnings ( value = "DMI_COLLECTION_OF_URLS" , justification = "Only local URLs involved" ) private Map < ConfigurationKey , Object > readFileProperties ( Set < URL > files ) { Map < ConfigurationKey , Object > found = new EnumMap < ConfigurationKey , Object > ( ConfigurationKey . class ) ; for ( URL file : files ) { ConfigurationLogger . LOG . readingPropertiesFile ( file ) ; Properties fileProperties = loadProperties ( file ) ; for ( String name : fileProperties . stringPropertyNames ( ) ) { processKeyValue ( found , name , fileProperties . getProperty ( name ) ) ; } } return found ; } | Read the set of property files . Keys and Values are automatically validated and converted . | 154 | 16 |
150,019 | private void processKeyValue ( Map < ConfigurationKey , Object > properties , ConfigurationKey key , Object value ) { if ( value instanceof String ) { value = key . convertValue ( ( String ) value ) ; } if ( key . isValidValue ( value ) ) { Object previous = properties . put ( key , value ) ; if ( previous != null && ! previous . equals ( value ) ) { throw ConfigurationLogger . LOG . configurationKeyHasDifferentValues ( key . get ( ) , previous , value ) ; } } else { throw ConfigurationLogger . LOG . invalidConfigurationPropertyValue ( value , key . get ( ) ) ; } } | Process the given key and value . First validate the value and check if there s no different value for the same key in the same source - invalid and different values are treated as a deployment problem . | 135 | 39 |
150,020 | public static < T , X > ObserverMethodImpl < T , X > create ( EnhancedAnnotatedMethod < T , ? super X > method , RIBean < X > declaringBean , BeanManagerImpl manager , boolean isAsync ) { if ( declaringBean instanceof ExtensionBean ) { return new ExtensionObserverMethodImpl < T , X > ( method , declaringBean , manager , isAsync ) ; } return new ObserverMethodImpl < T , X > ( method , declaringBean , manager , isAsync ) ; } | Creates an observer | 113 | 4 |
150,021 | public static TransactionPhase getTransactionalPhase ( EnhancedAnnotatedMethod < ? , ? > observer ) { EnhancedAnnotatedParameter < ? , ? > parameter = observer . getEnhancedParameters ( Observes . class ) . iterator ( ) . next ( ) ; return parameter . getAnnotation ( Observes . class ) . during ( ) ; } | Tests an observer method to see if it is transactional . | 73 | 13 |
150,022 | static WeldContainer startInitialization ( String id , Deployment deployment , Bootstrap bootstrap ) { if ( SINGLETON . isSet ( id ) ) { throw WeldSELogger . LOG . weldContainerAlreadyRunning ( id ) ; } WeldContainer weldContainer = new WeldContainer ( id , deployment , bootstrap ) ; SINGLETON . set ( id , weldContainer ) ; RUNNING_CONTAINER_IDS . add ( id ) ; return weldContainer ; } | Start the initialization . | 101 | 4 |
150,023 | static void endInitialization ( WeldContainer container , boolean isShutdownHookEnabled ) { container . complete ( ) ; // If needed, register one shutdown hook for all containers if ( shutdownHook == null && isShutdownHookEnabled ) { synchronized ( LOCK ) { if ( shutdownHook == null ) { shutdownHook = new ShutdownHook ( ) ; SecurityActions . addShutdownHook ( shutdownHook ) ; } } } container . fireContainerInitializedEvent ( ) ; } | Finish the initialization . | 106 | 4 |
150,024 | public synchronized void shutdown ( ) { checkIsRunning ( ) ; try { beanManager ( ) . fireEvent ( new ContainerBeforeShutdown ( id ) , BeforeDestroyed . Literal . APPLICATION ) ; } finally { discard ( id ) ; // Destroy all the dependent beans correctly creationalContext . release ( ) ; beanManager ( ) . fireEvent ( new ContainerShutdown ( id ) , Destroyed . Literal . APPLICATION ) ; bootstrap . shutdown ( ) ; WeldSELogger . LOG . weldContainerShutdown ( id ) ; } } | Shutdown the container . | 117 | 5 |
150,025 | @ Override public Collection < EnhancedAnnotatedConstructor < T > > getEnhancedConstructors ( Class < ? extends Annotation > annotationType ) { Set < EnhancedAnnotatedConstructor < T >> ret = new HashSet < EnhancedAnnotatedConstructor < T > > ( ) ; for ( EnhancedAnnotatedConstructor < T > constructor : constructors ) { if ( constructor . isAnnotationPresent ( annotationType ) ) { ret . add ( constructor ) ; } } return ret ; } | Gets constructors with given annotation type | 106 | 8 |
150,026 | protected void setBeanStore ( BoundBeanStore beanStore ) { if ( beanStore == null ) { this . beanStore . remove ( ) ; } else { this . beanStore . set ( beanStore ) ; } } | Sets the bean store | 48 | 5 |
150,027 | public void setArgs ( String [ ] args ) { if ( args == null ) { args = new String [ ] { } ; } this . args = args ; this . argsList = Collections . unmodifiableList ( new ArrayList < String > ( Arrays . asList ( args ) ) ) ; } | StartMain passes in the command line args here . | 65 | 10 |
150,028 | public Weld addPackages ( boolean scanRecursively , Class < ? > ... packageClasses ) { for ( Class < ? > packageClass : packageClasses ) { addPackage ( scanRecursively , packageClass ) ; } return this ; } | Packages of the specified classes will be scanned and found classes will be added to the set of bean classes for the synthetic bean archive . | 53 | 27 |
150,029 | public Weld addPackage ( boolean scanRecursively , Class < ? > packageClass ) { packages . add ( new PackInfo ( packageClass , scanRecursively ) ) ; return this ; } | A package of the specified class will be scanned and found classes will be added to the set of bean classes for the synthetic bean archive . | 41 | 27 |
150,030 | public Weld extensions ( Extension ... extensions ) { this . extensions . clear ( ) ; for ( Extension extension : extensions ) { addExtension ( extension ) ; } return this ; } | Define the set of extensions . | 37 | 7 |
150,031 | public Weld addExtension ( Extension extension ) { extensions . add ( new MetadataImpl < Extension > ( extension , SYNTHETIC_LOCATION_PREFIX + extension . getClass ( ) . getName ( ) ) ) ; return this ; } | Add an extension to the set of extensions . | 55 | 9 |
150,032 | public Weld property ( String key , Object value ) { properties . put ( key , value ) ; return this ; } | Set the configuration property . | 24 | 5 |
150,033 | public Weld addBeanDefiningAnnotations ( Class < ? extends Annotation > ... annotations ) { for ( Class < ? extends Annotation > annotation : annotations ) { this . extendedBeanDefiningAnnotations . add ( annotation ) ; } return this ; } | Registers annotations which will be considered as bean defining annotations . | 55 | 12 |
150,034 | private static void checkSensibility ( AnnotatedType < ? > type ) { // check if it has a constructor if ( type . getConstructors ( ) . isEmpty ( ) && ! type . getJavaClass ( ) . isInterface ( ) ) { MetadataLogger . LOG . noConstructor ( type ) ; } Set < Class < ? > > hierarchy = new HashSet < Class < ? > > ( ) ; for ( Class < ? > clazz = type . getJavaClass ( ) ; clazz != null ; clazz = clazz . getSuperclass ( ) ) { hierarchy . add ( clazz ) ; hierarchy . addAll ( Reflections . getInterfaceClosure ( clazz ) ) ; } checkMembersBelongToHierarchy ( type . getConstructors ( ) , hierarchy , type ) ; checkMembersBelongToHierarchy ( type . getMethods ( ) , hierarchy , type ) ; checkMembersBelongToHierarchy ( type . getFields ( ) , hierarchy , type ) ; } | Checks if the given AnnotatedType is sensible otherwise provides warnings . | 218 | 15 |
150,035 | private static boolean isWideningPrimitive ( Class < ? > argumentClass , Class < ? > targetClass ) { return WIDENING_TABLE . containsKey ( argumentClass ) && WIDENING_TABLE . get ( argumentClass ) . contains ( targetClass ) ; } | Checks that the targetClass is widening the argument class | 60 | 11 |
150,036 | public static < X > String createTypeId ( AnnotatedType < X > annotatedType ) { String id = createTypeId ( annotatedType . getJavaClass ( ) , annotatedType . getAnnotations ( ) , annotatedType . getMethods ( ) , annotatedType . getFields ( ) , annotatedType . getConstructors ( ) ) ; String hash = hash ( id ) ; MetadataLogger . LOG . tracef ( "Generated AnnotatedType id hash for %s: %s" , id , hash ) ; return hash ; } | Generates a unique signature for an annotated type . Members without annotations are omitted to reduce the length of the signature | 123 | 23 |
150,037 | public static boolean compareAnnotatedParameters ( AnnotatedParameter < ? > p1 , AnnotatedParameter < ? > p2 ) { return compareAnnotatedCallable ( p1 . getDeclaringCallable ( ) , p2 . getDeclaringCallable ( ) ) && p1 . getPosition ( ) == p2 . getPosition ( ) && compareAnnotated ( p1 , p2 ) ; } | Compares two annotated parameters and returns true if they are equal | 90 | 13 |
150,038 | public static boolean compareAnnotatedTypes ( AnnotatedType < ? > t1 , AnnotatedType < ? > t2 ) { if ( ! t1 . getJavaClass ( ) . equals ( t2 . getJavaClass ( ) ) ) { return false ; } if ( ! compareAnnotated ( t1 , t2 ) ) { return false ; } if ( t1 . getFields ( ) . size ( ) != t2 . getFields ( ) . size ( ) ) { return false ; } Map < Field , AnnotatedField < ? > > fields = new HashMap < Field , AnnotatedField < ? > > ( ) ; for ( AnnotatedField < ? > f : t2 . getFields ( ) ) { fields . put ( f . getJavaMember ( ) , f ) ; } for ( AnnotatedField < ? > f : t1 . getFields ( ) ) { if ( fields . containsKey ( f . getJavaMember ( ) ) ) { if ( ! compareAnnotatedField ( f , fields . get ( f . getJavaMember ( ) ) ) ) { return false ; } } else { return false ; } } if ( t1 . getMethods ( ) . size ( ) != t2 . getMethods ( ) . size ( ) ) { return false ; } Map < Method , AnnotatedMethod < ? > > methods = new HashMap < Method , AnnotatedMethod < ? > > ( ) ; for ( AnnotatedMethod < ? > f : t2 . getMethods ( ) ) { methods . put ( f . getJavaMember ( ) , f ) ; } for ( AnnotatedMethod < ? > f : t1 . getMethods ( ) ) { if ( methods . containsKey ( f . getJavaMember ( ) ) ) { if ( ! compareAnnotatedCallable ( f , methods . get ( f . getJavaMember ( ) ) ) ) { return false ; } } else { return false ; } } if ( t1 . getConstructors ( ) . size ( ) != t2 . getConstructors ( ) . size ( ) ) { return false ; } Map < Constructor < ? > , AnnotatedConstructor < ? > > constructors = new HashMap < Constructor < ? > , AnnotatedConstructor < ? > > ( ) ; for ( AnnotatedConstructor < ? > f : t2 . getConstructors ( ) ) { constructors . put ( f . getJavaMember ( ) , f ) ; } for ( AnnotatedConstructor < ? > f : t1 . getConstructors ( ) ) { if ( constructors . containsKey ( f . getJavaMember ( ) ) ) { if ( ! compareAnnotatedCallable ( f , constructors . get ( f . getJavaMember ( ) ) ) ) { return false ; } } else { return false ; } } return true ; } | Compares two annotated types and returns true if they are the same | 628 | 14 |
150,039 | public static boolean isPassivatingScope ( Bean < ? > bean , BeanManagerImpl manager ) { if ( bean == null ) { return false ; } else { return manager . getServices ( ) . get ( MetaAnnotationStore . class ) . getScopeModel ( bean . getScope ( ) ) . isPassivating ( ) ; } } | Indicates if a bean s scope type is passivating | 71 | 11 |
150,040 | public static boolean isBeanProxyable ( Bean < ? > bean , BeanManagerImpl manager ) { if ( bean instanceof RIBean < ? > ) { return ( ( RIBean < ? > ) bean ) . isProxyable ( ) ; } else { return Proxies . isTypesProxyable ( bean . getTypes ( ) , manager . getServices ( ) ) ; } } | Indicates if a bean is proxyable | 83 | 8 |
150,041 | public static boolean containsAllQualifiers ( Set < QualifierInstance > requiredQualifiers , Set < QualifierInstance > qualifiers ) { return qualifiers . containsAll ( requiredQualifiers ) ; } | Checks that all the qualifiers in the set requiredQualifiers are in the set of qualifiers . Qualifier equality rules for annotation members are followed . | 39 | 29 |
150,042 | public static < T extends Bean < ? > > Set < T > removeDisabledBeans ( Set < T > beans , final BeanManagerImpl beanManager ) { if ( beans . isEmpty ( ) ) { return beans ; } else { for ( Iterator < T > iterator = beans . iterator ( ) ; iterator . hasNext ( ) ; ) { if ( ! isBeanEnabled ( iterator . next ( ) , beanManager . getEnabled ( ) ) ) { iterator . remove ( ) ; } } return beans ; } } | Retains only beans which are enabled . | 111 | 8 |
150,043 | public static boolean isAlternative ( EnhancedAnnotated < ? , ? > annotated , MergedStereotypes < ? , ? > mergedStereotypes ) { return annotated . isAnnotationPresent ( Alternative . class ) || mergedStereotypes . isAlternative ( ) ; } | Is alternative . | 59 | 3 |
150,044 | public static < T > void injectEEFields ( Iterable < Set < ResourceInjection < ? > > > resourceInjectionsHierarchy , T beanInstance , CreationalContext < T > ctx ) { for ( Set < ResourceInjection < ? > > resourceInjections : resourceInjectionsHierarchy ) { for ( ResourceInjection < ? > resourceInjection : resourceInjections ) { resourceInjection . injectResourceReference ( beanInstance , ctx ) ; } } } | Injects EJBs and other EE resources . | 107 | 11 |
150,045 | public static Type getDeclaredBeanType ( Class < ? > clazz ) { Type [ ] actualTypeArguments = Reflections . getActualTypeArguments ( clazz ) ; if ( actualTypeArguments . length == 1 ) { return actualTypeArguments [ 0 ] ; } else { return null ; } } | Gets the declared bean type | 69 | 6 |
150,046 | public static < T > void injectBoundFields ( T instance , CreationalContext < T > creationalContext , BeanManagerImpl manager , Iterable < ? extends FieldInjectionPoint < ? , ? > > injectableFields ) { for ( FieldInjectionPoint < ? , ? > injectableField : injectableFields ) { injectableField . inject ( instance , manager , creationalContext ) ; } } | Injects bound fields | 88 | 5 |
150,047 | public static < T > void callInitializers ( T instance , CreationalContext < T > creationalContext , BeanManagerImpl manager , Iterable < ? extends MethodInjectionPoint < ? , ? > > initializerMethods ) { for ( MethodInjectionPoint < ? , ? > initializer : initializerMethods ) { initializer . invoke ( instance , null , manager , creationalContext , CreationException . class ) ; } } | Calls all initializers of the bean | 90 | 8 |
150,048 | public static boolean isTypeManagedBeanOrDecoratorOrInterceptor ( AnnotatedType < ? > annotatedType ) { Class < ? > javaClass = annotatedType . getJavaClass ( ) ; return ! javaClass . isEnum ( ) && ! Extension . class . isAssignableFrom ( javaClass ) && Reflections . isTopLevelOrStaticNestedClass ( javaClass ) && ! Reflections . isParameterizedTypeWithWildcard ( javaClass ) && hasSimpleCdiConstructor ( annotatedType ) ; } | Indicates if the type is a simple Web Bean | 117 | 10 |
150,049 | public static < T > NewSessionBean < T > of ( BeanAttributes < T > attributes , InternalEjbDescriptor < T > ejbDescriptor , BeanManagerImpl beanManager ) { EnhancedAnnotatedType < T > type = beanManager . getServices ( ) . get ( ClassTransformer . class ) . getEnhancedAnnotatedType ( ejbDescriptor . getBeanClass ( ) , beanManager . getId ( ) ) ; return new NewSessionBean < T > ( attributes , type , ejbDescriptor , new StringBeanIdentifier ( SessionBeans . createIdentifierForNew ( ejbDescriptor ) ) , beanManager ) ; } | Creates an instance of a NewEnterpriseBean from an annotated class | 154 | 16 |
150,050 | public static < X , T > ProducerField < X , T > of ( BeanAttributes < T > attributes , EnhancedAnnotatedField < T , ? super X > field , AbstractClassBean < X > declaringBean , DisposalMethod < X , ? > disposalMethod , BeanManagerImpl beanManager , ServiceRegistry services ) { return new ProducerField < X , T > ( attributes , field , declaringBean , disposalMethod , beanManager , services ) ; } | Creates a producer field | 99 | 5 |
150,051 | public static boolean hasPermission ( Permission permission ) { SecurityManager security = System . getSecurityManager ( ) ; if ( security != null ) { try { security . checkPermission ( permission ) ; } catch ( java . security . AccessControlException e ) { return false ; } } return true ; } | Determines whether the specified permission is permitted . | 64 | 10 |
150,052 | public static < T > ManagedBean < T > of ( BeanAttributes < T > attributes , EnhancedAnnotatedType < T > clazz , BeanManagerImpl beanManager ) { return new ManagedBean < T > ( attributes , clazz , createId ( attributes , clazz ) , beanManager ) ; } | Creates a simple annotation defined Web Bean | 68 | 8 |
150,053 | @ Override public void destroy ( T instance , CreationalContext < T > creationalContext ) { super . destroy ( instance , creationalContext ) ; try { getProducer ( ) . preDestroy ( instance ) ; // WELD-1010 hack? if ( creationalContext instanceof CreationalContextImpl ) { ( ( CreationalContextImpl < T > ) creationalContext ) . release ( this , instance ) ; } else { creationalContext . release ( ) ; } } catch ( Exception e ) { BeanLogger . LOG . errorDestroying ( instance , this ) ; BeanLogger . LOG . catchingDebug ( e ) ; } } | Destroys an instance of the bean | 137 | 8 |
150,054 | @ Override protected void checkType ( ) { if ( ! isDependent ( ) && getEnhancedAnnotated ( ) . isParameterizedType ( ) ) { throw BeanLogger . LOG . managedBeanWithParameterizedBeanClassMustBeDependent ( type ) ; } boolean passivating = beanManager . isPassivatingScope ( getScope ( ) ) ; if ( passivating && ! isPassivationCapableBean ( ) ) { if ( ! getEnhancedAnnotated ( ) . isSerializable ( ) ) { throw BeanLogger . LOG . passivatingBeanNeedsSerializableImpl ( this ) ; } else if ( hasDecorators ( ) && ! allDecoratorsArePassivationCapable ( ) ) { throw BeanLogger . LOG . passivatingBeanHasNonPassivationCapableDecorator ( this , getFirstNonPassivationCapableDecorator ( ) ) ; } else if ( hasInterceptors ( ) && ! allInterceptorsArePassivationCapable ( ) ) { throw BeanLogger . LOG . passivatingBeanHasNonPassivationCapableInterceptor ( this , getFirstNonPassivationCapableInterceptor ( ) ) ; } } } | Validates the type | 258 | 4 |
150,055 | @ SafeVarargs public static < T > Set < T > of ( T ... elements ) { Preconditions . checkNotNull ( elements ) ; return ImmutableSet . < T > builder ( ) . addAll ( elements ) . build ( ) ; } | Creates a new immutable set that consists of given elements . | 54 | 12 |
150,056 | Object readResolve ( ) throws ObjectStreamException { Bean < ? > bean = Container . instance ( contextId ) . services ( ) . get ( ContextualStore . class ) . < Bean < Object > , Object > getContextual ( beanId ) ; if ( bean == null ) { throw BeanLogger . LOG . proxyDeserializationFailure ( beanId ) ; } return Container . instance ( contextId ) . deploymentManager ( ) . getClientProxyProvider ( ) . getClientProxy ( bean ) ; } | Always returns the original proxy object that was serialized . | 108 | 11 |
150,057 | @ Override protected String getToken ( ) { GetAccessTokenResult token = accessToken . get ( ) ; if ( token == null || isExpired ( token ) || ( isAboutToExpire ( token ) && refreshInProgress . compareAndSet ( false , true ) ) ) { lock . lock ( ) ; try { token = accessToken . get ( ) ; if ( token == null || isAboutToExpire ( token ) ) { token = accessTokenProvider . getNewAccessToken ( oauthScopes ) ; accessToken . set ( token ) ; cacheExpirationHeadroom . set ( getNextCacheExpirationHeadroom ( ) ) ; } } finally { refreshInProgress . set ( false ) ; lock . unlock ( ) ; } } return token . getAccessToken ( ) ; } | Attempts to return the token from cache . If this is not possible because it is expired or was never assigned a new token is requested and parallel requests will block on retrieving a new token . As such no guarantee of maximum latency is provided . | 169 | 47 |
150,058 | private void waitForOutstandingRequest ( ) throws IOException { if ( outstandingRequest == null ) { return ; } try { RetryHelper . runWithRetries ( new Callable < Void > ( ) { @ Override public Void call ( ) throws IOException , InterruptedException { if ( RetryHelper . getContext ( ) . getAttemptNumber ( ) > 1 ) { outstandingRequest . retry ( ) ; } token = outstandingRequest . waitForNextToken ( ) ; outstandingRequest = null ; return null ; } } , retryParams , GcsServiceImpl . exceptionHandler ) ; } catch ( RetryInterruptedException ex ) { token = null ; throw new ClosedByInterruptException ( ) ; } catch ( NonRetriableException e ) { Throwables . propagateIfInstanceOf ( e . getCause ( ) , IOException . class ) ; throw e ; } } | Waits for the current outstanding request retrying it with exponential backoff if it fails . | 188 | 18 |
150,059 | static Date parseDate ( String dateString ) { try { return DATE_FORMAT . parseDateTime ( dateString ) . toDate ( ) ; } catch ( IllegalArgumentException e ) { return null ; } } | Parses the date or returns null if it fails to do so . | 47 | 15 |
150,060 | @ Override public Future < RawGcsCreationToken > continueObjectCreationAsync ( final RawGcsCreationToken token , final ByteBuffer chunk , long timeoutMillis ) { try { ensureInitialized ( ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } final Environment environment = ApiProxy . getCurrentEnvironment ( ) ; return writePool . schedule ( new Callable < RawGcsCreationToken > ( ) { @ Override public RawGcsCreationToken call ( ) throws Exception { ApiProxy . setEnvironmentForCurrentThread ( environment ) ; return append ( token , chunk ) ; } } , 50 , TimeUnit . MILLISECONDS ) ; } | Runs calls in a background thread so that the results will actually be asynchronous . | 150 | 16 |
150,061 | private void requestBlock ( ) { next = ByteBuffer . allocate ( blockSizeBytes ) ; long requestTimeout = retryParams . getRequestTimeoutMillisForCurrentAttempt ( ) ; pendingFetch = raw . readObjectAsync ( next , filename , fetchPosition , requestTimeout ) ; } | Allocates a new next buffer and pending fetch . | 61 | 11 |
150,062 | GcsRestCreationToken handlePutResponse ( final GcsRestCreationToken token , final boolean isFinalChunk , final int length , final HTTPRequestInfo reqInfo , HTTPResponse resp ) throws Error , IOException { switch ( resp . getResponseCode ( ) ) { case 200 : if ( ! isFinalChunk ) { throw new RuntimeException ( "Unexpected response code 200 on non-final chunk. Request: \n" + URLFetchUtils . describeRequestAndResponse ( reqInfo , resp ) ) ; } else { return null ; } case 308 : if ( isFinalChunk ) { throw new RuntimeException ( "Unexpected response code 308 on final chunk: " + URLFetchUtils . describeRequestAndResponse ( reqInfo , resp ) ) ; } else { return new GcsRestCreationToken ( token . filename , token . uploadId , token . offset + length ) ; } default : throw HttpErrorHandler . error ( resp . getResponseCode ( ) , URLFetchUtils . describeRequestAndResponse ( reqInfo , resp ) ) ; } } | Given a HTTPResponce process it throwing an error if needed and return a Token for the next request . | 234 | 23 |
150,063 | private RawGcsCreationToken put ( final GcsRestCreationToken token , ByteBuffer chunk , final boolean isFinalChunk , long timeoutMillis ) throws IOException { final int length = chunk . remaining ( ) ; HTTPRequest req = createPutRequest ( token , chunk , isFinalChunk , timeoutMillis , length ) ; HTTPRequestInfo info = new HTTPRequestInfo ( req ) ; HTTPResponse response ; try { response = urlfetch . fetch ( req ) ; } catch ( IOException e ) { throw createIOException ( info , e ) ; } return handlePutResponse ( token , isFinalChunk , length , info , response ) ; } | Write the provided chunk at the offset specified in the token . If finalChunk is set the file will be closed . | 144 | 24 |
150,064 | @ Override public boolean deleteObject ( GcsFilename filename , long timeoutMillis ) throws IOException { HTTPRequest req = makeRequest ( filename , null , DELETE , timeoutMillis ) ; HTTPResponse resp ; try { resp = urlfetch . fetch ( req ) ; } catch ( IOException e ) { throw createIOException ( new HTTPRequestInfo ( req ) , e ) ; } switch ( resp . getResponseCode ( ) ) { case 204 : return true ; case 404 : return false ; default : throw HttpErrorHandler . error ( new HTTPRequestInfo ( req ) , resp ) ; } } | True if deleted false if not found . | 133 | 8 |
150,065 | @ Override public Future < GcsFileMetadata > readObjectAsync ( final ByteBuffer dst , final GcsFilename filename , long startOffsetBytes , long timeoutMillis ) { Preconditions . checkArgument ( startOffsetBytes >= 0 , "%s: offset must be non-negative: %s" , this , startOffsetBytes ) ; final int n = dst . remaining ( ) ; Preconditions . checkArgument ( n > 0 , "%s: dst full: %s" , this , dst ) ; final int want = Math . min ( READ_LIMIT_BYTES , n ) ; final HTTPRequest req = makeRequest ( filename , null , GET , timeoutMillis ) ; req . setHeader ( new HTTPHeader ( RANGE , "bytes=" + startOffsetBytes + "-" + ( startOffsetBytes + want - 1 ) ) ) ; final HTTPRequestInfo info = new HTTPRequestInfo ( req ) ; return new FutureWrapper < HTTPResponse , GcsFileMetadata > ( urlfetch . fetchAsync ( req ) ) { @ Override protected GcsFileMetadata wrap ( HTTPResponse resp ) throws IOException { long totalLength ; switch ( resp . getResponseCode ( ) ) { case 200 : totalLength = getLengthFromHeader ( resp , X_GOOG_CONTENT_LENGTH ) ; break ; case 206 : totalLength = getLengthFromContentRange ( resp ) ; break ; case 404 : throw new FileNotFoundException ( "Could not find: " + filename ) ; case 416 : throw new BadRangeException ( "Requested Range not satisfiable; perhaps read past EOF? " + URLFetchUtils . describeRequestAndResponse ( info , resp ) ) ; default : throw HttpErrorHandler . error ( info , resp ) ; } byte [ ] content = resp . getContent ( ) ; Preconditions . checkState ( content . length <= want , "%s: got %s > wanted %s" , this , content . length , want ) ; dst . put ( content ) ; return getMetadataFromResponse ( filename , resp , totalLength ) ; } @ Override protected Throwable convertException ( Throwable e ) { return OauthRawGcsService . convertException ( info , e ) ; } } ; } | Might not fill all of dst . | 492 | 8 |
150,066 | private void copy ( InputStream input , OutputStream output ) throws IOException { try { byte [ ] buffer = new byte [ BUFFER_SIZE ] ; int bytesRead = input . read ( buffer ) ; while ( bytesRead != - 1 ) { output . write ( buffer , 0 , bytesRead ) ; bytesRead = input . read ( buffer ) ; } } finally { input . close ( ) ; output . close ( ) ; } } | Transfer the data from the inputStream to the outputStream . Then close both streams . | 92 | 17 |
150,067 | public Collection < Locale > getCountries ( ) { Collection < Locale > result = get ( KEY_QUERY_COUNTRIES , Collection . class ) ; if ( result == null ) { return Collections . emptySet ( ) ; } return result ; } | Returns the target locales . | 56 | 6 |
150,068 | public Collection < String > getCurrencyCodes ( ) { Collection < String > result = get ( KEY_QUERY_CURRENCY_CODES , Collection . class ) ; if ( result == null ) { return Collections . emptySet ( ) ; } return result ; } | Gets the currency codes or the regular expression to select codes . | 59 | 13 |
150,069 | public Collection < Integer > getNumericCodes ( ) { Collection < Integer > result = get ( KEY_QUERY_NUMERIC_CODES , Collection . class ) ; if ( result == null ) { return Collections . emptySet ( ) ; } return result ; } | Gets the numeric codes . Setting it to - 1 search for currencies that have no numeric code . | 59 | 20 |
150,070 | public Class < ? extends MonetaryAmount > getAmountType ( ) { Class < ? > clazz = get ( AMOUNT_TYPE , Class . class ) ; return clazz . asSubclass ( MonetaryAmount . class ) ; } | Get the MonetaryAmount implementation class . | 48 | 7 |
150,071 | @ Override public Set < String > getProviderNames ( ) { Set < String > result = new HashSet <> ( ) ; for ( RoundingProviderSpi prov : Bootstrap . getServices ( RoundingProviderSpi . class ) ) { try { result . add ( prov . getProviderName ( ) ) ; } catch ( Exception e ) { Logger . getLogger ( Monetary . class . getName ( ) ) . log ( Level . SEVERE , "Error loading RoundingProviderSpi from provider: " + prov , e ) ; } } return result ; } | Get the names of all current registered providers . | 124 | 9 |
150,072 | @ Override public List < String > getDefaultProviderChain ( ) { List < String > result = new ArrayList <> ( Monetary . getRoundingProviderNames ( ) ) ; Collections . sort ( result ) ; return result ; } | Get the default providers list to be used . | 49 | 9 |
150,073 | @ Override public Set < String > getRoundingNames ( String ... providers ) { Set < String > result = new HashSet <> ( ) ; String [ ] providerNames = providers ; if ( providerNames . length == 0 ) { providerNames = Monetary . getDefaultRoundingProviderChain ( ) . toArray ( new String [ Monetary . getDefaultRoundingProviderChain ( ) . size ( ) ] ) ; } for ( String providerName : providerNames ) { for ( RoundingProviderSpi prov : Bootstrap . getServices ( RoundingProviderSpi . class ) ) { try { if ( prov . getProviderName ( ) . equals ( providerName ) || prov . getProviderName ( ) . matches ( providerName ) ) { result . addAll ( prov . getRoundingNames ( ) ) ; } } catch ( Exception e ) { Logger . getLogger ( DefaultMonetaryRoundingsSingletonSpi . class . getName ( ) ) . log ( Level . SEVERE , "Error loading RoundingProviderSpi from provider: " + prov , e ) ; } } } return result ; } | Allows to access the identifiers of the current defined roundings . | 237 | 12 |
150,074 | @ SuppressWarnings ( "unchecked" ) public Set < RateType > getRateTypes ( ) { Set < RateType > result = get ( KEY_RATE_TYPES , Set . class ) ; if ( result == null ) { return Collections . emptySet ( ) ; } return result ; } | Get the rate types set . | 67 | 6 |
150,075 | public CurrencyQueryBuilder setCountries ( Locale ... countries ) { return set ( CurrencyQuery . KEY_QUERY_COUNTRIES , Arrays . asList ( countries ) ) ; } | Sets the country for which currencies should be requested . | 41 | 11 |
150,076 | public CurrencyQueryBuilder setCurrencyCodes ( String ... codes ) { return set ( CurrencyQuery . KEY_QUERY_CURRENCY_CODES , Arrays . asList ( codes ) ) ; } | Sets the currency code or the regular expression to select codes . | 45 | 13 |
150,077 | public CurrencyQueryBuilder setNumericCodes ( int ... codes ) { return set ( CurrencyQuery . KEY_QUERY_NUMERIC_CODES , Arrays . stream ( codes ) . boxed ( ) . collect ( Collectors . toList ( ) ) ) ; } | Set the numeric code . Setting it to - 1 search for currencies that have no numeric code . | 59 | 19 |
150,078 | public static List < String > getDefaultConversionProviderChain ( ) { List < String > defaultChain = getMonetaryConversionsSpi ( ) . getDefaultProviderChain ( ) ; Objects . requireNonNull ( defaultChain , "No default provider chain provided by SPI: " + getMonetaryConversionsSpi ( ) . getClass ( ) . getName ( ) ) ; return defaultChain ; } | Get the default provider used . | 85 | 6 |
150,079 | public Set < String > getKeys ( Class < ? > type ) { return data . entrySet ( ) . stream ( ) . filter ( val -> type . isAssignableFrom ( val . getValue ( ) . getClass ( ) ) ) . map ( Map . Entry :: getKey ) . collect ( Collectors . toSet ( ) ) ; } | Get the present keys of all entries with a given type checking hereby if assignable . | 75 | 17 |
150,080 | public Class < ? > getType ( String key ) { Object val = this . data . get ( key ) ; return val == null ? null : val . getClass ( ) ; } | Get the current attribute type . | 39 | 6 |
150,081 | public < T > T get ( String key , Class < T > type ) { Object value = this . data . get ( key ) ; if ( value != null && type . isAssignableFrom ( value . getClass ( ) ) ) { return ( T ) value ; } return null ; } | Access an attribute . | 63 | 4 |
150,082 | public < T > T get ( Class < T > type ) { return get ( type . getName ( ) , type ) ; } | Access an attribute hereby using the class name as key . | 28 | 11 |
150,083 | @ SuppressWarnings ( "unchecked" ) public B setTargetType ( Class < ? > type ) { Objects . requireNonNull ( type ) ; set ( AbstractQuery . KEY_QUERY_TARGET_TYPE , type ) ; return ( B ) this ; } | Sets the target implementation type required . This can be used to explicitly acquire a specific implementation type and use a query to configure the instance or factory to be returned . | 59 | 33 |
150,084 | public Set < RateType > getRateTypes ( ) { @ SuppressWarnings ( "unchecked" ) Set < RateType > rateSet = get ( KEY_RATE_TYPES , Set . class ) ; if ( rateSet == null ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( rateSet ) ; } | Get the deferred flag . Exchange rates can be deferred or real . time . | 78 | 15 |
150,085 | private static MonetaryFormatsSingletonSpi loadMonetaryFormatsSingletonSpi ( ) { try { return Optional . ofNullable ( Bootstrap . getService ( MonetaryFormatsSingletonSpi . class ) ) . orElseGet ( DefaultMonetaryFormatsSingletonSpi :: new ) ; } catch ( Exception e ) { Logger . getLogger ( MonetaryFormats . class . getName ( ) ) . log ( Level . WARNING , "Failed to load MonetaryFormatsSingletonSpi, using default." , e ) ; return new DefaultMonetaryFormatsSingletonSpi ( ) ; } } | Loads the SPI backing bean . | 133 | 7 |
150,086 | public static Collection < String > getFormatProviderNames ( ) { Collection < String > providers = Optional . ofNullable ( getMonetaryFormatsSpi ( ) ) . orElseThrow ( ( ) -> new MonetaryException ( "No MonetaryFormatsSingletonSpi loaded, query functionality is not available." ) ) . getProviderNames ( ) ; if ( Objects . isNull ( providers ) ) { Logger . getLogger ( MonetaryFormats . class . getName ( ) ) . warning ( "No supported rate/conversion providers returned by SPI: " + getMonetaryFormatsSpi ( ) . getClass ( ) . getName ( ) ) ; return Collections . emptySet ( ) ; } return providers ; } | Get the names of the currently registered format providers . | 153 | 10 |
150,087 | public ProviderContextBuilder setRateTypes ( Collection < RateType > rateTypes ) { Objects . requireNonNull ( rateTypes ) ; if ( rateTypes . isEmpty ( ) ) { throw new IllegalArgumentException ( "At least one RateType is required." ) ; } Set < RateType > rtSet = new HashSet <> ( rateTypes ) ; set ( ProviderContext . KEY_RATE_TYPES , rtSet ) ; return this ; } | Set the rate types . | 99 | 5 |
150,088 | public B importContext ( AbstractContext context , boolean overwriteDuplicates ) { for ( Map . Entry < String , Object > en : context . data . entrySet ( ) ) { if ( overwriteDuplicates ) { this . data . put ( en . getKey ( ) , en . getValue ( ) ) ; } else { this . data . putIfAbsent ( en . getKey ( ) , en . getValue ( ) ) ; } } return ( B ) this ; } | Apply all attributes on the given context . | 103 | 8 |
150,089 | public B importContext ( AbstractContext context ) { Objects . requireNonNull ( context ) ; return importContext ( context , false ) ; } | Apply all attributes on the given context hereby existing entries are preserved . | 29 | 13 |
150,090 | public B set ( String key , int value ) { this . data . put ( key , value ) ; return ( B ) this ; } | Sets an Integer attribute . | 29 | 6 |
150,091 | public static Set < String > getRoundingNames ( String ... providers ) { return Optional . ofNullable ( monetaryRoundingsSingletonSpi ( ) ) . orElseThrow ( ( ) -> new MonetaryException ( "No MonetaryRoundingsSpi loaded, query functionality is not available." ) ) . getRoundingNames ( providers ) ; } | Allows to access the names of the current defined roundings . | 72 | 12 |
150,092 | @ SuppressWarnings ( "rawtypes" ) public static MonetaryAmountFactory getAmountFactory ( MonetaryAmountFactoryQuery query ) { return Optional . ofNullable ( monetaryAmountsSingletonQuerySpi ( ) ) . orElseThrow ( ( ) -> new MonetaryException ( "No MonetaryAmountsSingletonQuerySpi loaded, query functionality is not available." ) ) . getAmountFactory ( query ) ; } | Executes the query and returns the factory found if there is only one factory . If multiple factories match the query one is selected . | 87 | 26 |
150,093 | public static Collection < MonetaryAmountFactory < ? > > getAmountFactories ( MonetaryAmountFactoryQuery query ) { return Optional . ofNullable ( monetaryAmountsSingletonQuerySpi ( ) ) . orElseThrow ( ( ) -> new MonetaryException ( "No MonetaryAmountsSingletonQuerySpi loaded, query functionality is not available." ) ) . getAmountFactories ( query ) ; } | Returns all factory instances that match the query . | 83 | 9 |
150,094 | public static Collection < CurrencyUnit > getCurrencies ( String ... providers ) { return Optional . ofNullable ( MONETARY_CURRENCIES_SINGLETON_SPI ( ) ) . orElseThrow ( ( ) -> new MonetaryException ( "No MonetaryCurrenciesSingletonSpi loaded, check your system setup." ) ) . getCurrencies ( providers ) ; } | Access all currencies known . | 81 | 5 |
150,095 | private PoolingHttpClientConnectionManager createConnectionMgr ( ) { PoolingHttpClientConnectionManager connectionMgr ; // prepare SSLContext SSLContext sslContext = buildSslContext ( ) ; ConnectionSocketFactory plainsf = PlainConnectionSocketFactory . getSocketFactory ( ) ; // we allow to disable host name verification against CA certificate, // notice: in general this is insecure and should be avoided in production, // (this type of configuration is useful for development purposes) boolean noHostVerification = false ; LayeredConnectionSocketFactory sslsf = new SSLConnectionSocketFactory ( sslContext , noHostVerification ? NoopHostnameVerifier . INSTANCE : new DefaultHostnameVerifier ( ) ) ; Registry < ConnectionSocketFactory > r = RegistryBuilder . < ConnectionSocketFactory > create ( ) . register ( "http" , plainsf ) . register ( "https" , sslsf ) . build ( ) ; connectionMgr = new PoolingHttpClientConnectionManager ( r , null , null , null , connectionPoolTimeToLive , TimeUnit . SECONDS ) ; connectionMgr . setMaxTotal ( maxConnectionsTotal ) ; connectionMgr . setDefaultMaxPerRoute ( maxConnectionsPerRoute ) ; HttpHost localhost = new HttpHost ( "localhost" , 80 ) ; connectionMgr . setMaxPerRoute ( new HttpRoute ( localhost ) , maxConnectionsPerRoute ) ; return connectionMgr ; } | Creates custom Http Client connection pool to be used by Http Client | 308 | 15 |
150,096 | @ Override public ArtifactoryResponse restCall ( ArtifactoryRequest artifactoryRequest ) throws IOException { HttpRequestBase httpRequest ; String requestPath = "/" + artifactoryRequest . getApiUrl ( ) ; ContentType contentType = Util . getContentType ( artifactoryRequest . getRequestType ( ) ) ; String queryPath = "" ; if ( ! artifactoryRequest . getQueryParams ( ) . isEmpty ( ) ) { queryPath = Util . getQueryPath ( "?" , artifactoryRequest . getQueryParams ( ) ) ; } switch ( artifactoryRequest . getMethod ( ) ) { case GET : httpRequest = new HttpGet ( ) ; break ; case POST : httpRequest = new HttpPost ( ) ; setEntity ( ( HttpPost ) httpRequest , artifactoryRequest . getBody ( ) , contentType ) ; break ; case PUT : httpRequest = new HttpPut ( ) ; setEntity ( ( HttpPut ) httpRequest , artifactoryRequest . getBody ( ) , contentType ) ; break ; case DELETE : httpRequest = new HttpDelete ( ) ; break ; case PATCH : httpRequest = new HttpPatch ( ) ; setEntity ( ( HttpPatch ) httpRequest , artifactoryRequest . getBody ( ) , contentType ) ; break ; case OPTIONS : httpRequest = new HttpOptions ( ) ; break ; default : throw new IllegalArgumentException ( "Unsupported request method." ) ; } httpRequest . setURI ( URI . create ( url + requestPath + queryPath ) ) ; addAccessTokenHeaderIfNeeded ( httpRequest ) ; if ( contentType != null ) { httpRequest . setHeader ( "Content-type" , contentType . getMimeType ( ) ) ; } Map < String , String > headers = artifactoryRequest . getHeaders ( ) ; for ( String key : headers . keySet ( ) ) { httpRequest . setHeader ( key , headers . get ( key ) ) ; } HttpResponse httpResponse = httpClient . execute ( httpRequest ) ; return new ArtifactoryResponseImpl ( httpResponse ) ; } | Create a REST call to artifactory with a generic request | 460 | 11 |
150,097 | protected void createDocument ( ) throws ParserConfigurationException { DocumentBuilderFactory builderFactory = DocumentBuilderFactory . newInstance ( ) ; DocumentBuilder builder = builderFactory . newDocumentBuilder ( ) ; DocumentType doctype = builder . getDOMImplementation ( ) . createDocumentType ( "html" , "-//W3C//DTD XHTML 1.1//EN" , "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" ) ; doc = builder . getDOMImplementation ( ) . createDocument ( "http://www.w3.org/1999/xhtml" , "html" , doctype ) ; head = doc . createElement ( "head" ) ; Element meta = doc . createElement ( "meta" ) ; meta . setAttribute ( "http-equiv" , "content-type" ) ; meta . setAttribute ( "content" , "text/html;charset=utf-8" ) ; head . appendChild ( meta ) ; title = doc . createElement ( "title" ) ; title . setTextContent ( "PDF Document" ) ; head . appendChild ( title ) ; globalStyle = doc . createElement ( "style" ) ; globalStyle . setAttribute ( "type" , "text/css" ) ; //globalStyle.setTextContent(createGlobalStyle()); head . appendChild ( globalStyle ) ; body = doc . createElement ( "body" ) ; Element root = doc . getDocumentElement ( ) ; root . appendChild ( head ) ; root . appendChild ( body ) ; } | Creates a new empty HTML document tree . | 344 | 9 |
150,098 | @ Override public void writeText ( PDDocument doc , Writer outputStream ) throws IOException { try { DOMImplementationRegistry registry = DOMImplementationRegistry . newInstance ( ) ; DOMImplementationLS impl = ( DOMImplementationLS ) registry . getDOMImplementation ( "LS" ) ; LSSerializer writer = impl . createLSSerializer ( ) ; LSOutput output = impl . createLSOutput ( ) ; writer . getDomConfig ( ) . setParameter ( "format-pretty-print" , true ) ; output . setCharacterStream ( outputStream ) ; createDOM ( doc ) ; writer . write ( getDocument ( ) , output ) ; } catch ( ClassCastException e ) { throw new IOException ( "Error: cannot initialize the DOM serializer" , e ) ; } catch ( ClassNotFoundException e ) { throw new IOException ( "Error: cannot initialize the DOM serializer" , e ) ; } catch ( InstantiationException e ) { throw new IOException ( "Error: cannot initialize the DOM serializer" , e ) ; } catch ( IllegalAccessException e ) { throw new IOException ( "Error: cannot initialize the DOM serializer" , e ) ; } } | Parses a PDF document and serializes the resulting DOM tree to an output . This requires a DOM Level 3 capable implementation to be available . | 257 | 29 |
150,099 | public Document createDOM ( PDDocument doc ) throws IOException { /* We call the original PDFTextStripper.writeText but nothing should be printed actually because our processing methods produce no output. They create the DOM structures instead */ super . writeText ( doc , new OutputStreamWriter ( System . out ) ) ; return this . doc ; } | Loads a PDF document and creates a DOM tree from it . | 71 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.