idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
19,600
public static void assertOnlyOneMethod ( final Collection < Method > methods , Class < ? extends Annotation > annotation ) { if ( methods . size ( ) > 1 ) { throw annotation == null ? MESSAGES . onlyOneMethodCanExist ( ) : MESSAGES . onlyOneMethodCanExist2 ( annotation ) ; } }
Asserts only one method is annotated with annotation .
19,601
public final void invoke ( final Endpoint endpoint , final Invocation invocation ) throws Exception { try { this . init ( endpoint , invocation ) ; final Object targetBean = invocation . getInvocationContext ( ) . getTargetBean ( ) ; final Class < ? > implClass = targetBean . getClass ( ) ; final Method seiMethod = invocation . getJavaMethod ( ) ; final Method implMethod = this . getImplMethod ( implClass , seiMethod ) ; final Object [ ] args = invocation . getArgs ( ) ; this . onBeforeInvocation ( invocation ) ; final Object retObj = implMethod . invoke ( targetBean , args ) ; invocation . setReturnValue ( retObj ) ; } catch ( Exception e ) { Loggers . ROOT_LOGGER . methodInvocationFailed ( e ) ; this . handleInvocationException ( e ) ; } finally { this . onAfterInvocation ( invocation ) ; } }
Invokes method on endpoint implementation .
19,602
public < T > T getSPI ( Class < T > spiType , ClassLoader loader ) { T returnType = null ; if ( DeploymentModelFactory . class . equals ( spiType ) ) { returnType = loadService ( spiType , DefaultDeploymentModelFactory . class , loader ) ; } else if ( EndpointMetricsFactory . class . equals ( spiType ) ) { returnType = loadService ( spiType , DefaultEndpointMetricsFactory . class , loader ) ; } else if ( LifecycleHandlerFactory . class . equals ( spiType ) ) { returnType = loadService ( spiType , DefaultLifecycleHandlerFactory . class , loader ) ; } else if ( SecurityAdaptorFactory . class . equals ( spiType ) ) { returnType = loadService ( spiType , DefaultSecurityAdapterFactory . class , loader ) ; } else if ( JMSEndpointResolver . class . equals ( spiType ) ) { returnType = loadService ( spiType , DefaultJMSEndpointResolver . class , loader ) ; } else { returnType = ( T ) loadService ( spiType , null , loader ) ; } if ( returnType == null ) throw Messages . MESSAGES . failedToProvideSPI ( spiType ) ; return returnType ; }
Gets the specified SPI using the provided classloader
19,603
@ SuppressWarnings ( "unchecked" ) private < T > T loadService ( Class < T > spiType , Class < ? > defaultImpl , ClassLoader loader ) { final String defaultImplName = defaultImpl != null ? defaultImpl . getName ( ) : null ; return ( T ) ServiceLoader . loadService ( spiType . getName ( ) , defaultImplName , loader ) ; }
Load SPI implementation through ServiceLoader
19,604
private boolean isRecording ( Endpoint endpoint ) { List < RecordProcessor > processors = endpoint . getRecordProcessors ( ) ; if ( processors == null || processors . isEmpty ( ) ) { return false ; } for ( RecordProcessor processor : processors ) { if ( processor . isRecording ( ) ) { return true ; } } return false ; }
Returns true if there s at least a record processor in recording mode
19,605
public static void rethrow ( final String message , final Exception reason ) { if ( reason == null ) { throw new IllegalArgumentException ( ) ; } Loggers . ROOT_LOGGER . error ( message == null ? reason . getMessage ( ) : message , reason ) ; throw new InjectionException ( message , reason ) ; }
Rethrows Injection exception that will wrap passed reason .
19,606
public EndpointConfig resolveEndpointConfig ( ) { final String endpointClassName = getEndpointClassName ( ) ; String configName = endpointClassName ; String configFile = EndpointConfig . DEFAULT_ENDPOINT_CONFIG_FILE ; boolean specifiedConfig = false ; if ( isEndpointClassAnnotated ( org . jboss . ws . api . annotation . EndpointConfig . class ) ) { final String cfgName = getEndpointConfigNameFromAnnotation ( ) ; if ( cfgName != null && ! cfgName . isEmpty ( ) ) { configName = cfgName ; } final String cfgFile = getEndpointConfigFileFromAnnotation ( ) ; if ( cfgFile != null && ! cfgFile . isEmpty ( ) ) { configFile = cfgFile ; } specifiedConfig = true ; } final String epCfgNameOverride = getEndpointConfigNameOverride ( ) ; if ( epCfgNameOverride != null && ! epCfgNameOverride . isEmpty ( ) ) { configName = epCfgNameOverride ; specifiedConfig = true ; } final String epCfgFileOverride = getEndpointConfigFileOverride ( ) ; if ( epCfgFileOverride != null && ! epCfgFileOverride . isEmpty ( ) ) { configFile = epCfgFileOverride ; } if ( configFile != EndpointConfig . DEFAULT_ENDPOINT_CONFIG_FILE ) { try { ConfigRoot configRoot = ConfigMetaDataParser . parse ( getConfigFile ( configFile ) ) ; EndpointConfig config = configRoot . getEndpointConfigByName ( configName ) ; if ( config == null && ! specifiedConfig ) { config = configRoot . getEndpointConfigByName ( EndpointConfig . STANDARD_ENDPOINT_CONFIG ) ; } if ( config != null ) { return config ; } } catch ( IOException e ) { throw Messages . MESSAGES . couldNotReadConfigFile ( configFile ) ; } } else { EndpointConfig config = null ; URL url = getDefaultConfigFile ( configFile ) ; if ( url != null ) { try { ConfigRoot configRoot = ConfigMetaDataParser . parse ( url ) ; config = configRoot . getEndpointConfigByName ( configName ) ; if ( config == null && ! specifiedConfig ) { config = configRoot . getEndpointConfigByName ( EndpointConfig . STANDARD_ENDPOINT_CONFIG ) ; } } catch ( IOException e ) { throw Messages . MESSAGES . couldNotReadConfigFile ( configFile ) ; } } if ( config == null ) { ServerConfig sc = getServerConfig ( ) ; config = sc . getEndpointConfig ( configName ) ; if ( config == null && ! specifiedConfig ) { config = sc . getEndpointConfig ( EndpointConfig . STANDARD_ENDPOINT_CONFIG ) ; } if ( config == null && specifiedConfig ) { throw Messages . MESSAGES . couldNotFindEndpointConfigName ( configName ) ; } } if ( config != null ) { return config ; } } return null ; }
Returns the EndpointConfig resolved for the current endpoint
19,607
public Set < String > getAllHandlers ( EndpointConfig config ) { Set < String > set = new HashSet < String > ( ) ; if ( config != null ) { for ( UnifiedHandlerChainMetaData uhcmd : config . getPreHandlerChains ( ) ) { for ( UnifiedHandlerMetaData uhmd : uhcmd . getHandlers ( ) ) { set . add ( uhmd . getHandlerClass ( ) ) ; } } for ( UnifiedHandlerChainMetaData uhcmd : config . getPostHandlerChains ( ) ) { for ( UnifiedHandlerMetaData uhmd : uhcmd . getHandlers ( ) ) { set . add ( uhmd . getHandlerClass ( ) ) ; } } } return set ; }
Returns a set of full qualified class names of the handlers from the specified endpoint config
19,608
@ SuppressWarnings ( "unchecked" ) protected void publishWsdlImports ( URL parentURL , Definition parentDefinition , List < String > published , String expLocation ) throws Exception { @ SuppressWarnings ( "rawtypes" ) Iterator it = parentDefinition . getImports ( ) . values ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { for ( Import wsdlImport : ( List < Import > ) it . next ( ) ) { String locationURI = wsdlImport . getLocationURI ( ) ; if ( locationURI . startsWith ( "http://" ) == false && locationURI . startsWith ( "https://" ) == false ) { if ( published . contains ( locationURI ) ) { continue ; } else { published . add ( locationURI ) ; } String baseURI = parentURL . toExternalForm ( ) ; URL targetURL = new URL ( baseURI . substring ( 0 , baseURI . lastIndexOf ( "/" ) + 1 ) + locationURI ) ; File targetFile = new File ( targetURL . getFile ( ) ) ; createParentDir ( targetFile ) ; Definition subdef = wsdlImport . getDefinition ( ) ; WSDLFactory wsdlFactory = WSDLFactory . newInstance ( ) ; javax . wsdl . xml . WSDLWriter wsdlWriter = wsdlFactory . newWSDLWriter ( ) ; BufferedOutputStream bfos = new BufferedOutputStream ( new FileOutputStream ( targetFile ) ) ; OutputStreamWriter osw = new OutputStreamWriter ( bfos , "UTF-8" ) ; try { wsdlWriter . writeWSDL ( subdef , osw ) ; } finally { osw . close ( ) ; } DEPLOYMENT_LOGGER . wsdlImportPublishedTo ( targetURL ) ; publishWsdlImports ( targetURL , subdef , published , expLocation ) ; Element subdoc = DOMUtils . parse ( targetURL . openStream ( ) , getDocumentBuilder ( ) ) ; publishSchemaImports ( targetURL , subdoc , published , expLocation ) ; } } } }
Publish the wsdl imports for a given wsdl definition
19,609
protected void publishSchemaImports ( URL parentURL , Element element , List < String > published , String expLocation ) throws Exception { Element childElement = getFirstChildElement ( element ) ; while ( childElement != null ) { final String ns = childElement . getNamespaceURI ( ) ; if ( Constants . NS_SCHEMA_XSD . equals ( ns ) ) { final String ln = childElement . getLocalName ( ) ; if ( "import" . equals ( ln ) || "include" . equals ( ln ) ) { String schemaLocation = childElement . getAttribute ( "schemaLocation" ) ; if ( schemaLocation . length ( ) > 0 && schemaLocation . startsWith ( "http://" ) == false && schemaLocation . startsWith ( "https://" ) == false ) { if ( ! published . contains ( schemaLocation ) ) { published . add ( schemaLocation ) ; String baseURI = parentURL . toExternalForm ( ) ; URL xsdURL = new URL ( baseURI . substring ( 0 , baseURI . lastIndexOf ( "/" ) + 1 ) + schemaLocation ) ; File targetFile = new File ( xsdURL . getFile ( ) ) ; createParentDir ( targetFile ) ; String deploymentName = dep . getCanonicalName ( ) ; int index = baseURI . indexOf ( deploymentName ) + 1 ; String resourcePath = baseURI . substring ( index + deploymentName . length ( ) ) ; resourcePath = resourcePath . substring ( 0 , resourcePath . lastIndexOf ( "/" ) + 1 ) ; resourcePath = expLocation + resourcePath + schemaLocation ; while ( resourcePath . indexOf ( "//" ) != - 1 ) { resourcePath = resourcePath . replace ( "//" , "/" ) ; } URL resourceURL = dep . getResourceResolver ( ) . resolve ( resourcePath ) ; InputStream is = new ResourceURL ( resourceURL ) . openStream ( ) ; if ( is == null ) throw MESSAGES . cannotFindSchemaImportInDeployment ( resourcePath , deploymentName ) ; FileOutputStream fos = null ; try { fos = new FileOutputStream ( targetFile ) ; IOUtils . copyStream ( fos , is ) ; } finally { if ( fos != null ) fos . close ( ) ; } DEPLOYMENT_LOGGER . xmlSchemaImportPublishedTo ( xsdURL ) ; Element subdoc = DOMUtils . parse ( xsdURL . openStream ( ) , getDocumentBuilder ( ) ) ; publishSchemaImports ( xsdURL , subdoc , published , expLocation ) ; } } } else if ( "schema" . equals ( ln ) ) { publishSchemaImports ( parentURL , childElement , published , expLocation ) ; } } else if ( Constants . NS_WSDL11 . equals ( ns ) && "types" . equals ( childElement . getLocalName ( ) ) ) { publishSchemaImports ( parentURL , childElement , published , expLocation ) ; } childElement = getNextSiblingElement ( childElement ) ; } }
Publish the schema imports for a given wsdl definition
19,610
public void unpublishWsdlFiles ( ) throws IOException { String deploymentDir = ( dep . getParent ( ) != null ? dep . getParent ( ) . getSimpleName ( ) : dep . getSimpleName ( ) ) ; File serviceDir = new File ( serverConfig . getServerDataDir ( ) . getCanonicalPath ( ) + "/wsdl/" + deploymentDir ) ; deleteWsdlPublishDirectory ( serviceDir ) ; }
Delete the published wsdl
19,611
protected void deleteWsdlPublishDirectory ( File dir ) throws IOException { String [ ] files = dir . list ( ) ; for ( int i = 0 ; files != null && i < files . length ; i ++ ) { String fileName = files [ i ] ; File file = new File ( dir + "/" + fileName ) ; if ( file . isDirectory ( ) ) { deleteWsdlPublishDirectory ( file ) ; } else { if ( file . delete ( ) == false ) DEPLOYMENT_LOGGER . cannotDeletePublishedWsdlDoc ( file . toURI ( ) . toURL ( ) ) ; } } if ( dir . delete ( ) == false ) { DEPLOYMENT_LOGGER . cannotDeletePublishedWsdlDoc ( dir . toURI ( ) . toURL ( ) ) ; } }
Delete the published wsdl document traversing down the dir structure
19,612
protected Object readResolve ( ) throws ObjectStreamException { try { Class < ? > proxyClass = getProxyClass ( ) ; Object instance = proxyClass . newInstance ( ) ; ProxyFactory . setInvocationHandlerStatic ( instance , handler ) ; return instance ; } catch ( InstantiationException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } }
Resolve the serialized proxy to a real instance .
19,613
protected Class < ? > getProxyClass ( ) throws ClassNotFoundException { ClassLoader classLoader = getProxyClassLoader ( ) ; return Class . forName ( proxyClassName , false , classLoader ) ; }
Get the associated proxy class .
19,614
public static DocumentBuilder newDocumentBuilder ( final DocumentBuilderFactory factory ) { try { final DocumentBuilder builder = factory . newDocumentBuilder ( ) ; return builder ; } catch ( Exception e ) { throw MESSAGES . unableToCreateInstanceOf ( e , DocumentBuilder . class . getName ( ) ) ; } }
Creates a new DocumentBuilder instance using the provided DocumentBuilderFactory
19,615
public static Element parse ( String xmlString ) throws IOException { try { return parse ( new ByteArrayInputStream ( xmlString . getBytes ( "UTF-8" ) ) ) ; } catch ( IOException e ) { ROOT_LOGGER . cannotParse ( xmlString ) ; throw e ; } }
Parse the given XML string and return the root Element This uses the document builder associated with the current thread .
19,616
public static Element parse ( InputStream xmlStream , DocumentBuilder builder ) throws IOException { try { Document doc ; synchronized ( builder ) { doc = builder . parse ( xmlStream ) ; } return doc . getDocumentElement ( ) ; } catch ( SAXException se ) { throw new IOException ( se . toString ( ) ) ; } finally { xmlStream . close ( ) ; } }
Parse the given XML stream and return the root Element
19,617
public static Element parse ( InputStream xmlStream ) throws IOException { DocumentBuilder builder = getDocumentBuilder ( ) ; return parse ( xmlStream , builder ) ; }
Parse the given XML stream and return the root Element This uses the document builder associated with the current thread .
19,618
public static Element parse ( InputSource source ) throws IOException { try { Document doc ; DocumentBuilder builder = getDocumentBuilder ( ) ; synchronized ( builder ) { doc = builder . parse ( source ) ; } return doc . getDocumentElement ( ) ; } catch ( SAXException se ) { throw new IOException ( se . toString ( ) ) ; } finally { InputStream is = source . getByteStream ( ) ; if ( is != null ) { is . close ( ) ; } Reader r = source . getCharacterStream ( ) ; if ( r != null ) { r . close ( ) ; } } }
Parse the given input source and return the root Element . This uses the document builder associated with the current thread .
19,619
public static Element createElement ( String localPart ) { Document doc = getOwnerDocument ( ) ; if ( ROOT_LOGGER . isTraceEnabled ( ) ) ROOT_LOGGER . trace ( "createElement {}" + localPart ) ; return doc . createElement ( localPart ) ; }
Create an Element for a given name . This uses the document builder associated with the current thread .
19,620
public static Element createElement ( String localPart , String prefix , String uri ) { Document doc = getOwnerDocument ( ) ; if ( prefix == null || prefix . length ( ) == 0 ) { if ( ROOT_LOGGER . isTraceEnabled ( ) ) ROOT_LOGGER . trace ( "createElement {" + uri + "}" + localPart ) ; return doc . createElementNS ( uri , localPart ) ; } else { if ( ROOT_LOGGER . isTraceEnabled ( ) ) ROOT_LOGGER . trace ( "createElement {" + uri + "}" + prefix + ":" + localPart ) ; return doc . createElementNS ( uri , prefix + ":" + localPart ) ; } }
Create an Element for a given name prefix and uri . This uses the document builder associated with the current thread .
19,621
public static Element createElement ( QName qname ) { return createElement ( qname . getLocalPart ( ) , qname . getPrefix ( ) , qname . getNamespaceURI ( ) ) ; }
Create an Element for a given QName . This uses the document builder associated with the current thread .
19,622
public static Text createTextNode ( String value ) { Document doc = getOwnerDocument ( ) ; return doc . createTextNode ( value ) ; }
Create a org . w3c . dom . Text node . This uses the document builder associated with the current thread .
19,623
public static Document getOwnerDocument ( ) { Document doc = documentThreadLocal . get ( ) ; if ( doc == null ) { doc = getDocumentBuilder ( ) . newDocument ( ) ; documentThreadLocal . set ( doc ) ; } return doc ; }
Get the owner document that is associated with the current thread
19,624
public static Element sourceToElement ( Source source ) throws IOException { Element retElement = null ; if ( source instanceof StreamSource ) { StreamSource streamSource = ( StreamSource ) source ; InputStream ins = streamSource . getInputStream ( ) ; if ( ins != null ) { retElement = DOMUtils . parse ( ins ) ; } Reader reader = streamSource . getReader ( ) ; if ( reader != null ) { retElement = DOMUtils . parse ( new InputSource ( reader ) ) ; } } else if ( source instanceof DOMSource ) { DOMSource domSource = ( DOMSource ) source ; Node node = domSource . getNode ( ) ; if ( node instanceof Element ) { retElement = ( Element ) node ; } else if ( node instanceof Document ) { retElement = ( ( Document ) node ) . getDocumentElement ( ) ; } } else if ( source instanceof SAXSource ) { final boolean hasInputSource = ( ( SAXSource ) source ) . getInputSource ( ) != null ; final boolean hasXMLReader = ( ( SAXSource ) source ) . getXMLReader ( ) != null ; if ( hasInputSource || hasXMLReader ) { try { TransformerFactory tf = TransformerFactory . newInstance ( ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( 1024 ) ; Transformer transformer = tf . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; transformer . setOutputProperty ( OutputKeys . METHOD , "xml" ) ; transformer . transform ( source , new StreamResult ( baos ) ) ; retElement = DOMUtils . parse ( new ByteArrayInputStream ( baos . toByteArray ( ) ) ) ; } catch ( TransformerException ex ) { throw new IOException ( ex ) ; } } } else { throw MESSAGES . sourceTypeNotImplemented ( source . getClass ( ) ) ; } return retElement ; }
Parse the contents of the provided source into an element . This uses the document builder associated with the current thread .
19,625
public static String node2String ( final Node node ) throws UnsupportedEncodingException { return node2String ( node , true , Constants . DEFAULT_XML_CHARSET ) ; }
Converts XML node in pretty mode using UTF - 8 encoding to string .
19,626
public static String node2String ( final Node node , boolean prettyPrint ) throws UnsupportedEncodingException { return node2String ( node , prettyPrint , Constants . DEFAULT_XML_CHARSET ) ; }
Converts XML node in specified pretty mode using UTF - 8 encoding to string .
19,627
public static String node2String ( final Node node , boolean prettyPrint , String encoding ) throws UnsupportedEncodingException { final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; new DOMWriter ( new PrintWriter ( baos ) , encoding ) . setPrettyprint ( prettyPrint ) . print ( node ) ; return baos . toString ( encoding ) ; }
Converts XML node in specified pretty mode and encoding to string .
19,628
public void setContextProperties ( Map < String , String > contextProperties ) { if ( contextProperties != null ) { this . contextProperties = new HashMap < String , String > ( 4 ) ; this . contextProperties . putAll ( contextProperties ) ; } }
This is called once at AS boot time during deployment aspect parsing ; this provided map is copied .
19,629
public String [ ] getParameterTypes ( ) { final String [ ] parameterTypes = this . parameterTypes ; return parameterTypes == NO_STRINGS ? parameterTypes : parameterTypes . clone ( ) ; }
Get the parameter type names as strings .
19,630
public Method getPublicMethod ( final Class < ? > clazz ) throws NoSuchMethodException , ClassNotFoundException { return clazz . getMethod ( name , typesOf ( parameterTypes , clazz . getClassLoader ( ) ) ) ; }
Look up a public method matching this method identifier using reflection .
19,631
public static MethodIdentifier getIdentifier ( final Class < ? > returnType , final String name , final Class < ? > ... parameterTypes ) { return new MethodIdentifier ( returnType . getName ( ) , name , namesOf ( parameterTypes ) ) ; }
Construct a new instance using class objects for the parameter types .
19,632
public static MethodIdentifier getIdentifier ( final String returnType , final String name , final String ... parameterTypes ) { return new MethodIdentifier ( returnType , name , parameterTypes ) ; }
Construct a new instance using string names for the return and parameter types .
19,633
public ProxyConfiguration < T > setProxyName ( final Package pkg , final String simpleName ) { this . proxyName = pkg . getName ( ) + '.' + simpleName ; return this ; }
Sets the proxy name
19,634
public static Class < ? > loadJavaType ( String typeName , ClassLoader classLoader ) throws ClassNotFoundException { if ( classLoader == null ) classLoader = getContextClassLoader ( ) ; Class < ? > javaType = primitiveNames . get ( typeName ) ; if ( javaType == null ) javaType = getArray ( typeName , classLoader ) ; if ( javaType == null ) javaType = classLoader . loadClass ( typeName ) ; return javaType ; }
Load a Java type from a given class loader .
19,635
public static boolean isPrimitive ( Class < ? > javaType ) { return javaType . isPrimitive ( ) || ( javaType . isArray ( ) && isPrimitive ( javaType . getComponentType ( ) ) ) ; }
True if the given class is a primitive or array of which .
19,636
public static String getJustClassName ( Class < ? > cls ) { if ( cls == null ) return null ; if ( cls . isArray ( ) ) { Class < ? > c = cls . getComponentType ( ) ; return getJustClassName ( c . getName ( ) ) ; } return getJustClassName ( cls . getName ( ) ) ; }
Given a class strip out the package name
19,637
public static String getJustClassName ( String classname ) { int index = classname . lastIndexOf ( '.' ) ; if ( index < 0 ) index = 0 ; else index = index + 1 ; return classname . substring ( index ) ; }
Given a FQN of a class strip out the package name
19,638
public static Class < ? > getPrimitiveType ( Class < ? > javaType ) { if ( javaType == Integer . class ) return int . class ; if ( javaType == Short . class ) return short . class ; if ( javaType == Boolean . class ) return boolean . class ; if ( javaType == Byte . class ) return byte . class ; if ( javaType == Long . class ) return long . class ; if ( javaType == Double . class ) return double . class ; if ( javaType == Float . class ) return float . class ; if ( javaType == Character . class ) return char . class ; if ( javaType == Integer [ ] . class ) return int [ ] . class ; if ( javaType == Short [ ] . class ) return short [ ] . class ; if ( javaType == Boolean [ ] . class ) return boolean [ ] . class ; if ( javaType == Byte [ ] . class ) return byte [ ] . class ; if ( javaType == Long [ ] . class ) return long [ ] . class ; if ( javaType == Double [ ] . class ) return double [ ] . class ; if ( javaType == Float [ ] . class ) return float [ ] . class ; if ( javaType == Character [ ] . class ) return char [ ] . class ; if ( javaType . isArray ( ) && javaType . getComponentType ( ) . isArray ( ) ) { Class < ? > compType = getPrimitiveType ( javaType . getComponentType ( ) ) ; return Array . newInstance ( compType , 0 ) . getClass ( ) ; } return javaType ; }
Get the corresponding primitive for a give wrapper type . Also handles arrays of which .
19,639
public static Object getPrimitiveValueArray ( Object value ) { if ( value == null ) return null ; Class < ? > javaType = value . getClass ( ) ; if ( javaType . isArray ( ) ) { int length = Array . getLength ( value ) ; Object destArr = Array . newInstance ( getPrimitiveType ( javaType . getComponentType ( ) ) , length ) ; for ( int i = 0 ; i < length ; i ++ ) { Object srcObj = Array . get ( value , i ) ; Array . set ( destArr , i , getPrimitiveValueArray ( srcObj ) ) ; } return destArr ; } return value ; }
Converts an n - dimensional array of wrapper types to primitive types
19,640
public static boolean isAssignableFrom ( Class < ? > dest , Class < ? > src ) { if ( dest == null || src == null ) throw MESSAGES . cannotCheckClassIsAssignableFrom ( dest , src ) ; boolean isAssignable = dest . isAssignableFrom ( src ) ; if ( isAssignable == false && dest . getName ( ) . equals ( src . getName ( ) ) ) { ClassLoader destLoader = dest . getClassLoader ( ) ; ClassLoader srcLoader = src . getClassLoader ( ) ; if ( ROOT_LOGGER . isTraceEnabled ( ) ) ROOT_LOGGER . notAssignableDueToConflictingClassLoaders ( dest , src , destLoader , srcLoader ) ; } if ( isAssignable == false && isPrimitive ( dest ) ) { dest = getWrapperType ( dest ) ; isAssignable = dest . isAssignableFrom ( src ) ; } if ( isAssignable == false && isPrimitive ( src ) ) { src = getWrapperType ( src ) ; isAssignable = dest . isAssignableFrom ( src ) ; } return isAssignable ; }
Return true if the dest class is assignable from the src . Also handles arrays and primitives .
19,641
public static Class < ? > erasure ( Type type ) { if ( type instanceof ParameterizedType ) { return erasure ( ( ( ParameterizedType ) type ) . getRawType ( ) ) ; } if ( type instanceof TypeVariable < ? > ) { return erasure ( ( ( TypeVariable < ? > ) type ) . getBounds ( ) [ 0 ] ) ; } if ( type instanceof WildcardType ) { return erasure ( ( ( WildcardType ) type ) . getUpperBounds ( ) [ 0 ] ) ; } if ( type instanceof GenericArrayType ) { return Array . newInstance ( erasure ( ( ( GenericArrayType ) type ) . getGenericComponentType ( ) ) , 0 ) . getClass ( ) ; } return ( Class < ? > ) type ; }
Erases a type according to the JLS type erasure rules
19,642
public static boolean isJBossRepositoryClassLoader ( ClassLoader loader ) { Class < ? > clazz = loader . getClass ( ) ; while ( ! clazz . getName ( ) . startsWith ( "java" ) ) { if ( "org.jboss.mx.loading.RepositoryClassLoader" . equals ( clazz . getName ( ) ) ) return true ; clazz = clazz . getSuperclass ( ) ; } return false ; }
Tests if this class loader is a JBoss RepositoryClassLoader
19,643
public static void clearBlacklists ( ClassLoader loader ) { if ( isJBossRepositoryClassLoader ( loader ) ) { for ( Method m : loader . getClass ( ) . getMethods ( ) ) { if ( "clearBlackLists" . equalsIgnoreCase ( m . getName ( ) ) ) { try { m . invoke ( loader ) ; } catch ( Exception e ) { if ( ROOT_LOGGER . isTraceEnabled ( ) ) ROOT_LOGGER . couldNotClearBlacklist ( loader , e ) ; } } } } }
Clears black lists on a JBoss RepositoryClassLoader . This is somewhat of a hack and could be replaced with an integration module . This is needed when the following order of events occur .
19,644
private static String getName ( final String resourceName , final String fallBackName ) { return resourceName . length ( ) > 0 ? resourceName : fallBackName ; }
Returns JNDI resource name .
19,645
private static String convertToBeanName ( final String methodName ) { return Character . toLowerCase ( methodName . charAt ( 3 ) ) + methodName . substring ( 4 ) ; }
Translates setBeanName to beanName string .
19,646
protected final Method getImplMethod ( final Class < ? > implClass , final Method seiMethod ) throws NoSuchMethodException { final String methodName = seiMethod . getName ( ) ; final Class < ? > [ ] paramTypes = seiMethod . getParameterTypes ( ) ; return implClass . getMethod ( methodName , paramTypes ) ; }
Returns implementation method that will be used for invocation .
19,647
@ SuppressWarnings ( "rawtypes" ) public void setupConfigHandlers ( Binding binding , CommonConfig config ) { if ( config != null ) { List < Handler > userHandlers = getNonConfigHandlers ( binding . getHandlerChain ( ) ) ; List < Handler > handlers = convertToHandlers ( config . getPreHandlerChains ( ) , binding . getBindingID ( ) , true ) ; handlers . addAll ( userHandlers ) ; handlers . addAll ( convertToHandlers ( config . getPostHandlerChains ( ) , binding . getBindingID ( ) , false ) ) ; binding . setHandlerChain ( handlers ) ; } }
Setups a given Binding instance using a specified CommonConfig
19,648
public T newInstance ( InvocationHandler handler ) throws InstantiationException , IllegalAccessException { T ret = newInstance ( ) ; setInvocationHandler ( ret , handler ) ; return ret ; }
Create a new proxy initialising it with the given invocation handler .
19,649
public void setInvocationHandler ( Object proxy , InvocationHandler handler ) { Field field = getInvocationHandlerField ( ) ; try { field . set ( proxy , handler ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } }
Sets the invocation handler for a proxy created from this factory .
19,650
public InvocationHandler getInvocationHandler ( Object proxy ) { Field field = getInvocationHandlerField ( ) ; try { return ( InvocationHandler ) field . get ( proxy ) ; } catch ( IllegalArgumentException e ) { throw new RuntimeException ( "Object is not a proxy of correct type" , e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } }
Returns the invocation handler for a proxy created from this factory .
19,651
public boolean isProxyClassDefined ( ClassLoader classLoader ) { try { classLoader . loadClass ( this . className ) ; return true ; } catch ( ClassNotFoundException e ) { return false ; } }
Checks if the proxy class has been defined in the given class loader
19,652
protected String getImplicitContextRoot ( ArchiveDeployment dep ) { String simpleName = dep . getSimpleName ( ) ; String contextRoot = simpleName . substring ( 0 , simpleName . length ( ) - 4 ) ; return contextRoot ; }
Use the implicit context root derived from the deployment name
19,653
public static void copyReader ( OutputStream outs , Reader reader ) throws IOException { try { OutputStreamWriter writer = new OutputStreamWriter ( outs , StandardCharsets . UTF_8 ) ; char [ ] bytes = new char [ 1024 ] ; int r = reader . read ( bytes ) ; while ( r > 0 ) { writer . write ( bytes , 0 , r ) ; r = reader . read ( bytes ) ; } } catch ( IOException e ) { throw e ; } finally { reader . close ( ) ; } }
Copy the reader to the output stream
19,654
public Object invoke ( final Object proxy , final Method method , final Object [ ] args ) throws Throwable { InterceptorContext context = new InterceptorContext ( ) ; context . setParameters ( args ) ; context . setMethod ( method ) ; return interceptor . processInvocation ( context ) ; }
Handle a proxy method invocation .
19,655
public static byte [ ] generateRandomUUIDBytes ( ) { if ( rand == null ) rand = new SecureRandom ( ) ; byte [ ] buffer = new byte [ 16 ] ; rand . nextBytes ( buffer ) ; buffer [ 6 ] = ( byte ) ( ( buffer [ 6 ] & 0x0f ) | 0x40 ) ; buffer [ 8 ] = ( byte ) ( ( buffer [ 8 ] & 0x3f ) | 0x80 ) ; return buffer ; }
Generates a pseudo random UUID and returns it in byte array form .
19,656
public static String convertToString ( byte [ ] uuid ) { if ( uuid . length != 16 ) throw Messages . MESSAGES . uuidMustBeOf16Bytes ( ) ; String string = bytesToHex ( uuid , 0 , 4 ) + "-" + bytesToHex ( uuid , 4 , 2 ) + "-" + bytesToHex ( uuid , 6 , 2 ) + "-" + bytesToHex ( uuid , 8 , 2 ) + "-" + bytesToHex ( uuid , 10 , 6 ) ; return string ; }
Converts a UUID in byte array form to the IETF string format .
19,657
public void afterClassLoad ( Class < ? > clazz ) { super . afterClassLoad ( clazz ) ; try { Class . forName ( clazz . getName ( ) , true , clazz . getClassLoader ( ) ) ; } catch ( ClassNotFoundException e ) { throw new RuntimeException ( e ) ; } }
Sets the accessible flag on the cached methods
19,658
static boolean isEscaped ( final String characters , final int position ) { int p = position ; int nbBackslash = 0 ; while ( p > 0 && characters . charAt ( -- p ) == '\\' ) { nbBackslash ++ ; } return ( nbBackslash % 2 == 1 ) ; }
Indicates if the character at the given position is escaped or not .
19,659
private Object wrappedAction ( final Context cx , final Scriptable scope , final Scriptable thisObj , final Object [ ] args , final int actionType ) { try { ScriptRuntime . setRegExpProxy ( cx , wrapped_ ) ; return wrapped_ . action ( cx , scope , thisObj , args , actionType ) ; } finally { ScriptRuntime . setRegExpProxy ( cx , this ) ; } }
Calls action on the wrapped RegExp proxy .
19,660
static String jsRegExpToJavaRegExp ( String re ) { re = re . replaceAll ( "\\[\\^\\\\\\d\\]" , "." ) ; re = re . replaceAll ( "\\[([^\\]]*)\\\\b([^\\]]*)\\]" , "[$1\\\\cH$2]" ) ; re = re . replaceAll ( "(?<!\\\\)\\[([^((?<!\\\\)\\[)\\]]*)\\[" , "[$1\\\\[" ) ; re = re . replaceAll ( "(?<!\\\\)\\[([^\\]]*)(?<!\\\\)\\\\\\d" , "[$1" ) ; re = re . replaceAll ( "(?<!\\\\)\\\\([ACE-RT-VX-Zaeg-mpqyz])" , "$1" ) ; re = escapeJSCurly ( re ) ; return re ; }
Transform a JavaScript regular expression to a Java regular expression
19,661
private void consumeInputFully ( HttpServletRequest req ) { try { ServletInputStream is = req . getInputStream ( ) ; while ( ! is . isFinished ( ) && is . read ( ) != - 1 ) { } } catch ( IOException e ) { log . info ( "Could not consume full client request" , e ) ; } }
connection - see SOLR - 8453 and SOLR - 8683
19,662
public void toSAX ( ContentHandler contentHandler ) throws SAXException { for ( SaxBit saxbit : this . saxbits ) { saxbit . send ( contentHandler ) ; } }
Stream this buffer into the provided content handler . If contentHandler object implements LexicalHandler it will get lexical events as well .
19,663
public void dump ( Writer writer ) throws IOException { Iterator < SaxBit > i = this . saxbits . iterator ( ) ; while ( i . hasNext ( ) ) { final SaxBit saxbit = i . next ( ) ; saxbit . dump ( writer ) ; } writer . flush ( ) ; }
Dump buffer contents into the provided writer .
19,664
public void addChild ( Tree t ) { if ( t == null ) { return ; } BaseTree childTree = ( BaseTree ) t ; if ( childTree . isNil ( ) ) { if ( this . children != null && this . children == childTree . children ) { throw new RuntimeException ( "attempt to add child list to itself" ) ; } if ( childTree . children != null ) { if ( this . children != null ) { int n = childTree . children . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { Tree c = ( Tree ) childTree . children . get ( i ) ; this . children . add ( c ) ; c . setParent ( this ) ; c . setChildIndex ( children . size ( ) - 1 ) ; } } else { this . children = childTree . children ; this . freshenParentAndChildIndexes ( ) ; } } } else { if ( children == null ) { children = createChildrenList ( ) ; } children . add ( t ) ; childTree . setParent ( this ) ; childTree . setChildIndex ( children . size ( ) - 1 ) ; } }
Add t as child of this node .
19,665
public void addChildren ( List < ? extends Tree > kids ) { for ( int i = 0 ; i < kids . size ( ) ; i ++ ) { Tree t = kids . get ( i ) ; addChild ( t ) ; } }
Add all elements of kids list as children of this node
19,666
public Tree getAncestor ( int ttype ) { Tree t = this ; t = t . getParent ( ) ; while ( t != null ) { if ( t . getType ( ) == ttype ) return t ; t = t . getParent ( ) ; } return null ; }
Walk upwards and get first ancestor with this token type .
19,667
public List < ? extends Tree > getAncestors ( ) { if ( getParent ( ) == null ) return null ; List < Tree > ancestors = new ArrayList < Tree > ( ) ; Tree t = this ; t = t . getParent ( ) ; while ( t != null ) { ancestors . add ( 0 , t ) ; t = t . getParent ( ) ; } return ancestors ; }
Return a list of all ancestors of this node . The first node of list is the root and the last is the parent of this node .
19,668
public String toStringTree ( ) { if ( children == null || children . isEmpty ( ) ) { return this . toString ( ) ; } StringBuilder buf = new StringBuilder ( ) ; if ( ! isNil ( ) ) { buf . append ( "(" ) ; buf . append ( this . toString ( ) ) ; buf . append ( ' ' ) ; } for ( int i = 0 ; children != null && i < children . size ( ) ; i ++ ) { Tree t = ( Tree ) children . get ( i ) ; if ( i > 0 ) { buf . append ( ' ' ) ; } buf . append ( t . toStringTree ( ) ) ; } if ( ! isNil ( ) ) { buf . append ( ")" ) ; } return buf . toString ( ) ; }
Print out a whole tree not just a node
19,669
public Obj work ( Obj cmd ) throws Exception { stopping = false ; return status ( ) . with ( P_STATUS , STATUS_STARTED ) ; }
null not run false err true ok
19,670
public String render ( SoyMapData model , String view ) throws IOException { return getSoyTofu ( null ) . newRenderer ( view ) . setData ( model ) . render ( ) ; }
simple helper method to quickly render a template
19,671
public Obj buildObject ( Object ... members ) { Obj o = newObject ( ) ; for ( int i = 0 ; i < members . length ; i += 2 ) { o . put ( ( String ) members [ i ] , members [ i + 1 ] ) ; } return o ; }
members in the form key val key val etc .
19,672
@ SuppressWarnings ( "unchecked" ) public < T > void sort ( Arr arr , Comparator < T > c ) { int l = arr . getLength ( ) ; Object [ ] objs = new Object [ l ] ; for ( int i = 0 ; i < l ; i ++ ) { objs [ i ] = arr . get ( i ) ; } Arrays . sort ( ( T [ ] ) objs , c ) ; for ( int i = 0 ; i < l ; i ++ ) { arr . put ( i , objs [ i ] ) ; } }
can lead to classcastexception if comparator is not of the right type
19,673
public JsonTransformer build ( ) { try { return new WrappingTransformer ( buildPipe ( ) ) ; } catch ( Exception e ) { throw new RuntimeException ( "Failed to build pipeline: " + e . getMessage ( ) , e ) ; } }
Build a raw pipeline without a terminating transformer . It is the caller s responsibility to set the final transformer (
19,674
public List < String > getSearchDimensions ( ) { List < String > dimensions = new ArrayList < String > ( ) ; for ( int i = 0 ; i < m_Space . dimensions ( ) ; ++ i ) { dimensions . add ( m_Space . getDimension ( i ) . getLabel ( ) ) ; } return dimensions ; }
Returns the search dimensions
19,675
protected String logPerformances ( Space space , Vector < Performance > performances , Tag type ) { return m_Owner . logPerformances ( space , performances , type ) ; }
generates a table string for all the performances in the space and returns that .
19,676
protected void logPerformances ( Space space , Vector < Performance > performances ) { m_Owner . logPerformances ( space , performances ) ; }
aligns all performances in the space and prints those tables to the log file .
19,677
public void addPerformance ( Performance performance , int folds ) { m_Performances . add ( performance ) ; m_Cache . add ( folds , performance ) ; m_Trace . add ( new AbstractMap . SimpleEntry < Integer , Performance > ( folds , performance ) ) ; }
Adds the performance to the cache and the current list of performances .
19,678
public List < Entry < String , Object > > getTraceParameterSettings ( int index ) { List < Entry < String , Object > > result = new ArrayList < Map . Entry < String , Object > > ( ) ; List < String > dimensions = getSearchDimensions ( ) ; for ( int i = 0 ; i < dimensions . size ( ) ; ++ i ) { String parameter = dimensions . get ( i ) ; Object value = m_Trace . get ( index ) . getValue ( ) . getValues ( ) . getValue ( i ) ; Map . Entry < String , Object > current = new AbstractMap . SimpleEntry < String , Object > ( parameter , value ) ; result . add ( i , current ) ; } return result ; }
Returns the parameter settings in structured way
19,679
public SearchResult search ( Instances data ) throws Exception { SearchResult result ; SearchResult best ; try { log ( "\n" + getClass ( ) . getName ( ) + "\n" + getClass ( ) . getName ( ) . replaceAll ( "." , "=" ) + "\n" + "Options: " + Utils . joinOptions ( getOptions ( ) ) + "\n" ) ; log ( "\n- ) ; check ( data ) ; log ( "\n- ) ; preSearch ( data ) ; log ( "\n- ) ; best = doSearch ( data ) ; log ( "\n- ) ; result = postSearch ( data , best ) ; } catch ( Exception e ) { throw e ; } finally { cleanUpSearch ( ) ; } return result ; }
Performs the search and returns the best setup .
19,680
public void cleanUp ( ) { m_Owner = null ; m_Train = null ; m_Test = null ; m_Generator = null ; m_Values = null ; }
Cleans up after the task finishes .
19,681
public int compareTo ( Point < E > obj ) { if ( obj == null ) return - 1 ; if ( dimensions ( ) != obj . dimensions ( ) ) return - 1 ; for ( int i = 0 ; i < dimensions ( ) ; i ++ ) { if ( getValue ( i ) . getClass ( ) != obj . getValue ( i ) . getClass ( ) ) return - 1 ; if ( getValue ( i ) instanceof Double ) { if ( Utils . sm ( ( Double ) getValue ( i ) , ( Double ) obj . getValue ( i ) ) ) { return - 1 ; } else if ( Utils . gr ( ( Double ) getValue ( i ) , ( Double ) obj . getValue ( i ) ) ) { return 1 ; } } else { int r = getValue ( i ) . toString ( ) . compareTo ( obj . getValue ( i ) . toString ( ) ) ; if ( r != 0 ) { return r ; } } } return 0 ; }
Compares the given point with this point .
19,682
public Space subspace ( Point < Integer > center ) { Space result ; SpaceDimension [ ] dimensions ; int i ; dimensions = new SpaceDimension [ dimensions ( ) ] ; for ( i = 0 ; i < dimensions . length ; i ++ ) dimensions [ i ] = getDimension ( i ) . subdimension ( center . getValue ( i ) - 1 , center . getValue ( i ) + 1 ) ; result = new Space ( dimensions ) ; return result ; }
Returns a subspace around the given point with just one more neighbor left and right on each dimension .
19,683
protected boolean inc ( Integer [ ] locations , int [ ] max ) { boolean result ; int i ; result = true ; i = 0 ; while ( i < locations . length ) { if ( locations [ i ] < max [ i ] - 1 ) { locations [ i ] ++ ; break ; } else { locations [ i ] = 0 ; i ++ ; if ( i == locations . length ) result = false ; } } return result ; }
Increments the location array by 1 .
19,684
protected Vector < Point < Integer > > listPoints ( ) { Vector < Point < Integer > > result ; int i ; int [ ] max ; Integer [ ] locations ; boolean ok ; result = new Vector < Point < Integer > > ( ) ; max = new int [ dimensions ( ) ] ; for ( i = 0 ; i < max . length ; i ++ ) max [ i ] = getDimension ( i ) . width ( ) ; locations = new Integer [ dimensions ( ) ] ; for ( i = 0 ; i < locations . length ; i ++ ) locations [ i ] = 0 ; result . add ( new Point < Integer > ( locations ) ) ; ok = true ; while ( ok ) { ok = inc ( locations , max ) ; if ( ok ) result . add ( new Point < Integer > ( locations ) ) ; } return result ; }
returns a Vector with all points in the space .
19,685
protected String getID ( int cv , Point < Object > values ) { String result ; int i ; result = "" + cv ; for ( i = 0 ; i < values . dimensions ( ) ; i ++ ) result += "\t" + values . getValue ( i ) ; return result ; }
returns the ID string for a cache item .
19,686
public Performance get ( int cv , Point < Object > values ) { return m_Cache . get ( getID ( cv , values ) ) ; }
returns a cached performance object null if not yet in the cache .
19,687
public void add ( int cv , Performance p ) { m_Cache . put ( getID ( cv , p . getValues ( ) ) , p ) ; }
adds the performance to the cache .
19,688
public DefaultEvaluationTask newTask ( MultiSearchCapable owner , Instances train , Instances test , SetupGenerator generator , Point < Object > values , int folds , int eval , int classLabel ) { return new DefaultEvaluationTask ( owner , train , test , generator , values , folds , eval , classLabel ) ; }
Returns a new task .
19,689
public boolean check ( int id ) { for ( Tag tag : getTags ( ) ) { if ( tag . getID ( ) == id ) return true ; } return false ; }
Returns whether the ID is valid .
19,690
public double getMetric ( int id , int classLabel ) { try { switch ( id ) { case DefaultEvaluationMetrics . EVALUATION_CC : return m_Evaluation . correlationCoefficient ( ) ; case DefaultEvaluationMetrics . EVALUATION_MATTHEWS_CC : return m_Evaluation . matthewsCorrelationCoefficient ( 0 ) ; case DefaultEvaluationMetrics . EVALUATION_RMSE : return m_Evaluation . rootMeanSquaredError ( ) ; case DefaultEvaluationMetrics . EVALUATION_RRSE : return m_Evaluation . rootRelativeSquaredError ( ) ; case DefaultEvaluationMetrics . EVALUATION_MAE : return m_Evaluation . meanAbsoluteError ( ) ; case DefaultEvaluationMetrics . EVALUATION_RAE : return m_Evaluation . relativeAbsoluteError ( ) ; case DefaultEvaluationMetrics . EVALUATION_COMBINED : return ( 1 - StrictMath . abs ( m_Evaluation . correlationCoefficient ( ) ) + m_Evaluation . rootRelativeSquaredError ( ) + m_Evaluation . relativeAbsoluteError ( ) ) ; case DefaultEvaluationMetrics . EVALUATION_ACC : return m_Evaluation . pctCorrect ( ) ; case DefaultEvaluationMetrics . EVALUATION_KAPPA : return m_Evaluation . kappa ( ) ; case DefaultEvaluationMetrics . EVALUATION_PRECISION : return m_Evaluation . precision ( classLabel ) ; case DefaultEvaluationMetrics . EVALUATION_WEIGHTED_PRECISION : return m_Evaluation . weightedPrecision ( ) ; case DefaultEvaluationMetrics . EVALUATION_RECALL : return m_Evaluation . recall ( classLabel ) ; case DefaultEvaluationMetrics . EVALUATION_WEIGHTED_RECALL : return m_Evaluation . weightedRecall ( ) ; case DefaultEvaluationMetrics . EVALUATION_AUC : return m_Evaluation . areaUnderROC ( classLabel ) ; case DefaultEvaluationMetrics . EVALUATION_WEIGHTED_AUC : return m_Evaluation . weightedAreaUnderROC ( ) ; case DefaultEvaluationMetrics . EVALUATION_PRC : return m_Evaluation . areaUnderPRC ( classLabel ) ; case DefaultEvaluationMetrics . EVALUATION_WEIGHTED_PRC : return m_Evaluation . weightedAreaUnderPRC ( ) ; case DefaultEvaluationMetrics . EVALUATION_FMEASURE : return m_Evaluation . fMeasure ( classLabel ) ; case DefaultEvaluationMetrics . EVALUATION_WEIGHTED_FMEASURE : return m_Evaluation . weightedFMeasure ( ) ; case DefaultEvaluationMetrics . EVALUATION_TRUE_POSITIVE_RATE : return m_Evaluation . truePositiveRate ( classLabel ) ; case DefaultEvaluationMetrics . EVALUATION_TRUE_NEGATIVE_RATE : return m_Evaluation . trueNegativeRate ( classLabel ) ; case DefaultEvaluationMetrics . EVALUATION_FALSE_POSITIVE_RATE : return m_Evaluation . falsePositiveRate ( classLabel ) ; case DefaultEvaluationMetrics . EVALUATION_FALSE_NEGATIVE_RATE : return m_Evaluation . falseNegativeRate ( classLabel ) ; default : return Double . NaN ; } } catch ( Exception e ) { return Double . NaN ; } }
Returns the metric for the given ID .
19,691
public boolean invert ( int id ) { switch ( id ) { case EVALUATION_CC : case EVALUATION_ACC : case EVALUATION_KAPPA : case EVALUATION_MATTHEWS_CC : case EVALUATION_PRECISION : case EVALUATION_WEIGHTED_PRECISION : case EVALUATION_RECALL : case EVALUATION_WEIGHTED_RECALL : case EVALUATION_AUC : case EVALUATION_WEIGHTED_AUC : case EVALUATION_PRC : case EVALUATION_WEIGHTED_PRC : case EVALUATION_FMEASURE : case EVALUATION_WEIGHTED_FMEASURE : case EVALUATION_TRUE_POSITIVE_RATE : case EVALUATION_TRUE_NEGATIVE_RATE : return true ; default : return false ; } }
Returns whether to negate the metric for sorting purposes .
19,692
public String [ ] getItems ( ) throws Exception { String [ ] result ; if ( getCustomDelimiter ( ) . isEmpty ( ) ) result = Utils . splitOptions ( getList ( ) ) ; else result = getList ( ) . split ( getCustomDelimiter ( ) ) ; return result ; }
Splits the list string using the appropriate delimiter .
19,693
public SpaceDimension spaceDimension ( ) throws Exception { String [ ] items ; items = getItems ( ) ; return new ListSpaceDimension ( 0 , items . length - 1 , items , getProperty ( ) ) ; }
Returns the parameter as space dimensions .
19,694
public boolean getBooleanSetting ( final ChaiSetting setting ) { final String settingValue = getSetting ( setting ) ; return StringHelper . convertStrToBoolean ( settingValue ) ; }
Get an individual setting value and test it as a boolean .
19,695
public List < String > bindURLsAsList ( ) { final List < String > splitUrls = Arrays . asList ( getSetting ( ChaiSetting . BIND_URLS ) . split ( LDAP_URL_SEPARATOR_REGEX_PATTERN ) ) ; return Collections . unmodifiableList ( splitUrls ) ; }
Returns an immutable list of the ldap URLs .
19,696
private static void pause ( final long time ) { final long startTime = System . currentTimeMillis ( ) ; do { try { final long sleepTime = time - ( System . currentTimeMillis ( ) - startTime ) ; Thread . sleep ( sleepTime > 0 ? sleepTime : 10 ) ; } catch ( InterruptedException e ) { } } while ( ( System . currentTimeMillis ( ) - startTime ) < time ) ; }
Causes the executing thread to pause for a period of time .
19,697
public static ChaiResponseSet newChaiResponseSet ( final Map < Challenge , String > challengeResponseMap , final Locale locale , final int minimumRandomRequired , final ChaiConfiguration chaiConfiguration , final String csIdentifier ) throws ChaiValidationException { return newChaiResponseSet ( challengeResponseMap , Collections . emptyMap ( ) , locale , minimumRandomRequired , chaiConfiguration , csIdentifier ) ; }
Create a new ResponseSet . The generated ResponseSet will be suitable for writing to the directory .
19,698
private void checkTimer ( ) { try { serviceThreadLock . lock ( ) ; if ( watchdogTimer == null ) { if ( ! issuedWatchdogWrappers . allValues ( ) . isEmpty ( ) ) { LOGGER . debug ( "starting up " + THREAD_NAME + ", " + watchdogFrequency + "ms check frequency" ) ; startWatchdogThread ( ) ; } } } finally { serviceThreadLock . unlock ( ) ; } }
Regulate the timer . This is important because the timer task creates its own thread and if the task isn t cleaned up there could be a thread leak .
19,699
public static ConfigObjectRecord createNew ( final ChaiEntry entry , final String attr , final String recordType , final String guid1 , final String guid2 ) { if ( entry == null ) { throw new NullPointerException ( "entry can not be null" ) ; } if ( recordType == null ) { throw new NullPointerException ( "recordType can not be null" ) ; } if ( attr == null ) { throw new NullPointerException ( "attr can not be null" ) ; } final String effectiveRecordType = recordType . length ( ) > 4 ? recordType . substring ( 0 , 4 ) : recordType ; final ConfigObjectRecord cor = new ConfigObjectRecord ( ) ; cor . objectEntry = entry ; cor . attr = attr ; cor . recordType = effectiveRecordType ; cor . guid1 = ( guid1 == null || guid1 . length ( ) < 1 ) ? EMPTY_RECORD_VALUE : guid1 ; cor . guid2 = ( guid2 == null || guid2 . length ( ) < 1 ) ? EMPTY_RECORD_VALUE : guid2 ; return cor ; }
Create a new config object record . This will only create a java object representing the config object record . It is up to the caller to call the updatePayload method which will actually commit the record to the directory .