idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
29,500 | void writeLine ( String line ) throws IOException { checkState ( isRunning ( ) , "Cannot read items from a %s StreamService" , state ( ) ) ; checkState ( socketWriter != null , "Attempted to write to the socket before it was opened." ) ; try { socketWriter . write ( line ) ; socketWriter . write ( '\n' ) ; socketWriter . flush ( ) ; } catch ( IOException e ) { Closeables . close ( socketWriter , true ) ; notifyFailed ( e ) ; throw e ; } } | Write a line of data to the worker process over the socket . |
29,501 | void closeWriter ( ) throws IOException { checkState ( isRunning ( ) , "Cannot read items from a %s StreamService" , state ( ) ) ; checkState ( socketWriter != null , "Attempted to close the socket before it was opened." ) ; try { socketWriter . close ( ) ; } catch ( IOException e ) { notifyFailed ( e ) ; throw e ; } closeStream ( ) ; } | Closes the socket writer . |
29,502 | private static < T > Callable < T > threadRenaming ( final String name , final Callable < T > callable ) { checkNotNull ( name ) ; checkNotNull ( callable ) ; return new Callable < T > ( ) { public T call ( ) throws Exception { Thread currentThread = Thread . currentThread ( ) ; String oldName = currentThread . getName ( ) ; currentThread . setName ( name ) ; try { return callable . call ( ) ; } finally { currentThread . setName ( oldName ) ; } } } ; } | Returns a callable that renames the the thread that the given callable runs in . |
29,503 | public ChannelFuture send ( Message message ) throws NotConnectedException { if ( ! connected ) { throw new NotConnectedException ( ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( ">>> {}" , message . toString ( ) . trim ( ) ) ; } return channel . write ( message ) ; } | Send a message through this connection |
29,504 | NodeState < T > addTransition ( ElementConstraint test , NodeState < T > targetState ) { assert ( test != null ) ; assert ( targetState != null ) ; for ( NodeTransition < T > transition : transitions ) { if ( transition . getTest ( ) . equals ( test ) ) { return transition . getTarget ( ) ; } } transitions . add ( new NodeTransition < T > ( test , targetState ) ) ; return targetState ; } | Add a transition to another node state based on the specified test . Only one transition is allowed for a given test so if a duplicate test is added the existing target node will be returned . |
29,505 | NodeState < T > follow ( StartElement element ) { assert ( element != null ) ; for ( NodeTransition < T > transition : transitions ) { if ( transition . getTest ( ) . matches ( element ) ) { return transition . getTarget ( ) ; } } return emptyState ( ) ; } | Attempt to process a node event and transition to a new state . If no suitable transition is found the empty state is returned . |
29,506 | public static StopWords getInstance ( ) { if ( INSTANCE == null ) { synchronized ( EnglishStopWords . class ) { if ( INSTANCE == null ) { INSTANCE = new EnglishStopWords ( ) ; } } } return INSTANCE ; } | Gets the instance . |
29,507 | private void printProgressBar ( ) { double x ; this . out . print ( "\r" ) ; this . out . print ( PROGRESS_BAR_END_CHAR ) ; for ( int i = 1 ; i <= this . length ; i ++ ) { if ( ! Double . isNaN ( this . progress ) ) { x = ( double ) i / this . length ; this . out . print ( this . progress >= x ? PROGRESS_BAR_CHAR : PROGRESS_BACKGROUND_CHAR ) ; } else { this . out . print ( PROGRESS_BAR_INDETERMINANT_CHAR ) ; } } this . out . print ( PROGRESS_BAR_END_CHAR ) ; if ( this . maximum > 0 ) { this . out . printf ( " (%d/%d)" , value , maximum ) ; } this . out . print ( " " ) ; this . out . print ( status ) ; } | Writes the progress bar to the stream . |
29,508 | public AppEngineGetList < E > sort ( Order < ? , ? > ... orders ) { if ( orders == null ) { throw new IllegalArgumentException ( "'orders' must not be [" + orders + "]" ) ; } this . orders = Arrays . asList ( orders ) ; return this ; } | Specifies sort orders by which the returned list is sorted . |
29,509 | public static boolean isClazzExists ( String name ) { try { Class . forName ( name , false , Decisions . class . getClassLoader ( ) ) ; } catch ( ClassNotFoundException e ) { return false ; } return true ; } | Checks if the given class name is exists |
29,510 | public static < T > Decision < T > unique ( ) { return new Decision < T > ( ) { private Set < T > seen = Sets . newHashSet ( ) ; private boolean sawNull = false ; public boolean apply ( T arg ) { if ( arg == null ) { boolean result = ! sawNull ; sawNull = true ; return result ; } else if ( seen . contains ( arg ) ) { return false ; } else { seen . add ( arg ) ; return true ; } } } ; } | Returns a stateful decision that returns true if its argument has been passed to the decision before else false . |
29,511 | protected void formatAndWrite ( LogLevel level , String correlationId , Exception error , String message , Object [ ] args ) { message = message != null ? message : "" ; if ( args != null && args . length > 0 ) message = String . format ( message , args ) ; write ( level , correlationId , error , message ) ; } | Formats the log message and writes it to the logger destination . |
29,512 | public void log ( LogLevel level , String correlationId , Exception error , String message , Object ... args ) { formatAndWrite ( level , correlationId , error , message , args ) ; } | Logs a message at specified log level . |
29,513 | public void warn ( String correlationId , String message , Object ... args ) { formatAndWrite ( LogLevel . Warn , correlationId , null , message , args ) ; } | Logs a warning that may or may not have a negative impact . |
29,514 | public void info ( String correlationId , String message , Object ... args ) { formatAndWrite ( LogLevel . Info , correlationId , null , message , args ) ; } | Logs an important information message |
29,515 | public void debug ( String correlationId , String message , Object ... args ) { formatAndWrite ( LogLevel . Debug , correlationId , null , message , args ) ; } | Logs a high - level debug information for troubleshooting . |
29,516 | public void trace ( String correlationId , String message , Object ... args ) { formatAndWrite ( LogLevel . Trace , correlationId , null , message , args ) ; } | Logs a low - level debug information for troubleshooting . |
29,517 | public static long getID3v2Length ( File file ) throws IOException { BufferedInputStream in = new BufferedInputStream ( new FileInputStream ( file ) ) ; try { byte buffer [ ] = new byte [ 10 ] ; if ( in . read ( buffer ) != 10 ) return 0 ; if ( buffer [ 0 ] != 'I' || buffer [ 1 ] != 'D' || buffer [ 2 ] != '3' ) return 0 ; return 10 + bytesToLength ( new byte [ ] { buffer [ 6 ] , buffer [ 7 ] , buffer [ 8 ] , buffer [ 9 ] } ) ; } finally { in . close ( ) ; } } | Takes the given file opens the header and reads the ID3v2 header size . The returned value is inclusive of the header preamble so taking the returned value and skipping exactly that number of bytes will place the read cursor at the correct beginning of the actual MP3 data . If the ID3v2 header is missing or the file is shorter than 10 bytes returns 0 . |
29,518 | public org . apache . commons . configuration . Configuration getConfiguration ( InjectionPoint injectionPoint ) { ConfigurationWrapper annotation = this . getConfigurationWrapper ( injectionPoint ) ; return this . getConfiguration ( annotation ) ; } | Given the injection point resolve an instance of Apache Commons Configuration |
29,519 | public org . apache . commons . configuration . Configuration getConfiguration ( ConfigurationWrapper wrapper ) { List < ISource > sources = this . locate ( wrapper ) ; OverrideCombiner combiner = new OverrideCombiner ( ) ; CombinedConfiguration combined = new CombinedConfiguration ( combiner ) ; for ( ISource source : sources ) { SupportedType type = MimeGuesser . guess ( source ) ; if ( ! source . available ( ) ) { continue ; } InputStream stream = source . stream ( ) ; if ( SupportedType . XML . equals ( type ) ) { XMLConfiguration xmlConfiguration = new XMLConfiguration ( ) ; try { xmlConfiguration . load ( stream ) ; combined . addConfiguration ( xmlConfiguration ) ; } catch ( ConfigurationException e ) { this . logger . error ( "An error occurred while reading XML properties: {}" , e . getMessage ( ) ) ; } } else { PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration ( ) ; try { propertiesConfiguration . load ( stream ) ; combined . addConfiguration ( propertiesConfiguration ) ; } catch ( ConfigurationException e ) { this . logger . error ( "An error occurred while reading properties: {}" , e . getMessage ( ) ) ; } } try { stream . close ( ) ; } catch ( IOException e ) { this . logger . trace ( "Could not close old stream: {}" , stream ) ; } if ( ! wrapper . merge ( ) ) { break ; } } return combined ; } | Shared implementation that is used to bootstrap other configurations if requested . |
29,520 | public static < T > Provider < T > ofInstance ( final T instance ) { return new Provider < T > ( ) { public T get ( ) { return instance ; } } ; } | Creates a provider which always returns the same getInstance . |
29,521 | Element evaluateXPathNode ( Node contextNode , String expression , Object ... args ) { return evaluateXPathNodeNS ( contextNode , null , expression , args ) ; } | Evaluate XPath expression expecting a single result node . |
29,522 | EList evaluateXPathNodeList ( Node contextNode , String expression , Object ... args ) { return evaluateXPathNodeListNS ( contextNode , null , expression , args ) ; } | Evaluate XPath expression expected to return nodes list . Evaluate expression and return result nodes as elements list . |
29,523 | String buildAttrXPath ( String name , String ... value ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "//*[@" ) ; sb . append ( name ) ; if ( value . length == 1 ) { sb . append ( "='" ) ; sb . append ( value [ 0 ] ) ; sb . append ( "'" ) ; } sb . append ( "]" ) ; return sb . toString ( ) ; } | Build XPath expression for elements with attribute name and optional value . |
29,524 | public void setInetAddress ( final String address ) { try { this . inetAddress = InetAddress . getByName ( address ) ; } catch ( final UnknownHostException e ) { throw new RuntimeException ( "Invalid address " + address ) ; } } | RADIUS server network address . |
29,525 | public void close ( ) { try { state = "CLOSING" ; if ( connection != null ) { logger . warn ( "Connection not committed, rolling back." ) ; rollback ( ) ; } if ( ! events . empty ( ) ) { state = "CLOSING EVENTS" ; do { Execution exec = ( Execution ) events . pop ( ) ; try { Stack < Execution > stack ; exec . close ( ) ; stack = eventCache . get ( exec . getClass ( ) . getName ( ) ) ; if ( stack != null ) { stack . push ( exec ) ; } } catch ( Throwable t ) { logger . error ( t . getMessage ( ) , t ) ; } } while ( ! events . empty ( ) ) ; } state = "CLOSED" ; } finally { if ( tracking ) { transactions . remove ( new Integer ( transactionId ) ) ; } events . clear ( ) ; statements . clear ( ) ; stackTrace = null ; } } | Closes the transaction . If the transaction has not been committed it is rolled back . |
29,526 | public void commit ( ) throws PersistenceException { try { if ( connection == null ) { if ( dirty ) { throw new PersistenceException ( "Attempt to commit a committed or aborted transaction." ) ; } return ; } state = "COMMITTING" ; try { connection . commit ( ) ; state = "CLOSING CONNECTIONS" ; connection . close ( ) ; connection = null ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( connectionCloseLog ( ) ) ; } if ( tracking ) { connections . decrementAndGet ( ) ; } close ( ) ; } catch ( SQLException e ) { throw new PersistenceException ( e . getMessage ( ) ) ; } finally { if ( connection != null ) { logger . warn ( "Commit failed: " + transactionId ) ; rollback ( ) ; } dirty = true ; } } finally { } } | Commits the transaction to the database and closes the transaction . The transaction should not be used or referenced after calling this method . |
29,527 | public HashMap < String , Object > execute ( Execution event , Map < String , Object > args ) throws PersistenceException { Map < String , Object > r = execute ( event . getClass ( ) , args ) ; if ( r == null ) { return null ; } if ( r instanceof HashMap ) { return ( HashMap < String , Object > ) r ; } else { HashMap < String , Object > tmp = new HashMap < String , Object > ( ) ; tmp . putAll ( r ) ; return tmp ; } } | Executes the specified event as part of this transaction . |
29,528 | private synchronized void open ( Execution event , String dsn ) throws SQLException , PersistenceException { try { Connection conn ; if ( connection != null ) { return ; } state = "OPENING" ; try { InitialContext ctx = new InitialContext ( ) ; DataSource ds ; if ( dsn == null ) { dsn = event . getDataSource ( ) ; } if ( dsn == null ) { throw new PersistenceException ( "No data source name" ) ; } state = "LOOKING UP" ; ds = dsCache . get ( dsn ) ; if ( ds == null ) { ds = ( DataSource ) ctx . lookup ( dsn ) ; if ( ds != null ) { dsCache . put ( dsn , ds ) ; } } if ( ds == null ) { throw new PersistenceException ( "Could not find data source: " + dsn ) ; } conn = ds . getConnection ( ) ; openTime = System . currentTimeMillis ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "DPTRANSID-" + transactionId + " connection.get - dsn='" + dsn + '\'' ) ; } state = "CONNECTED" ; } catch ( NamingException e ) { logger . error ( "Problem with datasource: " + e . getMessage ( ) ) ; throw new PersistenceException ( e . getMessage ( ) ) ; } conn . setAutoCommit ( false ) ; conn . setReadOnly ( readOnly ) ; connection = conn ; if ( tracking ) { connections . incrementAndGet ( ) ; transactions . put ( new Integer ( transactionId ) , this ) ; } } finally { } } | Opens a connection for the specified execution . |
29,529 | public void addLocale ( final LocaleId locale ) { synchronized ( this . locales ) { if ( this . locales == null ) { this . locales = new ArrayList < LocaleId > ( ) ; } this . locales . add ( locale ) ; } } | Add a locale to the list of managed locales . |
29,530 | public void removeLocale ( final LocaleId locale ) { LOG . info ( "Removing " + locale + " from further sync requests." ) ; synchronized ( locales ) { if ( locales . contains ( locale ) ) locales . remove ( locale ) ; } } | Remove a locale from being managed . |
29,531 | public String getString ( int index ) { Object object = getObject ( index ) ; try { return ( String ) object ; } catch ( ClassCastException exception ) { log . warn ( "Cannot cast value type (" + object . getClass ( ) . getName ( ) + ") to String for index (" + index + ")" ) ; } return null ; } | Retrieve an indexed element and return it as a String . |
29,532 | public Boolean getBoolean ( int index ) { String string = getString ( index ) ; return ( string != null ) ? Boolean . parseBoolean ( string ) : null ; } | Retrieve an indexed element and return it as a Boolean . |
29,533 | @ SuppressWarnings ( "WeakerAccess" ) public Long getLong ( int index ) { String string = getString ( index ) ; return ( string != null ) ? Long . parseLong ( string ) : null ; } | Retrieve an indexed element and return it as a Long . |
29,534 | public Integer getInteger ( int index ) { Long value = getLong ( index ) ; return ( value != null ) ? value . intValue ( ) : null ; } | Retrieve an indexed element and return it as an Integer . |
29,535 | public Double getDouble ( int index ) { String string = getString ( index ) ; return ( string != null ) ? Double . parseDouble ( string ) : null ; } | Retrieve an indexed element and return it as a Double . |
29,536 | public Float getFloat ( int index ) { Double value = getDouble ( index ) ; return ( value != null ) ? value . floatValue ( ) : null ; } | Retrieve an indexed element and return it as a Float . |
29,537 | public BagObject getBagObject ( int index ) { Object object = getObject ( index ) ; try { return ( BagObject ) object ; } catch ( ClassCastException exception ) { log . warn ( "Cannot cast value type (" + object . getClass ( ) . getName ( ) + ") to BagObject for index (" + index + ")" ) ; } return null ; } | Retrieve an indexed element and return it as a BagObject . |
29,538 | public BagArray getBagArray ( int index ) { Object object = getObject ( index ) ; try { return ( BagArray ) object ; } catch ( ClassCastException exception ) { log . warn ( "Cannot cast value type (" + object . getClass ( ) . getName ( ) + ") to BagArray for index (" + index + ")" ) ; } return null ; } | Retrieve an indexed element and return it as a BagArray . |
29,539 | private void init ( ) { Measure currSonarMeasure = null ; String currValue = null ; setValues ( new HashMap < HLAMeasure , String > ( ) ) ; setValuesInt ( new HashMap < HLAMeasure , Integer > ( ) ) ; setValuesDouble ( new HashMap < HLAMeasure , Double > ( ) ) ; setMeasures ( new ArrayList < HLAMeasure > ( ) ) ; setVersion ( getResource ( ) . getVersion ( ) ) ; for ( HLAMeasure currMeasure : HLAMeasure . values ( ) ) { LOG . debug ( "Analyzing measure " + currMeasure . getSonarName ( ) ) ; currSonarMeasure = getResource ( ) . getMeasure ( currMeasure . getSonarName ( ) ) ; if ( currSonarMeasure != null ) { LOG . debug ( "Found measure for " + currMeasure . getSonarName ( ) ) ; currValue = currSonarMeasure . getFormattedValue ( ) ; LOG . debug ( "Value is: " + currValue ) ; getValues ( ) . put ( currMeasure , currValue != null ? currValue : VALUE_NOT_AVAILABLE ) ; getValuesInt ( ) . put ( currMeasure , currSonarMeasure . getIntValue ( ) ) ; getValuesDouble ( ) . put ( currMeasure , currSonarMeasure . getValue ( ) ) ; getMeasures ( ) . add ( currMeasure ) ; } } } | Initialize the internal values . |
29,540 | public static ActivityEngine getDefaultEngine ( ) { if ( defaultEngine == null ) { synchronized ( ActivityEngineFactory . class ) { if ( defaultEngine == null ) { defaultEngine = makeDefaultEngine ( ) ; } } } return defaultEngine ; } | Retrieves the currently registered instance of engine as a default . |
29,541 | public int run ( String jobName , String [ ] args ) { int status = - 1 ; try { Class < ? extends SimpleJobTool > clazz = jobMap . get ( jobName ) ; if ( clazz == null ) { log . error ( "Tool " + jobName + " class not found." ) ; return status ; } status = ToolRunner . run ( clazz . newInstance ( ) , args ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; log . error ( e ) ; } return status ; } | Run the job . |
29,542 | public void addJob ( String name , Class < ? extends SimpleJobTool > clazz ) { jobMap . put ( name , clazz ) ; } | Add job sequence . |
29,543 | public String [ ] getJobList ( ) { String [ ] strings = new String [ jobMap . keySet ( ) . size ( ) ] ; int i = 0 ; for ( String s : jobMap . keySet ( ) ) { strings [ i ++ ] = s ; } return strings ; } | get job list |
29,544 | @ SuppressWarnings ( "rawtypes" ) public static Morphia create ( final Set < Class > classesToMap , final Set < Class < ? extends TypeConverter > > converters ) { Morphia morphia = ( classesToMap == null ? ( new Morphia ( ) ) : ( new Morphia ( classesToMap ) ) ) ; if ( converters != null && converters . size ( ) > 0 ) { DefaultConverters defaultConverters = morphia . getMapper ( ) . getConverters ( ) ; for ( Class < ? extends TypeConverter > converter : converters ) { defaultConverters . addConverter ( converter ) ; } } return morphia ; } | Construct a new instance with the classes to map and converters . |
29,545 | public static < T > Expiring < T > of ( Enumeration < T > enumeration ) { return of ( Iterators . forEnumeration ( enumeration ) ) ; } | Returns a new Expiring instance with given Enumeration |
29,546 | public Expiring < T > withDefault ( long expireTime , TimeUnit expireUnit ) { checkArgument ( expireTime > 0 ) ; this . defaultExpireTime = Optional . of ( expireTime ) ; this . defaultExpireUnit = Optional . of ( expireUnit ) ; return this ; } | Sets the default expire time and unit |
29,547 | public HttpClientBuilder basicAuth ( String username , String password ) { basicAuthUsername = username ; basicAuthPassword = password ; return this ; } | Turns on a Basic authentication . |
29,548 | public HttpClientBuilder sslEnabledProtocols ( String [ ] protocols ) { if ( protocols == null ) { sslEnabledProtocols = null ; } else { sslEnabledProtocols = new String [ protocols . length ] ; System . arraycopy ( protocols , 0 , sslEnabledProtocols , 0 , protocols . length ) ; } return this ; } | Sets a list of enabled SSL protocols . No other protocol will not be used . |
29,549 | public HttpClientBuilder timeouts ( int connectionTimeout , int soTimeout , long connectionManagerTimeout ) { this . connectionTimeout = connectionTimeout ; this . soTimeout = soTimeout ; this . connectionManagerTimeout = connectionManagerTimeout ; return this ; } | Configures timeouts of the HttpClient being built . |
29,550 | public HttpClient build ( ) { HttpClient httpClient = new HttpClient ( ) ; if ( proxyHost != null ) { ProxyHost h ; if ( proxyPort == - 1 ) { h = new ProxyHost ( proxyHost ) ; } else { h = new ProxyHost ( proxyHost , proxyPort ) ; } httpClient . getHostConfiguration ( ) . setProxyHost ( h ) ; } if ( basicAuthUsername != null ) { httpClient . getParams ( ) . setAuthenticationPreemptive ( authenticationPreemprive ) ; AuthScope authscope = new AuthScope ( basicAuthHost == null ? AuthScope . ANY_HOST : basicAuthHost , basicAuthPort == - 1 ? AuthScope . ANY_PORT : basicAuthPort ) ; Credentials credentials = new UsernamePasswordCredentials ( basicAuthUsername , basicAuthPassword ) ; httpClient . getState ( ) . setCredentials ( authscope , credentials ) ; } if ( sslHostConfig != null ) { sslHostConfigs . put ( secureHost , sslHostConfig ) ; } for ( Entry < String , SslHostConfig > entry : sslHostConfigs . entrySet ( ) ) { String host = entry . getKey ( ) ; SslHostConfig config = entry . getValue ( ) ; AuthSSLProtocolSocketFactory factory = new AuthSSLProtocolSocketFactory ( config . keyStoreUrl , config . keyStorePassword , config . trustKeyStoreUrl , config . trustKeyStorePassword ) ; if ( sslEnabledProtocols != null ) { factory . setEnabledProtocols ( sslEnabledProtocols ) ; } Protocol protocol = createProtocol ( factory , config ) ; httpClient . getHostConfiguration ( ) . setHost ( host , config . securePort , protocol ) ; } httpClient . getParams ( ) . setSoTimeout ( soTimeout ) ; httpClient . getParams ( ) . setConnectionManagerTimeout ( connectionManagerTimeout ) ; httpClient . getHttpConnectionManager ( ) . getParams ( ) . setConnectionTimeout ( connectionTimeout ) ; return httpClient ; } | Builds the configured HttpClient . |
29,551 | @ SuppressWarnings ( "unchecked" ) protected void processObject ( Object tempelObject , Set < String > objectClassPath , ITemplateRepository templateRepository , ITemplateSourceFactory templateSourceFactory ) { if ( tempelObject instanceof Map ) { properties = new TreeMap < String , String > ( ) ; Map < String , String > scopeProperties = ( Map < String , String > ) tempelObject ; for ( String key : scopeProperties . keySet ( ) ) { String value = scopeProperties . get ( key ) ; properties . put ( key , value ) ; } return ; } if ( tempelObject instanceof List ) { dependencies = ( List < TempelDependency > ) tempelObject ; return ; } if ( tempelObject instanceof Template ) { Template < ? > template = ( Template < ? > ) tempelObject ; template . addTemplateClassPathExtender ( new RepositoryTemplateClassPathExtender ( ) ) ; template . addTemplateClassPathExtender ( new DependenciesTemplateClassPathExtender ( ) ) ; template . addTemplateClassPathExtender ( new FixedSetTemplateClassPathExtender ( objectClassPath ) ) ; if ( template . getResources ( ) != null ) { for ( TemplateResource resource : template . getResources ( ) ) { resource . setParentTemplateReference ( template ) ; } } String gId = StringUtils . emptyIfBlank ( template . getGroupId ( ) ) ; String tId = StringUtils . emptyIfBlank ( template . getTemplateId ( ) ) ; String ver = StringUtils . emptyIfBlank ( template . getVersion ( ) ) ; if ( ! StringUtils . isBlank ( gId ) ) { templates . add ( gId + ":" + tId + ":" + ver ) ; templateRepository . put ( null , gId , tId , ver , template ) ; } String key = template . getKey ( ) ; if ( ! StringUtils . isBlank ( key ) ) { templateRepository . put ( key , null , null , null , template ) ; } template . setTemplateSourceFactory ( templateSourceFactory ) ; return ; } } | Przetwarza obiekt odczytany z pliku tempel . xml . |
29,552 | public String getHost ( ) { String host = getAsNullableString ( "host" ) ; host = host != null ? host : getAsNullableString ( "ip" ) ; return host ; } | Gets the host name or IP address . |
29,553 | public static ConnectionParams fromString ( String line ) { StringValueMap map = StringValueMap . fromString ( line ) ; return new ConnectionParams ( map ) ; } | Creates a new ConnectionParams object filled with key - value pairs serialized as a string . |
29,554 | public static ConnectionParams fromTuples ( Object ... tuples ) { StringValueMap map = StringValueMap . fromTuplesArray ( tuples ) ; return new ConnectionParams ( map ) ; } | Creates a new ConnectionParams object filled with provided key - value pairs called tuples . Tuples parameters contain a sequence of key1 value1 key2 value2 ... pairs . |
29,555 | public static List < ConnectionParams > manyFromConfig ( ConfigParams config , boolean configAsDefault ) { List < ConnectionParams > result = new ArrayList < ConnectionParams > ( ) ; ConfigParams connections = config . getSection ( "connections" ) ; if ( connections . size ( ) > 0 ) { List < String > connectionSections = connections . getSectionNames ( ) ; for ( String section : connectionSections ) { ConfigParams connection = connections . getSection ( section ) ; result . add ( new ConnectionParams ( connection ) ) ; } } else { ConfigParams connection = config . getSection ( "connection" ) ; if ( connection . size ( ) > 0 ) result . add ( new ConnectionParams ( connection ) ) ; else if ( configAsDefault ) result . add ( new ConnectionParams ( config ) ) ; } return result ; } | Retrieves all ConnectionParams from configuration parameters from connections section . If connection section is present instead than it returns a list with only one ConnectionParams . |
29,556 | public static ConnectionParams fromConfig ( ConfigParams config , boolean configAsDefault ) { List < ConnectionParams > connections = manyFromConfig ( config , configAsDefault ) ; return connections . size ( ) > 0 ? connections . get ( 0 ) : null ; } | Retrieves a single ConnectionParams from configuration parameters from connection section . If connections section is present instead then is returns only the first connection element . |
29,557 | protected Transformer _newTransformer ( ) { Transformer transformer = null ; if ( _stylesheet == null ) { try { transformer = TransformerFactory . newInstance ( ) . newTransformer ( ) ; } catch ( Exception ex ) { throw new XmlException ( ex ) ; } return transformer ; } if ( _templates == null ) { _templates = _getTemplates ( _stylesheet ) ; } try { transformer = _templates . newTransformer ( ) ; if ( _params . size ( ) > 0 ) { for ( String name : _params . keySet ( ) ) { Object value = _params . get ( name ) ; transformer . setParameter ( name , value ) ; } } } catch ( Exception ex ) { throw new XmlException ( ex ) ; } return transformer ; } | Creates a new JAXP Transformer . If there are parameters specified they are passed to the Transformer . |
29,558 | protected static Templates _getTemplates ( final URL stylesheet ) { Templates templates = _templatesCache . get ( stylesheet ) ; if ( templates == null ) { InputStream is = null ; try { is = stylesheet . openStream ( ) ; templates = TransformerFactory . newInstance ( ) . newTemplates ( new StreamSource ( is ) ) ; } catch ( Exception ex ) { throw new XmlException ( ex ) ; } finally { try { if ( is != null ) { is . close ( ) ; } } catch ( IOException io_ex ) { _LOG_ . warn ( io_ex . toString ( ) ) ; } } _templatesCache . put ( stylesheet , templates ) ; } return templates ; } | Returns a Templates object i . e . a compiled XSLT stylesheet of the specified URL . Once the stylesheet is loaded it is cached for the next time . That is firstly the cache is searched for the URL . |
29,559 | public static void main ( String [ ] args ) { CommandLineParser commandLine = new CommandLineParser ( new String [ ] [ ] { { "s" , "The sequence definition." , "[m:...:n](:sample=s)(:exp)" , "true" , MathUtils . SEQUENCE_REGEXP } , { "d" , "The duration definition." , "dDhHmMsS" , "false" , MathUtils . DURATION_REGEXP } } ) ; ParsedProperties options = null ; try { options = new ParsedProperties ( commandLine . parseCommandLine ( args ) ) ; } catch ( IllegalArgumentException e ) { e = null ; System . out . println ( commandLine . getErrors ( ) ) ; System . out . println ( commandLine . getUsage ( ) ) ; System . exit ( - 1 ) ; } String sequence = options . getProperty ( "s" ) ; String durationString = options . getProperty ( "d" ) ; System . out . println ( "Sequence is: " + printArray ( parseSequence ( sequence ) ) ) ; if ( durationString != null ) { System . out . println ( "Duration is: " + parseDuration ( durationString ) ) ; } } | Runs a quick test of the sequence generation methods to confirm that they work as expected . |
29,560 | public static long parseDuration ( CharSequence duration ) { Matcher matcher = DURATION_PATTERN . matcher ( duration ) ; if ( ! matcher . matches ( ) ) { throw new IllegalArgumentException ( "The duration definition is not in the correct format." ) ; } long result = 0 ; int numGroups = matcher . groupCount ( ) ; if ( numGroups >= 1 ) { String daysString = matcher . group ( 1 ) ; result += ( daysString == null ) ? 0 : ( Long . parseLong ( daysString . substring ( 0 , daysString . length ( ) - 1 ) ) * 24 * 60 * 60 * 1000 ) ; } if ( numGroups >= 2 ) { String hoursString = matcher . group ( 2 ) ; result += ( hoursString == null ) ? 0 : ( Long . parseLong ( hoursString . substring ( 0 , hoursString . length ( ) - 1 ) ) * 60 * 60 * 1000 ) ; } if ( numGroups >= 3 ) { String minutesString = matcher . group ( 3 ) ; result += ( minutesString == null ) ? 0 : ( Long . parseLong ( minutesString . substring ( 0 , minutesString . length ( ) - 1 ) ) * 60 * 1000 ) ; } if ( numGroups >= 4 ) { String secondsString = matcher . group ( 4 ) ; result += ( secondsString == null ) ? 0 : ( Long . parseLong ( secondsString . substring ( 0 , secondsString . length ( ) - 1 ) ) * 1000 ) ; } return result ; } | Parses a duration defined as a string giving a duration in days hours minutes and seconds into a number of milliseconds equal to that duration . |
29,561 | public static String printArray ( int [ ] array ) { String result = "[" ; for ( int i = 0 ; i < array . length ; i ++ ) { result += array [ i ] ; result += ( i < ( array . length - 1 ) ) ? ", " : "" ; } result += "]" ; return result ; } | Pretty prints an array of ints as a string . |
29,562 | public static int maxInArray ( int [ ] values ) { if ( ( values == null ) || ( values . length == 0 ) ) { throw new IllegalArgumentException ( "Cannot find the max of a null or empty array." ) ; } int max = values [ 0 ] ; for ( int value : values ) { max = ( max < value ) ? value : max ; } return max ; } | Returns the maximum value in an array of integers . |
29,563 | private static void roundAndAdd ( Collection < Integer > result , double value ) { int roundedValue = ( int ) Math . round ( value ) ; if ( ! result . contains ( roundedValue ) ) { result . add ( roundedValue ) ; } } | Rounds the specified floating point value to the nearest integer and adds it to the specified list of integers provided it is not already in the list . |
29,564 | protected final void doDefaults ( final Map < K , ? extends V > defaults ) { apply ( defaults . isEmpty ( ) ? Nop . instance ( ) : new Defaults < > ( defaults ) ) ; } | Post a delta consisting of defaults to register . |
29,565 | protected final void doRemove ( final Collection < K > toRemove ) { apply ( toRemove . isEmpty ( ) ? Nop . instance ( ) : new Remove < > ( toRemove ) ) ; } | Post a delta consisting of items to remove . |
29,566 | protected final void doUpdates ( final K key , final Function < ? super V , ? extends V > mutate ) { apply ( new Update < > ( key , mutate ) ) ; } | Post a delta consisting of a single update . |
29,567 | protected final void doUpdates ( final Map < K , Function < ? super V , ? extends V > > mutators ) { apply ( mutators . isEmpty ( ) ? Nop . instance ( ) : new Update < > ( mutators ) ) ; } | Post a delta consisting of updates . |
29,568 | protected final void doValues ( final Map < K , ? extends V > entries ) { apply ( entries . isEmpty ( ) ? Nop . instance ( ) : new Values < > ( entries ) ) ; } | Post a delta consisting of map entries . |
29,569 | public static final boolean stringIsBlank ( final String string ) { if ( string == null || string . length ( ) == 0 ) { return true ; } int stringLength = string . length ( ) ; for ( int i = 0 ; i < stringLength ; i ++ ) { if ( Character . isWhitespace ( string . charAt ( i ) ) == false ) { return false ; } } return true ; } | Checks if the provided String is blank meaning it is empty or contains whitespace only . |
29,570 | public static final String arrayToString ( final Object [ ] array ) { final StringBuilder builder = new StringBuilder ( ) ; builder . append ( ARRAY_START ) ; if ( array != null && array . length > 0 ) { appendNonEmptyArrayToString ( array , builder ) ; } builder . append ( ARRAY_END ) ; return builder . toString ( ) ; } | Provides a string representation of the provided array of objects . |
29,571 | public static String replaceStringInString ( final String text , final String searchString , final String replacement ) { if ( stringIsBlank ( text ) || stringIsBlank ( searchString ) || replacement == null ) { return text ; } int start = 0 ; int end = text . indexOf ( searchString , start ) ; if ( end == INDEX_NOT_FOUND ) { return text ; } final int replacedLength = searchString . length ( ) ; final StringBuilder builder = new StringBuilder ( ) ; while ( end != INDEX_NOT_FOUND ) { builder . append ( text . substring ( start , end ) ) . append ( replacement ) ; start = end + replacedLength ; end = text . indexOf ( searchString , start ) ; } builder . append ( text . substring ( start ) ) ; return builder . toString ( ) ; } | Replaces all occurrences of a string within a larger string with a replacement string . |
29,572 | protected void setupClasspathJarResourceIfNeeds ( WebAppContext context ) { if ( isWarableWorld ( ) || ! isValidMetaInfConfiguration ( ) ) { return ; } final List < String > classpathList = extractJarClassspathList ( ) ; for ( String classpath : classpathList ) { final String jarPath = convertClasspathToJarPath ( classpath ) ; final URL url ; try { url = new URL ( jarPath ) ; } catch ( MalformedURLException e ) { throw new IllegalStateException ( "Failed to create URL from the jar path: " + jarPath , e ) ; } context . getMetaData ( ) . addContainerResource ( new JarResource ( url ) { } ) ; } } | so manually enable it |
29,573 | public static void registerMixinType ( Session session , String mixin ) throws RepositoryException { NodeTypeManager nodeTypeManager = session . getWorkspace ( ) . getNodeTypeManager ( ) ; if ( ! nodeTypeManager . hasNodeType ( mixin ) ) { NodeTypeTemplate nodeTypeTemplate = nodeTypeManager . createNodeTypeTemplate ( ) ; nodeTypeTemplate . setMixin ( true ) ; nodeTypeTemplate . setName ( mixin ) ; NodeTypeDefinition [ ] nodeTypes = new NodeTypeDefinition [ ] { nodeTypeTemplate } ; nodeTypeManager . registerNodeTypes ( nodeTypes , true ) ; } } | Register new mixin type if does not exists on workspace |
29,574 | public static void registerAndAddMixinType ( Session session , Node node , String mixin ) throws RepositoryException { registerMixinType ( session , mixin ) ; if ( ! Arrays . asList ( node . getMixinNodeTypes ( ) ) . contains ( mixin ) ) { node . addMixin ( mixin ) ; } } | Register new mixin type if does not exists on workspace the add it to the given node |
29,575 | private void enlistTransaction ( ) { this . cleanupTransactionBinding ( ) ; TransactionBindingType transactionBindingType = this . transactionBinding . getTransactionBindingType ( ) ; if ( this . isInGlobalTransaction ( ) && transactionBindingType != TransactionBindingType . GlobalTransaction ) { try { Transaction ntx = this . transactionManager . getTransaction ( ) ; if ( ! enlisted && ntx != null ) { this . enlisted = true ; this . enlisted = ntx . enlistResource ( this . xaResource ) ; if ( ! enlisted ) { LOG . error ( "Enlisting " + xaResource + " failed" ) ; } else { } } else { LOG . debug ( "SampleXAConnection:connectionRequiresTransaction (no globalTransaction found)" ) ; } } catch ( RollbackException n ) { LOG . error ( "SampleXAConnection:prevokeAction enlistResource exception : " + n . toString ( ) ) ; } catch ( SystemException n ) { LOG . error ( "SampleXAConnection:connectionRequiresTransaction " + n + "\n" + ExceptionUtils . getStackTrace ( n ) ) ; throw new DelegatedRuntimeException ( n ) ; } } else if ( transactionBindingType == TransactionBindingType . NoTransaction ) { this . transactionBinding . activateLocalTransaction ( new LocalTransactionProxy < C > ( this . managedConnectionFactory . getManagedConnection ( ) ) ) ; } else { if ( this . isInGlobalTransaction ( ) && transactionBindingType == TransactionBindingType . GlobalTransaction ) { } else if ( ! this . isInGlobalTransaction ( ) && transactionBindingType == TransactionBindingType . LocalTransaction ) { } } } | if necessary the current xa resource is enlisted in the current TX . |
29,576 | protected void writeHandler ( IndentedWriter writer , String uiOwner , String handlerVarName , JClassType handlerType , JClassType eventType , String boundMethod ) throws UnableToCompleteException { JMethod [ ] methods = handlerType . getMethods ( ) ; if ( methods . length != 1 ) { logger . die ( "'%s' has more than one method defined." , handlerType . getName ( ) ) ; } JParameter [ ] parameters = methods [ 0 ] . getParameters ( ) ; if ( parameters . length != 1 || parameters [ 0 ] . getType ( ) != eventType ) { logger . die ( "Method '%s' needs '%s' as parameter" , methods [ 0 ] . getName ( ) , eventType . getName ( ) ) ; } writer . newline ( ) ; writer . write ( "final %1$s %2$s = new %1$s() {" , handlerType . getParameterizedQualifiedSourceName ( ) , handlerVarName ) ; writer . indent ( ) ; writer . write ( "public void %1$s(%2$s event) {" , methods [ 0 ] . getName ( ) , eventType . getParameterizedQualifiedSourceName ( ) ) ; writer . indent ( ) ; writer . write ( "%1$s.%2$s(event);" , uiOwner , boundMethod ) ; writer . outdent ( ) ; writer . write ( "}" ) ; writer . outdent ( ) ; writer . write ( "};" ) ; } | Writes a handler entry using the given writer . |
29,577 | private JClassType getHandlerForEvent ( JClassType eventType ) { if ( eventType == null ) { return null ; } JMethod method = eventType . findMethod ( "getAssociatedType" , new JType [ 0 ] ) ; if ( method == null ) { logger . warn ( "Method 'getAssociatedType()' could not be found in the event '%s'." , eventType . getName ( ) ) ; return null ; } JType returnType = method . getReturnType ( ) ; if ( returnType == null ) { logger . warn ( "The method 'getAssociatedType()' in the event '%s' returns void." , eventType . getName ( ) ) ; return null ; } JParameterizedType isParameterized = returnType . isParameterized ( ) ; if ( isParameterized == null ) { logger . warn ( "The method 'getAssociatedType()' in '%s' does not return Type<? extends EventHandler>." , eventType . getName ( ) ) ; return null ; } JClassType [ ] argTypes = isParameterized . getTypeArgs ( ) ; if ( ( argTypes . length != 1 ) && ! argTypes [ 0 ] . isAssignableTo ( eventHandlerJClass ) ) { logger . warn ( "The method 'getAssociatedType()' in '%s' does not return Type<? extends EventHandler>." , eventType . getName ( ) ) ; return null ; } return argTypes [ 0 ] ; } | Retrieves the handler associated with the event . |
29,578 | private static CloudErrorType toCloudErrorType ( String code ) { if ( "Throttling" . equals ( code ) ) { return CloudErrorType . THROTTLING ; } else if ( "TooManyBuckets" . equals ( code ) ) { return CloudErrorType . QUOTA ; } else if ( "SignatureDoesNotMatch" . equals ( code ) ) { return CloudErrorType . AUTHENTICATION ; } else { return CloudErrorType . GENERAL ; } } | Converts AWS error code to dasein cloud error type |
29,579 | private static byte [ ] requestWebContent ( String url ) throws TVRageException { try { HttpGet httpGet = new HttpGet ( url ) ; httpGet . addHeader ( "accept" , "application/xml" ) ; final DigestedResponse response = DigestedResponseReader . requestContent ( httpClient , httpGet , CHARSET ) ; if ( response . getStatusCode ( ) >= 500 ) { throw new TVRageException ( ApiExceptionType . HTTP_503_ERROR , url ) ; } else if ( response . getStatusCode ( ) >= 300 ) { throw new TVRageException ( ApiExceptionType . HTTP_404_ERROR , url ) ; } return response . getContent ( ) . getBytes ( DEFAULT_CHARSET ) ; } catch ( IOException ex ) { throw new TVRageException ( ApiExceptionType . MAPPING_FAILED , UNABLE_TO_PARSE , url , ex ) ; } } | Get content from URL in byte array |
29,580 | public static String getFilename ( final URL url ) throws UnsupportedEncodingException { if ( isJar ( url ) || isEar ( url ) ) { String fileName = URLDecoder . decode ( url . getFile ( ) , "UTF-8" ) ; fileName = fileName . substring ( 5 , fileName . indexOf ( "!" ) ) ; return fileName ; } return URLDecoder . decode ( url . getFile ( ) , "UTF-8" ) ; } | Gets the filename from the given url object . |
29,581 | public Map < String , Object > downloadAsFile ( Map < String , Object > params , HttpServletRequest request , HttpServletResponse response ) throws Exception { String database = Objects . get ( params , "database" ) ; String collection = Objects . get ( params , "collection" , COLLECTION ) ; String id = Objects . get ( params , "id" ) ; String name = Objects . get ( params , "name" ) ; FileStorage . FileReadBean b = null ; try { b = FileStorage . read ( new Id ( database , collection , id ) ) ; response . setContentType ( b . getMeta ( ) . getContentType ( ) ) ; if ( Objects . isNullOrEmpty ( name ) ) { name = b . getMeta ( ) . getName ( ) ; if ( name . length ( ) > 100 ) name = name . substring ( 0 , 100 ) ; if ( ! Objects . isNullOrEmpty ( b . getMeta ( ) . getExt ( ) ) ) name += "." + b . getMeta ( ) . getExt ( ) ; } response . addHeader ( "Content-Disposition" , "attachment;filename=" + URLEncoder . encode ( name , "UTF-8" ) ) ; try { IOUtils . copy ( b . getInputStream ( ) , response . getOutputStream ( ) ) ; } catch ( IOException e ) { throw S1SystemError . wrap ( e ) ; } } catch ( NotFoundException e ) { response . setStatus ( 404 ) ; } finally { FileStorage . closeAfterRead ( b ) ; } return null ; } | Download file from storage with content - disposition |
29,582 | public MultiPos < String , String , String > by ( final Object replacement ) { return new MultiPos < String , String , String > ( checkNotNull ( replacement ) . toString ( ) , null ) { protected String result ( ) { return findingReplacing ( left , Character . class . isInstance ( replacement ) ? 'C' : 'S' , pos , position ) ; } } ; } | Returns a MultiPos instance with all occurrences with given replacement |
29,583 | private void setType ( Type type ) { setSamplesPerSecond ( type . getSamplesPerSecond ( ) ) ; setFramesPerSecond ( type . getFramesPerSecond ( ) ) ; setUseSamples ( type . usesSamples ( ) ) ; } | Sets this timecodes samplesPerSecond and framesPerSecond based on the given type |
29,584 | public int toIntSeconds ( ) { int _minutes = getHours ( ) * 60 ; _minutes += getMinutes ( ) ; int _seconds = _minutes * 60 ; _seconds += getSeconds ( ) ; return _seconds ; } | Hours are added to the minutes and minutes are added to the seconds value so seconds could be larger than 60 . Units smaller than seconds are ignored completely . |
29,585 | private int getToken ( String inString , int index ) throws Timecode . TimecodeException { inString = inString . trim ( ) ; String valid = "0123456789" ; String token = "" ; int count = 0 ; for ( int i = 0 ; i < inString . length ( ) ; i ++ ) { char current = inString . charAt ( i ) ; if ( valid . indexOf ( current ) > - 1 ) { token += current ; } else { count ++ ; if ( count > index ) break ; token = "" ; } } if ( count < index || token . equals ( "" ) ) throw new Timecode . TimecodeException ( "Malformed timecode '" + inString + "', can't get index=" + index ) ; try { return Integer . parseInt ( token ) ; } catch ( NumberFormatException ex ) { throw new Timecode . TimecodeException ( "Malformed timecode '" + inString + "', '" + token + "' is not an integer" ) ; } } | Breaks a string on any non - numeric character and returns the index token zero indexed |
29,586 | private static String __getExtension ( String path ) { for ( int i = path . length ( ) - 1 ; i >= 0 ; i -- ) { if ( path . charAt ( i ) == '.' ) { return path . substring ( i + 1 ) ; } } return "" ; } | Returns the file extension acording to given path . |
29,587 | static String _getMimeType ( String uriOrPath ) { String mime = MIME_MAP . get ( __getExtension ( uriOrPath ) ) ; if ( mime == null ) { mime = DEFAULT_MIME ; } return mime ; } | Returns the mime - type associated with given URI or path |
29,588 | private static long __parseLong ( String strLong , long defaultValue ) { try { return Long . parseLong ( strLong ) ; } catch ( NumberFormatException ex ) { return defaultValue ; } } | value if given string could not be parsed . |
29,589 | private static Map < String , String > __getRequestHeaderMap ( HttpServletRequest req ) { Map < String , String > reqHeaders = new LinkedHashMap < > ( ) ; Enumeration < String > headerNames = req . getHeaderNames ( ) ; if ( headerNames != null ) { while ( headerNames . hasMoreElements ( ) ) { String headerName = headerNames . nextElement ( ) ; Enumeration < String > headerValues = req . getHeaders ( headerName ) ; if ( headerValues != null ) { StringBuilder headerValueBuilder = new StringBuilder ( ) ; int i = 0 ; while ( headerValues . hasMoreElements ( ) ) { if ( i > 0 ) { headerValueBuilder . append ( ", " ) ; } headerValueBuilder . append ( headerValues . nextElement ( ) ) ; i ++ ; } reqHeaders . put ( headerName , headerValueBuilder . toString ( ) ) ; } else { reqHeaders . put ( headerName , "" ) ; } } } return reqHeaders ; } | Retrive a map containing the request headers associated with given request . |
29,590 | private static void __flush ( InputStream is , OutputStream os , int bufferSize ) throws IOException { byte [ ] buffer = new byte [ bufferSize ] ; for ( int length = 0 ; ( length = is . read ( buffer ) ) > 0 ; ) { os . write ( buffer , 0 , length ) ; } } | buffer of given size |
29,591 | private static String __getStackTrace ( Throwable throwable ) { StringWriter stringWriter = new StringWriter ( ) ; throwable . printStackTrace ( new PrintWriter ( stringWriter ) ) ; return stringWriter . toString ( ) ; } | given throwable . |
29,592 | public < E > E get ( Class < E > clss ) { testControllerClass ( clss ) ; synchronized ( controllers ) { for ( Controller controller : controllers ) { if ( clss . isAssignableFrom ( controller . getClass ( ) ) ) { return clss . cast ( controller ) ; } } } return null ; } | Gets the controller of a specific class . |
29,593 | public long getMillisecondsFromId ( final Object id , final long offset ) { if ( id instanceof String && id . toString ( ) . length ( ) >= MAX_LONG_ALPHANUMERIC_VALUE_LENGTH ) { final char [ ] buffer = new char [ MAX_LONG_ALPHANUMERIC_VALUE_LENGTH ] ; System . arraycopy ( id . toString ( ) . toCharArray ( ) , 0 , buffer , 0 , MAX_LONG_ALPHANUMERIC_VALUE_LENGTH ) ; final boolean overflow = buffer [ 0 ] > '1' ; if ( overflow ) { buffer [ 0 ] -= 2 ; } long value = Long . parseLong ( new String ( buffer ) , ALPHA_NUMERIC_CHARSET_SIZE ) ; if ( overflow ) { value -= Long . MAX_VALUE + 1 ; } return value + offset ; } throw new IllegalArgumentException ( "'" + id + "' is not an id from this generator" ) ; } | Retrieve the number of milliseconds since 1st Jan 1970 that were the base for the given id . |
29,594 | public void setBindingToNegate ( final Binding binding ) { if ( binding == null ) { throw new IllegalArgumentException ( "no binding to negate specified" ) ; } if ( binding == this ) { throw new IllegalArgumentException ( "binding to negate is 'this' binding" ) ; } _bindingToNegate = binding ; } | Sets the binding to negate . |
29,595 | @ SuppressWarnings ( "unchecked" ) static public < T extends Execution > T getInstance ( Class < T > cls ) { logger . debug ( "enter - getInstance()" ) ; try { Stack < Execution > stack ; synchronized ( cache ) { if ( ! cache . containsKey ( cls . getName ( ) ) ) { return cls . newInstance ( ) ; } else { stack = cache . get ( cls . getName ( ) ) ; } } synchronized ( stack ) { if ( stack . empty ( ) ) { return cls . newInstance ( ) ; } else { return ( T ) stack . pop ( ) ; } } } catch ( InstantiationException e ) { throw new RuntimeException ( e . getMessage ( ) ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e . getMessage ( ) ) ; } finally { logger . debug ( "exit - getInstance()" ) ; } } | Provides an instance of an execution object for a specific subclass . Executions are stored in a hash map of stacks . This enables an instance to be reused if possible . Otherwise a new one is created . |
29,596 | public void close ( ) { logger . debug ( "enter - close()" ) ; try { connection = null ; data = null ; synchronized ( executions ) { executions . add ( this ) ; executions . notifyAll ( ) ; } } finally { logger . debug ( "exit - close()" ) ; } } | Closes out the event and returns it to the shared stack . |
29,597 | public HashMap < String , Object > execute ( Transaction trans , Map < String , Object > args ) throws PersistenceException { Map < String , Object > r = executeEvent ( trans , args , null ) ; if ( r instanceof HashMap ) { return ( HashMap < String , Object > ) r ; } else { HashMap < String , Object > tmp = new HashMap < String , Object > ( ) ; tmp . putAll ( r ) ; return tmp ; } } | Executes this event in the specified transaction context . |
29,598 | protected void save ( List < Counter > counters ) { if ( _logger == null ) return ; if ( counters . size ( ) == 0 ) return ; Collections . sort ( counters , ( c1 , c2 ) -> c1 . getName ( ) . compareTo ( c2 . getName ( ) ) ) ; for ( Counter counter : counters ) { _logger . info ( "counters" , counterToString ( counter ) ) ; } } | Saves the current counters measurements . |
29,599 | protected void ensureLongestLemma ( String lemma ) { this . longestLemma = Math . max ( this . longestLemma , lemma . split ( "\\s+" ) . length ) ; } | Ensure longest lemma . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.