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' ) { return ( long ) i ; } if ( multiplier == 'K' ) { return ( long ) i * 1024l ; } if ( multiplier == 'M' ) { return ( long ) i * 1024l * 1024l ; } if ( multiplier == 'G' ) { return ( long ) i * 1024l * 1024l * 1024l ; } } return - 1 ; } | 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_Type ) jcasType ) . casFeatCode_sequenceId ) ; } | 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_Type ) jcasType ) . casFeatCode_sequenceId , v ) ; } | 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 ) . casFeatCode_answer ) ; } | 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 ) . casFeatCode_answer , v ) ; } | 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 " + name + " at " + pos ) ; } | 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 " + pos ) ; return pos ; } | 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_header ) != DDC_SUCCESS ) { file . close ( ) ; fmode = RFM_UNKNOWN ; } } catch ( IOException ioe ) { fmode = RFM_UNKNOWN ; retcode = DDC_FILE_ERROR ; } break ; case RFM_READ : try { file = new RandomAccessFile ( Filename , "r" ) ; try { byte [ ] br = new byte [ 8 ] ; file . read ( br , 0 , 8 ) ; fmode = RFM_READ ; riff_header . ckID = ( ( br [ 0 ] << 24 ) & 0xFF000000 ) | ( ( br [ 1 ] << 16 ) & 0x00FF0000 ) | ( ( br [ 2 ] << 8 ) & 0x0000FF00 ) | ( br [ 3 ] & 0x000000FF ) ; riff_header . ckSize = ( ( br [ 7 ] << 24 ) & 0xFF000000 ) | ( ( br [ 6 ] << 16 ) & 0x00FF0000 ) | ( ( br [ 5 ] << 8 ) & 0x0000FF00 ) | ( br [ 4 ] & 0x000000FF ) ; } catch ( IOException ioe ) { file . close ( ) ; fmode = RFM_UNKNOWN ; } } catch ( IOException ioe ) { fmode = RFM_UNKNOWN ; retcode = DDC_FILE_ERROR ; } break ; default : retcode = DDC_INVALID_CALL ; } } return retcode ; } | 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 : try { file . close ( ) ; } catch ( IOException ioe ) { retcode = DDC_FILE_ERROR ; } break ; } file = null ; fmode = RFM_UNKNOWN ; return retcode ; } | 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 ( preflightResultCacheMaxAge != null ) { config . setPreflightResultCacheMaxAge ( preflightResultCacheMaxAge ) ; } setAllowedOrigins ( config ) ; setAllowedHeaders ( config ) ; setAllowedMethods ( config ) ; setExposedHeaders ( config ) ; return config ; } | 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 ) ; if ( result . substring ( 0 , TAG_START . length ( ) ) . equals ( TAG_START ) ) { if ( ( ( ( int ) buf [ 3 ] & 0xFF ) != 0xff ) && ( ( ( int ) buf [ 4 ] & 0xFF ) != 0xff ) ) { if ( ( ( int ) buf [ 6 ] & 0x80 ) == 0 && ( ( int ) buf [ 7 ] & 0x80 ) == 0 && ( ( int ) buf [ 8 ] & 0x80 ) == 0 && ( ( int ) buf [ 9 ] & 0x80 ) == 0 ) { return true ; } } } return false ; } | 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 ( majorVersion <= NEW_MAJOR_VERSION ) { minorVersion = ( int ) foot [ 4 ] ; unsynchronisation = ( foot [ 5 ] & 0x80 ) != 0 ; extended = ( foot [ 5 ] & 0x40 ) != 0 ; experimental = ( foot [ 5 ] & 0x20 ) != 0 ; footer = ( foot [ 5 ] & 0x10 ) != 0 ; tagSize = Helpers . convertDWordToInt ( foot , 6 ) ; } } | 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 ) { c = getDefaultConverter ( ) ; } final Object instance = ctx . getEntityInstance ( ) ; ctx . setField ( this ) ; if ( instance != null ) { ctx . setEntityInstanceWrapper ( ctx . buildInstanceWrapper ( instance ) ) ; ctx . setFieldValue ( getPm ( ) . get ( instance , getProperty ( ) ) ) ; } return c . visualize ( ctx ) ; } catch ( ConverterException e ) { throw e ; } catch ( Exception e ) { getPm ( ) . error ( e ) ; throw new ConverterException ( "Unable to convert " + entity . getId ( ) + "." + getProperty ( ) ) ; } } | 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 getPm ( ) . getDefaultConverter ( ) ; } } | 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 ( ) ) ) { return false ; } } } if ( getDisplay ( ) . equalsIgnoreCase ( "all" ) ) { return true ; } final String [ ] split = getDisplay ( ) . split ( "[ ]" ) ; for ( String string : split ) { if ( string . equalsIgnoreCase ( operationId ) ) { return true ; } } return false ; } | 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 && extendzEntity . getFieldById ( getId ( ) ) != null ) { return extendzEntity . getFieldById ( getId ( ) ) . getTitle ( ) ; } } return message ; } | 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 ; } } } if ( c == null ) { final String _property = getProperty ( ) ; try { final String [ ] _properties = _property . split ( "[.]" ) ; Class < ? > clazz = Class . forName ( getEntity ( ) . getClazz ( ) ) ; for ( int i = 0 ; i < _properties . length - 1 ; i ++ ) { clazz = FieldUtils . getField ( clazz , _properties [ i ] , true ) . getType ( ) ; } final String className = FieldUtils . getField ( clazz , _properties [ _properties . length - 1 ] , true ) . getType ( ) . getName ( ) ; c = getPm ( ) . getClassConverters ( ) . getConverter ( operation , className ) ; } catch ( Exception ex ) { getPm ( ) . info ( String . format ( "Unable to introspect field '%s' on entity '%s'" , _property , getEntity ( ) . getId ( ) ) ) ; } } return c ; } | 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 = new QueueStatisticsCollection ( updatedStats . getQueueName ( ) ) ; this . queueStats . put ( updatedStats . getQueueName ( ) , queueStatisticsCollection ) ; } } queueStatisticsCollection . onUpdatedStats ( updatedStats ) ; } | 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 . getQueueName ( ) , queueStatisticsCollection . getQueueTotalStats ( ) ) ; } } return result ; } | 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 ( tokenList . size ( ) > 1 ) { for ( int i = 0 ; i < tokenList . size ( ) - 1 ; i ++ ) { Set < Integer > ids = gnObjectMapNameLookup . get ( tokenList . get ( i ) + " " + tokenList . get ( i + 1 ) ) ; if ( ids != null ) { gnIds . addAll ( ids ) ; } } } List < GeoObject > locations = new ArrayList < GeoObject > ( gnIds . size ( ) ) ; for ( Integer id : gnIds ) { locations . add ( gnObjectMap . get ( id ) ) ; } return locations ; } | 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 ; } tokenList . add ( tokens [ i ] . trim ( ) ) ; } return tokenList ; } | 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?pmid=" + ctx . getEntity ( ) . getId ( ) ) . substring ( getContextPath ( ) . length ( ) ) ; throw new PMForwardException ( new ActionRedirect ( plainUrl ) ) ; } else { final String plainUrl = PMTags . plainUrl ( ctx . getPmsession ( ) , url ) . substring ( getContextPath ( ) . length ( ) ) ; if ( redirect ) { throw new PMForwardException ( new ActionRedirect ( plainUrl ) ) ; } else { throw new PMForwardException ( new ActionForward ( plainUrl ) ) ; } } } | 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 ActiveMQConnectionFactory ( vmTransportUrl ) ; try { jmsConnection = jmsConnectionFactory . createConnection ( ) ; } catch ( JMSException e ) { LOG . error ( "Unable to create connection" , e ) ; throw new RuntimeException ( e ) ; } try { jmsConnection . start ( ) ; } catch ( JMSException e ) { LOG . error ( "Unable to start connection" , e ) ; closeSafely ( jmsConnection ) ; jmsConnection = null ; } } | 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" ) ) ; if ( ignoreJobs != null && ignoreJobs . size ( ) > 0 ) { for ( int i = 0 ; i < ignoreJobs . size ( ) ; ++ i ) { nvp . add ( new BasicNameValuePair ( "ignore__" + ignoreJobs . get ( i ) , "on" ) ) ; } } StringEntity postEntity = null ; try { postEntity = new UrlEncodedFormEntity ( nvp ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } postEntity . setContentType ( "application/x-www-form-urlencoded" ) ; postRequest . addHeader ( "Accept" , "application/xml" ) ; postRequest . setEntity ( postEntity ) ; return engineResult ( postRequest ) ; } | 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 postEntity = null ; try { postEntity = new UrlEncodedFormEntity ( nvp ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } postEntity . setContentType ( "application/x-www-form-urlencoded" ) ; postRequest . addHeader ( "Accept" , "application/xml" ) ; postRequest . setEntity ( postEntity ) ; return engineResult ( postRequest ) ; } | 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 = response . getEntity ( ) ; long contentLength = responseEntity . getContentLength ( ) ; if ( contentLength < 0 ) { contentLength = 0 ; } ByteArrayOutputStream bOut = new ByteArrayOutputStream ( ( int ) contentLength ) ; InputStream in = responseEntity . getContent ( ) ; int read ; byte [ ] tmpBuf = new byte [ 8192 ] ; while ( ( read = in . read ( tmpBuf ) ) != - 1 ) { bOut . write ( tmpBuf , 0 , read ) ; } in . close ( ) ; bOut . close ( ) ; engineResult . response = bOut . toByteArray ( ) ; switch ( engineResult . responseCode ) { case 200 : engineResult . parse ( xmlValidator ) ; in = new ByteArrayInputStream ( engineResult . response ) ; engineResult . engine = Engine . unmarshall ( in ) ; in . close ( ) ; engineResult . status = ResultStatus . OK ; break ; case 404 : engineResult . status = ResultStatus . NOT_FOUND ; break ; case 500 : engineResult . status = ResultStatus . INTERNAL_ERROR ; break ; default : engineResult . status = ResultStatus . NO_RESPONSE ; break ; } } else { engineResult . status = ResultStatus . NO_RESPONSE ; } } catch ( NoHttpResponseException e ) { engineResult . status = ResultStatus . OFFLINE ; engineResult . t = e ; } catch ( ClientProtocolException e ) { engineResult . status = ResultStatus . RESPONSE_EXCEPTION ; engineResult . t = e ; } catch ( IOException e ) { engineResult . status = ResultStatus . RESPONSE_EXCEPTION ; engineResult . t = e ; } catch ( JAXBException e ) { engineResult . status = ResultStatus . JAXB_EXCEPTION ; engineResult . t = e ; } catch ( XMLStreamException e ) { engineResult . status = ResultStatus . XML_EXCEPTION ; engineResult . t = e ; } return engineResult ; } | 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 ( ) ; long contentLength = responseEntity . getContentLength ( ) ; if ( contentLength < 0 ) { contentLength = 0 ; } ByteArrayOutputStream bOut = new ByteArrayOutputStream ( ( int ) contentLength ) ; InputStream in = responseEntity . getContent ( ) ; int read ; byte [ ] tmpBuf = new byte [ 8192 ] ; while ( ( read = in . read ( tmpBuf ) ) != - 1 ) { bOut . write ( tmpBuf , 0 , read ) ; } in . close ( ) ; bOut . close ( ) ; jobResult . response = bOut . toByteArray ( ) ; switch ( jobResult . responseCode ) { case 200 : jobResult . parse ( xmlValidator ) ; in = new ByteArrayInputStream ( jobResult . response ) ; jobResult . job = Job . unmarshall ( in ) ; in . close ( ) ; jobResult . status = ResultStatus . OK ; break ; case 404 : jobResult . status = ResultStatus . NOT_FOUND ; break ; case 500 : jobResult . status = ResultStatus . INTERNAL_ERROR ; break ; default : jobResult . status = ResultStatus . NO_RESPONSE ; break ; } } else { jobResult . status = ResultStatus . NO_RESPONSE ; } } catch ( NoHttpResponseException e ) { jobResult . status = ResultStatus . OFFLINE ; jobResult . t = e ; } catch ( ClientProtocolException e ) { jobResult . status = ResultStatus . RESPONSE_EXCEPTION ; jobResult . t = e ; } catch ( IOException e ) { jobResult . status = ResultStatus . RESPONSE_EXCEPTION ; jobResult . t = e ; } catch ( JAXBException e ) { jobResult . status = ResultStatus . JAXB_EXCEPTION ; jobResult . t = e ; } catch ( XMLStreamException e ) { jobResult . status = ResultStatus . XML_EXCEPTION ; jobResult . t = e ; } return jobResult ; } | 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 . add ( new BasicNameValuePair ( "asProfile" , "on" ) ) ; } StringEntity postEntity = null ; try { postEntity = new UrlEncodedFormEntity ( nvp ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } postEntity . setContentType ( "application/x-www-form-urlencoded" ) ; postRequest . addHeader ( "Accept" , "application/xml" ) ; postRequest . setEntity ( postEntity ) ; return jobResult ( postRequest ) ; } | 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 ( "application/x-www-form-urlencoded" ) ; postRequest . addHeader ( "Accept" , "application/xml" ) ; postRequest . setEntity ( postEntity ) ; return jobResult ( postRequest ) ; } | 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 ( date > dates [ newestIndex ] ) newestIndex = size ; size ++ ; return ; } if ( dates [ oldestIndex ] > date ) { if ( newestIndex < 0 ) refreshNewestIndex ( ) ; elements [ newestIndex ] = element ; dates [ newestIndex ] = date ; oldestIndex = newestIndex ; newestIndex = - 1 ; return ; } if ( newestIndex < 0 ) refreshNewestIndex ( ) ; if ( dates [ newestIndex ] < date ) return ; elements [ newestIndex ] = element ; dates [ newestIndex ] = date ; oldestIndex = newestIndex ; newestIndex = - 1 ; return ; } | 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 ) { Gremlin gremlin = ( Gremlin ) expression ; gremlinExpression = new GremlinExpression ( gremlin . name ( ) , gremlin . value ( ) ) ; } else if ( AnnotatedElement . class . isAssignableFrom ( expression . getClass ( ) ) ) { AnnotatedElement < ? > typeExpression = ( AnnotatedElement < ? > ) expression ; gremlinExpression = extractExpression ( typeExpression ) ; } else if ( Class . class . isAssignableFrom ( expression . getClass ( ) ) ) { Class < ? > clazz = ( Class < ? > ) expression ; gremlinExpression = extractExpression ( clazz ) ; } else if ( Method . class . isAssignableFrom ( expression . getClass ( ) ) ) { Method method = ( Method ) expression ; gremlinExpression = extractExpression ( method ) ; } else { throw new XOException ( "Unsupported query expression " + expression . toString ( ) + "(class=" + expression . getClass ( ) + ")" ) ; } return applyParameters ( parameters , gremlinExpression ) ; } | 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 . getURL ( ) , saAdvert . getScopes ( ) , saAdvert . getAttributes ( ) , saAdvert . getLanguage ( ) ) ; } | 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 ( ) ; } } return - 1 ; } | 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 . printStackTrace ( ) ; } } } } return action ; } | 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 ( LOGGER . isLoggable ( Level . FINER ) ) LOGGER . finer ( "User Agent " + pid + " starting..." ) ; userAgent . start ( ) ; if ( LOGGER . isLoggable ( Level . FINE ) ) LOGGER . fine ( "User Agent " + pid + " started successfully" ) ; ServiceRegistration serviceRegistration = bundleContext . registerService ( IServiceAgent . class . getName ( ) , userAgent , dictionary ) ; userAgents . put ( pid , serviceRegistration ) ; LOGGER . exiting ( CLASS_NAME , "updated" ) ; } | 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 ( ":" ) ; subStrings = StringUtils . stripAll ( subStrings ) ; for ( Artifact artifact : dependencies ) { if ( compareDependency ( subStrings , artifact ) ) { if ( foundMatches == null ) { foundMatches = new HashSet < Artifact > ( ) ; } foundMatches . add ( artifact ) ; } } } } return foundMatches ; } | 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 ) ; } super . paint ( g2 , c ) ; } | 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_byte_idx = pos ; return val ; } | 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 ) offset = 0 ; else offset = ofs ; } | 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 instanceof ToolContext ) { ctxt = ( ToolContext ) velocityContext ; loadFileId ( ctxt ) ; decorationObj = ctxt . get ( ConfigToolConstants . DECORATION_KEY ) ; if ( decorationObj instanceof DecorationModel ) { processDecoration ( ( DecorationModel ) decorationObj ) ; } } } | 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 ( "Unknown dispatcherId '" + dispatcherId + "'" ) ; } mailboxesDispatcher = dispatchers . get ( dispatcherId ) ; } return mailboxesDispatcher . referenceActor ( path , props ) ; } | 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 . next ( ) ; if ( point . getPluginClass ( ) . isAssignableFrom ( pi . getClass ( ) ) ) { plugins . add ( pi ) ; it . remove ( ) ; } } } synchronized ( point ) { for ( Plugin pi : plugins ) point . addPlugin ( ( T ) pi ) ; } } | 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 ; } if ( ep == null ) { waitingPlugins . add ( pi ) ; return ; } } synchronized ( ep ) { ep . addPlugin ( pi ) ; } } | 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 ) ; } points . trimToSize ( ) ; } synchronized ( customs ) { for ( Iterator < CustomExtensionPoint > it = customs . iterator ( ) ; it . hasNext ( ) ; ) { CustomExtensionPoint ep = it . next ( ) ; s . append ( "\r\n- " ) ; ep . printInfo ( s ) ; if ( ! ep . keepAfterInit ( ) ) it . remove ( ) ; } customs . trimToSize ( ) ; } LCCore . getApplication ( ) . getDefaultLogger ( ) . info ( s . toString ( ) ) ; logRemainingPlugins ( ) ; } | 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 ( INSTANCE ) ) { if ( match ( instance , field , highlight ) ) { result . add ( highlight ) ; } } } return result ; } | 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 ( Exception e ) { } return false ; } | 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_LIFETIME ) ) { try { int lifetime = Integer . parseInt ( ( String ) reference . getProperty ( SLP_URL_LIFETIME ) ) ; serviceURL = new ServiceURL ( slpUrl , lifetime ) ; } catch ( NumberFormatException e ) { serviceURL = new ServiceURL ( slpUrl ) ; } } else { serviceURL = new ServiceURL ( slpUrl ) ; } String language ; if ( keys . contains ( SLP_LANGUAGE ) ) language = ( String ) reference . getProperty ( SLP_LANGUAGE ) ; else language = Locale . getDefault ( ) . getLanguage ( ) ; Scopes scopes = Scopes . NONE ; if ( keys . contains ( SLP_SCOPES ) ) { String [ ] values = ( ( String ) reference . getProperty ( SLP_SCOPES ) ) . split ( "," ) ; for ( int i = 0 ; i < values . length ; i ++ ) values [ i ] = values [ i ] . trim ( ) ; scopes = Scopes . from ( values ) ; } ServiceType serviceType = null ; if ( keys . contains ( SLP_SERVICE_TYPE ) ) { serviceType = new ServiceType ( ( String ) reference . getProperty ( SLP_SERVICE_TYPE ) ) ; } map . remove ( SLP_URL ) ; map . remove ( SLP_URL_LIFETIME ) ; map . remove ( SLP_LANGUAGE ) ; map . remove ( SLP_SCOPES ) ; map . remove ( SLP_SERVICE_TYPE ) ; Attributes attributes = Attributes . from ( map ) ; ServiceInfo serviceInfo ; if ( serviceType != null ) { serviceInfo = new ServiceInfo ( serviceType , serviceURL , language , scopes , attributes ) ; } else { serviceInfo = new ServiceInfo ( serviceURL , language , scopes , attributes ) ; } return serviceInfo ; } | 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 { InputStream stream = new ByteArrayInputStream ( vstring . getBytes ( StandardCharsets . UTF_8 ) ) ; ANTLRInputStream input = new ANTLRInputStream ( stream ) ; VersionErrorListener errorListener = new VersionErrorListener ( ) ; VersionLexer lexer = new VersionLexer ( input ) ; lexer . removeErrorListeners ( ) ; lexer . addErrorListener ( errorListener ) ; CommonTokenStream tokens = new CommonTokenStream ( lexer ) ; VersionParser parser = new VersionParser ( tokens ) ; parser . addErrorListener ( errorListener ) ; RangeContext context = parser . range ( ) ; ParseTreeWalker walker = new ParseTreeWalker ( ) ; VersionListener listener = new VersionListener ( strict ) ; walker . walk ( listener , context ) ; IVersionRange range = listener . getRange ( ) ; if ( errorListener . hasErrors ( ) ) { if ( strict ) { throw new InvalidRangeException ( "Parse errors on " + vstring ) ; } range . setHasErrors ( true ) ; } return range ; } catch ( EmptyStackException e ) { if ( strict ) { throw new InvalidRangeException ( e ) ; } System . err . println ( "ERROR: Could not parse: " + vstring ) ; } catch ( InvalidRangeRuntimeException e ) { throw new InvalidRangeException ( e . getMessage ( ) , e ) ; } catch ( Exception e ) { if ( strict ) { throw new InvalidRangeException ( e ) ; } System . err . println ( "ERROR: Could not parse: " + vstring ) ; } IVersion version = new NamedVersion ( vstring ) ; return new VersionSet ( version ) ; } | 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 ] ) . size ( ) != 2 ) { throw new UnsupportedOperationException ( "Incorrect size for ranges[0]" ) ; } } else { if ( ! ( ( VersionRange ) ranges [ 0 ] ) . isUnbounded ( ) ) { throw new UnsupportedOperationException ( "ranges[0] should be unbounded (> or >=)" ) ; } } int lastIndex = ranges . length - 1 ; if ( ! ( ranges [ lastIndex ] instanceof VersionRange ) ) { if ( ! ( ranges [ lastIndex ] instanceof OrRange ) ) { throw new UnsupportedOperationException ( "Incorrect type for ranges[last]" ) ; } if ( ( ( OrRange ) ranges [ lastIndex ] ) . size ( ) != 2 ) { throw new UnsupportedOperationException ( "Incorrect size for ranges[last]" ) ; } } else { if ( ( ( VersionRange ) ranges [ lastIndex ] ) . isUnbounded ( ) ) { throw new UnsupportedOperationException ( "ranges[0] should be bounded (< or <=)" ) ; } } for ( int i = 1 ; i < lastIndex ; i ++ ) { if ( ! ( ranges [ i ] instanceof OrRange ) ) { throw new UnsupportedOperationException ( "Incorrect type for ranges[" + i + "]" ) ; } if ( ( ( OrRange ) ranges [ i ] ) . size ( ) != 2 ) { throw new UnsupportedOperationException ( "Incorrect size for ranges[" + i + "]" ) ; } } List < IVersionRange > results = new LinkedList < IVersionRange > ( ) ; IVersionRange last = null ; for ( int i = 0 ; i < ranges . length ; i ++ ) { IVersionRange range = ranges [ i ] ; if ( last == null ) { if ( range instanceof VersionRange ) { last = range ; } else { OrRange orange = ( OrRange ) range ; results . add ( orange . first ( ) ) ; last = orange . last ( ) ; } } else { if ( range instanceof VersionRange ) { AndRange arange = new AndRange ( last , range ) ; results . add ( arange ) ; last = null ; } else { OrRange orange = ( OrRange ) range ; AndRange arange = new AndRange ( last , orange . first ( ) ) ; results . add ( arange ) ; last = orange . last ( ) ; } } } if ( last != null ) { results . add ( last ) ; } return new OrRange ( results ) ; } | 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 ) { for ( Runnable listener : list ) listener . run ( ) ; } synchronized ( this ) { this . notify ( ) ; } } | 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 ( ( IdentifierExtension ) extension ) ; } return result ; } | 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." ) ; } return obj ; } | 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 . SECONDS ) ) { log . info ( "Executor service did not terminate before timeout; forcing shutdown." ) ; List < Runnable > queuedTasks = pool . shutdownNow ( ) ; log . info ( "Discarded {} tasks that were still queued; still waiting for executor service to terminate." , queuedTasks . size ( ) ) ; if ( ! pool . awaitTermination ( 60 , TimeUnit . SECONDS ) ) { log . error ( "Pool did not terminate." ) ; } else { log . info ( "Executor service terminated after forced shutdown." ) ; } } else { log . info ( "Executor service finished all queued tasks and terminated." ) ; } } catch ( InterruptedException ie ) { log . error ( "Interrupted while waiting for pool to terminate; forcing shutdown." , ie ) ; List < Runnable > queuedTasks = pool . shutdownNow ( ) ; log . info ( "Discarded {} tasks that were still queued; no longer waiting for executor service to terminate." , queuedTasks . size ( ) ) ; Thread . currentThread ( ) . interrupt ( ) ; } } | 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 IOAsInputStream ( io ) ; } | 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 ( currentRead != null ) canRead . restart ( ) ; else readBufferBack ( ) ; b = - 1 ; } else { b = buffer [ -- posInBuffer ] & 0xFF ; if ( currentRead == null && posInBuffer < buffer . length / 2 && bufferPosInFile > 0 ) readBufferBack ( ) ; } } } while ( b == - 1 ) ; return b ; } | 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 , "UncheckedPlugins" ) ; plugins . remove ( plugin ) ; } } return plugins ; } | 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 != null ) { log . warn ( "The parameter 'unCheckedPlugins' is deprecated. Use 'unCheckedPluginList' instead" ) ; } uncheckedPlugins . addAll ( Arrays . asList ( uncheckedPluginsList . split ( "," ) ) ) ; } return uncheckedPlugins ; } | 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 HashSet < Plugin > ( ) ; existing . add ( plugin ) ; } else if ( ! existing . contains ( plugin ) ) { existing . add ( plugin ) ; } } } return existing ; } | Add the additional plugins if they don t exist yet . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.