idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
13,800
public static XElement parseXML ( InputStream in ) throws XMLStreamException { XMLInputFactory inf = XMLInputFactory . newInstance ( ) ; XMLStreamReader ir = inf . createXMLStreamReader ( in ) ; return parseXML ( ir ) ; }
Parse an XML document from the given input stream . Does not close the stream .
13,801
public static XElement parseXML ( ResultSet rs , int index ) throws SQLException , IOException , XMLStreamException { try ( InputStream is = rs . getBinaryStream ( index ) ) { if ( is != null ) { return parseXML ( is ) ; } return null ; } }
Reads the contents of a indexed column as an XML .
13,802
public static XElement parseXML ( ResultSet rs , String column ) throws SQLException , IOException , XMLStreamException { try ( InputStream is = rs . getBinaryStream ( column ) ) { if ( is != null ) { return parseXML ( is ) ; } return null ; } }
Reads the contents of a named column as an XML .
13,803
public static XElement parseXML ( String fileName ) throws XMLStreamException { try ( InputStream in = new FileInputStream ( fileName ) ) { return parseXML ( in ) ; } catch ( IOException ex ) { throw new XMLStreamException ( ex ) ; } }
Parse an XML from the given local filename .
13,804
public static XElement parseXML ( URL u ) throws XMLStreamException , IOException { try ( InputStream in = u . openStream ( ) ) { return parseXML ( in ) ; } }
Parses an XML from the given URL .
13,805
public static XElement parseXMLGZ ( File file ) throws XMLStreamException { try ( GZIPInputStream gin = new GZIPInputStream ( new BufferedInputStream ( new FileInputStream ( file ) , 64 * 1024 ) ) ) { return parseXML ( gin ) ; } catch ( IOException ex ) { throw new XMLStreamException ( ex ) ; } }
Parse an XML file compressed by GZIP .
13,806
public void add ( Iterable < XElement > elements ) { for ( XElement e : elements ) { e . parent = this ; children . add ( e ) ; } }
Add the iterable of elements as children .
13,807
public XElement add ( String name ) { XElement result = new XElement ( name ) ; result . parent = this ; children . add ( result ) ; return result ; }
Add a new child element with the given name .
13,808
public XElement add ( String name , Object value ) { XElement result = add ( name ) ; result . parent = this ; result . setValue ( value ) ; return result ; }
Add an element with the supplied content text .
13,809
public void copyFrom ( XElement other ) { content = other . content ; userObject = other . userObject ; attributes . putAll ( other . attributes ) ; for ( XElement c : other . children ) { add ( c . copy ( ) ) ; } }
Copy the attributes content and child elements from the other element in a deep - copy fashion .
13,810
public Double getDoubleObject ( String attributeName ) { String val = get ( attributeName , null ) ; if ( val != null ) { return Double . valueOf ( val ) ; } return null ; }
Get a double attribute as object or null if not present .
13,811
public Integer getIntObject ( String attributeName ) { String val = get ( attributeName , null ) ; if ( val != null ) { return Integer . valueOf ( val ) ; } return null ; }
Get an integer attribute as object or null if not present .
13,812
public boolean hasPositiveInt ( String attributeName ) { String attr = attributes . get ( attributeName ) ; if ( attr == null || attr . isEmpty ( ) ) { return false ; } try { return Integer . parseInt ( attr ) >= 0 ; } catch ( NumberFormatException ex ) { return false ; } }
Check if there is a valid positive integer attribute .
13,813
public boolean isNullOrEmpty ( String attributeName ) { String attr = attributes . get ( attributeName ) ; if ( attr == null || attr . isEmpty ( ) ) { return true ; } return false ; }
Check if the given attribute is present an is not empty .
13,814
public void removeChildrenWithName ( String name ) { for ( int i = children . size ( ) - 1 ; i >= 0 ; i -- ) { if ( children . get ( i ) . name . equals ( name ) ) { children . remove ( i ) . parent = null ; } } }
Removes all children with the given element name .
13,815
public void replace ( XElement oldChild , XElement newChild ) { int idx = children . indexOf ( oldChild ) ; if ( idx >= 0 ) { children . get ( idx ) . parent = null ; children . set ( idx , newChild ) ; newChild . parent = this ; } }
Replaces the specified child node with the new node . If the old node is not present the method does nothing .
13,816
public void save ( OutputStream stream , boolean header , boolean flush ) throws IOException { OutputStreamWriter out = new OutputStreamWriter ( stream , "UTF-8" ) ; save ( out , header , flush ) ; }
Save this XML into the supplied output stream .
13,817
public void save ( Writer writer , boolean header , boolean flush ) throws IOException { final PrintWriter out = new PrintWriter ( new BufferedWriter ( writer ) ) ; try { if ( header ) { out . println ( "<?xml version='1.0' encoding='UTF-8'?>" ) ; } toStringRep ( "" , new XAppender ( ) { public XAppender append ( Object o ) { out . print ( o ) ; return this ; } } ) ; } finally { if ( flush ) { out . flush ( ) ; } } }
Save this XML into the supplied output writer .
13,818
public void set ( String name , Object value ) { if ( value != null ) { attributes . put ( name , String . valueOf ( value ) ) ; } else { attributes . remove ( name ) ; } }
Set an attribute value .
13,819
public void visit ( boolean depthFirst , Consumer < ? super XElement > action ) { Deque < XElement > queue = new LinkedList < > ( ) ; queue . add ( this ) ; while ( ! queue . isEmpty ( ) ) { XElement x = queue . removeFirst ( ) ; action . accept ( x ) ; if ( depthFirst ) { ListIterator < XElement > li = x . children . listIterator ( x . children . size ( ) ) ; while ( li . hasPrevious ( ) ) { queue . addFirst ( li . previous ( ) ) ; } } else { for ( XElement c : x . children ) { queue . addLast ( c ) ; } } } }
Iterate through the elements of this XElement and invoke the action for each .
13,820
public static XElement parseXMLActiveFragment ( XMLStreamReader in ) throws XMLStreamException { XElement node = null ; XElement root = null ; final StringBuilder emptyBuilder = new StringBuilder ( ) ; StringBuilder b = null ; Deque < StringBuilder > stack = new LinkedList < > ( ) ; int type = in . getEventType ( ) ; for ( ; ; ) { switch ( type ) { case XMLStreamConstants . START_ELEMENT : if ( b != null ) { stack . push ( b ) ; b = null ; } else { stack . push ( emptyBuilder ) ; } XElement n = new XElement ( in . getName ( ) . getLocalPart ( ) ) ; n . parent = node ; int attCount = in . getAttributeCount ( ) ; if ( attCount > 0 ) { for ( int i = 0 ; i < attCount ; i ++ ) { n . set ( in . getAttributeLocalName ( i ) , in . getAttributeValue ( i ) ) ; } } if ( node != null ) { node . add ( n ) ; } node = n ; if ( root == null ) { root = n ; } break ; case XMLStreamConstants . CDATA : case XMLStreamConstants . CHARACTERS : if ( node != null && ! in . isWhiteSpace ( ) ) { if ( b == null ) { b = new StringBuilder ( ) ; } b . append ( in . getText ( ) ) ; } break ; case XMLStreamConstants . END_ELEMENT : if ( node != null ) { if ( b != null ) { node . content = b . toString ( ) ; } node = node . parent ; } b = stack . pop ( ) ; if ( b == emptyBuilder ) { b = null ; } if ( stack . isEmpty ( ) ) { return root ; } break ; default : } if ( in . hasNext ( ) ) { type = in . next ( ) ; } else { break ; } } return root ; }
Parses the stream as a fragment from the current element and returns an XElement .
13,821
public void addTimeInterval ( T interval ) { timeIntervals . add ( interval ) ; minBorders . setStart ( Math . max ( minBorders . getStart ( ) , interval . getStart ( ) ) ) ; minBorders . setEnd ( Math . min ( minBorders . getEnd ( ) , interval . getEnd ( ) ) ) ; if ( maxBorders == null ) { maxBorders = interval . clone ( ) ; } else { maxBorders . setStart ( Math . min ( maxBorders . getStart ( ) , interval . getStart ( ) ) ) ; maxBorders . setEnd ( Math . max ( maxBorders . getEnd ( ) , interval . getEnd ( ) ) ) ; } }
Adds a new time interval to the list of time intervals and adjusts the minimum and maximum borders .
13,822
private void loadTypePriorities ( AnyObject config ) { AnyObject tpObject = config . getAnyObject ( "type-priorities" ) ; if ( tpObject == null ) { return ; } try { String [ ] typePrioritiesArray = getFromListOrInherit ( tpObject , "type-list" ) ; this . typePriorities = TypePrioritiesFactory . createTypePriorities ( typePrioritiesArray ) ; } catch ( IOException e ) { System . err . println ( "Failed to load type-priorities." ) ; e . printStackTrace ( ) ; } }
Load type priorities
13,823
public AnalysisEngineDescription buildComponent ( int stageId , int phase , AnyObject aeDescription ) throws Exception { Map < String , Object > tuples = Maps . newLinkedHashMap ( ) ; tuples . put ( BasePhase . QA_INTERNAL_PHASEID , new Integer ( phase ) ) ; tuples . put ( EXPERIMENT_UUID_PROPERTY , experimentUuid ) ; tuples . put ( STAGE_ID_PROPERTY , stageId ) ; Class < ? extends AnalysisComponent > ac = getFromClassOrInherit ( aeDescription , AnalysisComponent . class , tuples ) ; Object [ ] params = getParamList ( tuples ) ; AnalysisEngineDescription description = AnalysisEngineFactory . createPrimitiveDescription ( ac , typeSystem , typePriorities , params ) ; String name = ( String ) tuples . get ( "name" ) ; description . getAnalysisEngineMetaData ( ) . setName ( name ) ; return description ; }
Made this method public to invoke it from BasePhaseTest
13,824
public static < C > Class < ? extends C > loadFromClassOrInherit ( String handle , Class < C > ifaceClass , Map < String , Object > tuples ) throws Exception { String [ ] name = handle . split ( "!" ) ; if ( name [ 0 ] . equals ( "class" ) ) { return Class . forName ( name [ 1 ] ) . asSubclass ( ifaceClass ) ; } else { if ( name [ 0 ] . equals ( "inherit" ) ) { AnyObject yaml = ConfigurationLoader . load ( name [ 1 ] ) ; return getFromClassOrInherit ( yaml , ifaceClass , tuples ) ; } else { throw new IllegalArgumentException ( "Illegal experiment descriptor, must contain one node of type <class> or <inherit>" ) ; } } }
These methods are preserved for compatibility with the old version of PhaseImpl
13,825
void lpc_to_curve ( float [ ] curve , float [ ] lpc , float amp ) { for ( int i = 0 ; i < ln * 2 ; i ++ ) curve [ i ] = 0.0f ; if ( amp == 0 ) return ; for ( int i = 0 ; i < m ; i ++ ) { curve [ i * 2 + 1 ] = lpc [ i ] / ( 4 * amp ) ; curve [ i * 2 + 2 ] = - lpc [ i ] / ( 4 * amp ) ; } fft . backward ( curve ) ; { int l2 = ln * 2 ; float unit = ( float ) ( 1. / amp ) ; curve [ 0 ] = ( float ) ( 1. / ( curve [ 0 ] * 2 + unit ) ) ; for ( int i = 1 ; i < ln ; i ++ ) { float real = ( curve [ i ] + curve [ l2 - i ] ) ; float imag = ( curve [ i ] - curve [ l2 - i ] ) ; float a = real + unit ; curve [ i ] = ( float ) ( 1.0 / FAST_HYPOT ( a , imag ) ) ; } } }
interpolates the log curve from the linear curve .
13,826
private void handleReadBuffer ( ) throws IOException { if ( readBuffer . remaining ( ) == 0 ) { readBuffer . clear ( ) ; actualFile . read ( actualFileOffset , readBuffer ) ; actualFileOffset += readBuffer . limit ( ) ; readBuffer . position ( 0 ) ; } }
fills the ReadBuffer from the HeaderIndexFile
13,827
private void initialize ( ) { this . setLayout ( new java . awt . GridBagLayout ( ) ) ; if ( ! showBarOnly ) { this . add ( getTimeTextField ( ) , Helpers . getGridBagConstraint ( 0 , 0 , 1 , 1 , java . awt . GridBagConstraints . NONE , java . awt . GridBagConstraints . WEST , 0.0 , 0.0 ) ) ; this . add ( getTimeLabel ( ) , Helpers . getGridBagConstraint ( 1 , 0 , 1 , 1 , java . awt . GridBagConstraints . NONE , java . awt . GridBagConstraints . WEST , 1.0 , 0.0 ) ) ; this . add ( getKBSField ( ) , Helpers . getGridBagConstraint ( 2 , 0 , 1 , 1 , java . awt . GridBagConstraints . NONE , java . awt . GridBagConstraints . WEST , 0.0 , 0.0 ) ) ; this . add ( getKBSLabel ( ) , Helpers . getGridBagConstraint ( 3 , 0 , 1 , 1 , java . awt . GridBagConstraints . NONE , java . awt . GridBagConstraints . WEST , 1.0 , 0.0 ) ) ; this . add ( getKHZField ( ) , Helpers . getGridBagConstraint ( 4 , 0 , 1 , 1 , java . awt . GridBagConstraints . NONE , java . awt . GridBagConstraints . WEST , 0.0 , 0.0 ) ) ; this . add ( getKHZLabel ( ) , Helpers . getGridBagConstraint ( 5 , 0 , 1 , 1 , java . awt . GridBagConstraints . NONE , java . awt . GridBagConstraints . WEST , 1.0 , 0.0 ) ) ; this . add ( getActiveChannelsTextField ( ) , Helpers . getGridBagConstraint ( 6 , 0 , 1 , 1 , java . awt . GridBagConstraints . NONE , java . awt . GridBagConstraints . WEST , 0.0 , 0.0 ) ) ; this . add ( getActiveChannelsLabel ( ) , Helpers . getGridBagConstraint ( 7 , 0 , 1 , 0 , java . awt . GridBagConstraints . NONE , java . awt . GridBagConstraints . WEST , 1.0 , 0.0 ) ) ; this . add ( getTimeBar ( ) , Helpers . getGridBagConstraint ( 0 , 1 , 1 , 0 , java . awt . GridBagConstraints . HORIZONTAL , java . awt . GridBagConstraints . WEST , 1.0 , 0.0 ) ) ; } else { this . add ( getTimeTextField ( ) , Helpers . getGridBagConstraint ( 0 , 0 , 1 , 1 , java . awt . GridBagConstraints . NONE , java . awt . GridBagConstraints . WEST , 0.0 , 0.0 ) ) ; this . add ( getTimeBar ( ) , Helpers . getGridBagConstraint ( 1 , 0 , 1 , 0 , java . awt . GridBagConstraints . HORIZONTAL , java . awt . GridBagConstraints . EAST , 1.0 , 0.0 ) ) ; } }
Will drop the graphical elements
13,828
public static String escapeCsvStr ( String str ) { if ( str != null && ! str . equals ( "" ) ) { boolean needQuote = false ; if ( str . contains ( "\"" ) ) { str = str . replaceAll ( "\"" , "\"\"" ) ; needQuote = true ; } if ( ! needQuote && str . contains ( "," ) ) { needQuote = true ; } if ( needQuote ) { str = "\"" + str + "\"" ; } return str ; } else { return "" ; } }
CSV Escape handling for given string . - > - >
13,829
public double getExpectationAt ( int index ) { if ( index < 0 || index >= expectations . getObservationCount ( ) ) throw new IndexOutOfBoundsException ( ) ; return expectations . getValueAt ( index ) ; }
Returns the expectation for a certain insertion step specified by the given index .
13,830
public HashMap < Integer , Double > getMomentsAt ( int index ) { if ( index < 0 || index >= getObservationCount ( ) ) throw new IndexOutOfBoundsException ( ) ; HashMap < Integer , Double > ret = new HashMap < Integer , Double > ( ) ; for ( Integer m : momentObservation . keySet ( ) ) { Double value = momentObservation . get ( m ) . getValueAt ( index ) ; if ( value != null ) ret . put ( m , value ) ; } return ret ; }
Returns the values of all moments for a certain insertion step specified by the given index .
13,831
protected double getRange ( ValueDimension dim ) { return zeroBased ? diagram . getValues ( dim ) . max ( ) . doubleValue ( ) : diagram . getValues ( dim ) . range ( ) ; }
Returns the range of the maintained values for the given dimension .
13,832
public void setZeroBased ( boolean zeroBased ) { if ( zeroBased != this . zeroBased ) { this . zeroBased = zeroBased ; for ( ValueDimension dim : tickInfo . keySet ( ) ) tickInfo . get ( dim ) . setZeroBased ( zeroBased ) ; } }
Sets the operation mode . In zero - based mode coordinate axes always start at 0 and end near the maximum value of the corresponding dimension . Otherwise axes start at the minimum value .
13,833
protected void paintTicks ( Graphics g , ValueDimension dim ) { for ( int i = 0 ; i < getTickInfo ( dim ) . getTickNumber ( ) ; i ++ ) { if ( i % getTickInfo ( dim ) . getTickMultiplicator ( ) != 0 ) paintTick ( g , dim , getTickInfo ( dim ) . getFirstTick ( ) + i * getTickInfo ( dim ) . getMinorTickSpacing ( ) , getTickInfo ( dim ) . getMinorTickLength ( ) ) ; else paintTick ( g , dim , getTickInfo ( dim ) . getFirstTick ( ) + i * getTickInfo ( dim ) . getMinorTickSpacing ( ) , getTickInfo ( dim ) . getMajorTickLength ( ) ) ; } }
Paints tick information for the coordinate axis of the given dimension .
13,834
protected void paintTick ( Graphics g , ValueDimension dim , Number tickValue , int tickLength ) { String str = String . format ( getTickInfo ( dim ) . getFormat ( ) , tickValue . doubleValue ( ) ) ; int xPosition ; int yPosition ; Point descPos ; switch ( dim ) { case X : xPosition = getXFor ( tickValue ) ; yPosition = getPaintingRegion ( ) . getBottomLeft ( ) . y ; g . drawLine ( xPosition , yPosition , xPosition , yPosition + tickLength ) ; descPos = getPaintingRegion ( ) . getDescriptionPos ( dim , str , xPosition ) ; g . drawString ( str , descPos . x , descPos . y + tickLength ) ; break ; case Y : xPosition = getPaintingRegion ( ) . getBottomLeft ( ) . x ; yPosition = getYFor ( tickValue ) ; g . drawLine ( xPosition , yPosition , xPosition - tickLength , yPosition ) ; descPos = getPaintingRegion ( ) . getDescriptionPos ( dim , str , yPosition ) ; g . drawString ( str , descPos . x - tickLength , descPos . y + tickLength ) ; break ; } }
Paints a tick with the specified length and value with respect to the given dimension .
13,835
protected void paintValues ( Graphics g , boolean paintLines ) { Point valueLocation ; Point lastLocation = null ; for ( int i = 0 ; i < getValueCount ( ) ; i ++ ) { valueLocation = getPointFor ( i ) ; GraphicUtils . fillCircle ( g , valueLocation , getPointDiameter ( ) ) ; if ( paintLines && lastLocation != null ) { g . drawLine ( lastLocation . x , lastLocation . y , valueLocation . x , valueLocation . y ) ; } lastLocation = valueLocation ; } }
Paints diagram - content on the base of the values for different dimensions .
13,836
public Node < T > get ( long value ) { if ( root == null ) return null ; if ( value == first . value ) return first ; if ( value == last . value ) return last ; if ( value < first . value ) return null ; if ( value > last . value ) return null ; return get ( root , value ) ; }
Returns the node associated to the given key or null if no such key exists .
13,837
private Node < T > get ( Node < T > x , long key ) { while ( x != null ) { if ( x . value == key ) return x ; if ( key < x . value ) x = x . left ; else x = x . right ; } return null ; }
value associated with the given key in subtree rooted at x ; null if no such key
13,838
public boolean contains ( long value , T element ) { if ( root == null ) return false ; if ( value < first . value ) return false ; if ( value > last . value ) return false ; if ( value == first . value && ObjectUtil . equalsOrNull ( element , first . element ) ) return true ; if ( value == last . value && ObjectUtil . equalsOrNull ( element , last . element ) ) return true ; return contains ( root , value , element ) ; }
Returns true if the given key exists in the tree and its associated value is the given element . Comparison of the element is using the equals method .
13,839
public Node < T > searchNearestHigher ( long value , boolean acceptEquals ) { if ( root == null ) return null ; return searchNearestHigher ( root , value , acceptEquals ) ; }
Returns the node containing the lowest value strictly higher than the given one .
13,840
public List < Data > select ( byte [ ] ... keys ) throws DRUMSException { List < Data > result = new ArrayList < Data > ( ) ; IntObjectOpenHashMap < ArrayList < byte [ ] > > bucketKeyMapping = getBucketKeyMapping ( keys ) ; String filename ; for ( IntObjectCursor < ArrayList < byte [ ] > > entry : bucketKeyMapping ) { filename = gp . DATABASE_DIRECTORY + "/" + hashFunction . getFilename ( entry . key ) ; HeaderIndexFile < Data > indexFile = null ; try { indexFile = new HeaderIndexFile < Data > ( filename , HeaderIndexFile . AccessMode . READ_ONLY , gp . HEADER_FILE_LOCK_RETRY , gp ) ; ArrayList < byte [ ] > keyList = entry . value ; result . addAll ( searchForData ( indexFile , keyList . toArray ( new byte [ keyList . size ( ) ] [ ] ) ) ) ; } catch ( FileLockException ex ) { logger . error ( "Could not access the file {} within {} retries. The file seems to be locked." , filename , gp . HEADER_FILE_LOCK_RETRY ) ; throw new DRUMSException ( ex ) ; } catch ( IOException ex ) { logger . error ( "An exception occurred while trying to get objects from the file {}." , filename , ex ) ; throw new DRUMSException ( ex ) ; } finally { if ( indexFile != null ) { indexFile . close ( ) ; } } } return result ; }
Selects all existing records to the keys in the given array .
13,841
protected IntObjectOpenHashMap < ArrayList < byte [ ] > > getBucketKeyMapping ( byte [ ] ... keys ) { IntObjectOpenHashMap < ArrayList < byte [ ] > > bucketKeyMapping = new IntObjectOpenHashMap < ArrayList < byte [ ] > > ( ) ; int bucketId ; for ( byte [ ] key : keys ) { bucketId = hashFunction . getBucketId ( key ) ; if ( ! bucketKeyMapping . containsKey ( bucketId ) ) { bucketKeyMapping . put ( bucketId , new ArrayList < byte [ ] > ( ) ) ; } bucketKeyMapping . get ( bucketId ) . add ( key ) ; } return bucketKeyMapping ; }
This method maps all keys in the given array to their corresponding buckets and returns the determined mapping .
13,842
public long size ( ) throws FileLockException , IOException { long size = 0L ; for ( int bucketId = 0 ; bucketId < hashFunction . getNumberOfBuckets ( ) ; bucketId ++ ) { HeaderIndexFile < Data > headerIndexFile = new HeaderIndexFile < Data > ( gp . DATABASE_DIRECTORY + "/" + hashFunction . getFilename ( bucketId ) , gp . HEADER_FILE_LOCK_RETRY , gp ) ; size += headerIndexFile . getFilledUpFromContentStart ( ) / gp . getElementSize ( ) ; headerIndexFile . close ( ) ; } return size ; }
Determines the number of elements in each buckets by opening all files .
13,843
public void close ( ) throws InterruptedException { if ( reader_instance != null ) { reader_instance . closeFiles ( ) ; } reader_instance = null ; if ( syncManager != null ) { syncManager . shutdown ( ) ; syncManager . join ( ) ; } }
Closes this DRUMS .
13,844
public static VersionSpecification parseVersionSpecification ( String s ) { if ( s == null ) return null ; if ( s . length ( ) == 0 ) return null ; char c = s . charAt ( 0 ) ; if ( c == '[' ) { int i = s . indexOf ( ']' ) ; boolean excluded = false ; if ( i < 0 ) { i = s . indexOf ( ')' ) ; if ( i > 0 ) excluded = true ; } if ( i < 0 ) { return new VersionSpecification . SingleVersion ( new Version ( s ) ) ; } String range = s . substring ( 1 , i ) . trim ( ) ; i = range . indexOf ( ',' ) ; if ( i < 0 ) { return new VersionSpecification . SingleVersion ( new Version ( range ) ) ; } Version min = new Version ( range . substring ( 0 , i ) . trim ( ) ) ; range = range . substring ( i + 1 ) . trim ( ) ; Version max ; if ( range . length ( ) == 0 && excluded ) max = null ; else max = new Version ( range ) ; return new VersionSpecification . Range ( new VersionRange ( min , max , ! excluded ) ) ; } Version v = new Version ( s ) ; return new VersionSpecification . RangeWithRecommended ( new VersionRange ( v , null , false ) , v ) ; }
Parse a version specification in POM format .
13,845
public static StringBuilder chompChomp ( StringBuilder builder ) { return builder . delete ( builder . length ( ) - 2 , builder . length ( ) ) ; }
Deletes the last two characters .
13,846
public boolean addValuePart ( String name , int size ) throws IOException { if ( INSTANCE_EXISITS ) { throw new IOException ( "A GeneralStroable was already instantiated. You cant further add Value Parts" ) ; } int hash = Arrays . hashCode ( name . getBytes ( ) ) ; int index = valuePartNames . size ( ) ; if ( valueHash2Index . containsKey ( hash ) ) { logger . error ( "A valuePart with the name {} already exists" , name ) ; return false ; } valuePartNames . add ( name ) ; valueHash2Index . put ( hash , index ) ; valueIndex2Hash . add ( hash ) ; valueSizes . add ( size ) ; valueByteOffsets . add ( valueSize ) ; valueSize += size ; return true ; }
Adds a new ValuePart
13,847
public boolean addKeyPart ( String name , int size ) throws IOException { if ( INSTANCE_EXISITS ) { throw new IOException ( "A GeneralStroable was already instantiated. You cant further add Key Parts" ) ; } int hash = Arrays . hashCode ( name . getBytes ( ) ) ; int index = keyPartNames . size ( ) ; if ( keyHash2Index . containsKey ( hash ) ) { logger . error ( "A keyPart with the name {} already exists" , name ) ; return false ; } keyPartNames . add ( name ) ; keyHash2Index . put ( hash , index ) ; keyIndex2Hash . add ( hash ) ; keySizes . add ( size ) ; keyByteOffsets . add ( keySize ) ; keySize += size ; return true ; }
Adds a new KeyPart
13,848
protected void setPeriodBorders ( ChannelMemory aktMemo ) { if ( frequencyTableType == Helpers . AMIGA_TABLE ) { aktMemo . portaStepUpEnd = getFineTunePeriod ( aktMemo , Helpers . getNoteIndexForPeriod ( 113 ) + 1 ) ; aktMemo . portaStepDownEnd = getFineTunePeriod ( aktMemo , Helpers . getNoteIndexForPeriod ( 856 ) + 1 ) ; } else { aktMemo . portaStepUpEnd = getFineTunePeriod ( aktMemo , 119 ) ; aktMemo . portaStepDownEnd = getFineTunePeriod ( aktMemo , 0 ) ; } }
Sets the borders for Portas
13,849
protected void resetAllEffects ( ChannelMemory aktMemo , PatternElement nextElement , boolean forced ) { if ( aktMemo . arpegioIndex >= 0 ) { aktMemo . arpegioIndex = - 1 ; int nextNotePeriod = aktMemo . arpegioNote [ 0 ] ; if ( nextNotePeriod != 0 ) { setNewPlayerTuningFor ( aktMemo , aktMemo . currentNotePeriod = nextNotePeriod ) ; } } if ( aktMemo . vibratoOn ) { if ( forced || ( nextElement . getEffekt ( ) != 0x04 && nextElement . getEffekt ( ) != 0x06 ) ) { aktMemo . vibratoOn = false ; if ( ! aktMemo . vibratoNoRetrig ) aktMemo . vibratoTablePos = 0 ; setNewPlayerTuningFor ( aktMemo ) ; } } if ( aktMemo . tremoloOn ) { if ( forced || nextElement . getEffekt ( ) != 0x07 ) { aktMemo . tremoloOn = false ; if ( ! aktMemo . tremoloNoRetrig ) aktMemo . tremoloTablePos = 0 ; } } if ( aktMemo . panbrelloOn ) { if ( forced || nextElement . getEffekt ( ) != 0x22 ) { aktMemo . panbrelloOn = false ; if ( ! aktMemo . panbrelloNoRetrig ) aktMemo . panbrelloTablePos = 0 ; } } }
Clear all effekts . Sometimes if Effekts do continue they are not stopped .
13,850
private void doPortaToNoteEffekt ( ChannelMemory aktMemo ) { if ( aktMemo . portaTargetNotePeriod < aktMemo . currentNotePeriod ) { aktMemo . currentNotePeriod -= aktMemo . portaNoteStep ; if ( aktMemo . currentNotePeriod < aktMemo . portaTargetNotePeriod ) aktMemo . currentNotePeriod = aktMemo . portaTargetNotePeriod ; } else { aktMemo . currentNotePeriod += aktMemo . portaNoteStep ; if ( aktMemo . currentNotePeriod > aktMemo . portaTargetNotePeriod ) aktMemo . currentNotePeriod = aktMemo . portaTargetNotePeriod ; } setNewPlayerTuningFor ( aktMemo ) ; }
Convenient Method for the Porta to note Effekt
13,851
protected void doVibratoEffekt ( ChannelMemory aktMemo ) { int periodAdd ; switch ( aktMemo . vibratoType & 0x03 ) { case 1 : periodAdd = ( Helpers . ModRampDownTable [ aktMemo . vibratoTablePos ] ) ; break ; case 2 : periodAdd = ( Helpers . ModSquareTable [ aktMemo . vibratoTablePos ] ) ; break ; case 3 : periodAdd = ( Helpers . ModRandomTable [ aktMemo . vibratoTablePos ] ) ; break ; default : periodAdd = ( Helpers . ModSinusTable [ aktMemo . vibratoTablePos ] ) ; break ; } periodAdd = ( ( periodAdd << 4 ) * aktMemo . vibratoAmplitude ) >> 7 ; setNewPlayerTuningFor ( aktMemo , aktMemo . currentNotePeriod + periodAdd ) ; aktMemo . vibratoTablePos = ( aktMemo . vibratoTablePos + aktMemo . vibratoStep ) & 0x3F ; }
Convenient Method for the vibrato effekt
13,852
protected void doTremoloEffekt ( ChannelMemory aktMemo ) { int volumeAdd ; switch ( aktMemo . tremoloType & 0x03 ) { case 1 : volumeAdd = ( Helpers . ModRampDownTable [ aktMemo . tremoloTablePos ] ) ; break ; case 2 : volumeAdd = ( Helpers . ModSquareTable [ aktMemo . tremoloTablePos ] ) ; break ; case 3 : volumeAdd = ( Helpers . ModRandomTable [ aktMemo . tremoloTablePos ] ) ; break ; default : volumeAdd = ( Helpers . ModSinusTable [ aktMemo . tremoloTablePos ] ) ; break ; } volumeAdd = ( volumeAdd * aktMemo . tremoloAmplitude ) >> 7 ; aktMemo . currentVolume = aktMemo . currentSetVolume + volumeAdd ; aktMemo . tremoloTablePos = ( aktMemo . tremoloTablePos + aktMemo . tremoloStep ) & 0x3F ; }
Convenient Method for the tremolo effekt
13,853
public int updatePosition ( int p , boolean keyOff ) { p ++ ; if ( loop && p >= position [ loopEndPoint ] ) p = position [ loopStartPoint ] ; if ( sustain && p >= position [ sustainEndPoint ] && ! keyOff ) p = position [ sustainStartPoint ] ; return p ; }
Get the new position
13,854
public int getValueForPosition ( int p ) { int pt = nPoints - 1 ; for ( int i = 0 ; i < pt ; i ++ ) { if ( p <= position [ i ] ) { pt = i ; break ; } } int x2 = position [ pt ] ; int x1 , v ; if ( p >= x2 ) { v = value [ pt ] << SHIFT ; x1 = x2 ; } else if ( pt > 0 ) { v = value [ pt - 1 ] << SHIFT ; x1 = position [ pt - 1 ] ; } else { v = x1 = 0 ; } if ( p > x2 ) p = x2 ; if ( ( x2 > x1 ) && ( p > x1 ) ) { v += ( ( p - x1 ) * ( ( value [ pt ] << SHIFT ) - v ) ) / ( x2 - x1 ) ; } if ( v < 0 ) v = 0 ; else if ( v > MAXVALUE ) v = MAXVALUE ; return v ; }
get the value at the position Returns values between 0 and 512
13,855
public void setXMType ( int flag ) { on = ( flag & 0x01 ) != 0 ; sustain = ( flag & 0x02 ) != 0 ; loop = ( flag & 0x04 ) != 0 ; carry = filter = false ; }
Sets the boolean values corresponding to the flag value XM - Version
13,856
private void loadID3v2 ( InputStream in ) { int size = - 1 ; try { in . mark ( 10 ) ; size = readID3v2Header ( in ) ; header_pos = size ; } catch ( IOException e ) { } finally { try { in . reset ( ) ; } catch ( IOException e ) { } } try { if ( size > 0 ) { rawid3v2 = new byte [ size ] ; in . read ( rawid3v2 , 0 , rawid3v2 . length ) ; } } catch ( IOException e ) { } }
Load ID3v2 frames .
13,857
private int readID3v2Header ( InputStream in ) throws IOException { byte [ ] id3header = new byte [ 4 ] ; int size = - 10 ; in . read ( id3header , 0 , 3 ) ; if ( ( id3header [ 0 ] == 'I' ) && ( id3header [ 1 ] == 'D' ) && ( id3header [ 2 ] == '3' ) ) { in . read ( id3header , 0 , 3 ) ; in . read ( id3header , 0 , 4 ) ; size = ( int ) ( id3header [ 0 ] << 21 ) + ( id3header [ 1 ] << 14 ) + ( id3header [ 2 ] << 7 ) + ( id3header [ 3 ] ) ; } return ( size + 10 ) ; }
Parse ID3v2 tag header to find out size of ID3v2 frames .
13,858
public InputStream getRawID3v2 ( ) { if ( rawid3v2 == null ) return null ; else { ByteArrayInputStream bain = new ByteArrayInputStream ( rawid3v2 ) ; return bain ; } }
Return raw ID3v2 frames + header .
13,859
public Header readFrame ( ) throws BitstreamException { Header result = null ; try { result = readNextFrame ( ) ; if ( firstframe == true ) { result . parseVBR ( frame_bytes ) ; firstframe = false ; } } catch ( BitstreamException ex ) { if ( ( ex . getErrorCode ( ) == INVALIDFRAME ) ) { try { closeFrame ( ) ; result = readNextFrame ( ) ; } catch ( BitstreamException e ) { if ( ( e . getErrorCode ( ) != STREAM_EOF ) ) { throw newBitstreamException ( e . getErrorCode ( ) , e ) ; } } } else if ( ( ex . getErrorCode ( ) != STREAM_EOF ) ) { throw newBitstreamException ( ex . getErrorCode ( ) , ex ) ; } } return result ; }
Reads and parses the next frame from the input source .
13,860
public boolean isSyncCurrentPosition ( int syncmode ) throws BitstreamException { int read = readBytes ( syncbuf , 0 , 4 ) ; int headerstring = ( ( syncbuf [ 0 ] << 24 ) & 0xFF000000 ) | ( ( syncbuf [ 1 ] << 16 ) & 0x00FF0000 ) | ( ( syncbuf [ 2 ] << 8 ) & 0x0000FF00 ) | ( ( syncbuf [ 3 ] << 0 ) & 0x000000FF ) ; try { source . unread ( syncbuf , 0 , read ) ; } catch ( IOException ex ) { } boolean sync = false ; switch ( read ) { case 0 : sync = true ; break ; case 4 : sync = isSyncMark ( headerstring , syncmode , syncword ) ; break ; } return sync ; }
Determines if the next 4 bytes of the stream represent a frame header .
13,861
int syncHeader ( byte syncmode ) throws BitstreamException { boolean sync ; int headerstring ; int bytesRead = readBytes ( syncbuf , 0 , 3 ) ; if ( bytesRead != 3 ) throw newBitstreamException ( STREAM_EOF , null ) ; headerstring = ( ( syncbuf [ 0 ] << 16 ) & 0x00FF0000 ) | ( ( syncbuf [ 1 ] << 8 ) & 0x0000FF00 ) | ( ( syncbuf [ 2 ] << 0 ) & 0x000000FF ) ; do { headerstring <<= 8 ; if ( readBytes ( syncbuf , 3 , 1 ) != 1 ) throw newBitstreamException ( STREAM_EOF , null ) ; headerstring |= ( syncbuf [ 3 ] & 0x000000FF ) ; sync = isSyncMark ( headerstring , syncmode , syncword ) ; } while ( ! sync ) ; current_frame_number ++ ; if ( last_frame_number < current_frame_number ) last_frame_number = current_frame_number ; return headerstring ; }
Get next 32 bits from bitstream . They are stored in the headerstring . syncmod allows Synchro flag ID The returned value is False at the end of stream .
13,862
int read_frame_data ( int bytesize ) throws BitstreamException { int numread = 0 ; numread = readFully ( frame_bytes , 0 , bytesize ) ; framesize = bytesize ; wordpointer = - 1 ; bitindex = - 1 ; return numread ; }
Reads the data for the next frame . The frame is not parsed until parse frame is called .
13,863
private int readFully ( byte [ ] b , int offs , int len ) throws BitstreamException { int nRead = 0 ; try { while ( len > 0 ) { int bytesread = source . read ( b , offs , len ) ; if ( bytesread == - 1 ) { while ( len -- > 0 ) { b [ offs ++ ] = 0 ; } break ; } nRead = nRead + bytesread ; offs += bytesread ; len -= bytesread ; } } catch ( IOException ex ) { throw newBitstreamException ( STREAM_ERROR , ex ) ; } return nRead ; }
Reads the exact number of bytes from the source input stream into a byte array .
13,864
private int readBytes ( byte [ ] b , int offs , int len ) throws BitstreamException { int totalBytesRead = 0 ; try { while ( len > 0 ) { int bytesread = source . read ( b , offs , len ) ; if ( bytesread == - 1 ) { break ; } totalBytesRead += bytesread ; offs += bytesread ; len -= bytesread ; } } catch ( IOException ex ) { throw newBitstreamException ( STREAM_ERROR , ex ) ; } return totalBytesRead ; }
Simlar to readFully but doesn t throw exception when EOF is reached .
13,865
public String getUuid ( ) { if ( ExperimentUUID_Type . featOkTst && ( ( ExperimentUUID_Type ) jcasType ) . casFeat_uuid == null ) jcasType . jcas . throwFeatMissing ( "uuid" , "edu.cmu.lti.oaqa.framework.types.ExperimentUUID" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( ExperimentUUID_Type ) jcasType ) . casFeatCode_uuid ) ; }
getter for uuid - gets
13,866
public void setUuid ( String v ) { if ( ExperimentUUID_Type . featOkTst && ( ( ExperimentUUID_Type ) jcasType ) . casFeat_uuid == null ) jcasType . jcas . throwFeatMissing ( "uuid" , "edu.cmu.lti.oaqa.framework.types.ExperimentUUID" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( ExperimentUUID_Type ) jcasType ) . casFeatCode_uuid , v ) ; }
setter for uuid - sets
13,867
public int getStageId ( ) { if ( ExperimentUUID_Type . featOkTst && ( ( ExperimentUUID_Type ) jcasType ) . casFeat_stageId == null ) jcasType . jcas . throwFeatMissing ( "stageId" , "edu.cmu.lti.oaqa.framework.types.ExperimentUUID" ) ; return jcasType . ll_cas . ll_getIntValue ( addr , ( ( ExperimentUUID_Type ) jcasType ) . casFeatCode_stageId ) ; }
getter for stageId - gets
13,868
public void setStageId ( int v ) { if ( ExperimentUUID_Type . featOkTst && ( ( ExperimentUUID_Type ) jcasType ) . casFeat_stageId == null ) jcasType . jcas . throwFeatMissing ( "stageId" , "edu.cmu.lti.oaqa.framework.types.ExperimentUUID" ) ; jcasType . ll_cas . ll_setIntValue ( addr , ( ( ExperimentUUID_Type ) jcasType ) . casFeatCode_stageId , v ) ; }
setter for stageId - sets
13,869
public Number getValue ( ValueDimension dim , int index ) { return values . get ( dim ) . get ( index ) ; }
Returns the value with the given index of the given dimension .
13,870
public static void propagateToParent ( WorkProgress subTask , WorkProgress parentTask , long amount ) { Runnable update = new Runnable ( ) { private long propagated = 0 ; public void run ( ) { long pos = subTask . getAmount ( ) ; if ( pos > 0 ) pos = subTask . getPosition ( ) * amount / pos ; if ( pos == propagated ) return ; synchronized ( parentTask ) { parentTask . progress ( pos - propagated ) ; } propagated = pos ; } } ; subTask . listen ( update ) ; update . run ( ) ; }
Propagate the progression of a sub - task to a prent .
13,871
public APETagField GetTagField ( String pFieldName ) throws IOException { int nIndex = GetTagFieldIndex ( pFieldName ) ; return ( nIndex != - 1 ) ? ( APETagField ) m_aryFields . get ( nIndex ) : null ; }
again be careful because this a pointer to the actual field in this class
13,872
protected boolean isProfileActive ( MavenProject project , String profileName ) { @ SuppressWarnings ( "unchecked" ) List < Profile > activeProfiles = project . getActiveProfiles ( ) ; if ( activeProfiles != null && ! activeProfiles . isEmpty ( ) ) { for ( Profile profile : activeProfiles ) { if ( profile . getId ( ) . equals ( profileName ) ) { return true ; } } } return false ; }
Checks if profile is active .
13,873
protected void queueSendToWebsocketNB ( String msg ) { if ( this . sendProcess . getPendingStepCount ( ) < MAX_MSG_BACKLOG ) { MySendStep sendStep = new MySendStep ( msg ) ; this . sendProcess . addStep ( sendStep ) ; } else { log . info ( "websocket backlog is full; aborting connection: sessionId={}" , this . socketSessionId ) ; this . safeClose ( ) ; } }
Send the given message to the
13,874
protected void safeClose ( ) { Session closeSession = this . socketSession ; this . socketSession = null ; try { if ( closeSession != null ) { registry . remove ( this . socketSessionId ) ; closeSession . close ( ) ; } } catch ( IOException ioExc ) { log . debug ( "io exception on safe close of session" , ioExc ) ; } }
Safely close the websocket .
13,875
public int compare ( Field o1 , Field o2 ) { int i = order . indexOf ( o1 . getId ( ) ) ; int j = order . indexOf ( o2 . getId ( ) ) ; if ( i == j ) return 0 ; if ( i == - 1 && j >= 0 ) return 1 ; if ( j == - 1 && i >= 0 ) return - 1 ; return i - j ; }
Compare method .
13,876
public Integer getOccurrencesOf ( Double value ) { if ( ! insertStat . containsKey ( value ) ) throw new IllegalArgumentException ( "No occurrences of value \"" + value + "\"" ) ; return insertStat . get ( value ) ; }
Returns the number of occurrences of the given value .
13,877
public double getValueAt ( int index ) { if ( index < 0 || index >= insertSeq . size ( ) ) throw new IndexOutOfBoundsException ( ) ; return insertSeq . get ( index ) ; }
Returns the inserted value of a given insertion step .
13,878
public static ILocalizableString get ( AnnotatedElement element , String name ) { for ( LocalizableProperty p : element . getAnnotationsByType ( LocalizableProperty . class ) ) { if ( ! p . name ( ) . equals ( name ) ) continue ; String ns = p . namespace ( ) ; if ( ns . length ( ) == 0 ) { LocalizableNamespace lns = element . getAnnotation ( LocalizableNamespace . class ) ; if ( lns == null ) { if ( element instanceof Member ) lns = ( ( Member ) element ) . getDeclaringClass ( ) . getAnnotation ( LocalizableNamespace . class ) ; } if ( lns != null ) ns = lns . value ( ) ; } String [ ] values = p . values ( ) ; Object [ ] v = new Object [ values . length ] ; for ( int i = 0 ; i < values . length ; ++ i ) v [ i ] = values [ i ] ; return new LocalizableString ( ns , p . key ( ) , v ) ; } for ( Property p : element . getAnnotationsByType ( Property . class ) ) { if ( ! p . name ( ) . equals ( name ) ) continue ; return new FixedLocalizedString ( p . value ( ) ) ; } return null ; }
Get a localizable string from the given element .
13,879
public static String convert ( final String aCode ) { String langName ; switch ( aCode . length ( ) ) { case 2 : langName = ISO639_1_MAP . get ( aCode . toLowerCase ( ) ) ; break ; case 3 : langName = ISO639_2_MAP . get ( aCode . toLowerCase ( ) ) ; break ; default : langName = aCode ; } return langName == null ? aCode : langName ; }
Converts a two or three digit ISO - 639 language code into a human readable name for the language represented by the code .
13,880
public static void onProcessExited ( Process process , Listener < Integer > exitValueListener ) { Application app = LCCore . getApplication ( ) ; Mutable < Thread > mt = new Mutable < > ( null ) ; Thread t = app . getThreadFactory ( ) . newThread ( ( ) -> { try { exitValueListener . fire ( Integer . valueOf ( process . waitFor ( ) ) ) ; } catch ( InterruptedException e ) { } app . interrupted ( mt . get ( ) ) ; } ) ; mt . set ( t ) ; t . setName ( "Waiting for process to exit" ) ; t . start ( ) ; app . toInterruptOnShutdown ( t ) ; }
Create a thread that wait for the given process to end and call the given listener .
13,881
public static void consumeProcessConsole ( Process process , Listener < String > outputListener , Listener < String > errorListener ) { Application app = LCCore . getApplication ( ) ; ThreadFactory factory = app . getThreadFactory ( ) ; Thread t ; ConsoleConsumer cc ; cc = new ConsoleConsumer ( process . getInputStream ( ) , outputListener ) ; t = factory . newThread ( cc ) ; t . setName ( "Process output console consumer" ) ; cc . app = app ; cc . t = t ; t . start ( ) ; app . toInterruptOnShutdown ( t ) ; cc = new ConsoleConsumer ( process . getErrorStream ( ) , errorListener ) ; t = factory . newThread ( cc ) ; t . setName ( "Process error console consumer" ) ; cc . app = app ; cc . t = t ; t . start ( ) ; app . toInterruptOnShutdown ( t ) ; }
Launch 2 threads to consume both output and error streams and call the listeners for each line read .
13,882
public Map < String , String > toMap ( ) { Map < String , String > ret = new HashMap < > ( ) ; ret . put ( "id" , this . getID ( ) ) ; ret . put ( "version" , this . getVersion ( ) . toString ( ) ) ; return ret ; }
Returns the string as a map using the key id for the identifier part and the key version for the version part .
13,883
public boolean sameAs ( Object obj ) { if ( obj == null ) { return false ; } if ( obj instanceof String || obj instanceof IdVersionString ) { if ( this . toString ( ) . equals ( obj . toString ( ) ) ) { return true ; } } return false ; }
Tests if the parameter is the same id and version .
13,884
public static void consume ( final HttpEntity entity ) throws IOException { if ( entity == null ) { return ; } if ( entity . isStreaming ( ) ) { InputStream instream = entity . getContent ( ) ; if ( instream != null ) { instream . close ( ) ; } } }
Ensures that the entity content is fully consumed and the content stream if exists is closed .
13,885
public static byte [ ] toByteArray ( final HttpEntity entity ) throws IOException { if ( entity == null ) { throw new IllegalArgumentException ( "HTTP entity may not be null" ) ; } InputStream instream = entity . getContent ( ) ; if ( instream == null ) { return null ; } try { if ( entity . getContentLength ( ) > Integer . MAX_VALUE ) { throw new IllegalArgumentException ( "HTTP entity too large to be buffered in memory" ) ; } int i = ( int ) entity . getContentLength ( ) ; if ( i < 0 ) { i = 4096 ; } ByteArrayBuffer buffer = new ByteArrayBuffer ( i ) ; byte [ ] tmp = new byte [ 4096 ] ; int l ; while ( ( l = instream . read ( tmp ) ) != - 1 ) { buffer . append ( tmp , 0 , l ) ; } return buffer . toByteArray ( ) ; } finally { instream . close ( ) ; } }
Read the contents of an entity and return it as a byte array .
13,886
public static String getContentMimeType ( final HttpEntity entity ) throws ParseException { if ( entity == null ) { throw new IllegalArgumentException ( "HTTP entity may not be null" ) ; } String mimeType = null ; if ( entity . getContentType ( ) != null ) { HeaderElement values [ ] = entity . getContentType ( ) . getElements ( ) ; if ( values . length > 0 ) { mimeType = values [ 0 ] . getName ( ) ; } } return mimeType ; }
Obtains mime type of the entity if known .
13,887
public int [ ] get ( int size , boolean acceptGreater ) { Node < ArraysBySize > node ; int [ ] buf ; synchronized ( arraysBySize ) { if ( acceptGreater ) node = arraysBySize . searchNearestHigher ( size , true ) ; else node = arraysBySize . get ( size ) ; if ( node != null && acceptGreater && node . getValue ( ) > size * 3 / 2 ) node = null ; if ( node == null ) buf = null ; else { ArraysBySize arrays = node . getElement ( ) ; arrays . lastUsageTime = System . currentTimeMillis ( ) ; buf = arrays . arrays . poll ( ) ; if ( arrays . arrays . isEmpty ( ) ) arraysBySize . remove ( node ) ; } } if ( buf == null ) return new int [ size ] ; totalSize -= buf . length * 4 ; return buf ; }
Get an array .
13,888
public static < S , E > void applyAll ( Query filterTree , GraphTraversal < S , E > q ) { if ( filterTree == null ) { return ; } QueryTranslationState state = new QueryTranslationState ( ) ; applyAll ( filterTree , q , false , state ) ; }
Applies all the filters from the applicator tree to the provided Gremlin query .
13,889
public static < T > Iterable < T > iterable ( Enumeration < T > enumeration ) { LinkedList < T > list = new LinkedList < > ( ) ; while ( enumeration . hasMoreElements ( ) ) list . add ( enumeration . nextElement ( ) ) ; return list ; }
Create an Iterable from the enumeration by filling a LinkedList with the elements in the enumeration .
13,890
public static < T > Iterator < T > iterator ( Enumeration < T > enumeration ) { return new Iterator < T > ( ) { public boolean hasNext ( ) { return enumeration . hasMoreElements ( ) ; } public T next ( ) { return enumeration . nextElement ( ) ; } } ; }
Create an Iterator from an Enumeration .
13,891
public static < T > Iterable < T > singleTimeIterable ( Enumeration < T > enumeration ) { return new Iterable < T > ( ) { public Iterator < T > iterator ( ) { return CollectionsUtil . iterator ( enumeration ) ; } } ; }
Create an Iterable from an Enumeration but avoiding to create a list so the Iterable can be iterated only once .
13,892
public static < T > void addAll ( Collection < T > col , Enumeration < T > e ) { while ( e . hasMoreElements ( ) ) col . add ( e . nextElement ( ) ) ; }
Add all elements of the given enumeration into the given collection .
13,893
final void rescheduleIfNeeded ( ) { if ( executeEvery > 0 && ! TaskScheduler . stopping ) { synchronized ( this ) { status = Task . STATUS_NOT_STARTED ; executeIn ( executeEvery ) ; } TaskScheduler . schedule ( this ) ; } else if ( nextExecution > 0 && ! TaskScheduler . stopping ) { synchronized ( this ) { this . status = Task . STATUS_NOT_STARTED ; } TaskScheduler . schedule ( this ) ; } }
Called by a task executor just after execute method finished .
13,894
public final Task < T , TError > start ( ) { if ( this instanceof Done ) return this ; if ( cancelling != null ) result . cancelled ( cancelling ) ; synchronized ( this ) { if ( result . isCancelled ( ) ) return this ; if ( status != Task . STATUS_NOT_STARTED ) { if ( status >= Task . STATUS_DONE ) throw new RuntimeException ( "Task already done: " + description + " with " + ( result . getError ( ) != null ? "error " + result . getError ( ) . getMessage ( ) : "success" ) ) ; throw new RuntimeException ( "Task already started (" + status + "): " + description ) ; } if ( nextExecution > 0 ) { long now = System . currentTimeMillis ( ) ; if ( nextExecution > now ) { TaskScheduler . schedule ( this ) ; return this ; } } sendToTaskManager ( ) ; return this ; } }
Ask to start the task . This does not start it immediately but adds it to the queue of tasks to execute .
13,895
public final void cancel ( CancelException reason ) { if ( cancelling != null ) return ; if ( reason == null ) reason = new CancelException ( "No reason given" ) ; cancelling = reason ; if ( TaskScheduler . cancel ( this ) ) { status = Task . STATUS_DONE ; result . cancelled ( reason ) ; return ; } if ( manager . remove ( this ) ) { status = Task . STATUS_DONE ; result . cancelled ( reason ) ; return ; } if ( status == Task . STATUS_NOT_STARTED ) { status = Task . STATUS_DONE ; result . cancelled ( reason ) ; return ; } }
Cancel this task .
13,896
public final synchronized void setPriority ( byte priority ) { if ( this . priority == priority ) return ; if ( status == STATUS_STARTED_READY ) { if ( manager . remove ( this ) ) { this . priority = priority ; while ( manager . getTransferTarget ( ) != null ) manager = manager . getTransferTarget ( ) ; manager . addReady ( this ) ; return ; } } this . priority = priority ; }
Change the priority of this task .
13,897
protected void setVersion ( String buf ) { while ( buf . endsWith ( "-" ) ) { buf = buf . substring ( 0 , buf . length ( ) - 1 ) ; } while ( buf . endsWith ( "." ) ) { buf = buf . substring ( 0 , buf . length ( ) - 1 ) ; } head = Version . valueOf ( buf ) ; significantDigits = - 1 ; }
Set the version
13,898
public String getQuestion ( ) { if ( InputElement_Type . featOkTst && ( ( InputElement_Type ) jcasType ) . casFeat_question == null ) jcasType . jcas . throwFeatMissing ( "question" , "edu.cmu.lti.oaqa.framework.types.InputElement" ) ; return jcasType . ll_cas . ll_getStringValue ( addr , ( ( InputElement_Type ) jcasType ) . casFeatCode_question ) ; }
getter for question - gets
13,899
public void setQuestion ( String v ) { if ( InputElement_Type . featOkTst && ( ( InputElement_Type ) jcasType ) . casFeat_question == null ) jcasType . jcas . throwFeatMissing ( "question" , "edu.cmu.lti.oaqa.framework.types.InputElement" ) ; jcasType . ll_cas . ll_setStringValue ( addr , ( ( InputElement_Type ) jcasType ) . casFeatCode_question , v ) ; }
setter for question - sets