idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
13,600
public static long parseSize ( String s ) { Matcher m = p_mem . matcher ( s ) ; if ( m . find ( ) ) { long i = Long . parseLong ( m . group ( 1 ) ) ; char multiplier = 'B' ; if ( m . group ( 2 ) != null && m . group ( 2 ) . length ( ) == 1 ) { multiplier = m . group ( 2 ) . charAt ( 0 ) ; } if ( multiplier == 'B' ) { r...
This methods parses the given String which should represent a size to a long . K is interpreted as 1024 M as 1024^2 and G as 1024^3 .
13,601
public String getSequenceId ( ) { if ( OutputElement_Type . featOkTst && ( ( OutputElement_Type ) jcasType ) . casFeat_sequenceId == null ) jcasType . jcas . throwFeatMissing ( "sequenceId" , "edu.cmu.lti.oaqa.framework.types.OutputElement" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( OutputElement_Typ...
getter for sequenceId - gets
13,602
public void setSequenceId ( String v ) { if ( OutputElement_Type . featOkTst && ( ( OutputElement_Type ) jcasType ) . casFeat_sequenceId == null ) jcasType . jcas . throwFeatMissing ( "sequenceId" , "edu.cmu.lti.oaqa.framework.types.OutputElement" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( OutputElement_Typ...
setter for sequenceId - sets
13,603
public String getAnswer ( ) { if ( OutputElement_Type . featOkTst && ( ( OutputElement_Type ) jcasType ) . casFeat_answer == null ) jcasType . jcas . throwFeatMissing ( "answer" , "edu.cmu.lti.oaqa.framework.types.OutputElement" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( OutputElement_Type ) jcasType...
getter for answer - gets
13,604
public void setAnswer ( String v ) { if ( OutputElement_Type . featOkTst && ( ( OutputElement_Type ) jcasType ) . casFeat_answer == null ) jcasType . jcas . throwFeatMissing ( "answer" , "edu.cmu.lti.oaqa.framework.types.OutputElement" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( OutputElement_Type ) jcasType...
setter for answer - sets
13,605
public void add ( int pos , Name name ) { if ( pos > MAX_POINTER ) return ; int row = ( name . hashCode ( ) & 0x7FFFFFFF ) % TABLE_SIZE ; Entry entry = new Entry ( ) ; entry . name = name ; entry . pos = pos ; entry . next = table [ row ] ; table [ row ] = entry ; if ( verbose ) System . err . println ( "Adding " + nam...
Adds a compression entry mapping a name to a position in a message .
13,606
public int get ( Name name ) { int row = ( name . hashCode ( ) & 0x7FFFFFFF ) % TABLE_SIZE ; int pos = - 1 ; for ( Entry entry = table [ row ] ; entry != null ; entry = entry . next ) { if ( entry . name . equals ( name ) ) pos = entry . pos ; } if ( verbose ) System . err . println ( "Looking for " + name + ", found "...
Retrieves the position of the given name if it has been previously included in the message .
13,607
public int open ( String Filename , int NewMode ) { int retcode = DDC_SUCCESS ; if ( fmode != RFM_UNKNOWN ) { retcode = close ( ) ; } if ( retcode == DDC_SUCCESS ) { switch ( NewMode ) { case RFM_WRITE : try { file = new RandomAccessFile ( Filename , "rw" ) ; fmode = RFM_WRITE ; if ( writeHeader_internally ( riff_heade...
Open a RIFF file .
13,608
public int read ( byte [ ] Data , int NumBytes ) { int retcode = DDC_SUCCESS ; try { file . read ( Data , 0 , NumBytes ) ; } catch ( IOException ioe ) { retcode = DDC_FILE_ERROR ; } return retcode ; }
Read NumBytes data .
13,609
public int expect ( String Data , int NumBytes ) { byte target = 0 ; int cnt = 0 ; try { while ( ( NumBytes -- ) != 0 ) { target = file . readByte ( ) ; if ( target != Data . charAt ( cnt ++ ) ) return DDC_FILE_ERROR ; } } catch ( IOException ioe ) { return DDC_FILE_ERROR ; } return DDC_SUCCESS ; }
Expect NumBytes data .
13,610
public int close ( ) { int retcode = DDC_SUCCESS ; switch ( fmode ) { case RFM_WRITE : try { file . seek ( 0 ) ; try { writeHeader_internally ( riff_header ) ; file . close ( ) ; } catch ( IOException ioe ) { retcode = DDC_FILE_ERROR ; } } catch ( IOException ioe ) { retcode = DDC_FILE_ERROR ; } break ; case RFM_READ :...
Close Riff File . Length is written too .
13,611
public int backpatchHeader ( long FileOffset , RiffChunkHeader data ) { if ( file == null ) { return DDC_INVALID_CALL ; } try { file . seek ( FileOffset ) ; } catch ( IOException ioe ) { return DDC_FILE_ERROR ; } return writeHeader_internally ( data ) ; }
Write Data to specified offset .
13,612
protected int seek ( long offset ) { int rc ; try { file . seek ( offset ) ; rc = DDC_SUCCESS ; } catch ( IOException ioe ) { rc = DDC_FILE_ERROR ; } return rc ; }
Seek in the File .
13,613
public static int fourCC ( String ChunkName ) { byte [ ] p = { 0x20 , 0x20 , 0x20 , 0x20 } ; System . arraycopy ( ChunkName . getBytes ( ) , 0 , p , 0 , 4 ) ; int ret = ( ( ( p [ 0 ] << 24 ) & 0xFF000000 ) | ( ( p [ 1 ] << 16 ) & 0x00FF0000 ) | ( ( p [ 2 ] << 8 ) & 0x0000FF00 ) | ( p [ 3 ] & 0x000000FF ) ) ; return ret...
Fill the header .
13,614
JCorsConfig buildConfig ( ) { JCorsConfig config = new JCorsConfig ( ) ; if ( enableNonCorsRequests != null ) { config . setEnableNonCorsRequests ( enableNonCorsRequests ) ; } if ( resourcesSupportCredentials != null ) { config . setResourcesSupportCredentials ( resourcesSupportCredentials ) ; } if ( preflightResultCac...
Build a new configuration
13,615
private boolean checkFooter ( RandomAccessInputStream raf , int location ) throws IOException { raf . seek ( location ) ; byte [ ] buf = new byte [ FOOT_SIZE ] ; if ( raf . read ( buf ) != FOOT_SIZE ) { throw new IOException ( "Error encountered finding id3v2 footer" ) ; } String result = new String ( buf , ENC_TYPE ) ...
Checks to see if there is an id3v2 footer in the file provided to the constructor .
13,616
private void readFooter ( RandomAccessInputStream raf , int location ) throws IOException { raf . seek ( location ) ; byte [ ] foot = new byte [ FOOT_SIZE ] ; if ( raf . read ( foot ) != FOOT_SIZE ) { throw new IOException ( "Error encountered reading id3v2 footer" ) ; } majorVersion = ( int ) foot [ 3 ] ; if ( majorVe...
Extracts the information from the footer .
13,617
public static String of ( InventoryStructure < ? > structure , CanonicalPath rootPath ) { return ComputeHash . of ( structure , rootPath , true , true , true ) . getSyncHash ( ) ; }
The root path is required so that paths in the blueprints can be correctly relativized .
13,618
public Object visualize ( PMContext ctx , Operation operation , Entity entity ) throws PMException { debug ( "Converting [" + operation . getId ( ) + "]" + entity . getId ( ) + "." + getId ( ) ) ; try { Converter c = null ; if ( getConverters ( ) != null ) { c = getConverter ( operation . getId ( ) ) ; } if ( c == null...
Visualize the field using the given operation and entity
13,619
public Converter getDefaultConverter ( ) { if ( getPm ( ) . getDefaultConverter ( ) == null ) { Converter c = new GenericConverter ( ) ; Properties properties = new Properties ( ) ; properties . put ( "filename" , "converters/show.tostring.converter" ) ; c . setProperties ( properties ) ; return c ; } else { return get...
Return the default converter if none is defined
13,620
public Object visualize ( PMContext ctx , Operation operation ) throws PMException { return visualize ( ctx , operation , ctx . getEntity ( ) ) ; }
Visualize the field using the given operation and context entity
13,621
public boolean shouldDisplay ( String operationId , PMSecurityUser user ) { if ( operationId == null ) { return false ; } for ( FieldOperationConfig config : getConfigs ( ) ) { if ( config . includes ( operationId ) ) { if ( config . getPerm ( ) != null && user != null && ! user . hasPermission ( config . getPerm ( ) )...
Indicates if the field is shown in the given operation id
13,622
public String getTitle ( ) { final String key = String . format ( "pm.field.%s.%s" , getEntity ( ) . getId ( ) , getId ( ) ) ; final String message = getPm ( ) . message ( key ) ; if ( key . equals ( message ) ) { final Entity extendzEntity = getEntity ( ) . getExtendzEntity ( ) ; if ( extendzEntity != null && extendzE...
Returns the internationalized field title
13,623
public String getTooltip ( ) { final String key = "pm.field." + getEntity ( ) . getId ( ) + "." + getId ( ) + ".tooltip" ; if ( key == null ) { return null ; } final String message = getPm ( ) . message ( key ) ; if ( key . equals ( message ) ) { return null ; } return message ; }
Returns the internationalized field tooltip
13,624
public Converter getConverter ( String operation ) { Converter c = getConverters ( ) . getConverterForOperation ( operation ) ; if ( c == null ) { for ( FieldOperationConfig config : getConfigs ( ) ) { if ( config . includes ( operation ) ) { c = getPm ( ) . findExternalConverter ( config . getEconverter ( ) ) ; break ...
Find the right converter for this field on the given operation .
13,625
public void onUpdatedStats ( ActiveMQQueueJmxStats updatedStats ) { QueueStatisticsCollection queueStatisticsCollection ; synchronized ( this . queueStats ) { queueStatisticsCollection = this . queueStats . get ( updatedStats . getQueueName ( ) ) ; if ( queueStatisticsCollection == null ) { queueStatisticsCollection = ...
Update the statistics in the registry given one set of polled statistics . These statistics are assigned a timestamp equal to now .
13,626
public Map < String , ActiveMQQueueStats > getQueueStats ( ) { Map < String , ActiveMQQueueStats > result ; result = new TreeMap < > ( ) ; synchronized ( this . queueStats ) { for ( QueueStatisticsCollection queueStatisticsCollection : this . queueStats . values ( ) ) { result . put ( queueStatisticsCollection . getQue...
Retrieve statistics for all of the queues .
13,627
public List < GeoObject > getMentionedGnObjects ( List < String > tokenList ) { Set < Integer > gnIds = new HashSet < Integer > ( ) ; for ( int i = 0 ; i < tokenList . size ( ) ; i ++ ) { Set < Integer > ids = gnObjectMapNameLookup . get ( tokenList . get ( i ) ) ; if ( ids != null ) { gnIds . addAll ( ids ) ; } } if (...
Given an arbitrary text string extract the referred names of locations
13,628
protected List < String > getTokens ( String text ) { String [ ] tokens = text . toLowerCase ( ) . split ( "[\\s\\p{Punct}]" ) ; List < String > tokenList = new ArrayList < String > ( tokens . length ) ; for ( int i = 0 ; i < tokens . length ; i ++ ) { if ( tokens [ i ] . trim ( ) . length ( ) < 1 ) { continue ; } toke...
Utility method for splitting a piece of text to tokens
13,629
protected void success ( PMStrutsContext ctx , String url , boolean redirect ) throws PMForwardException { if ( ctx . getOperation ( ) != null && ctx . getOperation ( ) . getFollows ( ) != null ) { final String plainUrl = PMTags . plainUrl ( ctx . getPmsession ( ) , "/" + ctx . getOperation ( ) . getFollows ( ) + ".do?...
Consider the operation successful and redirect or forward to the given url
13,630
protected void jSONSuccess ( PMStrutsContext ctx , Object object ) throws PMForwardException { final String toJson = new Gson ( ) . toJson ( object ) ; ctx . put ( PM_VOID_TEXT , toJson ) ; success ( ctx , "converters/void.jsp" , false ) ; }
Just a helper to return a serialized object with jSON .
13,631
public void init ( Map < String , String > properties ) { vmTransportUrl = properties . getOrDefault ( KEY_VM_TRANSPORT_URL , KEY_VM_TRANSPORT_URL_DEFAULT ) ; memberInteractionsQueueName = properties . getOrDefault ( KEY_MEMBER_INTERACTIONS_QUEUE , KEY_MEMBER_INTERACTIONS_QUEUE_DEFAULT ) ; jmsConnectionFactory = new Ac...
region > init shutdown
13,632
private static String getExtension ( String fileName ) { int length = fileName . length ( ) ; int newEnd = fileName . lastIndexOf ( '#' ) ; if ( newEnd == - 1 ) { newEnd = length ; } int i = fileName . lastIndexOf ( '.' , newEnd ) ; if ( i != - 1 ) { return fileName . substring ( i + 1 , newEnd ) ; } else { return null...
Get extension of file without fragment id
13,633
public String getValuesAsString ( ) { StringBuilder builder = new StringBuilder ( ) ; for ( E row : rowKeys . keySet ( ) ) for ( E col : colKeys . keySet ( ) ) { builder . append ( getValueAsString ( row , col , true ) ) ; builder . append ( '\n' ) ; } return builder . toString ( ) ; }
Returns a String representation of all matrix entries .
13,634
public boolean match ( Artifact artifact ) throws InvalidVersionSpecificationException { for ( Pattern pattern : patterns ) { if ( pattern . match ( artifact ) ) { for ( Pattern ignorePattern : ignorePatterns ) { if ( ignorePattern . match ( artifact ) ) { return false ; } } return true ; } } return false ; }
Check if artifact matches patterns .
13,635
public void registerProtocol ( String protocol , IOProviderFrom < URL > provider ) { protocols . put ( protocol . toLowerCase ( ) , provider ) ; }
Register a new IOProvider from URL for a specific protocol .
13,636
public EngineResult exitJavaProcess ( List < String > ignoreJobs ) { HttpPost postRequest = new HttpPost ( baseUrl ) ; List < NameValuePair > nvp = new LinkedList < NameValuePair > ( ) ; nvp . add ( new BasicNameValuePair ( "action" , "exit java process" ) ) ; nvp . add ( new BasicNameValuePair ( "im_sure" , "on" ) ) ;...
Send JVM shutdown action to Heritrix 3 . If there are any running jobs they must be included in the ignored jobs list passed as argument . Otherwise the shutdown action is ignored .
13,637
public EngineResult createNewJob ( String jobname ) { HttpPost postRequest = new HttpPost ( baseUrl ) ; List < NameValuePair > nvp = new LinkedList < NameValuePair > ( ) ; nvp . add ( new BasicNameValuePair ( "action" , "create" ) ) ; nvp . add ( new BasicNameValuePair ( "createpath" , jobname ) ) ; StringEntity postEn...
Creates a new job and initialises it with the default cxml file which must be modified before launch .
13,638
public EngineResult engineResult ( HttpRequestBase request ) { EngineResult engineResult = new EngineResult ( ) ; try { HttpResponse response = httpClient . execute ( request ) ; if ( response != null ) { engineResult . responseCode = response . getStatusLine ( ) . getStatusCode ( ) ; HttpEntity responseEntity = respon...
Process the engine result XML and turn it into a Java object .
13,639
public JobResult jobResult ( HttpRequestBase request ) { JobResult jobResult = new JobResult ( ) ; try { HttpResponse response = httpClient . execute ( request ) ; if ( response != null ) { jobResult . responseCode = response . getStatusLine ( ) . getStatusCode ( ) ; HttpEntity responseEntity = response . getEntity ( )...
Send a job request and process the XML response and turn it into a Java object .
13,640
public JobResult job ( String jobname ) { HttpGet getRequest = new HttpGet ( baseUrl + "job/" + jobname ) ; getRequest . addHeader ( "Accept" , "application/xml" ) ; return jobResult ( getRequest ) ; }
Returns the job state object given a jobname .
13,641
public JobResult copyJob ( String srcJobname , String dstJobName , boolean bAsProfile ) { HttpPost postRequest = new HttpPost ( baseUrl + "job/" + srcJobname ) ; List < NameValuePair > nvp = new LinkedList < NameValuePair > ( ) ; nvp . add ( new BasicNameValuePair ( "copyTo" , dstJobName ) ) ; if ( bAsProfile ) { nvp ....
Copy a job .
13,642
public JobResult buildJobConfiguration ( String jobname ) { HttpPost postRequest = new HttpPost ( baseUrl + "job/" + jobname ) ; StringEntity postEntity = null ; try { postEntity = new StringEntity ( BUILD_ACTION ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } postEntity . setContentType ( ...
Build an existing job .
13,643
public void add ( long date , T element ) { if ( size == 0 ) { elements [ 0 ] = element ; dates [ 0 ] = date ; size = 1 ; oldestIndex = 0 ; newestIndex = 0 ; return ; } if ( size < elements . length ) { elements [ size ] = element ; dates [ size ] = date ; if ( date < dates [ oldestIndex ] ) oldestIndex = size ; if ( d...
Add an elements with the given timestamp .
13,644
public static < QL > GremlinExpression getGremlinExpression ( QL expression , Map < String , Object > parameters ) { GremlinExpression gremlinExpression = null ; if ( expression instanceof String ) { gremlinExpression = new GremlinExpression ( "" , ( String ) expression ) ; } else if ( expression instanceof Gremlin ) {...
This is a helper method to extract the Gremlin expression .
13,645
public Map < String , String > getDetails ( ) { if ( details == null ) { return null ; } return Collections . unmodifiableMap ( details ) ; }
Optional additional details about this message . This could be null if there are no additional details associated with this message .
13,646
public static ServiceAgentInfo from ( SAAdvert saAdvert ) { IdentifierExtension identifierExtension = IdentifierExtension . findFirst ( saAdvert . getExtensions ( ) ) ; String identifier = identifierExtension == null ? null : identifierExtension . getIdentifier ( ) ; return new ServiceAgentInfo ( identifier , saAdvert ...
private final int port ;
13,647
public static Servlet wrap ( Servlet servlet ) { Require . nonNull ( servlet , "servlet" ) ; if ( servlet instanceof TinyPlugzContextServlet ) { return servlet ; } return new TinyPlugzContextServlet ( servlet ) ; }
Wraps the given Servlet .
13,648
public int getPlayingPosition ( ) { if ( playerThread != null ) { final Mixer mixer = playerThread . getCurrentMixer ( ) ; if ( mixer != null && mixer instanceof ModMixer ) { final BasicModMixer modMixer = ( ( ModMixer ) mixer ) . getModMixer ( ) ; if ( modMixer != null ) return modMixer . getCurrentPatternPosition ( )...
PLAYER INFO METHOD FOR JAVASCRIPT
13,649
public SeekPoint getSeekPoint ( int idx ) { if ( idx < 0 || idx >= points . length ) return null ; return points [ idx ] ; }
Return the selected seek point .
13,650
private void createThreads ( int threadCount ) { for ( int i = 0 ; i < threadCount ; i ++ ) { AsyncActionWorkerThread worker = new AsyncActionWorkerThread ( "Async-Action-Worker-" + i ) ; this . threadPool . add ( worker ) ; worker . start ( ) ; } }
Creates the worker threads and starts their execution
13,651
public void addAction ( ModelAction action , ModelActionListener listener ) { synchronized ( actionQueue ) { this . actionQueue . add ( new ModelActionEntry ( action , listener ) ) ; } wakeUp ( ) ; }
Adds an action to the processing queue
13,652
private ModelActionEntry pollAction ( ) { ModelActionEntry action = null ; while ( ! stop ) { synchronized ( actionQueue ) { action = this . actionQueue . poll ( ) ; } if ( action != null ) { break ; } else { synchronized ( semaphore ) { try { semaphore . wait ( ) ; } catch ( InterruptedException ex ) { ex . printStack...
Retrieves an action from the queue It is a blocking method it blocks until an action is available in the queue or the processing pool is stopped
13,653
public void CreateBuffer ( int nBytes , int nMaxDirectWriteBytes ) { m_nMaxDirectWriteBytes = nMaxDirectWriteBytes ; m_nTotal = nBytes + 1 + nMaxDirectWriteBytes ; m_pBuffer = new byte [ m_nTotal ] ; byteBuffer = new ByteBuffer ( ) ; m_nHead = 0 ; m_nTail = 0 ; m_nEndCap = m_nTotal ; }
create the buffer
13,654
public void updated ( String pid , Dictionary dictionary ) throws ConfigurationException { LOGGER . entering ( CLASS_NAME , "updated" , new Object [ ] { pid , dictionary } ) ; deleted ( pid ) ; UserAgent userAgent = SLP . newUserAgent ( dictionary == null ? null : DictionarySettings . from ( dictionary ) ) ; if ( LOGGE...
Update the SLP user agent s configuration unregistering from the OSGi service registry and stopping it if it had already started . The new SLP user agent will be started with the new configuration and registered in the OSGi service registry using the configuration parameters as service properties .
13,655
private Set < Artifact > checkDependencies ( Set < Artifact > dependencies , List < String > thePatterns ) throws EnforcerRuleException { Set < Artifact > foundMatches = null ; if ( thePatterns != null && thePatterns . size ( ) > 0 ) { for ( String pattern : thePatterns ) { String [ ] subStrings = pattern . split ( ":"...
Checks the set of dependencies against the list of patterns .
13,656
public static void register ( Class < ? > typeClass , Class < ? extends PropertyEditor > editorClass ) { synchronized ( editors ) { editors . put ( typeClass , editorClass ) ; } }
Registers the given editor class to be used to edit values of the given type class .
13,657
public int getBaseline ( JComponent c , int width , int height ) { super . getBaseline ( c , width , height ) ; return - 1 ; }
Overridden to always return - 1 since a vertical label does not have a meaningful baseline .
13,658
public Component . BaselineResizeBehavior getBaselineResizeBehavior ( JComponent c ) { super . getBaselineResizeBehavior ( c ) ; return Component . BaselineResizeBehavior . OTHER ; }
Overridden to always return Component . BaselineResizeBehavior . OTHER since a vertical label does not have a meaningful baseline
13,659
public void paint ( Graphics g , JComponent c ) { Graphics2D g2 = ( Graphics2D ) g . create ( ) ; if ( clockwiseRotation ) { g2 . rotate ( Math . PI / 2 , c . getSize ( ) . width / 2 , c . getSize ( ) . width / 2 ) ; } else { g2 . rotate ( - Math . PI / 2 , c . getSize ( ) . height / 2 , c . getSize ( ) . height / 2 ) ...
Transforms the Graphics for vertical rendering and invokes the super method .
13,660
public int hgetbits ( int N ) { totbit += N ; int val = 0 ; int pos = buf_byte_idx ; if ( pos + N < BUFSIZE ) { while ( N -- > 0 ) { val <<= 1 ; val |= ( ( buf [ pos ++ ] != 0 ) ? 1 : 0 ) ; } } else { while ( N -- > 0 ) { val <<= 1 ; val |= ( ( buf [ pos ] != 0 ) ? 1 : 0 ) ; pos = ( pos + 1 ) & BUFSIZE_MASK ; } } buf_b...
Read a number bits from the bit stream .
13,661
public void hputbuf ( int val ) { int ofs = offset ; buf [ ofs ++ ] = val & 0x80 ; buf [ ofs ++ ] = val & 0x40 ; buf [ ofs ++ ] = val & 0x20 ; buf [ ofs ++ ] = val & 0x10 ; buf [ ofs ++ ] = val & 0x08 ; buf [ ofs ++ ] = val & 0x04 ; buf [ ofs ++ ] = val & 0x02 ; buf [ ofs ++ ] = val & 0x01 ; if ( ofs == BUFSIZE ) offse...
Write 8 bits into the bit stream .
13,662
public void rewindNbytes ( int N ) { int bits = ( N << 3 ) ; totbit -= bits ; buf_byte_idx -= bits ; if ( buf_byte_idx < 0 ) buf_byte_idx += BUFSIZE ; }
Rewind N bytes in Stream .
13,663
protected final void configure ( final ValueParser values ) { final Object velocityContext ; final ToolContext ctxt ; final Object decorationObj ; checkNotNull ( values , "Received a null pointer as values" ) ; velocityContext = values . get ( ConfigToolConstants . VELOCITY_CONTEXT_KEY ) ; if ( velocityContext instance...
Sets up the tool with the skin configuration and file id .
13,664
public void addDispatcher ( String dispatcherId , AbsActorDispatcher dispatcher ) { synchronized ( dispatchers ) { if ( dispatchers . containsKey ( dispatcherId ) ) { return ; } dispatchers . put ( dispatcherId , dispatcher ) ; } }
Registering custom dispatcher
13,665
public < T extends Actor > ActorRef actorOf ( Class < T > actor , String path ) { return actorOf ( Props . create ( actor ) , path ) ; }
Creating or getting existing actor from actor class
13,666
public ActorRef actorOf ( Props props , String path ) { String dispatcherId = props . getDispatcher ( ) == null ? DEFAULT_DISPATCHER : props . getDispatcher ( ) ; AbsActorDispatcher mailboxesDispatcher ; synchronized ( dispatchers ) { if ( ! dispatchers . containsKey ( dispatcherId ) ) { throw new RuntimeException ( "U...
Creating or getting existing actor from actor props
13,667
@ SuppressWarnings ( "unchecked" ) public static < T extends Plugin > void add ( ExtensionPoint < T > point ) { ArrayList < Plugin > plugins = new ArrayList < > ( ) ; synchronized ( points ) { points . add ( point ) ; for ( Iterator < Plugin > it = waitingPlugins . iterator ( ) ; it . hasNext ( ) ; ) { Plugin pi = it ....
Add an extension point .
13,668
@ SuppressWarnings ( "unchecked" ) public static void add ( String epClassName , Plugin pi ) { ExtensionPoint < Plugin > ep = null ; synchronized ( points ) { for ( ExtensionPoint < ? > point : points ) if ( point . getClass ( ) . getName ( ) . equals ( epClassName ) ) { ep = ( ExtensionPoint < Plugin > ) point ; break...
Add a plug - in for the given extension point class name .
13,669
public static void allPluginsLoaded ( ) { StringBuilder s = new StringBuilder ( 1024 ) ; s . append ( "Extension points:" ) ; synchronized ( points ) { for ( ExtensionPoint < ? > ep : points ) ep . allPluginsLoaded ( ) ; for ( ExtensionPoint < ? > ep : points ) { s . append ( "\r\n- " ) ; ep . printInfo ( s ) ; } point...
Call the method allPluginsLoaded on every extension point .
13,670
public static void logRemainingPlugins ( ) { Logger logger = LCCore . getApplication ( ) . getDefaultLogger ( ) ; if ( ! logger . warn ( ) ) return ; synchronized ( points ) { for ( Plugin pi : waitingPlugins ) logger . warn ( "Plugin ignored because extension point is not loaded: " + pi . getClass ( ) . getName ( ) ) ...
Print to the error console the plugins that are available without their corresponding extension point .
13,671
public List < Highlight > getHighlights ( Entity entity , Field field , Object instance ) { if ( field == null ) { return getHighlights ( entity , instance ) ; } final List < Highlight > result = new ArrayList < Highlight > ( ) ; for ( Highlight highlight : highlights ) { if ( ! highlight . getScope ( ) . equals ( INST...
Return all the highlights that matches the given instance in the given field of the given entity
13,672
public Highlight getHighlight ( Entity entity , Object instance ) { for ( Highlight highlight : highlights ) { if ( highlight . getScope ( ) . equals ( INSTANCE ) ) { for ( Field field : entity . getOrderedFields ( ) ) { if ( match ( instance , field , highlight ) ) { return highlight ; } } } } return null ; }
Return the first highlight that match in any value of this instance with some of the highlights values .
13,673
protected boolean match ( Object instance , Field field , Highlight highlight ) { try { Object o = getPm ( ) . get ( instance , field . getProperty ( ) ) ; if ( o != null && o . toString ( ) . equals ( highlight . getValue ( ) ) && highlight . getField ( ) . equals ( field . getId ( ) ) ) { return true ; } } catch ( Ex...
Indicate if the field of the given instance matches with the given highlight
13,674
private ServiceInfo generateServiceInfo ( ServiceReference reference ) { Map < String , String > map = Utils . toMap ( reference ) ; Set < String > keys = map . keySet ( ) ; String slpUrl = Utils . subst ( ( String ) reference . getProperty ( SLP_URL ) , map ) ; ServiceURL serviceURL ; if ( keys . contains ( SLP_URL_LI...
Generate SLP service information by scraping relevant information from the OSGi service reference s properties .
13,675
public AskFuture combine ( AskCallback < Object [ ] > callback , AskFuture ... futures ) { AskFuture future = combine ( futures ) ; future . addListener ( callback ) ; return future ; }
Combine multiple asks to single one
13,676
public < T > void ask ( Future < T > future , FutureCallback < T > callback ) { typedAsk . ask ( future , callback ) ; }
Ask TypedActor future method for result
13,677
public < T > T proxy ( final T src , Class < T > tClass ) { return callbackExtension . proxy ( src , tClass ) ; }
Proxy callback interface for invoking methods as actor messages
13,678
public void sendOnce ( Object message , long delay , ActorRef sender ) { dispatcher . sendMessageOnce ( endpoint , message , ActorTime . currentTime ( ) + delay , sender ) ; }
Send message once
13,679
public IVersion getVersion ( String vstring ) throws InvalidRangeException { IVersionRange range = getRange ( vstring ) ; if ( range == null ) { return null ; } return range . getMinimum ( ) ; }
Get a version implementation . Return the best match for the provided string .
13,680
public IVersionRange getRange ( String vstring ) throws InvalidRangeException { if ( vstring == null || vstring . isEmpty ( ) ) { if ( strict ) { throw new InvalidRangeException ( "Cannot have an empty version" ) ; } else { IVersion version = new NamedVersion ( "" ) ; return new VersionSet ( version ) ; } } try { Input...
Get a version range
13,681
public IVersionRange merge ( IVersionRange ... ranges ) { if ( ranges . length < 2 ) { return ranges [ 0 ] ; } if ( ! ( ranges [ 0 ] instanceof VersionRange ) ) { if ( ! ( ranges [ 0 ] instanceof OrRange ) ) { throw new UnsupportedOperationException ( "Incorrect type for ranges[0]" ) ; } if ( ( ( OrRange ) ranges [ 0 ]...
Given two or ranges or simple ranges merge them together . We are assuming that the ranges are provided in order for now .
13,682
public void newDataReady ( DataType data ) { ArrayList < Runnable > list ; synchronized ( this ) { if ( end ) throw new IllegalStateException ( "method endOfData already called, method newDataReady is not allowed anymore" ) ; waitingData . addLast ( data ) ; list = listeners ; listeners = null ; } if ( list != null ) {...
Queue a new data which may unblock a thread waiting for it .
13,683
public void endOfData ( ) { ArrayList < Runnable > list = null ; synchronized ( this ) { end = true ; if ( waitingData . isEmpty ( ) ) { list = listeners ; listeners = null ; } } if ( list != null ) { for ( Runnable listener : list ) listener . run ( ) ; } synchronized ( this ) { this . notifyAll ( ) ; } }
Signal that no more data will be queued so any waiting thread can be unblocked .
13,684
public static < S > Key < S > from ( String key , Class < ? extends S > valueClass ) { return new Key < S > ( key , valueClass ) ; }
Creates a new Key with the given key string and value class .
13,685
public T convert ( Object value ) { T result = null ; if ( value != null ) { if ( getValueClass ( ) . isInstance ( value ) ) result = getValueClass ( ) . cast ( value ) ; else result = convertFromString ( value . toString ( ) ) ; } return result ; }
Converts the given value object into an object of the value class specified by this Key .
13,686
protected void initDispatcher ( AbstractDispatcher < Envelope , MailboxesQueue > dispatcher ) { if ( this . dispatcher != null ) { throw new RuntimeException ( "Double dispatcher init" ) ; } this . dispatcher = dispatcher ; }
Must be called in super constructor
13,687
public static PathFragment [ ] from ( Filter ... filters ) { PathFragment [ ] ret = new PathFragment [ filters . length ] ; Arrays . setAll ( ret , ( i ) -> new PathFragment ( filters [ i ] ) ) ; return ret ; }
Constructs path fragments corresponding to the provided filters .
13,688
public static IdentifierExtension findFirst ( Collection < ? extends Extension > extensions ) { for ( Extension extension : extensions ) { if ( IDENTIFIER_EXTENSION_ID == extension . getId ( ) ) return ( IdentifierExtension ) extension ; } return null ; }
Returns the first IdentifierExtension found in the given collection of extensions or null if no IdentifierExtensions exist in the given collection .
13,689
public static Collection < IdentifierExtension > findAll ( Collection < ? extends Extension > extensions ) { List < IdentifierExtension > result = new ArrayList < IdentifierExtension > ( ) ; for ( Extension extension : extensions ) { if ( IDENTIFIER_EXTENSION_ID == extension . getId ( ) ) result . add ( ( IdentifierExt...
Returns all IdentifierExtensions found in the given collection of extensions .
13,690
static public Object deserialize ( InputStream in , Class < ? > cls ) throws IOException { if ( cls == null ) throw new NullPointerException ( "cls" ) ; Object obj = deserialize ( in ) ; if ( ! cls . isInstance ( obj ) ) { throw new InvalidObjectException ( "type of deserialized instance not of required class." ) ; } r...
Deserializes the object contained in the given input stream .
13,691
static synchronized public InputStream getResourceAsStream ( String name ) { InputStream is = null ; if ( hook != null ) { is = hook . getResourceAsStream ( name ) ; } else { Class < JavaLayerUtils > cls = JavaLayerUtils . class ; is = cls . getResourceAsStream ( name ) ; } return is ; }
Retrieves an InputStream for a named resource .
13,692
private void shutdownAndAwaitTermination ( ExecutorService pool , int queueSize ) { log . info ( "Shutting down executor service; queue size={}." , queueSize ) ; pool . shutdown ( ) ; log . info ( "Waiting for executor service to finish all queued tasks." ) ; try { if ( ! pool . awaitTermination ( 60 , TimeUnit . SECON...
Adapted from example in javadoc of ExecutorService .
13,693
public static InputStream get ( IO . Readable io , boolean closeAsync ) { if ( io instanceof IOFromInputStream ) return ( ( IOFromInputStream ) io ) . getInputStream ( ) ; if ( io instanceof IO . Readable . Buffered ) return new BufferedToInputStream ( ( IO . Readable . Buffered ) io , closeAsync ) ; return new IOAsInp...
Get an instance for the given IO .
13,694
public int readReverse ( ) throws IOException { int b ; do { canRead . block ( 0 ) ; synchronized ( this ) { if ( error != null ) throw error ; if ( io == null ) throw new IOException ( "IO closed" ) ; if ( bufferPosInFile == 0 && posInBuffer == minInBuffer ) return - 1 ; if ( posInBuffer == minInBuffer ) { if ( curren...
Read a byte backward .
13,695
public long getSampleCount ( ) { long total = ( _audioInputStream . getFrameLength ( ) * getFormat ( ) . getFrameSize ( ) * 8 ) / getFormat ( ) . getSampleSizeInBits ( ) ; return total / getFormat ( ) . getChannels ( ) ; }
Return the number of samples of all channels
13,696
public void getChannelSamples ( int channel , double [ ] interleavedSamples , double [ ] channelSamples ) { int nbChannels = getFormat ( ) . getChannels ( ) ; for ( int i = 0 ; i < channelSamples . length ; i ++ ) { channelSamples [ i ] = interleavedSamples [ nbChannels * i + channel ] ; } }
Extract samples of a particular channel from interleavedSamples and copy them into channelSamples
13,697
public Collection < Plugin > removeUncheckedPlugins ( Collection < String > uncheckedPlugins , Collection < Plugin > plugins ) throws MojoExecutionException { if ( uncheckedPlugins != null && ! uncheckedPlugins . isEmpty ( ) ) { for ( String pluginKey : uncheckedPlugins ) { Plugin plugin = parsePluginString ( pluginKey...
Remove the plugins that the user doesn t want to check .
13,698
public Collection < String > combineUncheckedPlugins ( Collection < String > uncheckedPlugins , String uncheckedPluginsList ) { if ( StringUtils . isNotEmpty ( uncheckedPluginsList ) ) { if ( uncheckedPlugins == null ) { uncheckedPlugins = new HashSet < String > ( ) ; } else if ( ! uncheckedPlugins . isEmpty ( ) && log...
Combines the old Collection with the new comma separated list .
13,699
public Set < Plugin > addAdditionalPlugins ( Set < Plugin > existing , List < String > additional ) throws MojoExecutionException { if ( additional != null ) { for ( String pluginString : additional ) { Plugin plugin = parsePluginString ( pluginString , "AdditionalPlugins" ) ; if ( existing == null ) { existing = new H...
Add the additional plugins if they don t exist yet .