idx int64 0 41.2k | question stringlengths 83 4.15k | target stringlengths 5 715 |
|---|---|---|
10,500 | public void createNewSecurityDomain ( String securityDomainName , LoginModuleRequest ... loginModules ) throws Exception { CoreJBossASClient coreClient = new CoreJBossASClient ( getModelControllerClient ( ) ) ; String serverVersion = coreClient . getAppServerVersion ( ) ; if ( serverVersion . startsWith ( "7.2" ) ) { createNewSecurityDomain72 ( securityDomainName , loginModules ) ; } else { createNewSecurityDomain71 ( securityDomainName , loginModules ) ; } } | Creates a new security domain including one or more login modules . The security domain will be replaced if it exists . |
10,501 | public boolean securityDomainHasLoginModule ( String domainName , String moduleName ) throws Exception { Address addr = Address . root ( ) . add ( SUBSYSTEM , SUBSYSTEM_SECURITY , SECURITY_DOMAIN , domainName ) ; addr . add ( AUTHENTICATION , CLASSIC ) ; addr . add ( LOGIN_MODULE , moduleName ) ; ModelNode request = createRequest ( "read-resource" , addr ) ; ModelNode response = execute ( request ) ; return isSuccess ( response ) ; } | Check if a certain login module is present inside the passed security domain |
10,502 | private static < L > void populateMetricTypesForResourceType ( ResourceType . Builder < ? , L > resourceTypeBuilder , TypeSets . Builder < L > typeSetsBuilder ) { Map < Name , TypeSet < MetricType < L > > > metricTypeSets = typeSetsBuilder . getMetricTypeSets ( ) ; List < Name > metricSetNames = resourceTypeBuilder . getMetricSetNames ( ) ; for ( Name metricSetName : metricSetNames ) { TypeSet < MetricType < L > > metricSet = metricTypeSets . get ( metricSetName ) ; if ( metricSet != null && metricSet . isEnabled ( ) ) { resourceTypeBuilder . metricTypes ( metricSet . getTypeMap ( ) . values ( ) ) ; } } } | Given a resource type builder this will fill in its metric types . |
10,503 | public < N , S extends Session < L > > void discoverChildren ( Resource < L > parent , ResourceType < L > childType , Session < L > session , EndpointService < L , S > service , Consumer < Resource < L > > resourceConsumer ) { try { L parentLocation = parent != null ? parent . getLocation ( ) : null ; log . debugf ( "Discovering children of [%s] of type [%s]" , parent , childType ) ; final L childQuery = session . getLocationResolver ( ) . absolutize ( parentLocation , childType . getLocation ( ) ) ; Map < L , N > nativeResources = session . getDriver ( ) . fetchNodes ( childQuery ) ; for ( Map . Entry < L , N > entry : nativeResources . entrySet ( ) ) { L location = entry . getKey ( ) ; String resourceName = session . getLocationResolver ( ) . applyTemplate ( childType . getResourceNameTemplate ( ) , location , session . getEndpoint ( ) . getName ( ) ) ; ID id = InventoryIdUtil . generateResourceId ( session . getFeedId ( ) , session . getEndpoint ( ) , location . toString ( ) ) ; Builder < L > builder = Resource . < L > builder ( ) . id ( id ) . name ( new Name ( resourceName ) ) . location ( location ) . type ( childType ) ; if ( parent != null ) { builder . parent ( parent ) ; } discoverResourceConfiguration ( id , childType , location , entry . getValue ( ) , builder , session ) ; addMetricInstances ( id , childType , location , entry . getValue ( ) , builder , session ) ; Resource < L > resource = builder . build ( ) ; for ( MeasurementInstance < L , MetricType < L > > instance : resource . getMetrics ( ) ) { instance . setMetricFamily ( service . generateMetricFamily ( instance ) ) ; instance . setMetricLabels ( service . generateMetricLabels ( instance ) ) ; } log . debugf ( "Discovered resource [%s]" , resource ) ; if ( resourceConsumer != null ) { resourceConsumer . accept ( resource ) ; } Set < ResourceType < L > > childTypes = session . getResourceTypeManager ( ) . getChildren ( childType ) ; for ( ResourceType < L > nextLevelChildType : childTypes ) { discoverChildren ( resource , nextLevelChildType , session , service , resourceConsumer ) ; } } } catch ( Exception e ) { log . errorFailedToDiscoverResources ( e , session . getEndpoint ( ) ) ; resourceConsumer . report ( e ) ; } } | Discovers children of the given type underneath the given parent . |
10,504 | public void doScrape ( ) throws Exception { MBeanServerConnection beanConn ; JMXConnector jmxc = null ; if ( jmxUrl . isEmpty ( ) ) { beanConn = ManagementFactory . getPlatformMBeanServer ( ) ; } else { Map < String , Object > environment = new HashMap < String , Object > ( ) ; if ( username != null && username . length ( ) != 0 && password != null && password . length ( ) != 0 ) { String [ ] credent = new String [ ] { username , password } ; environment . put ( javax . management . remote . JMXConnector . CREDENTIALS , credent ) ; } if ( ssl ) { environment . put ( Context . SECURITY_PROTOCOL , "ssl" ) ; SslRMIClientSocketFactory clientSocketFactory = new SslRMIClientSocketFactory ( ) ; environment . put ( RMIConnectorServer . RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE , clientSocketFactory ) ; environment . put ( "com.sun.jndi.rmi.factory.socket" , clientSocketFactory ) ; } jmxc = JMXConnectorFactory . connect ( new JMXServiceURL ( jmxUrl ) , environment ) ; beanConn = jmxc . getMBeanServerConnection ( ) ; } try { Set < ObjectInstance > mBeanNames = new HashSet ( ) ; for ( ObjectName name : whitelistObjectNames ) { mBeanNames . addAll ( beanConn . queryMBeans ( name , null ) ) ; } for ( ObjectName name : whitelistObjectInstances ) { mBeanNames . add ( beanConn . getObjectInstance ( name ) ) ; } for ( ObjectName name : blacklistObjectNames ) { mBeanNames . removeAll ( beanConn . queryMBeans ( name , null ) ) ; } for ( ObjectName name : blacklistObjectInstances ) { mBeanNames . remove ( beanConn . getObjectInstance ( name ) ) ; } for ( ObjectInstance name : mBeanNames ) { long start = System . nanoTime ( ) ; scrapeBean ( beanConn , name . getObjectName ( ) ) ; logger . fine ( "TIME: " + ( System . nanoTime ( ) - start ) + " ns for " + name . getObjectName ( ) . toString ( ) ) ; } } finally { if ( jmxc != null ) { jmxc . close ( ) ; } } } | Get a list of mbeans on host_port and scrape their values . |
10,505 | public boolean isCacheContainer ( String cacheContainerName ) throws Exception { Address addr = Address . root ( ) . add ( SUBSYSTEM , SUBSYSTEM_INFINISPAN ) ; String haystack = CACHE_CONTAINER ; return null != findNodeInList ( addr , haystack , cacheContainerName ) ; } | Checks to see if there is already a cache container with the given name . |
10,506 | public boolean isLocalCache ( String cacheContainerName , String localCacheName ) throws Exception { if ( ! isCacheContainer ( cacheContainerName ) ) { return false ; } Address addr = Address . root ( ) . add ( SUBSYSTEM , SUBSYSTEM_INFINISPAN , CACHE_CONTAINER , cacheContainerName ) ; String haystack = LOCAL_CACHE ; return null != findNodeInList ( addr , haystack , localCacheName ) ; } | Checks to see if there is already a local cache with the given name . |
10,507 | public boolean isJDBCDriver ( String jdbcDriverName ) throws Exception { Address addr = Address . root ( ) . add ( SUBSYSTEM , SUBSYSTEM_DATASOURCES ) ; String haystack = JDBC_DRIVER ; return null != findNodeInList ( addr , haystack , jdbcDriverName ) ; } | Checks to see if there is already a JDBC driver with the given name . |
10,508 | public boolean isDatasource ( String datasourceName ) throws Exception { Address addr = Address . root ( ) . add ( SUBSYSTEM , SUBSYSTEM_DATASOURCES ) ; String haystack = DATA_SOURCE ; return null != findNodeInList ( addr , haystack , datasourceName ) ; } | Checks to see if there is already a datasource with the given name . |
10,509 | public boolean isXADatasource ( String datasourceName ) throws Exception { Address addr = Address . root ( ) . add ( SUBSYSTEM , SUBSYSTEM_DATASOURCES ) ; String haystack = XA_DATA_SOURCE ; return null != findNodeInList ( addr , haystack , datasourceName ) ; } | Checks to see if there is already a XA datasource with the given name . |
10,510 | public ModelNode createNewDatasourceRequest ( String name , int blockingTimeoutWaitMillis , String connectionUrlExpression , String driverName , String exceptionSorterClassName , int idleTimeoutMinutes , boolean jta , int minPoolSize , int maxPoolSize , int preparedStatementCacheSize , String securityDomain , String staleConnectionCheckerClassName , String transactionIsolation , String validConnectionCheckerClassName , boolean validateOnMatch , Map < String , String > connectionProperties ) { String jndiName = "java:jboss/datasources/" + name ; String dmrTemplate = "" + "{" + "\"blocking-timeout-wait-millis\" => %dL " + ", \"connection-url\" => expression \"%s\" " + ", \"driver-name\" => \"%s\" " + ", \"exception-sorter-class-name\" => \"%s\" " + ", \"idle-timeout-minutes\" => %dL " + ", \"jndi-name\" => \"%s\" " + ", \"jta\" => %s " + ", \"min-pool-size\" => %d " + ", \"max-pool-size\" => %d " + ", \"prepared-statements-cache-size\" => %dL " + ", \"security-domain\" => \"%s\" " + ", \"stale-connection-checker-class-name\" => \"%s\" " + ", \"transaction-isolation\" => \"%s\" " + ", \"use-java-context\" => true " + ", \"valid-connection-checker-class-name\" => \"%s\" " + ", \"validate-on-match\" => %s " + "}" ; String dmr = String . format ( dmrTemplate , blockingTimeoutWaitMillis , connectionUrlExpression , driverName , exceptionSorterClassName , idleTimeoutMinutes , jndiName , jta , minPoolSize , maxPoolSize , preparedStatementCacheSize , securityDomain , staleConnectionCheckerClassName , transactionIsolation , validConnectionCheckerClassName , validateOnMatch ) ; Address addr = Address . root ( ) . add ( SUBSYSTEM , SUBSYSTEM_DATASOURCES , DATA_SOURCE , name ) ; final ModelNode request1 = ModelNode . fromString ( dmr ) ; request1 . get ( OPERATION ) . set ( ADD ) ; request1 . get ( ADDRESS ) . set ( addr . getAddressNode ( ) ) ; if ( connectionProperties == null || connectionProperties . size ( ) == 0 ) { return request1 ; } ModelNode [ ] batch = new ModelNode [ 1 + connectionProperties . size ( ) ] ; batch [ 0 ] = request1 ; int n = 1 ; for ( Map . Entry < String , String > entry : connectionProperties . entrySet ( ) ) { addr = Address . root ( ) . add ( SUBSYSTEM , SUBSYSTEM_DATASOURCES , DATA_SOURCE , name , CONNECTION_PROPERTIES , entry . getKey ( ) ) ; final ModelNode requestN = new ModelNode ( ) ; requestN . get ( OPERATION ) . set ( ADD ) ; requestN . get ( ADDRESS ) . set ( addr . getAddressNode ( ) ) ; setPossibleExpression ( requestN , VALUE , entry . getValue ( ) ) ; batch [ n ++ ] = requestN ; } return createBatchRequest ( batch ) ; } | Returns a ModelNode that can be used to create a datasource . Callers are free to tweak the datasource request that is returned if they so choose before asking the client to execute the request . |
10,511 | public void add ( EndpointService < L , S > newEndpointService ) { if ( newEndpointService == null ) { throw new IllegalArgumentException ( "New endpoint service must not be null" ) ; } synchronized ( this . inventoryListeners ) { for ( InventoryListener listener : this . inventoryListeners ) { newEndpointService . addInventoryListener ( listener ) ; } } endpointServices . put ( newEndpointService . getMonitoredEndpoint ( ) . getName ( ) , newEndpointService ) ; newEndpointService . start ( ) ; log . infoAddedEndpointService ( newEndpointService . toString ( ) ) ; newEndpointService . discoverAll ( ) ; } | This will add a new endpoint service to the list . Once added the new service will immediately be started . |
10,512 | public void remove ( String name ) { EndpointService < L , S > service = endpointServices . remove ( name ) ; if ( service != null ) { service . stop ( ) ; log . infoRemovedEndpointService ( service . toString ( ) ) ; } } | This will stop the given endpoint service and remove it from the list of endpoint services . |
10,513 | public WebSocketCall createWebSocketCall ( String url , Map < String , String > headers ) { String base64Credentials = buildBase64Credentials ( ) ; Request . Builder requestBuilder = new Request . Builder ( ) . url ( url ) . addHeader ( "Authorization" , "Basic " + base64Credentials ) . addHeader ( "Accept" , "application/json" ) ; if ( headers != null ) { for ( Map . Entry < String , String > header : headers . entrySet ( ) ) { requestBuilder . addHeader ( header . getKey ( ) , header . getValue ( ) ) ; } } Request request = requestBuilder . build ( ) ; WebSocketCall wsc = WebSocketCall . create ( getHttpClient ( ) , request ) ; return wsc ; } | Creates a websocket that connects to the given URL . |
10,514 | public void stopHawkularAgent ( ) { synchronized ( agentServiceStatus ) { if ( agentServiceStatus . get ( ) == ServiceStatus . STOPPED ) { log . infoStoppedAlready ( ) ; return ; } else if ( agentServiceStatus . get ( ) == ServiceStatus . STOPPING ) { while ( agentServiceStatus . get ( ) == ServiceStatus . STOPPING ) { try { agentServiceStatus . wait ( 30000L ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; return ; } return ; } } setStatus ( ServiceStatus . STOPPING ) ; } log . infoStopping ( ) ; AtomicReference < Throwable > error = new AtomicReference < > ( null ) ; try { try { stopMetricsExporter ( ) ; } catch ( Throwable t ) { error . compareAndSet ( null , t ) ; log . debug ( "Cannot shutdown metrics exporter but will continue shutdown" , t ) ; } try { if ( feedComm != null ) { feedComm . destroy ( ) ; feedComm = null ; } } catch ( Throwable t ) { error . compareAndSet ( null , t ) ; log . debug ( "Cannot shutdown feed comm but will continue shutdown" , t ) ; } try { if ( protocolServices != null ) { protocolServices . stop ( ) ; if ( inventoryStorageProxy != null ) { protocolServices . removeInventoryListener ( inventoryStorageProxy ) ; } if ( platformMBeanGenerator != null ) { platformMBeanGenerator . unregisterAllMBeans ( ) ; } if ( notificationDispatcher != null ) { protocolServices . removeInventoryListener ( notificationDispatcher ) ; } protocolServices = null ; } } catch ( Throwable t ) { error . compareAndSet ( null , t ) ; log . debug ( "Cannot shutdown protocol services but will continue shutdown" , t ) ; } try { if ( storageAdapter != null ) { storageAdapter . shutdown ( ) ; storageAdapter = null ; } } catch ( Throwable t ) { error . compareAndSet ( null , t ) ; log . debug ( "Cannot shutdown storage adapter but will continue shutdown" , t ) ; } if ( diagnosticsReporter != null ) { diagnosticsReporter . stop ( ) ; if ( configuration . getDiagnostics ( ) . isEnabled ( ) ) { diagnosticsReporter . report ( ) ; } diagnosticsReporter = null ; } try { cleanupDuringStop ( ) ; } catch ( Exception e ) { error . compareAndSet ( null , e ) ; log . debug ( "Cannot shutdown - subclass exception" , e ) ; } if ( error . get ( ) != null ) { throw error . get ( ) ; } } catch ( Throwable t ) { log . warnFailedToStopAgent ( t ) ; } finally { setStatus ( ServiceStatus . STOPPED ) ; } } | Stops this service . If the service is already stopped this method is a no - op . |
10,515 | private void startStorageAdapter ( ) throws Exception { this . storageAdapter = new HawkularStorageAdapter ( ) ; this . storageAdapter . initialize ( feedId , configuration . getStorageAdapter ( ) , diagnostics , httpClientBuilder ) ; inventoryStorageProxy . setStorageAdapter ( storageAdapter ) ; this . diagnosticsReporter = JBossLoggingReporter . forRegistry ( this . diagnostics . getMetricRegistry ( ) ) . convertRatesTo ( TimeUnit . SECONDS ) . convertDurationsTo ( TimeUnit . MILLISECONDS ) . outputTo ( Logger . getLogger ( getClass ( ) ) ) . withLoggingLevel ( LoggingLevel . DEBUG ) . build ( ) ; if ( this . configuration . getDiagnostics ( ) . isEnabled ( ) ) { diagnosticsReporter . start ( this . configuration . getDiagnostics ( ) . getInterval ( ) , this . configuration . getDiagnostics ( ) . getTimeUnits ( ) ) ; } } | Creates and starts the storage adapter that will be used to store our inventory data and monitoring data . |
10,516 | public static < L > Builder < L > builder ( Resource < L > template ) { return new Builder < L > ( template ) ; } | Creates a builder with the given resource as a starting template . You can use this to clone a resource as well as build a resource that looks similar to the given template resource . |
10,517 | public AddResult < L > addResource ( Resource < L > newResource ) throws IllegalArgumentException { AddResult < L > result ; graphLockWrite . lock ( ) ; try { if ( newResource . getParent ( ) != null ) { Resource < L > parentInGraph = getResource ( newResource . getParent ( ) . getID ( ) ) ; if ( parentInGraph == null ) { throw new IllegalArgumentException ( String . format ( "The new resource [%s] has a parent [%s] that has not been added yet" , newResource , newResource . getParent ( ) ) ) ; } if ( parentInGraph != newResource . getParent ( ) ) { newResource = Resource . < L > builder ( newResource ) . parent ( parentInGraph ) . build ( ) ; } } boolean added = this . resourcesGraph . addVertex ( newResource ) ; if ( ! added ) { Resource < L > oldResource = getResource ( newResource . getID ( ) ) ; if ( new ResourceComparator ( ) . compare ( oldResource , newResource ) != 0 ) { Set < Resource < L > > children = getChildren ( oldResource ) ; this . resourcesGraph . removeVertex ( oldResource ) ; this . resourcesGraph . addVertex ( newResource ) ; for ( Resource < L > child : children ) { ResourceManager . this . resourcesGraph . addEdge ( newResource , child ) ; } result = new AddResult < > ( AddResult . Effect . MODIFIED , newResource ) ; } else { result = new AddResult < > ( AddResult . Effect . UNCHANGED , oldResource ) ; } } else { result = new AddResult < > ( AddResult . Effect . ADDED , newResource ) ; } if ( ( result . getEffect ( ) != AddResult . Effect . UNCHANGED ) && ( newResource . getParent ( ) != null ) ) { this . resourcesGraph . addEdge ( newResource . getParent ( ) , newResource ) ; } return result ; } finally { graphLockWrite . unlock ( ) ; } } | Adds the given resource to the resource hierarchy replacing the resource if it already exist but has changed . |
10,518 | public Resource < L > getParent ( Resource < L > resource ) { graphLockRead . lock ( ) ; try { Set < Resource < L > > directParents = neighborIndex . predecessorsOf ( resource ) ; if ( directParents . isEmpty ( ) ) { return null ; } return directParents . iterator ( ) . next ( ) ; } finally { graphLockRead . unlock ( ) ; } } | Returns the direct parent of the given resource . This examines the internal hierarchical graph to determine parentage . |
10,519 | private void getAllDescendants ( Resource < L > parent , List < Resource < L > > descendants ) { for ( Resource < L > child : getChildren ( parent ) ) { if ( ! descendants . contains ( child ) ) { getAllDescendants ( child , descendants ) ; descendants . add ( child ) ; } } return ; } | make sure you call this with a graph lock - either read or write |
10,520 | private List < String > getDomainHostServers ( ModelControllerClient mcc , String hostName ) { return getChildrenNames ( PathAddress . EMPTY_ADDRESS . append ( "host" , hostName ) , "server" , mcc ) ; } | returns empty list if not in domain mode |
10,521 | public static void main ( String [ ] args ) { try { start ( args ) ; } catch ( Exception e ) { System . err . println ( "Hawkular Java Agent failed at startup" ) ; e . printStackTrace ( System . err ) ; return ; } synchronized ( JavaAgent . class ) { try { JavaAgent . class . wait ( ) ; } catch ( InterruptedException e ) { } } } | an agent can be started in its own VM as the main class |
10,522 | public static void premain ( String args ) { if ( args == null ) { args = "config=config.yaml" ; } try { start ( args . split ( "," ) ) ; } catch ( Exception e ) { System . err . println ( "Hawkular Java Agent failed at startup" ) ; e . printStackTrace ( System . err ) ; } } | an agent can be started in a VM as a javaagent allowing it to be embedded with some other main app |
10,523 | public static void ensureEndsWithSlash ( StringBuilder str ) { if ( str . length ( ) == 0 || str . charAt ( str . length ( ) - 1 ) != '/' ) { str . append ( '/' ) ; } } | Given a string builder this ensures its last character is a forward - slash . |
10,524 | public static long copyStream ( InputStream input , OutputStream output , boolean closeStreams ) throws RuntimeException { long numBytesCopied = 0 ; int bufferSize = BUFFER_SIZE ; try { input = new BufferedInputStream ( input , bufferSize ) ; byte [ ] buffer = new byte [ bufferSize ] ; for ( int bytesRead = input . read ( buffer ) ; bytesRead != - 1 ; bytesRead = input . read ( buffer ) ) { output . write ( buffer , 0 , bytesRead ) ; numBytesCopied += bytesRead ; } output . flush ( ) ; } catch ( IOException ioe ) { throw new RuntimeException ( "Stream data cannot be copied" , ioe ) ; } finally { if ( closeStreams ) { try { output . close ( ) ; } catch ( IOException ioe2 ) { } try { input . close ( ) ; } catch ( IOException ioe2 ) { } } } return numBytesCopied ; } | Copies one stream to another optionally closing the streams . |
10,525 | public static String base64Encode ( String plainTextString ) { String encoded = new String ( Base64 . getEncoder ( ) . encode ( plainTextString . getBytes ( ) ) ) ; return encoded ; } | Encodes a string using Base64 encoding . |
10,526 | public static String getContainerId ( ) { if ( containerId == null ) { containerId = System . getProperty ( HAWKULAR_AGENT_CONTAINER_ID ) ; if ( containerId != null ) { log . infof ( "Container ID was explicitly set to [%s]" , containerId ) ; } } if ( containerId == null ) { final String containerIdFilename = "/proc/self/cgroup" ; File containerIdFile = new File ( containerIdFilename ) ; if ( containerIdFile . exists ( ) && containerIdFile . canRead ( ) ) { try ( Reader reader = new InputStreamReader ( new FileInputStream ( containerIdFile ) ) ) { new BufferedReader ( reader ) . lines ( ) . forEach ( new Consumer < String > ( ) { public void accept ( String s ) { if ( containerId == null ) { containerId = extractDockerContainerIdFromString ( s ) ; } } } ) ; } catch ( IOException e ) { log . warnf ( e , "%s exists and is readable, but a read error occurred" , containerIdFilename ) ; containerId = "" ; } finally { if ( containerId == null ) { log . infof ( "%s exists but could not find a container ID in it" , containerIdFilename ) ; containerId = "" ; } } } else { log . debugf ( "%s does not exist or is unreadable. Assuming not inside a container" , containerIdFilename ) ; containerId = "" ; } } return ( containerId . isEmpty ( ) ) ? null : containerId ; } | Tries to determine the container ID for the machine where this JVM is located . First check if the user explicitly set it . If not try determine it . |
10,527 | public void setDefaultTransactionTimeout ( int timeoutSecs ) throws Exception { final Address address = Address . root ( ) . add ( SUBSYSTEM , TRANSACTIONS ) ; final ModelNode req = createWriteAttributeRequest ( "default-timeout" , String . valueOf ( timeoutSecs ) , address ) ; final ModelNode response = execute ( req ) ; if ( ! isSuccess ( response ) ) { throw new FailureException ( response ) ; } return ; } | Sets the default transaction timeout . |
10,528 | public static Address fromModelNode ( ModelNode node ) { Address address = Address . root ( ) ; if ( ! node . isDefined ( ) ) { return address ; } try { List < Property > addressList = node . asPropertyList ( ) ; for ( Property addressProperty : addressList ) { String resourceType = addressProperty . getName ( ) ; String resourceName = addressProperty . getValue ( ) . asString ( ) ; address . add ( resourceType , resourceName ) ; } return address ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Node cannot be used as an address: " + node . toJSONString ( true ) ) ; } } | Obtains the address from the given ModelNode which is assumed to be a property list that contains all the address parts and only the address parts . |
10,529 | public Address add ( String ... addressParts ) { if ( addressParts != null ) { if ( ( addressParts . length % 2 ) != 0 ) { throw new IllegalArgumentException ( "address is incomplete: " + Arrays . toString ( addressParts ) ) ; } if ( addressParts . length > 0 ) { for ( int i = 0 ; i < addressParts . length ; i += 2 ) { addressNode . add ( addressParts [ i ] , addressParts [ i + 1 ] ) ; } } } return this ; } | Appends the given address parts to this address . This lets you build up addresses in a step - wise fashion . |
10,530 | public Address add ( Address address ) { if ( address == null || address . isRoot ( ) ) { return this ; } if ( isRoot ( ) ) { this . addressNode = address . addressNode . clone ( ) ; } else { List < Property > parts = address . addressNode . asPropertyList ( ) ; for ( Property part : parts ) { this . addressNode . add ( part ) ; } } return this ; } | Appends the given address to this address . This lets you build up addresses in a step - wise fashion . |
10,531 | public String toAddressPathString ( ) { if ( isRoot ( ) ) { return "/" ; } StringBuilder str = new StringBuilder ( ) ; List < Property > parts = addressNode . asPropertyList ( ) ; for ( Property part : parts ) { String name = part . getName ( ) ; String value = part . getValue ( ) . asString ( ) ; str . append ( "/" ) . append ( name ) . append ( "=" ) . append ( value ) ; } return str . toString ( ) ; } | Returns the address as a flattened string that is compatible with the DMR CLI address paths . |
10,532 | public Double getPowerSourceMetric ( String powerSourceName , ID metricToCollect ) { Map < String , PowerSource > cache = getPowerSources ( ) ; PowerSource powerSource = cache . get ( powerSourceName ) ; if ( powerSource == null ) { return null ; } if ( PlatformMetricType . POWER_SOURCE_REMAINING_CAPACITY . getMetricTypeId ( ) . equals ( metricToCollect ) ) { return powerSource . getRemainingCapacity ( ) ; } else if ( PlatformMetricType . POWER_SOURCE_TIME_REMAINING . getMetricTypeId ( ) . equals ( metricToCollect ) ) { return powerSource . getTimeRemaining ( ) ; } else { throw new UnsupportedOperationException ( "Invalid power source metric to collect: " + metricToCollect ) ; } } | Returns the given metric s value or null if there is no power source with the given name . |
10,533 | public Double getProcessorMetric ( String processorNumber , ID metricToCollect ) { CentralProcessor processor = getProcessor ( ) ; if ( processor == null ) { return null ; } int processorIndex ; try { processorIndex = Integer . parseInt ( processorNumber ) ; if ( processorIndex < 0 || processorIndex >= processor . getLogicalProcessorCount ( ) ) { return null ; } } catch ( Exception e ) { return null ; } if ( PlatformMetricType . PROCESSOR_CPU_USAGE . getMetricTypeId ( ) . equals ( metricToCollect ) ) { return processor . getProcessorCpuLoadBetweenTicks ( ) [ processorIndex ] ; } else { throw new UnsupportedOperationException ( "Invalid processor metric to collect: " + metricToCollect ) ; } } | Returns the given metric s value or null if there is no processor with the given number . |
10,534 | public Double getFileStoreMetric ( String fileStoreNameName , ID metricToCollect ) { Map < String , OSFileStore > cache = getFileStores ( ) ; OSFileStore fileStore = cache . get ( fileStoreNameName ) ; if ( fileStore == null ) { return null ; } if ( PlatformMetricType . FILE_STORE_TOTAL_SPACE . getMetricTypeId ( ) . equals ( metricToCollect ) ) { return Double . valueOf ( fileStore . getTotalSpace ( ) ) ; } else if ( PlatformMetricType . FILE_STORE_USABLE_SPACE . getMetricTypeId ( ) . equals ( metricToCollect ) ) { return Double . valueOf ( fileStore . getUsableSpace ( ) ) ; } else { throw new UnsupportedOperationException ( "Invalid file store metric to collect: " + metricToCollect ) ; } } | Returns the given metric s value or null if there is no file store with the given name . |
10,535 | public Double getMemoryMetric ( ID metricToCollect ) { GlobalMemory mem = getMemory ( ) ; if ( PlatformMetricType . MEMORY_AVAILABLE . getMetricTypeId ( ) . equals ( metricToCollect ) ) { return Double . valueOf ( mem . getAvailable ( ) ) ; } else if ( PlatformMetricType . MEMORY_TOTAL . getMetricTypeId ( ) . equals ( metricToCollect ) ) { return Double . valueOf ( mem . getTotal ( ) ) ; } else { throw new UnsupportedOperationException ( "Invalid memory metric to collect: " + metricToCollect ) ; } } | Returns the given memory metric s value . |
10,536 | public Double getOperatingSystemMetric ( ID metricId ) { if ( PlatformMetricType . OS_SYS_CPU_LOAD . getMetricTypeId ( ) . equals ( metricId ) ) { return Double . valueOf ( getProcessor ( ) . getSystemCpuLoad ( ) ) ; } else if ( PlatformMetricType . OS_SYS_LOAD_AVG . getMetricTypeId ( ) . equals ( metricId ) ) { return Double . valueOf ( getProcessor ( ) . getSystemLoadAverage ( ) ) ; } else if ( PlatformMetricType . OS_PROCESS_COUNT . getMetricTypeId ( ) . equals ( metricId ) ) { return Double . valueOf ( getOperatingSystem ( ) . getProcessCount ( ) ) ; } else { throw new UnsupportedOperationException ( "Invalid OS metric to collect: " + metricId ) ; } } | Returns the given OS metric s value . |
10,537 | public Double getMetric ( PlatformResourceType type , String name , ID metricToCollect ) { switch ( type ) { case OPERATING_SYSTEM : { return getOperatingSystemMetric ( metricToCollect ) ; } case MEMORY : { return getMemoryMetric ( metricToCollect ) ; } case FILE_STORE : { return getFileStoreMetric ( name , metricToCollect ) ; } case PROCESSOR : { return getProcessorMetric ( name , metricToCollect ) ; } case POWER_SOURCE : { return getPowerSourceMetric ( name , metricToCollect ) ; } default : { throw new IllegalArgumentException ( "Platform resource [" + type + "][" + name + "] does not have metrics" ) ; } } } | Given a platform resource type a name and a metric name this will return that metric s value or null if there is no resource that can be identified by the name and type . |
10,538 | private static < L > Map < Name , TypeSet < ResourceType < L > > > buildTypeMapForConstructor ( Collection < ResourceType < L > > allTypes ) { TypeSetBuilder < ResourceType < L > > bldr = TypeSet . < ResourceType < L > > builder ( ) ; bldr . enabled ( true ) ; bldr . name ( new Name ( "all" ) ) ; for ( ResourceType < L > type : allTypes ) { bldr . type ( type ) ; } TypeSet < ResourceType < L > > typeSet = bldr . build ( ) ; return Collections . singletonMap ( typeSet . getName ( ) , typeSet ) ; } | for use by the above constructor |
10,539 | public Set < ResourceType < L > > getChildren ( ResourceType < L > resourceType ) { Set < ResourceType < L > > directChildren = index . successorsOf ( resourceType ) ; return Collections . unmodifiableSet ( directChildren ) ; } | Returns the direct child types of the given resource type . |
10,540 | public Set < ResourceType < L > > getParents ( ResourceType < L > resourceType ) { Set < ResourceType < L > > directParents = index . predecessorsOf ( resourceType ) ; return Collections . unmodifiableSet ( directParents ) ; } | Returns the direct parent types of the given resource type . |
10,541 | private void prepareGraph ( ) throws IllegalStateException { List < ResourceType < L > > disabledTypes = new ArrayList < > ( ) ; Map < Name , ResourceType < L > > allResourceTypes = new HashMap < > ( ) ; for ( TypeSet < ResourceType < L > > rTypeSet : typeSetMap . values ( ) ) { for ( ResourceType < L > rType : rTypeSet . getTypeMap ( ) . values ( ) ) { if ( null != allResourceTypes . put ( rType . getName ( ) , rType ) ) { throw new IllegalStateException ( "Multiple resource types have the same name: " + rType . getName ( ) ) ; } resourceTypesGraph . addVertex ( rType ) ; if ( ! rTypeSet . isEnabled ( ) ) { disabledTypes . add ( rType ) ; } } } for ( TypeSet < ResourceType < L > > rTypeSet : typeSetMap . values ( ) ) { for ( ResourceType < L > rType : rTypeSet . getTypeMap ( ) . values ( ) ) { for ( Name parent : rType . getParents ( ) ) { ResourceType < L > parentResourceType = allResourceTypes . get ( parent ) ; if ( parentResourceType == null ) { log . debugf ( "Resource type [%s] will ignore unknown parent [%s]" , rType . getName ( ) , parent ) ; } else { resourceTypesGraph . addEdge ( parentResourceType , rType ) ; } } } } List < ResourceType < L > > toBeDisabled = new ArrayList < > ( ) ; for ( ResourceType < L > disabledType : disabledTypes ) { toBeDisabled . add ( disabledType ) ; getDeepChildrenList ( disabledType , toBeDisabled ) ; log . infoDisablingResourceTypes ( disabledType , toBeDisabled ) ; } resourceTypesGraph . removeAllVertices ( toBeDisabled ) ; } | Prepares the graph . |
10,542 | public void sendAsync ( BasicMessageWithExtraData < ? extends BasicMessage > messageWithData ) { if ( ! isConnected ( ) ) { throw new IllegalStateException ( "WebSocket connection was closed. Cannot send any messages" ) ; } BasicMessage message = messageWithData . getBasicMessage ( ) ; configurationAuthentication ( message ) ; sendExecutor . execute ( new Runnable ( ) { public void run ( ) { try { if ( messageWithData . getBinaryData ( ) == null ) { String messageString = ApiDeserializer . toHawkularFormat ( message ) ; @ SuppressWarnings ( "resource" ) Buffer buffer = new Buffer ( ) . writeUtf8 ( messageString ) ; RequestBody requestBody = RequestBody . create ( WebSocket . TEXT , buffer . readByteArray ( ) ) ; FeedCommProcessor . this . webSocket . sendMessage ( requestBody ) ; } else { BinaryData messageData = ApiDeserializer . toHawkularFormat ( message , messageWithData . getBinaryData ( ) ) ; RequestBody requestBody = new RequestBody ( ) { public MediaType contentType ( ) { return WebSocket . BINARY ; } public void writeTo ( BufferedSink bufferedSink ) throws IOException { emitToSink ( messageData , bufferedSink ) ; } } ; FeedCommProcessor . this . webSocket . sendMessage ( requestBody ) ; } } catch ( Throwable t ) { log . errorFailedToSendOverFeedComm ( message . getClass ( ) . getName ( ) , t ) ; } } } ) ; } | Sends a message to the server asynchronously . This method returns immediately ; the message may not go out until some time in the future . |
10,543 | public void sendSync ( BasicMessageWithExtraData < ? extends BasicMessage > messageWithData ) throws Exception { if ( ! isConnected ( ) ) { throw new IllegalStateException ( "WebSocket connection was closed. Cannot send any messages" ) ; } BasicMessage message = messageWithData . getBasicMessage ( ) ; configurationAuthentication ( message ) ; if ( messageWithData . getBinaryData ( ) == null ) { String messageString = ApiDeserializer . toHawkularFormat ( message ) ; @ SuppressWarnings ( "resource" ) Buffer buffer = new Buffer ( ) . writeUtf8 ( messageString ) ; RequestBody requestBody = RequestBody . create ( WebSocket . TEXT , buffer . readByteArray ( ) ) ; FeedCommProcessor . this . webSocket . sendMessage ( requestBody ) ; } else { BinaryData messageData = ApiDeserializer . toHawkularFormat ( message , messageWithData . getBinaryData ( ) ) ; RequestBody requestBody = new RequestBody ( ) { public MediaType contentType ( ) { return WebSocket . BINARY ; } public void writeTo ( BufferedSink bufferedSink ) throws IOException { emitToSink ( messageData , bufferedSink ) ; } } ; FeedCommProcessor . this . webSocket . sendMessage ( requestBody ) ; } } | Sends a message to the server synchronously . This will return only when the message has been sent . |
10,544 | private void destroyPingExecutor ( ) { synchronized ( pingExecutor ) { if ( ! pingExecutor . isShutdown ( ) ) { try { log . debugf ( "Shutting down WebSocket ping executor" ) ; pingExecutor . shutdown ( ) ; if ( ! pingExecutor . awaitTermination ( 1 , TimeUnit . SECONDS ) ) { pingExecutor . shutdownNow ( ) ; } } catch ( Throwable t ) { log . warnf ( "Cannot shut down WebSocket ping executor. Cause=%s" , t . toString ( ) ) ; } } } } | Call this when you know the feed comm processor object will never be used again and thus the ping executor will also never be used again . |
10,545 | public static ID generateResourceId ( String feedId , MonitoredEndpoint < ? extends AbstractEndpointConfiguration > endpoint , String idPart ) { ID id = new ID ( String . format ( "%s~%s~%s" , feedId , endpoint . getName ( ) , idPart ) ) ; return id ; } | Generates an ID for a resource . |
10,546 | public void addProperty ( String name , Object value ) { if ( value != null ) { properties . put ( name , value ) ; } else { removeProperty ( name ) ; } } | Adds an optional property to this object . If null any property with the given name will be removed . If the property already exists this new value will replace the old value . |
10,547 | public boolean isSocketBinding ( String socketBindingGroupName , String socketBindingName ) throws Exception { Address addr = Address . root ( ) . add ( SOCKET_BINDING_GROUP , socketBindingGroupName ) ; String haystack = SOCKET_BINDING ; return null != findNodeInList ( addr , haystack , socketBindingName ) ; } | Checks to see if there is already a socket binding in the given group . |
10,548 | public void addSocketBinding ( String socketBindingGroupName , String socketBindingName , int port ) throws Exception { addSocketBinding ( socketBindingGroupName , socketBindingName , null , port ) ; } | Adds a socket binding with the given name in the named socket binding group . If a socket binding with the given name already exists this method does nothing . |
10,549 | public void setSocketBindingPort ( String socketBindingGroupName , String socketBindingName , int port ) throws Exception { setSocketBindingPortExpression ( socketBindingGroupName , socketBindingName , null , port ) ; } | Sets the port number for the named socket binding found in the named socket binding group . |
10,550 | public void setStandardSocketBindingInterface ( String socketBindingName , String interfaceName ) throws Exception { setStandardSocketBindingInterfaceExpression ( socketBindingName , null , interfaceName ) ; } | Sets the interface name for the named standard socket binding . |
10,551 | public void setSocketBindingPort ( String socketBindingGroupName , String socketBindingName , String interfaceName ) throws Exception { setSocketBindingInterfaceExpression ( socketBindingGroupName , socketBindingName , null , interfaceName ) ; } | Sets the interface name for the named socket binding found in the named socket binding group . |
10,552 | private static String toCanonicalName ( String className ) { className = StringUtils . deleteWhitespace ( className ) ; Validate . notNull ( className , "className must not be null." ) ; if ( className . endsWith ( "[]" ) ) { final StringBuilder classNameBuffer = new StringBuilder ( ) ; while ( className . endsWith ( "[]" ) ) { className = className . substring ( 0 , className . length ( ) - 2 ) ; classNameBuffer . append ( "[" ) ; } final String abbreviation = abbreviationMap . get ( className ) ; if ( abbreviation != null ) { classNameBuffer . append ( abbreviation ) ; } else { classNameBuffer . append ( "L" ) . append ( className ) . append ( ";" ) ; } className = classNameBuffer . toString ( ) ; } return className ; } | Converts a class name to a JLS style class name . |
10,553 | public static String [ ] [ ] invert ( final String [ ] [ ] array ) { final String [ ] [ ] newarray = new String [ array . length ] [ 2 ] ; for ( int i = 0 ; i < array . length ; i ++ ) { newarray [ i ] [ 0 ] = array [ i ] [ 1 ] ; newarray [ i ] [ 1 ] = array [ i ] [ 0 ] ; } return newarray ; } | Used to invert an escape array into an unescape array |
10,554 | private Fraction addSub ( final Fraction fraction , final boolean isAdd ) { Validate . isTrue ( fraction != null , "The fraction must not be null" ) ; if ( numerator == 0 ) { return isAdd ? fraction : fraction . negate ( ) ; } if ( fraction . numerator == 0 ) { return this ; } final int d1 = greatestCommonDivisor ( denominator , fraction . denominator ) ; if ( d1 == 1 ) { final int uvp = mulAndCheck ( numerator , fraction . denominator ) ; final int upv = mulAndCheck ( fraction . numerator , denominator ) ; return new Fraction ( isAdd ? addAndCheck ( uvp , upv ) : subAndCheck ( uvp , upv ) , mulPosAndCheck ( denominator , fraction . denominator ) ) ; } final BigInteger uvp = BigInteger . valueOf ( numerator ) . multiply ( BigInteger . valueOf ( fraction . denominator / d1 ) ) ; final BigInteger upv = BigInteger . valueOf ( fraction . numerator ) . multiply ( BigInteger . valueOf ( denominator / d1 ) ) ; final BigInteger t = isAdd ? uvp . add ( upv ) : uvp . subtract ( upv ) ; final int tmodd1 = t . mod ( BigInteger . valueOf ( d1 ) ) . intValue ( ) ; final int d2 = tmodd1 == 0 ? d1 : greatestCommonDivisor ( tmodd1 , d1 ) ; final BigInteger w = t . divide ( BigInteger . valueOf ( d2 ) ) ; if ( w . bitLength ( ) > 31 ) { throw new ArithmeticException ( "overflow: numerator too large after multiply" ) ; } return new Fraction ( w . intValue ( ) , mulPosAndCheck ( denominator / d1 , fraction . denominator / d2 ) ) ; } | Implement add and subtract using algorithm described in Knuth 4 . 5 . 1 . |
10,555 | public ZonedDateTime intoZonedDateTimeOrUse ( ZoneId fallback ) { try { return intoZonedDateTime ( ) ; } catch ( RuntimeException ex ) { return intoLocalDateTime ( ) . atZone ( fallback ) ; } } | Converts to string & permissively parses as a date uses parsed time zone or falls back on input defaults day - > 1 month - > 1 hour - > 0 minute - > 0 second - > 0 nanoseconds - > 0 time - zone - > input |
10,556 | public final Morpheme createMorpheme ( final String word , final String tag ) { final Morpheme morpheme = new Morpheme ( ) ; morpheme . setValue ( word ) ; morpheme . setTag ( tag ) ; return morpheme ; } | Construct morpheme object with word and morphological tag . |
10,557 | public final void annotate ( final InputStream inputStream , final OutputStream outputStream ) throws IOException , JDOMException { final String model = this . parsedArguments . getString ( "model" ) ; final String lemmatizerModel = this . parsedArguments . getString ( "lemmatizerModel" ) ; final boolean allMorphology = this . parsedArguments . getBoolean ( "allMorphology" ) ; final String multiwords = Boolean . toString ( this . parsedArguments . getBoolean ( "multiwords" ) ) ; final String dictag = Boolean . toString ( this . parsedArguments . getBoolean ( "dictag" ) ) ; String outputFormat = parsedArguments . getString ( "outputFormat" ) ; BufferedReader breader = null ; BufferedWriter bwriter = null ; breader = new BufferedReader ( new InputStreamReader ( System . in , "UTF-8" ) ) ; bwriter = new BufferedWriter ( new OutputStreamWriter ( System . out , "UTF-8" ) ) ; final KAFDocument kaf = KAFDocument . createFromStream ( breader ) ; String lang ; if ( this . parsedArguments . getString ( "language" ) != null ) { lang = this . parsedArguments . getString ( "language" ) ; if ( ! kaf . getLang ( ) . equalsIgnoreCase ( lang ) ) { System . err . println ( "Language parameter in NAF and CLI do not match!!" ) ; } } else { lang = kaf . getLang ( ) ; } final Properties properties = setAnnotateProperties ( model , lemmatizerModel , lang , multiwords , dictag ) ; final Annotate annotator = new Annotate ( properties ) ; final KAFDocument . LinguisticProcessor newLp = kaf . addLinguisticProcessor ( "terms" , "ixa-pipe-pos-" + Files . getNameWithoutExtension ( model ) , this . version + "-" + this . commit ) ; newLp . setBeginTimestamp ( ) ; if ( allMorphology ) { if ( outputFormat . equalsIgnoreCase ( "conll" ) ) { bwriter . write ( annotator . getAllTagsLemmasToCoNLL ( kaf ) ) ; } else { annotator . getAllTagsLemmasToNAF ( kaf ) ; newLp . setEndTimestamp ( ) ; bwriter . write ( kaf . toString ( ) ) ; } } else { if ( outputFormat . equalsIgnoreCase ( "conll" ) ) { bwriter . write ( annotator . annotatePOSToCoNLL ( kaf ) ) ; } else { annotator . annotatePOSToKAF ( kaf ) ; newLp . setEndTimestamp ( ) ; bwriter . write ( kaf . toString ( ) ) ; } } bwriter . close ( ) ; breader . close ( ) ; } | Main entry point for annotation . Takes system . in as input and outputs annotated text via system . out . |
10,558 | private void loadAnnotateParameters ( ) { this . annotateParser . addArgument ( "-m" , "--model" ) . required ( true ) . help ( "It is required to provide a POS tagging model." ) ; this . annotateParser . addArgument ( "-lm" , "--lemmatizerModel" ) . required ( true ) . help ( "It is required to provide a lemmatizer model." ) ; this . annotateParser . addArgument ( "-l" , "--language" ) . choices ( "de" , "en" , "es" , "eu" , "fr" , "gl" , "it" , "nl" ) . required ( false ) . help ( "Choose a language." ) ; this . annotateParser . addArgument ( "--beamSize" ) . required ( false ) . setDefault ( DEFAULT_BEAM_SIZE ) . help ( "Choose beam size for decoding, it defaults to 3." ) ; annotateParser . addArgument ( "-o" , "--outputFormat" ) . required ( false ) . choices ( "naf" , "conll" ) . setDefault ( Flags . DEFAULT_OUTPUT_FORMAT ) . help ( "Choose output format; it defaults to NAF.\n" ) ; this . annotateParser . addArgument ( "-mw" , "--multiwords" ) . action ( Arguments . storeTrue ( ) ) . help ( "Use to detect and process multiwords.\n" ) ; this . annotateParser . addArgument ( "-d" , "--dictag" ) . action ( Arguments . storeTrue ( ) ) . help ( "Post process POS tagger output with a monosemic dictionary.\n" ) ; this . annotateParser . addArgument ( "-a" , "--allMorphology" ) . action ( Arguments . storeTrue ( ) ) . help ( "Print all the POS tags and lemmas before disambiguation.\n" ) ; } | Generate the annotation parameter of the CLI . |
10,559 | public final void train ( ) throws IOException { final String paramFile = this . parsedArguments . getString ( "params" ) ; final TrainingParameters params = InputOutputUtils . loadTrainingParameters ( paramFile ) ; String outModel = null ; if ( params . getSettings ( ) . get ( "OutputModel" ) == null || params . getSettings ( ) . get ( "OutputModel" ) . length ( ) == 0 ) { outModel = Files . getNameWithoutExtension ( paramFile ) + ".bin" ; params . put ( "OutputModel" , outModel ) ; } else { outModel = Flags . getModel ( params ) ; } String component = Flags . getComponent ( params ) ; if ( component . equalsIgnoreCase ( "POS" ) ) { final TaggerTrainer posTaggerTrainer = new FixedTrainer ( params ) ; final POSModel trainedModel = posTaggerTrainer . train ( params ) ; CmdLineUtil . writeModel ( "ixa-pipe-pos" , new File ( outModel ) , trainedModel ) ; } else if ( component . equalsIgnoreCase ( "Lemma" ) ) { final LemmatizerTrainer lemmatizerTrainer = new LemmatizerFixedTrainer ( params ) ; final LemmatizerModel trainedModel = lemmatizerTrainer . train ( params ) ; CmdLineUtil . writeModel ( "ixa-pipe-lemma" , new File ( outModel ) , trainedModel ) ; } } | Main entry point for training . |
10,560 | public final void eval ( ) throws IOException { final String component = this . parsedArguments . getString ( "component" ) ; final String testFile = this . parsedArguments . getString ( "testSet" ) ; final String model = this . parsedArguments . getString ( "model" ) ; Evaluate evaluator = null ; if ( component . equalsIgnoreCase ( "pos" ) ) { evaluator = new POSEvaluate ( testFile , model ) ; } else { evaluator = new LemmaEvaluate ( testFile , model ) ; } if ( this . parsedArguments . getString ( "evalReport" ) != null ) { if ( this . parsedArguments . getString ( "evalReport" ) . equalsIgnoreCase ( "detailed" ) ) { evaluator . detailEvaluate ( ) ; } else if ( this . parsedArguments . getString ( "evalReport" ) . equalsIgnoreCase ( "error" ) ) { evaluator . evalError ( ) ; } else if ( this . parsedArguments . getString ( "evalReport" ) . equalsIgnoreCase ( "brief" ) ) { evaluator . evaluate ( ) ; } } else { evaluator . evaluate ( ) ; } } | Main entry point for evaluation . |
10,561 | private void loadEvalParameters ( ) { this . evalParser . addArgument ( "-c" , "--component" ) . required ( true ) . choices ( "pos" , "lemma" ) . help ( "Choose component for evaluation" ) ; this . evalParser . addArgument ( "-m" , "--model" ) . required ( true ) . help ( "Choose model" ) ; this . evalParser . addArgument ( "-t" , "--testSet" ) . required ( true ) . help ( "Input testset for evaluation" ) ; this . evalParser . addArgument ( "--evalReport" ) . required ( false ) . choices ( "brief" , "detailed" , "error" ) . help ( "Choose type of evaluation report; defaults to brief" ) ; } | Load the evaluation parameters of the CLI . |
10,562 | public final void crossValidate ( ) throws IOException { final String paramFile = this . parsedArguments . getString ( "params" ) ; final TrainingParameters params = InputOutputUtils . loadTrainingParameters ( paramFile ) ; final POSCrossValidator crossValidator = new POSCrossValidator ( params ) ; crossValidator . crossValidate ( params ) ; } | Main access to the cross validation . |
10,563 | private void loadServerParameters ( ) { serverParser . addArgument ( "-p" , "--port" ) . required ( true ) . help ( "Port to be assigned to the server.\n" ) ; serverParser . addArgument ( "-m" , "--model" ) . required ( true ) . help ( "It is required to provide a model to perform POS tagging." ) ; this . serverParser . addArgument ( "-lm" , "--lemmatizerModel" ) . required ( true ) . help ( "It is required to provide a lemmatizer model." ) ; serverParser . addArgument ( "-l" , "--language" ) . choices ( "de" , "en" , "es" , "eu" , "fr" , "gl" , "it" , "nl" ) . required ( true ) . help ( "Choose a language to perform annotation with ixa-pipe-pos." ) ; serverParser . addArgument ( "--beamSize" ) . required ( false ) . setDefault ( DEFAULT_BEAM_SIZE ) . help ( "Choose beam size for decoding, it defaults to 3." ) ; serverParser . addArgument ( "-o" , "--outputFormat" ) . required ( false ) . choices ( "naf" , "conll" ) . setDefault ( Flags . DEFAULT_OUTPUT_FORMAT ) . help ( "Choose output format; it defaults to NAF.\n" ) ; serverParser . addArgument ( "-mw" , "--multiwords" ) . action ( Arguments . storeTrue ( ) ) . help ( "Use to detect and process multiwords.\n" ) ; serverParser . addArgument ( "-d" , "--dictag" ) . action ( Arguments . storeTrue ( ) ) . help ( "Post process POS tagger output with a monosemic dictionary.\n" ) ; serverParser . addArgument ( "-a" , "--allMorphology" ) . action ( Arguments . storeTrue ( ) ) . help ( "Print all the POS tags and lemmas before disambiguation.\n" ) ; } | Create the available parameters for POS tagging . |
10,564 | private Properties setAnnotateProperties ( final String model , final String lemmatizerModel , final String language , final String multiwords , final String dictag ) { final Properties annotateProperties = new Properties ( ) ; annotateProperties . setProperty ( "model" , model ) ; annotateProperties . setProperty ( "lemmatizerModel" , lemmatizerModel ) ; annotateProperties . setProperty ( "language" , language ) ; annotateProperties . setProperty ( "multiwords" , multiwords ) ; annotateProperties . setProperty ( "dictag" , dictag ) ; return annotateProperties ; } | Generate Properties objects for CLI usage . |
10,565 | public String [ ] getTokenArray ( ) { checkTokenized ( ) ; if ( this . tokens == null ) { return null ; } final String [ ] clone = new String [ this . tokens . length ] ; for ( int i = 0 ; i < this . tokens . length ; i ++ ) { clone [ i ] = this . tokens [ i ] ; } return clone ; } | Gets a copy of the full token list as an independent modifiable array . |
10,566 | public List < String > getTokenList ( ) { checkTokenized ( ) ; final List < String > list = new ArrayList < > ( tokens . length ) ; list . addAll ( Arrays . asList ( tokens ) ) ; return list ; } | Gets a copy of the full token list as an independent modifiable list . |
10,567 | public StrTokenizer reset ( final String input ) { reset ( ) ; if ( input != null ) { this . chars = input . toCharArray ( ) ; } else { this . chars = null ; } return this ; } | Reset this tokenizer giving it a new input string to parse . In this manner you can re - use a tokenizer with the same settings on multiple input lines . |
10,568 | private void checkTokenized ( ) { if ( tokens == null ) { if ( chars == null ) { final List < String > split = tokenize ( null , 0 , 0 ) ; tokens = split . toArray ( new String [ split . size ( ) ] ) ; } else { final List < String > split = tokenize ( chars , 0 , chars . length ) ; tokens = split . toArray ( new String [ split . size ( ) ] ) ; } } } | Checks if tokenization has been done and if not then do it . |
10,569 | private void addToken ( final List < String > list , String tok ) { if ( StringUtils . isEmpty ( tok ) ) { if ( isIgnoreEmptyTokens ( ) ) { return ; } if ( isEmptyTokenAsNull ( ) ) { tok = null ; } } list . add ( tok ) ; } | Adds a token to a list paying attention to the parameters we ve set . |
10,570 | private int readNextToken ( final char [ ] srcChars , int start , final int len , final StrBuilder workArea , final List < String > tokenList ) { while ( start < len ) { final int removeLen = Math . max ( getIgnoredMatcher ( ) . isMatch ( srcChars , start , start , len ) , getTrimmerMatcher ( ) . isMatch ( srcChars , start , start , len ) ) ; if ( removeLen == 0 || getDelimiterMatcher ( ) . isMatch ( srcChars , start , start , len ) > 0 || getQuoteMatcher ( ) . isMatch ( srcChars , start , start , len ) > 0 ) { break ; } start += removeLen ; } if ( start >= len ) { addToken ( tokenList , StringUtils . EMPTY ) ; return - 1 ; } final int delimLen = getDelimiterMatcher ( ) . isMatch ( srcChars , start , start , len ) ; if ( delimLen > 0 ) { addToken ( tokenList , StringUtils . EMPTY ) ; return start + delimLen ; } final int quoteLen = getQuoteMatcher ( ) . isMatch ( srcChars , start , start , len ) ; if ( quoteLen > 0 ) { return readWithQuotes ( srcChars , start + quoteLen , len , workArea , tokenList , start , quoteLen ) ; } return readWithQuotes ( srcChars , start , len , workArea , tokenList , 0 , 0 ) ; } | Reads character by character through the String to get the next token . |
10,571 | private int readWithQuotes ( final char [ ] srcChars , final int start , final int len , final StrBuilder workArea , final List < String > tokenList , final int quoteStart , final int quoteLen ) { workArea . clear ( ) ; int pos = start ; boolean quoting = quoteLen > 0 ; int trimStart = 0 ; while ( pos < len ) { if ( quoting ) { if ( isQuote ( srcChars , pos , len , quoteStart , quoteLen ) ) { if ( isQuote ( srcChars , pos + quoteLen , len , quoteStart , quoteLen ) ) { workArea . append ( srcChars , pos , quoteLen ) ; pos += quoteLen * 2 ; trimStart = workArea . size ( ) ; continue ; } quoting = false ; pos += quoteLen ; continue ; } workArea . append ( srcChars [ pos ++ ] ) ; trimStart = workArea . size ( ) ; } else { final int delimLen = getDelimiterMatcher ( ) . isMatch ( srcChars , pos , start , len ) ; if ( delimLen > 0 ) { addToken ( tokenList , workArea . substring ( 0 , trimStart ) ) ; return pos + delimLen ; } if ( quoteLen > 0 && isQuote ( srcChars , pos , len , quoteStart , quoteLen ) ) { quoting = true ; pos += quoteLen ; continue ; } final int ignoredLen = getIgnoredMatcher ( ) . isMatch ( srcChars , pos , start , len ) ; if ( ignoredLen > 0 ) { pos += ignoredLen ; continue ; } final int trimmedLen = getTrimmerMatcher ( ) . isMatch ( srcChars , pos , start , len ) ; if ( trimmedLen > 0 ) { workArea . append ( srcChars , pos , trimmedLen ) ; pos += trimmedLen ; continue ; } workArea . append ( srcChars [ pos ++ ] ) ; trimStart = workArea . size ( ) ; } } addToken ( tokenList , workArea . substring ( 0 , trimStart ) ) ; return - 1 ; } | Reads a possibly quoted string token . |
10,572 | Object cloneReset ( ) throws CloneNotSupportedException { final StrTokenizer cloned = new StrTokenizer ( ) ; if ( this . chars != null ) { cloned . chars = new char [ this . chars . length ] ; for ( int i = 0 ; i < this . chars . length ; i ++ ) { cloned . chars [ i ] = this . chars [ i ] ; } } if ( this . tokens == null ) { cloned . tokens = null ; } else { cloned . tokens = this . getTokenArray ( ) ; } cloned . tokenPos = this . tokenPos ; cloned . emptyAsNull = this . emptyAsNull ; cloned . ignoreEmptyTokens = this . ignoreEmptyTokens ; cloned . delimMatcher = this . delimMatcher ; cloned . quoteMatcher = this . quoteMatcher ; cloned . ignoredMatcher = this . ignoredMatcher ; cloned . trimmerMatcher = this . trimmerMatcher ; cloned . reset ( ) ; return cloned ; } | Creates a new instance of this Tokenizer . The new instance is reset so that it will be at the start of the token list . |
10,573 | private HashMap < List < String > , String > getLemmaTagsDict ( final String word ) { final List < WordData > wdList = this . dictLookup . lookup ( word ) ; final HashMap < List < String > , String > dictMap = new HashMap < List < String > , String > ( ) ; for ( final WordData wd : wdList ) { final List < String > wordLemmaTags = new ArrayList < String > ( ) ; wordLemmaTags . add ( word ) ; wordLemmaTags . add ( wd . getTag ( ) . toString ( ) ) ; dictMap . put ( wordLemmaTags , wd . getStem ( ) . toString ( ) ) ; } return dictMap ; } | Get the lemma for a surface form word and a postag from a FSA morfologik generated dictionary . |
10,574 | private HashMap < List < String > , String > getDictMap ( final String word , final String postag ) { HashMap < List < String > , String > dictMap = new HashMap < List < String > , String > ( ) ; dictMap = this . getLemmaTagsDict ( word . toLowerCase ( ) ) ; return dictMap ; } | Generates the dictionary map . |
10,575 | public static String getStringFromTokens ( final String [ ] tokens ) { final StringBuilder sb = new StringBuilder ( ) ; for ( final String tok : tokens ) { sb . append ( tok ) . append ( " " ) ; } return sb . toString ( ) . trim ( ) ; } | Gets the String joined by a space of an array of tokens . |
10,576 | public static List < File > getFilesInDir ( final File inputPath ) { final List < File > fileList = new ArrayList < File > ( ) ; for ( final File aFile : Files . fileTreeTraverser ( ) . preOrderTraversal ( inputPath ) ) { if ( aFile . isFile ( ) ) { fileList . add ( aFile ) ; } } return fileList ; } | Recursively get every file in a directory and add them to a list . |
10,577 | private static int minimum ( int a , int b , int c ) { int minValue ; minValue = a ; if ( b < minValue ) { minValue = b ; } if ( c < minValue ) { minValue = c ; } return minValue ; } | Get mininum of three values . |
10,578 | private static String mapGermanTagSetToKaf ( final String postag ) { if ( postag . startsWith ( "ADV" ) ) { return "A" ; } else if ( postag . startsWith ( "KO" ) ) { return "C" ; } else if ( postag . equalsIgnoreCase ( "ART" ) ) { return "D" ; } else if ( postag . startsWith ( "ADJ" ) ) { return "G" ; } else if ( postag . equalsIgnoreCase ( "NN" ) ) { return "N" ; } else if ( postag . startsWith ( "NE" ) ) { return "R" ; } else if ( postag . startsWith ( "AP" ) ) { return "P" ; } else if ( postag . startsWith ( "PD" ) || postag . startsWith ( "PI" ) || postag . startsWith ( "PP" ) || postag . startsWith ( "PR" ) || postag . startsWith ( "PW" ) || postag . startsWith ( "PA" ) ) { return "Q" ; } else if ( postag . startsWith ( "V" ) ) { return "V" ; } else { return "O" ; } } | Mapping between CoNLL 2009 German tagset and KAF tagset . Based on the Stuttgart - Tuebingen tagset . |
10,579 | private static String mapEnglishTagSetToKaf ( final String postag ) { if ( postag . startsWith ( "RB" ) ) { return "A" ; } else if ( postag . equalsIgnoreCase ( "CC" ) ) { return "C" ; } else if ( postag . startsWith ( "D" ) || postag . equalsIgnoreCase ( "PDT" ) ) { return "D" ; } else if ( postag . startsWith ( "J" ) ) { return "G" ; } else if ( postag . equalsIgnoreCase ( "NN" ) || postag . equalsIgnoreCase ( "NNS" ) ) { return "N" ; } else if ( postag . startsWith ( "NNP" ) ) { return "R" ; } else if ( postag . equalsIgnoreCase ( "TO" ) || postag . equalsIgnoreCase ( "IN" ) ) { return "P" ; } else if ( postag . startsWith ( "PRP" ) || postag . startsWith ( "WP" ) ) { return "Q" ; } else if ( postag . startsWith ( "V" ) ) { return "V" ; } else { return "O" ; } } | Mapping between Penn Treebank tagset and KAF tagset . |
10,580 | private static String mapSpanishTagSetToKaf ( final String postag ) { if ( postag . equalsIgnoreCase ( "RG" ) || postag . equalsIgnoreCase ( "RN" ) ) { return "A" ; } else if ( postag . equalsIgnoreCase ( "CC" ) || postag . equalsIgnoreCase ( "CS" ) ) { return "C" ; } else if ( postag . startsWith ( "D" ) ) { return "D" ; } else if ( postag . startsWith ( "A" ) ) { return "G" ; } else if ( postag . startsWith ( "NC" ) ) { return "N" ; } else if ( postag . startsWith ( "NP" ) ) { return "R" ; } else if ( postag . startsWith ( "SP" ) ) { return "P" ; } else if ( postag . startsWith ( "P" ) ) { return "Q" ; } else if ( postag . startsWith ( "V" ) ) { return "V" ; } else { return "O" ; } } | Mapping between EAGLES PAROLE tagset and NAF . |
10,581 | public synchronized void shutdown ( ) { if ( ! shutdown ) { if ( ownExecutor ) { getExecutorService ( ) . shutdownNow ( ) ; } if ( task != null ) { task . cancel ( false ) ; } shutdown = true ; } } | Initializes a shutdown . After that the object cannot be used any more . This method can be invoked an arbitrary number of times . All invocations after the first one do not have any effect . |
10,582 | public static Function < CharSequence , TemporalAccessor > orderedParseAttempter ( Function < CharSequence , TemporalAccessor > ... parsers ) { return date -> { RuntimeException first = null ; for ( Function < CharSequence , TemporalAccessor > parser : parsers ) { try { return parser . apply ( date ) ; } catch ( RuntimeException ex ) { if ( first == null ) first = ex ; } } if ( first == null ) throw new IllegalStateException ( "Empty parse attempter" ) ; throw first ; } ; } | Returns an ordered functional blend of all input parsers . The attempter will try all functions until it succeeds . If none succeed will re - throw the first exception |
10,583 | public static Charset forName ( String charsetName ) { if ( charsetName == null ) { throw new IllegalArgumentException ( "Null charset name" ) ; } charsetName = charsetName . toUpperCase ( ) ; if ( EmulatedCharset . ISO_8859_1 . name ( ) . equals ( charsetName ) ) { return EmulatedCharset . ISO_8859_1 ; } else if ( EmulatedCharset . ISO_LATIN_1 . name ( ) . equals ( charsetName ) ) { return EmulatedCharset . ISO_LATIN_1 ; } else if ( EmulatedCharset . UTF_8 . name ( ) . equals ( charsetName ) ) { return EmulatedCharset . UTF_8 ; } if ( ! charsetName . matches ( "^[A-Za-z0-9][\\w-:\\.\\+]*$" ) ) { throw new IllegalCharsetNameException ( charsetName ) ; } else { throw new UnsupportedCharsetException ( charsetName ) ; } } | get charset for name . |
10,584 | public ReflectionToStringBuilder setExcludeFieldNames ( final String ... excludeFieldNamesParam ) { if ( excludeFieldNamesParam == null ) { this . excludeFieldNames = null ; } else { this . excludeFieldNames = toNoNullStringArray ( excludeFieldNamesParam ) ; Arrays . sort ( this . excludeFieldNames ) ; } return this ; } | Sets the field names to exclude . |
10,585 | @ GwtIncompatible ( "incompatible method" ) private static long getFragment ( final Date date , final int fragment , final TimeUnit unit ) { validateDateNotNull ( date ) ; final Calendar calendar = Calendar . getInstance ( ) ; calendar . setTime ( date ) ; return getFragment ( calendar , fragment , unit ) ; } | Gets a Date fragment for any unit . |
10,586 | @ GwtIncompatible ( "incompatible method" ) private static long getFragment ( final Calendar calendar , final int fragment , final TimeUnit unit ) { if ( calendar == null ) { throw new IllegalArgumentException ( "The date must not be null" ) ; } long result = 0 ; final int offset = ( unit == TimeUnit . DAYS ) ? 0 : 1 ; switch ( fragment ) { case Calendar . YEAR : result += unit . convert ( calendar . get ( Calendar . DAY_OF_YEAR ) - offset , TimeUnit . DAYS ) ; break ; case Calendar . MONTH : result += unit . convert ( calendar . get ( Calendar . DAY_OF_MONTH ) - offset , TimeUnit . DAYS ) ; break ; default : break ; } switch ( fragment ) { case Calendar . YEAR : case Calendar . MONTH : case Calendar . DAY_OF_YEAR : case Calendar . DATE : result += unit . convert ( calendar . get ( Calendar . HOUR_OF_DAY ) , TimeUnit . HOURS ) ; case Calendar . HOUR_OF_DAY : result += unit . convert ( calendar . get ( Calendar . MINUTE ) , TimeUnit . MINUTES ) ; case Calendar . MINUTE : result += unit . convert ( calendar . get ( Calendar . SECOND ) , TimeUnit . SECONDS ) ; case Calendar . SECOND : result += unit . convert ( calendar . get ( Calendar . MILLISECOND ) , TimeUnit . MILLISECONDS ) ; break ; case Calendar . MILLISECOND : break ; default : throw new IllegalArgumentException ( "The fragment " + fragment + " is not supported" ) ; } return result ; } | Gets a Calendar fragment for any unit . |
10,587 | public static boolean truncatedEquals ( final Date date1 , final Date date2 , final int field ) { return truncatedCompareTo ( date1 , date2 , field ) == 0 ; } | Determines if two dates are equal up to no more than the specified most significant field . |
10,588 | public static int truncatedCompareTo ( final Calendar cal1 , final Calendar cal2 , final int field ) { final Calendar truncatedCal1 = truncate ( cal1 , field ) ; final Calendar truncatedCal2 = truncate ( cal2 , field ) ; return truncatedCal1 . compareTo ( truncatedCal2 ) ; } | Determines how two calendars compare up to no more than the specified most significant field . |
10,589 | public static int truncatedCompareTo ( final Date date1 , final Date date2 , final int field ) { final Date truncatedDate1 = truncate ( date1 , field ) ; final Date truncatedDate2 = truncate ( date2 , field ) ; return truncatedDate1 . compareTo ( truncatedDate2 ) ; } | Determines how two dates compare up to no more than the specified most significant field . |
10,590 | public static < L > void bindEventsToMethod ( final Object target , final String methodName , final Object eventSource , final Class < L > listenerType , final String ... eventTypes ) { final L listener = listenerType . cast ( Proxy . newProxyInstance ( target . getClass ( ) . getClassLoader ( ) , new Class [ ] { listenerType } , new EventBindingInvocationHandler ( target , methodName , eventTypes ) ) ) ; addEventListener ( eventSource , listenerType , listener ) ; } | Binds an event listener to a specific method on a specific object . |
10,591 | public static < T > Builder < T > newSorter ( Serializer < T > serializer , Comparator < T > comparator ) { return new Builder < T > ( serializer , comparator ) ; } | Fluent API building a new instance of ExternalMergeSort<T . |
10,592 | public CloseableIterator < T > mergeSort ( Iterator < T > values ) throws IOException { ChunkSizeIterator < T > csi = new ChunkSizeIterator < T > ( values , config . chunkSize ) ; if ( csi . isMultipleChunks ( ) ) { List < File > sortedChunks = writeSortedChunks ( csi ) ; return mergeSortedChunks ( sortedChunks ) ; } else { if ( config . distinct ) { SortedSet < T > list = new TreeSet < T > ( comparator ) ; while ( csi . hasNext ( ) ) { list . add ( csi . next ( ) ) ; } return new DelegatingMergeIterator < T > ( list . iterator ( ) ) ; } else { List < T > list = new ArrayList < T > ( csi . getHeadSize ( ) ) ; while ( csi . hasNext ( ) ) { list . add ( csi . next ( ) ) ; } Collections . sort ( list , comparator ) ; return new DelegatingMergeIterator < T > ( list . iterator ( ) ) ; } } } | Performs an external merge on the values in the iterator . |
10,593 | public CloseableIterator < T > mergeSortedChunks ( List < File > sortedChunks ) throws IOException { return mergeSortedChunksNoPartialMerge ( partialMerge ( sortedChunks ) ) ; } | Returns an iterator over the sorted result . Takes a list of already sorted chunk files as input . Note that this method is normally used with one of the writeSortedChunks methods . |
10,594 | public List < File > writeSortedChunks ( Iterator < T > input ) throws IOException { List < File > result = new ArrayList < File > ( ) ; while ( input . hasNext ( ) ) { File chunkFile = writeSortedChunk ( input ) ; result . add ( chunkFile ) ; } if ( debugMerge ) { System . out . printf ( "Chunks %d (chunkSize=%d, maxOpenFiles=%d)\n" , result . size ( ) , config . chunkSize , config . maxOpenFiles ) ; } return result ; } | Read the data from the iterator then perform a sort and write individually sorted chunk files to disk . |
10,595 | public File writeSortedChunk ( Iterator < T > input ) throws IOException { List < T > chunk = readChunk ( input ) ; return writeInternalSortedChunk ( chunk ) ; } | Read the data from the iterator then perform a sort and write a single sorted chunk file to disk . Note that a maximum of elements equal to the chunk size will be read from the iterator so make sure that the iterator contains no more than that . If that is the case then you may want to use the writeSortedChunks method instead . |
10,596 | public static String removeNotation ( String name ) { if ( name . matches ( "^m[A-Z]{1}" ) ) { return name . substring ( 1 , 2 ) . toLowerCase ( ) ; } else if ( name . matches ( "m[A-Z]{1}.*" ) ) { return name . substring ( 1 , 2 ) . toLowerCase ( ) + name . substring ( 2 ) ; } return name ; } | Get the name of the field removing hungarian notation |
10,597 | public static String removeNotationFromSetterAndSetPrefix ( String methodName ) { if ( methodName . matches ( "^set\\w+" ) ) { String withoutSetPrefix = methodName . substring ( 3 ) ; if ( Character . isLowerCase ( withoutSetPrefix . charAt ( 0 ) ) ) { return HungarianNotation . removeNotation ( withoutSetPrefix ) ; } else if ( withoutSetPrefix . length ( ) >= 2 && withoutSetPrefix . charAt ( 0 ) == 'M' && Character . isUpperCase ( withoutSetPrefix . charAt ( 1 ) ) ) { return Character . toLowerCase ( withoutSetPrefix . charAt ( 1 ) ) + withoutSetPrefix . substring ( 2 ) ; } return removeNotation ( withoutSetPrefix ) ; } return removeNotation ( methodName ) ; } | Removes the hungarian notation from setter method |
10,598 | public String apply ( final String word , final String postag ) { String lemma = null ; final List < String > keys = this . getDictKeys ( word , postag ) ; final String keyValue = this . dictMap . get ( keys ) ; if ( keyValue != null ) { lemma = keyValue ; } else { lemma = "O" ; } return lemma ; } | Lookup lemma in a dictionary . Outputs O if not found . |
10,599 | @ SuppressWarnings ( "boxing" ) public static void inclusiveBetween ( final double start , final double end , final double value ) { if ( value < start || value > end ) { throw new IllegalArgumentException ( StringUtils . simpleFormat ( DEFAULT_INCLUSIVE_BETWEEN_EX_MESSAGE , value , start , end ) ) ; } } | Validate that the specified primitive value falls between the two inclusive values specified ; otherwise throws an exception . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.