idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
5,200
private Polygon createPolygon ( double [ ] [ ] [ ] coordinates , CrsId crsId ) { LinearRing [ ] rings = new LinearRing [ coordinates . length ] ; for ( int i = 0 ; i < coordinates . length ; i ++ ) { rings [ i ] = new LinearRing ( createPointSequence ( coordinates [ i ] , crsId ) ) ; } return new Polygon ( rings ) ; }
Creates a polygon starting from its geojson coordinate array
5,201
private PointSequence createPointSequence ( double [ ] [ ] coordinates , CrsId crsId ) { if ( coordinates == null ) { return null ; } else if ( coordinates . length == 0 ) { return PointCollectionFactory . createEmpty ( ) ; } DimensionalFlag df = coordinates [ 0 ] . length == 4 ? DimensionalFlag . d3DM : coordinates [ ...
Helpermethod that creates a geolatte pointsequence starting from an array containing coordinate arrays
5,202
private Point createPoint ( double [ ] input , CrsId crsIdValue ) { if ( input == null ) { return null ; } if ( input . length == 2 ) { return Points . create2D ( input [ 0 ] , input [ 1 ] , crsIdValue ) ; } else if ( input . length == 3 ) { return Points . create3D ( input [ 0 ] , input [ 1 ] , input [ 2 ] , crsIdValu...
Helpermethod that creates a point starting from its geojsonto coordinate array
5,203
private double [ ] [ ] getPoints ( Geometry input ) { double [ ] [ ] result = new double [ input . getNumPoints ( ) ] [ ] ; for ( int i = 0 ; i < input . getPoints ( ) . size ( ) ; i ++ ) { Point p = input . getPointN ( i ) ; if ( p . isMeasured ( ) && p . is3D ( ) ) { result [ i ] = new double [ ] { p . getX ( ) , p ....
Serializes all points of the input into a list of their coordinates
5,204
public static void invoke ( ) { for ( final Runnable instance : instances ) { try { instance . run ( ) ; } catch ( final Throwable t ) { LOGGER . error ( SHUTDOWN_HOOK_MARKER , "Caught exception executing shutdown hook {}" , instance , t ) ; } } }
Invoke all ShutdownCallbackRegistry instances .
5,205
public void run ( ) { if ( state . compareAndSet ( State . STARTED , State . STOPPING ) ) { for ( final Runnable hook : hooks ) { try { hook . run ( ) ; } catch ( final Throwable t ) { LOGGER . error ( SHUTDOWN_HOOK_MARKER , "Caught exception executing shutdown hook {}" , hook , t ) ; } } state . set ( State . STOPPED ...
Executes the registered shutdown callbacks .
5,206
public void checkExpectedValidationViolations ( Set < ConstraintViolation < T > > violations , List < String > expectedValidationViolations ) { if ( violations != null && expectedValidationViolations != null ) { List < String > givenViolations = new ArrayList < String > ( ) ; for ( ConstraintViolation < T > violation :...
This method checks the violations against expected violations .
5,207
public static void checkExpectedValidationViolations ( ConstraintViolationException exception , List < String > expectedValidationViolations ) { if ( exception != null && expectedValidationViolations != null ) { List < String > givenViolations = new ArrayList < String > ( ) ; for ( ConstraintViolation < ? > violation :...
This method checks if the validation violations matches the violations given in a ViolationException .
5,208
private static void checkViolations ( List < String > givenViolations , List < String > expectedValidationViolations ) { Assert . assertEquals ( String . format ( "number of expected validation violations (%s) does not match the number of given violations (%s)" , StringUtils . join ( expectedValidationViolations , LIST...
Helper method doing the checking work .
5,209
public synchronized String toJson ( Object input ) throws JsonException { try { return recurse ( input ) ; } catch ( IOException e ) { throw new JsonException ( e ) ; } }
Converts a given object into a JSON String
5,210
public synchronized < T > T fromJson ( String jsonString , Class < T > clazz ) throws JsonException { if ( jsonString == null ) { return null ; } Reader reader = new StringReader ( jsonString ) ; try { return mapper . readValue ( reader , clazz ) ; } catch ( JsonParseException e ) { throw new JsonException ( e . getMes...
Converts a given string into an object of the given class .
5,211
public < T > List < T > collectionFromJson ( String json , Class < T > clazz ) throws JsonException { if ( json == null ) { return null ; } try { List < T > result = new ArrayList < T > ( ) ; List tempParseResult = ( List ) mapper . readValue ( json , new TypeReference < List < T > > ( ) { } ) ; for ( Object temp : tem...
Converts a JsonString into a corresponding javaobject of the requested type .
5,212
protected String recurse ( Object input ) throws IOException { increaseDepth ( ) ; if ( depth > MAXIMUMDEPTH ) { decreaseDepth ( ) ; return "{ \"error\": \"maximum serialization-depth reached.\" }" ; } StringWriter writer = new StringWriter ( ) ; mapper . writeValue ( writer , input ) ; writer . close ( ) ; decreaseDep...
This method should only be used by serializers who need recursive calls . It prevents overflow due to circular references and ensures that the maximum depth of different sub - parts is limited
5,213
public < T > void addClassSerializer ( Class < ? extends T > classToMap , JsonSerializer < T > classSerializer ) { setNewObjectMapper ( ) ; SimpleModule mod = new SimpleModule ( "GeolatteCommonModule-" + classSerializer . getClass ( ) . getSimpleName ( ) ) ; mod . addSerializer ( classToMap , classSerializer ) ; mapper...
Adds a serializer to this mapper . Allows a user to alter the serialization behavior for a certain type .
5,214
public < T > void addClassDeserializer ( Class < T > classToMap , JsonDeserializer < ? extends T > classDeserializer ) { setNewObjectMapper ( ) ; SimpleModule mod = new SimpleModule ( "GeolatteCommonModule-" + classDeserializer . getClass ( ) . getSimpleName ( ) ) ; mod . addDeserializer ( classToMap , classDeserialize...
Adds a deserializer to this mapper . Allows a user to alter the deserialization behavior for a certain type .
5,215
private void setNewObjectMapper ( ) { mapper = new ObjectMapper ( ) ; if ( ! serializeNullValues ) { mapper . setSerializationInclusion ( JsonInclude . Include . NON_NULL ) ; if ( ignoreUnknownProperties ) { mapper . configure ( DeserializationFeature . FAIL_ON_UNKNOWN_PROPERTIES , false ) ; } } }
Sets a new object mapper taking into account the original configuration parameters .
5,216
public static CrsTo createCrsTo ( String crsName ) { String nameToUse = crsName == null ? "EPSG:4326" : crsName ; CrsTo result = new CrsTo ( ) ; NamedCrsPropertyTo property = new NamedCrsPropertyTo ( ) ; property . setName ( nameToUse ) ; result . setProperties ( property ) ; return result ; }
Convenience method to create a named crs to .
5,217
public static double [ ] createBoundingBox ( double [ ] coordinates ) { int maxActualCoords = Math . min ( coordinates . length , 3 ) ; double [ ] result = new double [ maxActualCoords * 2 ] ; for ( int i = 0 ; i < maxActualCoords ; i ++ ) { result [ i ] = coordinates [ i ] ; result [ maxActualCoords + i ] = coordinate...
Creates a boundingbox for a point . In this case both the lower and higher edges of the bbox are the point itself
5,218
private static void mergeInto ( double [ ] first , double [ ] second ) { for ( int j = 0 ; j < first . length / 2 ; j ++ ) { first [ j ] = Math . min ( first [ j ] , second [ j ] ) ; first [ j + first . length / 2 ] = Math . max ( first [ j + first . length / 2 ] , second [ j + first . length / 2 ] ) ; } }
Merges the second boundingbox into the first . Basically this extends the first boundingbox to also encapsulate the second
5,219
public final double distance ( final double [ ] value1 , final double [ ] value2 ) { double agg = 0 ; for ( int i = 0 ; i < value1 . length ; i ++ ) { agg += ( value1 [ i ] - value2 [ i ] ) * ( value1 [ i ] - value2 [ i ] ) ; } return Math . sqrt ( agg ) ; }
Compute traditional Euclidean distance .
5,220
public Boolean transform ( T input ) throws TransformationException { try { return cqlFilter . evaluate ( input ) ; } catch ( ParseException e ) { throw new TransformationException ( e , input ) ; } }
Checks whether the given input object passes the cql filter .
5,221
public Envelope createEnvelope ( double [ ] coordinates ) throws TypeConversionException { if ( coordinates . length < 4 ) { throw new TypeConversionException ( "Not enough coordinates in inputstring" ) ; } else { double minX = Double . MAX_VALUE ; double minY = Double . MAX_VALUE ; double maxX = Double . MIN_VALUE ; d...
Creates an envelope based on a list of coordinates . If less than two coordinates are in the list a typeconversion exception is thrown . If more than two coordinates are in the list the minimum X - and Y - coordinates are searched .
5,222
public double [ ] getCoordinates ( String inputString ) throws TypeConversionException { String [ ] cstr = inputString . split ( "," ) ; int coordLength ; if ( cstr . length % 2 == 0 ) { coordLength = cstr . length ; } else { coordLength = cstr . length - 1 ; } double [ ] coordinates = new double [ coordLength ] ; try ...
Retrieves a list of coordinates from the given string . If the number of numbers in the string is odd the last number is ignored .
5,223
public void start ( ) { collectedOutput = new ArrayList < T > ( ) ; for ( T element : input ) { collectedOutput . add ( element ) ; } }
Starts iterating over its input .
5,224
protected String getPropertyPath ( Collection < String > parts ) { StringBuilder propertyPath = new StringBuilder ( ) ; Iterator < String > partsIterator = parts . iterator ( ) ; propertyPath . append ( partsIterator . next ( ) ) ; while ( partsIterator . hasNext ( ) ) propertyPath . append ( "." ) . append ( partsIter...
Creates a dot - separated string of the given parts .
5,225
protected String getStringParam ( String paramName , String errorMessage ) throws IOException { return getStringParam ( paramName , errorMessage , ( Map < String , Object > ) inputParams . get ( ) ) ; }
Convenience method for subclasses . Uses the default map for parameterinput
5,226
protected Double getDoubleParam ( String paramName , String errorMessage ) throws IOException { return getDoubleParam ( paramName , errorMessage , ( Map < String , Object > ) inputParams . get ( ) ) ; }
Convenience method for subclasses . Retrieves a double with the given parametername even if that parametercontent is actually a string containing a number or a long or an int or ... Anything that can be converted to a double is returned . uses the default parameterhashmap from this deserializer .
5,227
protected Double getDoubleParam ( String paramName , String errorMessage , Map < String , Object > mapToUse ) throws IOException { Object o = mapToUse . get ( paramName ) ; if ( o != null ) { try { return Double . parseDouble ( o . toString ( ) ) ; } catch ( NumberFormatException ignored ) { } } return getTypedParam ( ...
Convenience method for subclasses . Retrieves a double with the given parametername even if that parametercontent is actually a string containing a number or a long or an int or ... Anything that can be converted to a double is returned .
5,228
protected < A > A getTypedParam ( String paramName , String errorMessage , Class < A > clazz ) throws IOException { return getTypedParam ( paramName , errorMessage , clazz , ( Map < String , Object > ) inputParams . get ( ) ) ; }
Convenience method for subclasses . Uses the default parametermap for this deserializer .
5,229
private GeometryCollection asGeomCollection ( CrsId crsId ) throws IOException { try { String subJson = getSubJson ( "geometries" , "A geometrycollection requires a geometries parameter" ) . replaceAll ( " " , "" ) ; String noSpaces = subJson . replace ( " " , "" ) ; if ( noSpaces . contains ( "\"crs\":{" ) ) { throw n...
Parses the JSON as a GeometryCollection .
5,230
private MultiPolygon asMultiPolygon ( List < List < List < List > > > coords , CrsId crsId ) throws IOException { if ( coords == null || coords . isEmpty ( ) ) { throw new IOException ( "A multipolygon should have at least one polyon." ) ; } Polygon [ ] polygons = new Polygon [ coords . size ( ) ] ; for ( int i = 0 ; i...
Parses the JSON as a MultiPolygon geometry
5,231
private MultiLineString asMultiLineString ( List < List < List > > coords , CrsId crsId ) throws IOException { if ( coords == null || coords . isEmpty ( ) ) { throw new IOException ( "A multilinestring requires at least one line string" ) ; } LineString [ ] lineStrings = new LineString [ coords . size ( ) ] ; for ( int...
Parses the JSON as a MultiLineString geometry
5,232
private Polygon asPolygon ( List < List < List > > coords , CrsId crsId ) throws IOException { if ( coords == null || coords . isEmpty ( ) ) { throw new IOException ( "A polygon requires the specification of its outer ring" ) ; } List < LinearRing > rings = new ArrayList < LinearRing > ( ) ; try { for ( List < List > r...
Parses the JSON as a polygon geometry
5,233
private Point asPoint ( List coords , CrsId crsId ) throws IOException { if ( coords != null && coords . size ( ) >= 2 ) { ArrayList < List > coordinates = new ArrayList < List > ( ) ; coordinates . add ( coords ) ; return new Point ( getPointSequence ( coordinates , crsId ) ) ; } else { throw new IOException ( "A poin...
Parses the JSON as a point geometry .
5,234
public final Solution < T > cluster ( final JavaRDD < T > input_data ) { if ( k <= 0 ) { throw new IllegalStateException ( "k must be > 0!" ) ; } if ( similarity == null ) { throw new IllegalStateException ( "Similarity is not defined!" ) ; } if ( budget == null ) { throw new IllegalStateException ( "No budget is defin...
Cluster the data according to defined parameters .
5,235
private static int argmax ( final double [ ] values ) { double max = - Double . MAX_VALUE ; int max_index = - 1 ; for ( int i = 0 ; i < values . length ; i ++ ) { if ( values [ i ] > max ) { max = values [ i ] ; max_index = i ; } } return max_index ; }
Return the index of the highest value in the array .
5,236
public static BooleanIsEqual isEqual ( ComparableExpression < Boolean > left , Boolean constant ) { return new BooleanIsEqual ( left , constant ( constant ) ) ; }
Creates a BooleanIsEqual expression from the given expression and constant .
5,237
public static IsGreaterThan isGreaterThan ( ComparableExpression < Number > left , ComparableExpression < Number > right ) { return new IsGreaterThan ( left , right ) ; }
Creates an IsGreaterThan expression from the given expressions .
5,238
public static IsGreaterThanOrEqual isGreaterThanOrEqual ( ComparableExpression < Number > left , ComparableExpression < Number > right ) { return new IsGreaterThanOrEqual ( left , right ) ; }
Creates an IsGreaterThanOrEqual expression from the given expressions .
5,239
public static BooleanIsLessThanOrEqual isLessThanOrEqual ( ComparableExpression < Boolean > left , Object constant ) { if ( ! ( constant instanceof Boolean ) ) throw new IllegalArgumentException ( "constant is not a Boolean" ) ; return new BooleanIsLessThanOrEqual ( left , constant ( ( Boolean ) constant ) ) ; }
Creates an BooleanIsGreaterThanOrEqual expression from the given expression and constant .
5,240
public static IsLessThan isLessThan ( ComparableExpression < Number > left , ComparableExpression < Number > right ) { return new IsLessThan ( left , right ) ; }
Creates an IsLessThan expression from the given expressions .
5,241
public static IsLessThan isLessThan ( ComparableExpression < Number > left , Object constant ) { if ( ! ( constant instanceof Number ) ) throw new IllegalArgumentException ( "constant is not a Number" ) ; return new IsLessThan ( left , constant ( ( Number ) constant ) ) ; }
Creates an IsLessThan expression from the given expression and constant .
5,242
public static BooleanIsLessThan isLessThan ( BooleanExpression left , Object constant ) { if ( ! ( constant instanceof Boolean ) ) throw new IllegalArgumentException ( "constant is not a Boolean" ) ; return new BooleanIsLessThan ( left , constant ( ( Boolean ) constant ) ) ; }
Creates an BooleanIsLessThan expression from the given expression and constant .
5,243
public static StringIsLessThan isLessThan ( StringExpression left , Object constant ) { if ( ! ( constant instanceof String ) ) throw new IllegalArgumentException ( "constant is not a String" ) ; return new StringIsLessThan ( left , constant ( ( String ) constant ) ) ; }
Creates an StringIsLessThan expression from the given expression and constant .
5,244
public static IsLessThanOrEqual isLessThanOrEqual ( NumberExpression left , Object constant ) { if ( ! ( constant instanceof Number ) ) throw new IllegalArgumentException ( "constant is not a Number" ) ; return new IsLessThanOrEqual ( left , constant ( ( Number ) constant ) ) ; }
Creates an IsLessThanOrEqual expression from the given expression and constant .
5,245
public static StringIsLessThanOrEqual isLessThanOrEqual ( StringExpression left , Object constant ) { if ( ! ( constant instanceof String ) ) throw new IllegalArgumentException ( "constant is not a String" ) ; return new StringIsLessThanOrEqual ( left , constant ( ( String ) constant ) ) ; }
Creates an StringIsLessThanOrEqual expression from the given expression and constant .
5,246
public static IsNotEqual isNotEqual ( ComparableExpression < Number > left , Object constant ) { if ( ! ( constant instanceof Number ) ) throw new IllegalArgumentException ( "constant is not a Number" ) ; return new IsNotEqual ( left , constant ( ( Number ) constant ) ) ; }
Creates an IsNotEqual expression from the given expression and constant .
5,247
public static BooleanIsNotEqual isNotEqual ( ComparableExpression < Boolean > left , ComparableExpression < Boolean > right ) { return new BooleanIsNotEqual ( left , right ) ; }
Creates an BooleanIsNotEqual expression from the given expressions .
5,248
public static Add add ( Expression < Number > left , Expression < Number > right ) { return new Add ( left , right ) ; }
Creates an Add expression from the given expressions .
5,249
public static NotLike notLike ( Expression < String > left , String constant , boolean caseInsensitive ) { return new NotLike ( left , constant ( constant ) , caseInsensitive ) ; }
Creates a NotLike expression from the given expressions with % as the wildcard character
5,250
public static NotLike notLike ( Expression < String > left , Expression < String > right , char wildCardCharacter ) { return new NotLike ( left , right , wildCardCharacter ) ; }
Creates a NotLike expression from the given expressions .
5,251
public static And and ( Expression < Boolean > left , Expression < Boolean > right ) { return new And ( left , right ) ; }
Creates an And expression from the given expressions .
5,252
public static Or or ( Expression < Boolean > left , Expression < Boolean > right ) { return new Or ( left , right ) ; }
Creates an Or expression from the given expressions .
5,253
public static IsBefore isBefore ( Expression < Date > left , Expression < Date > right ) { return new IsBefore ( left , right ) ; }
Creates an IsBefore expression from the given expressions .
5,254
public static IsAfter isAfter ( Expression < Date > left , Expression < Date > right ) { return new IsAfter ( left , right ) ; }
Creates an IsAfter expression from the given expressions .
5,255
public static DateIsBetween isBetween ( ComparableExpression < Date > date , ComparableExpression < Date > lowDate , ComparableExpression < Date > highDate ) { return new DateIsBetween ( date , lowDate , highDate ) ; }
Creates an IsBetween expression from the given expressions .
5,256
public static GeoEquals geoEquals ( Expression < Geometry > left , Expression < Geometry > right ) { return new GeoEquals ( left , right ) ; }
Creates a GeoEquals expression from the left and right expressions .
5,257
public void setGeometry ( String name , Geometry value ) { if ( name == null ) { geomPropertyName = null ; geomValue = null ; } else { geomPropertyName = name ; geomValue = value ; } }
Sets the geometry property of the feature . This method also allows wiping the current geometry by setting the name of the property to null . The value will in that case be ignored .
5,258
public void setId ( String name , Object value ) { if ( name == null ) { idPropertyName = null ; idValue = null ; } else { idPropertyName = name ; idValue = value ; } }
Sets the id property of the feature . This method also allows wiping the current id by setting the name of the id to null . The value will in that case be ignored .
5,259
public void addProperty ( String propertyName , Object value ) { if ( propertyName != null ) { propertyNames . add ( propertyName ) ; if ( value == null ) { properties . remove ( propertyName ) ; } else { properties . put ( propertyName , value ) ; } } }
The name of the property to add . if it already exists the value is updated . If the propertyname is null the property addition is ignored .
5,260
public void wipeProperty ( String propertyName ) { if ( propertyName != null ) { propertyNames . remove ( propertyName ) ; if ( properties . containsKey ( propertyName ) ) { properties . remove ( propertyName ) ; } } }
If a property with the specified name exists it is removed from this feature . if the given propertyname is null the call is ignored . Note that this method has no effect whatsoever regarding the geometry or id property .
5,261
public static Filter toStaticFilter ( String cqlExpression , Class clazz ) throws ParseException { try { Parser p = new Parser ( new Lexer ( new PushbackReader ( new StringReader ( cqlExpression ) , 1024 ) ) ) ; Start tree = p . parse ( ) ; FilterExpressionBuilder builder = new FilterExpressionBuilder ( ) ; tree . appl...
Creates an executable object filter based on the given CQL expression . This filter is only applicable for the given class .
5,262
private void swap ( int n , int m ) { int eM = elements [ m ] ; int eN = elements [ n ] ; elements [ m ] = eN ; elements [ n ] = eM ; positions [ eM ] = n ; positions [ eN ] = m ; }
swap data in node n with data in node m
5,263
private void moveAtFirst ( int n_from ) { int eT = elements [ 0 ] ; int eF = elements [ n_from ] ; positions [ eT ] = - 1 ; positions [ eF ] = 0 ; elements [ 0 ] = eF ; elements [ n_from ] = - 1 ; }
moveAtFirst data in node n_from to node 0 Erase previous information of node 0
5,264
public boolean registerConfiguration ( EncodingConfiguration ec ) { boolean changed = false ; if ( sc . getChannelCount ( ) != 2 ) ec . setChannelConfig ( EncodingConfiguration . ChannelConfig . INDEPENDENT ) ; this . ec = new EncodingConfiguration ( ec ) ; verbatimSubframe . registerConfiguration ( this . ec ) ; fixed...
This method is used to set the encoding configuration . This configuration can be altered throughout the stream but cannot be called while an encoding process is active .
5,265
public boolean removeNode ( int x , ICause cause ) throws ContradictionException { assert cause != null ; assert ( x >= 0 && x < n ) ; if ( LB . getNodes ( ) . contains ( x ) ) { this . contradiction ( cause , "remove mandatory node" ) ; return true ; } else if ( ! UB . getNodes ( ) . contains ( x ) ) { return false ; ...
Remove node x from the domain Removes x from the upper bound graph
5,266
public boolean enforceNode ( int x , ICause cause ) throws ContradictionException { assert cause != null ; assert ( x >= 0 && x < n ) ; if ( UB . getNodes ( ) . contains ( x ) ) { if ( LB . addNode ( x ) ) { if ( reactOnModification ) { delta . add ( x , GraphDelta . NE , cause ) ; } GraphEventType e = GraphEventType ....
Enforce the node x to belong to any solution Adds x to the lower bound graph
5,267
public void clear ( int size , int off ) { if ( size % 4 != 4 ) size = ( size / 4 + 1 ) * 4 ; next = null ; previous = null ; data = new byte [ size ] ; offset = off ; for ( int i = 0 ; i < data . length ; i ++ ) data [ i ] = 0 ; usableBits = off ; }
Completely clear this element and use the given size and offset for the new data array .
5,268
protected static EncodedElement getEnd_S ( EncodedElement e ) { if ( e == null ) return null ; EncodedElement temp = e . next ; EncodedElement end = e ; while ( temp != null ) { end = temp ; temp = temp . next ; } return end ; }
Return the last element of the list given . This is a static funtion to provide minor speed improvement . Loops through all elements next pointers till the last is found .
5,269
public EncodedElement getEnd ( ) { EncodedElement temp = next ; EncodedElement end = this ; while ( temp != null ) { end = temp ; temp = temp . next ; } return end ; }
Return the last element of the list given . Loops through all elements next pointers till the last is found .
5,270
public boolean attachEnd ( EncodedElement e ) { if ( DEBUG_LEV > 0 ) System . err . println ( "EncodedElement::attachEnd : Begin" ) ; boolean attached = true ; EncodedElement current = this ; while ( current . getNext ( ) != null ) { current = current . getNext ( ) ; } current . setNext ( e ) ; e . setPrevious ( curren...
Attach an element to the end of this list .
5,271
public EncodedElement addLong ( long input , int bitCount ) { if ( next != null ) { EncodedElement end = EncodedElement . getEnd_S ( next ) ; return end . addLong ( input , bitCount ) ; } else if ( data . length * 8 <= usableBits + bitCount ) { int tOff = usableBits % 8 ; int size = data . length / 2 + 1 ; if ( size < ...
Add a number of bits from a long to the end of this list s data . Will add a new element if necessary . The bits stored are taken from the lower - order of input .
5,272
public EncodedElement packInt ( int [ ] inputArray , int bitSize , int start , int skip , int countA ) { if ( next != null ) { EncodedElement end = EncodedElement . getEnd_S ( next ) ; return end . packInt ( inputArray , bitSize , start , skip , countA ) ; } int writeCount = ( data . length * 8 - usableBits ) / bitSize...
Append an equal number of bits from each int in an array within given limits to the end of this list .
5,273
public int getTotalBits ( ) { int total = 0 ; EncodedElement iter = this ; while ( iter != null ) { total += iter . usableBits - iter . offset ; iter = iter . next ; } return total ; }
Total number of usable bits stored by this entire list . This sums the difference of each list element s usableBits and offset .
5,274
private static void addLong ( long input , int count , int startPos , byte [ ] dest ) { if ( DEBUG_LEV > 30 ) System . err . println ( "EncodedElement::addLong : Begin" ) ; int currentByte = startPos / 8 ; int currentOffset = startPos % 8 ; int bitRoom ; long upMask ; int downShift ; int upShift ; while ( count > 0 ) {...
This method adds a given number of bits of a long to a byte array .
5,275
private static void packInt ( int [ ] inputArray , int bitSize , int startPosIn , int start , int skip , int countA , byte [ ] dest ) { if ( DEBUG_LEV > 30 ) System . err . println ( "EncodedElement::packInt : Begin" ) ; for ( int valI = 0 ; valI < countA ; valI ++ ) { int input = inputArray [ valI * ( skip + 1 ) + sta...
Append an equal number of bits from each int in an array within given limits to the given byte array .
5,276
public boolean padToByte ( ) { boolean padded = false ; EncodedElement end = EncodedElement . getEnd_S ( this ) ; int tempVal = end . usableBits ; if ( tempVal % 8 != 0 ) { int toWrite = 8 - ( tempVal % 8 ) ; end . addInt ( 0 , toWrite ) ; assert ( ( this . getTotalBits ( ) + offset ) % 8 == 0 ) ; padded = true ; } ret...
Force the usable data stored in this list ends on a a byte boundary by padding to the end with zeros .
5,277
public static int getDataFormatSupport ( AudioFormat format ) { int result = SUPPORTED ; float sampleRate = format . getSampleRate ( ) ; AudioFormat . Encoding encoding = format . getEncoding ( ) ; if ( format . getChannels ( ) > 8 || format . getChannels ( ) < 1 ) result |= UNSUPPORTED_CHANNELCOUNT ; if ( format . get...
Checks whether the given AudioFormat can be properly encoded by this FLAC library .
5,278
private static byte encodeBlockSize ( int blockSize ) { if ( DEBUG_LEV > 0 ) System . err . println ( "FrameHeader::encodeBlockSize : Begin" ) ; byte value = 0 ; int i ; for ( i = 0 ; i < definedBlockSizes . length ; i ++ ) { if ( blockSize == definedBlockSizes [ i ] ) { value = ( byte ) i ; break ; } } if ( i >= defin...
Given a block size select the proper bit settings to use according to the FLAC stream .
5,279
public void blockWhileQueueExceeds ( int count ) { boolean loop = true ; boolean interrupted = false ; try { do { synchronized ( outstandingCountLock ) { if ( outstandingCount > count ) { try { outstandingCountLock . wait ( ) ; } catch ( InterruptedException e ) { interrupted = true ; } } else loop = false ; } } while ...
This function is used to help control flow of BlockEncodeRequests into this manager . It will block so long as their is at least as many unprocessed blocks waiting to be encoded as the value given .
5,280
synchronized public boolean addFrameThread ( Frame frame ) { FrameThread ft = new FrameThread ( frame , this ) ; inactiveFrameThreads . add ( ft ) ; boolean r = true ; startFrameThreads ( ) ; return r ; }
Add a Frame to this manager which it will use to encode a block . Each Frame added allows one more thread to be used for encoding . At least one Frame must be added for this manager to encode .
5,281
synchronized private void startFrameThreads ( ) { if ( ! process ) return ; int requests = unassignedEncodeRequests . size ( ) ; int frames = inactiveFrameThreads . size ( ) ; frames = ( requests <= frames ) ? requests : frames ; for ( int i = 0 ; i < frames ; i ++ ) { FrameThread ft = inactiveFrameThreads . remove ( 0...
Start any available FrameThread objects encoding so long as there are waiting BlockEncodeRequest objects .
5,282
public void run ( ) { boolean loop = true ; boolean interrupted = false ; try { while ( loop ) { try { if ( nextTarget == null ) nextTarget = orderedEncodeRequests . poll ( 500 , TimeUnit . MILLISECONDS ) ; if ( nextTarget == null ) { loop = false ; } else if ( nextTarget . frameNumber < 0 ) { loop = false ; nextTarget...
Waits for the next BlockEncodeRequest that needs to be sent back to the FLACEncoder for finalizing . If no request is finished or currently assigned to an encoding thread will timeout after 0 . 5 seconds and end .
5,283
private void proceedFirstDFS ( ) { for ( int i = 0 ; i < nbNodes ; i ++ ) { iterator [ i ] = successors [ i ] . iterator ( ) ; } int i = root ; int k = 0 ; father [ k ] = k ; dfsNumberOfNode [ root ] = k ; nodeOfDfsNumber [ k ] = root ; int j ; k ++ ; while ( true ) { if ( iterator [ i ] . hasNext ( ) ) { j = iterator ...
perform a dfs in graph to label nodes
5,284
public GraphSearch configure ( int policy , boolean enforce ) { if ( enforce ) { decisionType = GraphAssignment . graph_enforcer ; } else { decisionType = GraphAssignment . graph_remover ; } mode = policy ; return this ; }
Configures the search
5,285
public void generate ( org . codehaus . doxia . sink . Sink sink , Locale locale ) throws MavenReportException { generate ( ( Sink ) sink , locale ) ; }
eventually we must replace this with the o . a . m . d . s . Sink class as a parameter
5,286
public boolean setSampleRate ( int rate ) { boolean result = ( rate <= MAX_SAMPLE_RATE && rate >= MIN_SAMPLE_RATE ) ; sampleRate = rate ; return result ; }
Set the sample rate . Because this is not a value that may be guessed and corrected the value will be set to that given even if it is not valid .
5,287
public boolean setBitsPerSample ( int bitsPerSample ) { boolean result = ( ( bitsPerSample <= MAX_BITS_PER_SAMPLE ) && ( bitsPerSample >= MIN_BITS_PER_SAMPLE ) ) ; this . bitsPerSample = bitsPerSample ; return result ; }
Set the bits per sample . Because this is not a value that may be guessed and corrected the value will be set to that given even if it is not valid .
5,288
public int setMaxBlockSize ( int size ) { maxBlockSize = ( size <= MAX_BLOCK_SIZE ) ? size : MAX_BLOCK_SIZE ; maxBlockSize = ( maxBlockSize >= MIN_BLOCK_SIZE ) ? maxBlockSize : MIN_BLOCK_SIZE ; return maxBlockSize ; }
Set the maximum block size to use . If this value is out of a valid range it will be set to the closest valid value . User must ensure that this value is set above or equal to the minimum block size .
5,289
public int setMinBlockSize ( int size ) { minBlockSize = ( size <= MAX_BLOCK_SIZE ) ? size : MAX_BLOCK_SIZE ; minBlockSize = ( minBlockSize >= MIN_BLOCK_SIZE ) ? maxBlockSize : MIN_BLOCK_SIZE ; return minBlockSize ; }
Set the minimum block size to use . If this value is out of a valid range it will be set to the closest valid value . User must ensure that this value is set below or equal to the maximum block size .
5,290
public boolean isEncodingSubsetCompliant ( EncodingConfiguration ec ) { boolean result = true ; result = isStreamSubsetCompliant ( ) ; if ( this . sampleRate <= 48000 ) { result &= ec . maximumLPCOrder <= 12 ; result &= ec . maximumRicePartitionOrder <= 8 ; } return result ; }
Test if this StreamConfiguration and a paired EncodingConfiguration define a Subset compliant stream . FLAC defines a subset of options to ensure resulting FLAC streams are streamable .
5,291
public static EncodedElement getStreamInfo ( StreamConfiguration sc , int minFrameSize , int maxFrameSize , long samplesInStream , byte [ ] md5Hash ) { int bytes = getByteSize ( ) ; EncodedElement ele = new EncodedElement ( bytes , 0 ) ; int encodedBitsPerSample = sc . getBitsPerSample ( ) - 1 ; ele . addInt ( sc . get...
Create a FLAC StreamInfo metadata block with the given parameters . Because of the data stored in a StreamInfo block this should generally be created only after all encoding is done .
5,292
static public int getByteSize ( ) { int size = 0 ; size += 16 ; size += 16 ; size += 24 ; size += 24 ; size += 20 ; size += 3 ; size += 5 ; size += 36 ; size += 64 ; size += 64 ; size = size / 8 ; return size ; }
Get the expected size of a properly formed STREAMINFO metadata block .
5,293
public static void calculate ( LPC lpc , long [ ] R ) { int coeffCount = lpc . order ; double [ ] A = lpc . rawCoefficients ; for ( int i = 0 ; i < coeffCount + 1 ; i ++ ) A [ i ] = 0.0 ; A [ 0 ] = 1 ; double E = R [ 0 ] ; if ( R [ 0 ] == 0 ) { for ( int i = 0 ; i < coeffCount + 1 ; i ++ ) A [ i ] = 0.0 ; } else { doub...
Calculate an LPC using the given Auto - correlation data . Static method used since this is slightly faster than a more strictly object - oriented approach .
5,294
public static void calculateFromPrior ( LPC lpc , long [ ] R , LPC priorLPC ) { int coeffCount = lpc . order ; double [ ] A = lpc . rawCoefficients ; for ( int i = 0 ; i < coeffCount + 1 ; i ++ ) A [ i ] = 0.0 ; A [ 0 ] = 1 ; double E = R [ 0 ] ; int startIter = 0 ; if ( priorLPC != null && priorLPC . order < lpc . ord...
Calculate an LPC using a prior order LPC s values to save calculations .
5,295
public static int binaryLCA ( int x , int y ) { if ( x == y ) { return x ; } int xor = x ^ y ; int idx = getMaxExp ( xor ) ; if ( idx == - 1 ) { throw new UnsupportedOperationException ( ) ; } return replaceBy1and0sFrom ( x , idx ) ; }
Get the lowest common ancestor of x and y in a complete binary tree
5,296
public void setAll ( int [ ] samples , int count , int start , int skip , long frameNumber , EncodedElement result ) { this . samples = samples ; this . count = count ; this . start = start ; this . skip = skip ; this . frameNumber = frameNumber ; this . result = result ; valid = false ; this . encodedSamples = 0 ; }
Set all values preparing this object to be sent to an encoder . Member variable valid is set to false by this call .
5,297
int getInt ( String [ ] args , int index ) { int result = - 1 ; if ( index >= 0 && index < args . length ) { try { result = Integer . parseInt ( args [ index ] ) ; } catch ( NumberFormatException e ) { result = - 1 ; } } return result ; }
Utility function to parse a positive integer argument out of a String array at the given index .
5,298
private StreamConfiguration adjustConfigurations ( AudioFormat format ) { int sampleRate = ( int ) format . getSampleRate ( ) ; int sampleSize = format . getSampleSizeInBits ( ) ; int channels = format . getChannels ( ) ; StreamConfiguration streamConfiguration = new StreamConfiguration ( ) ; streamConfiguration . setS...
Method sets input stream configuration for encoder .
5,299
private static void validateCategories ( String ... categories ) { for ( String category : categories ) { if ( ! category . matches ( FCM_TOPIC_PATTERN ) ) { throw new IllegalArgumentException ( String . format ( "%s does not match %s" , category , FCM_TOPIC_PATTERN ) ) ; } } }
Validates categories against Google s pattern .