idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
20,900
private static InputStream inputStreamFromFile ( String relativePathPrefix , String src ) throws IOException { File file = getFile ( relativePathPrefix , src ) ; if ( ! file . exists ( ) ) { if ( src . length ( ) > 0 && src . charAt ( 0 ) == File . separatorChar ) { file = getFile ( relativePathPrefix , src . substring...
Create InputStream from file resource .
20,901
private static InputStream inputStreamFromJar ( String relativePathPrefix , String src ) throws IOException { String absoluteName = getAbsoluteName ( relativePathPrefix , src ) ; return XmlUtils . class . getResourceAsStream ( absoluteName ) ; }
Create InputStream from jar resource .
20,902
public synchronized void add ( int index , Layer layer , boolean redraw ) { checkIsNull ( layer ) ; layer . setDisplayModel ( this . displayModel ) ; this . layersList . add ( index , layer ) ; layer . assign ( this . redrawer ) ; if ( redraw ) { this . redrawer . redrawLayers ( ) ; } }
Adds a new layer at the specified position .
20,903
public synchronized void addAll ( Collection < Layer > layers , boolean redraw ) { checkIsNull ( layers ) ; for ( Layer layer : layers ) { layer . setDisplayModel ( this . displayModel ) ; } this . layersList . addAll ( layers ) ; for ( Layer layer : layers ) { layer . assign ( this . redrawer ) ; } if ( redraw ) { thi...
Adds multiple new layers on top .
20,904
public synchronized void clear ( boolean redraw ) { for ( Layer layer : this . layersList ) { layer . unassign ( ) ; } this . layersList . clear ( ) ; if ( redraw ) { this . redrawer . redrawLayers ( ) ; } }
Removes all layers .
20,905
int fillWindow ( CursorWindow window , int startPos , int requiredPos , boolean countAllRows ) { acquireReference ( ) ; try { window . acquireReference ( ) ; try { int numRows = getSession ( ) . executeForCursorWindow ( getSql ( ) , getBindArgs ( ) , window , startPos , requiredPos , countAllRows , getConnectionFlags (...
Reads rows into a buffer .
20,906
Set < MapElementContainer > getOverlappingElements ( Tile from , Tile to ) { if ( overlapData . containsKey ( from ) && overlapData . get ( from ) . containsKey ( to ) ) { return overlapData . get ( from ) . get ( to ) ; } return new HashSet < MapElementContainer > ( 0 ) ; }
Retrieves the overlap data from the neighbouring tiles
20,907
void removeTileData ( Tile from , Tile to ) { if ( overlapData . containsKey ( from ) ) { overlapData . get ( from ) . remove ( to ) ; } }
Cache maintenance operation to remove data for a tile from the cache . This should be excuted if a tile is removed from the TileCache and will be drawn again .
20,908
public LatLong fromPixels ( double x , double y ) { if ( this . mapView . getWidth ( ) <= 0 || this . mapView . getHeight ( ) <= 0 ) { return null ; } MapPosition mapPosition = this . mapView . getModel ( ) . frameBufferModel . getMapPosition ( ) ; if ( mapPosition == null ) { return null ; } LatLong latLong = mapPosit...
Computes the geographic coordinates of a screen point .
20,909
public double getLatitudeSpan ( ) { if ( this . mapView . getWidth ( ) > 0 && this . mapView . getHeight ( ) > 0 ) { LatLong top = fromPixels ( 0 , 0 ) ; LatLong bottom = fromPixels ( 0 , this . mapView . getHeight ( ) ) ; return Math . abs ( top . latitude - bottom . latitude ) ; } throw new IllegalStateException ( IN...
Computes vertical extend of the map view .
20,910
public double getLongitudeSpan ( ) { if ( this . mapView . getWidth ( ) > 0 && this . mapView . getHeight ( ) > 0 ) { LatLong left = fromPixels ( 0 , 0 ) ; LatLong right = fromPixels ( this . mapView . getWidth ( ) , 0 ) ; return Math . abs ( left . longitude - right . longitude ) ; } throw new IllegalStateException ( ...
Computes horizontal extend of the map view .
20,911
public double angleTo ( LineSegment other ) { double angle1 = Math . atan2 ( this . start . y - this . end . y , this . start . x - this . end . x ) ; double angle2 = Math . atan2 ( other . start . y - other . end . y , other . start . x - other . end . x ) ; double angle = Math . toDegrees ( angle1 - angle2 ) ; if ( a...
Computes the angle between this LineSegment and another one .
20,912
public boolean intersectsRectangle ( Rectangle r , boolean bias ) { int codeStart = code ( r , this . start ) ; int codeEnd = code ( r , this . end ) ; if ( 0 == ( codeStart | codeEnd ) ) { return true ; } else if ( 0 != ( codeStart & codeEnd ) ) { return false ; } return bias ; }
Returns a fast computation if the line intersects the rectangle or bias if there is no fast way to compute the intersection .
20,913
public Point pointAlongLineSegment ( double distance ) { if ( start . x == end . x ) { if ( start . y > end . y ) { return new Point ( end . x , end . y + distance ) ; } else { return new Point ( start . x , start . y + distance ) ; } } else { double slope = ( end . y - start . y ) / ( end . x - start . x ) ; double dx...
Computes a Point along the line segment with a given distance to the start Point .
20,914
public LineSegment subSegment ( double offset , double length ) { Point subSegmentStart = pointAlongLineSegment ( offset ) ; Point subSegmentEnd = pointAlongLineSegment ( offset + length ) ; return new LineSegment ( subSegmentStart , subSegmentEnd ) ; }
LineSegment that starts at offset from start and runs for length towards end point
20,915
public boolean readFromFile ( int length ) throws IOException { if ( this . bufferData == null || this . bufferData . length < length ) { if ( length > Parameters . MAXIMUM_BUFFER_SIZE ) { LOGGER . warning ( "invalid read length: " + length ) ; return false ; } this . bufferData = new byte [ length ] ; this . bufferWra...
Reads the given amount of bytes from the file into the read buffer and resets the internal buffer position . If the capacity of the read buffer is too small a larger one is created automatically .
20,916
public String readUTF8EncodedString ( int stringLength ) { if ( stringLength > 0 && this . bufferPosition + stringLength <= this . bufferData . length ) { this . bufferPosition += stringLength ; try { return new String ( this . bufferData , this . bufferPosition - stringLength , stringLength , CHARSET_UTF8 ) ; } catch ...
Decodes the given amount of bytes from the read buffer to a string .
20,917
void fillOutsideAreas ( int color , Rectangle insideArea ) { this . canvas . setClipDifference ( ( int ) insideArea . left , ( int ) insideArea . top , ( int ) insideArea . getWidth ( ) , ( int ) insideArea . getHeight ( ) ) ; this . canvas . fillColor ( color ) ; this . canvas . resetClip ( ) ; }
Fills the area outside the specificed rectangle with color . This method is used to blank out areas that fall outside the map area .
20,918
double calculateRaw ( double n , double e ) { double normPlaneDist = ( e + n + a ) / ( ast2 * Math . sqrt ( n * n + e * e + 1 ) ) ; double lightness = Math . max ( 0 , normPlaneDist ) ; return lightness ; }
return 0 .. 1
20,919
long getIndexEntry ( SubFileParameter subFileParameter , long blockNumber ) throws IOException { if ( blockNumber >= subFileParameter . numberOfBlocks ) { throw new IOException ( "invalid block number: " + blockNumber ) ; } long indexBlockNumber = blockNumber / INDEX_ENTRIES_PER_BLOCK ; IndexCacheEntryKey indexCacheEnt...
Returns the index entry of a block in the given map file . If the required index entry is not cached it will be read from the map file index and put in the cache .
20,920
private static String getSQLWhereClauseString ( PoiCategoryFilter filter , int version ) { Collection < PoiCategory > superCategories = filter . getAcceptedSuperCategories ( ) ; if ( superCategories . isEmpty ( ) ) { return "" ; } StringBuilder sb = new StringBuilder ( ) ; sb . append ( " AND (" ) ; for ( Iterator < Po...
Gets the WHERE clause for the SQL query that looks up POI entries .
20,921
private static Cell getCentroidCell ( Polygon polygon ) { double area = 0.0 ; double x = 0.0 ; double y = 0.0 ; LineString exterior = polygon . getExteriorRing ( ) ; for ( int i = 0 , n = exterior . getNumPoints ( ) - 1 , j = n - 1 ; i < n ; j = i , i ++ ) { Coordinate a = exterior . getCoordinateN ( i ) ; Coordinate b...
Get polygon centroid
20,922
private static double getSegDistSq ( double px , double py , Coordinate a , Coordinate b ) { double x = a . x ; double y = a . y ; double dx = b . x - x ; double dy = b . y - y ; if ( dx != 0f || dy != 0f ) { double t = ( ( px - x ) * dx + ( py - y ) * dy ) / ( dx * dx + dy * dy ) ; if ( t > 1 ) { x = b . x ; y = b . y...
Get squared distance from a point to a segment
20,923
private static double latitudeToY ( double latitude ) { double sinLatitude = Math . sin ( latitude * ( Math . PI / 180 ) ) ; return 0.5 - Math . log ( ( 1 + sinLatitude ) / ( 1 - sinLatitude ) ) / ( 4 * Math . PI ) ; }
Re - projection functions
20,924
public List < TileCoordinate > translateToZoomLevel ( byte zoomlevelNew ) { List < TileCoordinate > tiles = null ; int zoomlevelDistance = zoomlevelNew - this . zoomlevel ; int factor = ( int ) Math . pow ( 2 , Math . abs ( zoomlevelDistance ) ) ; if ( zoomlevelDistance > 0 ) { tiles = new ArrayList < > ( ( int ) Math ...
Computes which tile on a lower zoom level covers this given tile or which tiles on a higher zoom level together cover this tile .
20,925
public static Geometry toJtsGeometry ( TDWay way , List < TDWay > innerWays ) { if ( way == null ) { LOGGER . warning ( "way is null" ) ; return null ; } if ( way . isForcePolygonLine ( ) ) { return buildMultiLineString ( way , innerWays ) ; } if ( way . getShape ( ) != TDWay . LINE || innerWays != null && innerWays . ...
Converts a way with potential inner ways to a JTS geometry .
20,926
public LineString extractPart ( double startDistance , double endDistance ) { LineString result = new LineString ( ) ; for ( int i = 0 ; i < this . segments . size ( ) ; startDistance -= this . segments . get ( i ) . length ( ) , endDistance -= this . segments . get ( i ) . length ( ) , i ++ ) { LineSegment segment = t...
Creates a new LineString that consists of only the part between startDistance and endDistance .
20,927
public static final boolean shouldLogSlowQuery ( long elapsedTimeMillis ) { int slowQueryMillis = Integer . parseInt ( System . getProperty ( "db.log.slow_query_threshold" , "10000" ) ) ; return slowQueryMillis >= 0 && elapsedTimeMillis >= slowQueryMillis ; }
Determines whether a query should be logged .
20,928
public static PagerStats getDatabaseInfo ( ) { PagerStats stats = new PagerStats ( ) ; nativeGetPagerStats ( stats ) ; stats . dbStats = SQLiteDatabase . getDbStats ( ) ; return stats ; }
return all pager and database stats for the current process .
20,929
public static void dump ( Printer printer , String [ ] args ) { boolean verbose = false ; for ( String arg : args ) { if ( arg . equals ( "-v" ) ) { verbose = true ; } } SQLiteDatabase . dumpAll ( printer , verbose ) ; }
Dumps detailed information about all databases used by the process .
20,930
public static double distance ( LatLong latLong1 , LatLong latLong2 ) { return Math . hypot ( latLong1 . longitude - latLong2 . longitude , latLong1 . latitude - latLong2 . latitude ) ; }
Calculate the Euclidean distance between two LatLongs in degrees using the Pythagorean theorem .
20,931
public static LatLong fromString ( String latLongString ) { double [ ] coordinates = parseCoordinateString ( latLongString , 2 ) ; return new LatLong ( coordinates [ 0 ] , coordinates [ 1 ] ) ; }
Creates a new LatLong from a comma - separated string of coordinates in the order latitude longitude . All coordinate values must be in degrees .
20,932
public static double longitudeDistance ( int meters , double latitude ) { return ( meters * 360 ) / ( 2 * Math . PI * EQUATORIAL_RADIUS * Math . cos ( Math . toRadians ( latitude ) ) ) ; }
Calculates the amount of degrees of longitude for a given distance in meters .
20,933
public static double [ ] parseCoordinateString ( String coordinatesString , int numberOfCoordinates ) { StringTokenizer stringTokenizer = new StringTokenizer ( coordinatesString , DELIMITER , true ) ; boolean isDelimiter = true ; List < String > tokens = new ArrayList < > ( numberOfCoordinates ) ; while ( stringTokeniz...
Parses a given number of comma - separated coordinate values from the supplied string .
20,934
private void setMarkerBitmap ( ) { for ( markerType = 0 ; markerType < cluster . getClusterManager ( ) . markerIconBmps . size ( ) ; markerType ++ ) { if ( cluster . getItems ( ) . size ( ) <= cluster . getClusterManager ( ) . markerIconBmps . get ( markerType ) . getItemMax ( ) ) { return ; } } markerType -- ; }
change icon bitmaps according to the state and content size .
20,935
private boolean executeSpecial ( String sql , Object [ ] bindArgs , int connectionFlags , CancellationSignal cancellationSignal ) { if ( cancellationSignal != null ) { cancellationSignal . throwIfCanceled ( ) ; } final int type = DatabaseUtils . getSqlStatementType ( sql ) ; switch ( type ) { case DatabaseUtils . STATE...
Performs special reinterpretation of certain SQL statements such as BEGIN COMMIT and ROLLBACK to ensure that transaction state invariants are maintained .
20,936
public void onCorruption ( SQLiteDatabase dbObj ) { Log . e ( TAG , "Corruption reported by sqlite on database: " + dbObj . getPath ( ) ) ; if ( SQLiteDatabase . hasCodec ( ) ) return ; if ( ! dbObj . isOpen ( ) ) { deleteDatabaseFile ( dbObj . getPath ( ) ) ; return ; } List < Pair < String , String > > attachedDbs = ...
defines the default method to be invoked when database corruption is detected .
20,937
public ParcelFileDescriptor executeForBlobFileDescriptor ( String sql , Object [ ] bindArgs , CancellationSignal cancellationSignal ) { if ( sql == null ) { throw new IllegalArgumentException ( "sql must not be null." ) ; } final int cookie = mRecentOperations . beginOperation ( "executeForBlobFileDescriptor" , sql , b...
Executes a statement that returns a single BLOB result as a file descriptor to a shared memory region .
20,938
public int executeForChangedRowCount ( String sql , Object [ ] bindArgs , CancellationSignal cancellationSignal ) { if ( sql == null ) { throw new IllegalArgumentException ( "sql must not be null." ) ; } int changedRows = 0 ; final int cookie = mRecentOperations . beginOperation ( "executeForChangedRowCount" , sql , bi...
Executes a statement that returns a count of the number of rows that were changed . Use for UPDATE or DELETE SQL statements .
20,939
public void addMapDataStore ( MapDataStore mapDataStore , boolean useStartZoomLevel , boolean useStartPosition ) { if ( this . mapDatabases . contains ( mapDataStore ) ) { throw new IllegalArgumentException ( "Duplicate map database" ) ; } this . mapDatabases . add ( mapDataStore ) ; if ( useStartZoomLevel ) { this . s...
adds another mapDataStore
20,940
public void bindAllArgsAsStrings ( String [ ] bindArgs ) { if ( bindArgs != null ) { for ( int i = bindArgs . length ; i != 0 ; i -- ) { bindString ( i , bindArgs [ i - 1 ] ) ; } } }
Given an array of String bindArgs this method binds all of them in one single call .
20,941
public void warnIfOpen ( ) { if ( allocationSite == null || ! ENABLED ) { return ; } String message = ( "A resource was acquired at attached stack trace but never released. " + "See java.io.Closeable for information on avoiding resource leaks." ) ; REPORTER . report ( message , allocationSite ) ; }
If CloseGuard is enabled logs a warning if the caller did not properly cleanup by calling an explicit close method before finalization . If CloseGuard is disabled no action is performed .
20,942
public int compareTo ( LatLong latLong ) { if ( this . latitude > latLong . latitude || this . longitude > latLong . longitude ) { return 1 ; } else if ( this . latitude < latLong . latitude || this . longitude < latLong . longitude ) { return - 1 ; } return 0 ; }
This method is necessary for inserting LatLongs into tree data structures .
20,943
public static LatLong fromMicroDegrees ( int latitudeE6 , int longitudeE6 ) { return new LatLong ( LatLongUtils . microdegreesToDegrees ( latitudeE6 ) , LatLongUtils . microdegreesToDegrees ( longitudeE6 ) ) ; }
Constructs a new LatLong with the given latitude and longitude values measured in microdegrees .
20,944
protected void createLayers ( ) { TileRendererLayer tileRendererLayer = AndroidUtil . createTileRendererLayer ( this . tileCaches . get ( 0 ) , this . mapView . getModel ( ) . mapViewPosition , getMapFile ( ) , getRenderTheme ( ) , false , true , false ) ; this . mapView . getLayerManager ( ) . getLayers ( ) . add ( ti...
Creates a simple tile renderer layer with the AndroidUtil helper .
20,945
protected void createTileCaches ( ) { this . tileCaches . add ( AndroidUtil . createTileCache ( this , getPersistableId ( ) , this . mapView . getModel ( ) . displayModel . getTileSize ( ) , this . getScreenRatio ( ) , this . mapView . getModel ( ) . frameBufferModel . getOverdrawFactor ( ) ) ) ; }
Creates the tile cache with the AndroidUtil helper
20,946
public static BoundingBox getBoundingBox ( Tile upperLeft , Tile lowerRight ) { BoundingBox ul = upperLeft . getBoundingBox ( ) ; BoundingBox lr = lowerRight . getBoundingBox ( ) ; return ul . extendBoundingBox ( lr ) ; }
Return the BoundingBox of a rectangle of tiles defined by upper left and lower right tile .
20,947
public static Rectangle getBoundaryAbsolute ( Tile upperLeft , Tile lowerRight ) { return new Rectangle ( upperLeft . getOrigin ( ) . x , upperLeft . getOrigin ( ) . y , lowerRight . getOrigin ( ) . x + upperLeft . tileSize , lowerRight . getOrigin ( ) . y + upperLeft . tileSize ) ; }
Extend of the area defined by the two tiles in absolute coordinates .
20,948
public BoundingBox getBoundingBox ( ) { if ( this . boundingBox == null ) { double minLatitude = Math . max ( MercatorProjection . LATITUDE_MIN , MercatorProjection . tileYToLatitude ( tileY + 1 , zoomLevel ) ) ; double minLongitude = Math . max ( - 180 , MercatorProjection . tileXToLongitude ( this . tileX , zoomLevel...
Gets the geographic extend of this Tile as a BoundingBox .
20,949
public Set < Tile > getNeighbours ( ) { Set < Tile > neighbours = new HashSet < Tile > ( 8 ) ; neighbours . add ( getLeft ( ) ) ; neighbours . add ( getAboveLeft ( ) ) ; neighbours . add ( getAbove ( ) ) ; neighbours . add ( getAboveRight ( ) ) ; neighbours . add ( getRight ( ) ) ; neighbours . add ( getBelowRight ( ) ...
Returns a set of the eight neighbours of this tile .
20,950
public Rectangle getBoundaryAbsolute ( ) { return new Rectangle ( getOrigin ( ) . x , getOrigin ( ) . y , getOrigin ( ) . x + tileSize , getOrigin ( ) . y + tileSize ) ; }
Extend of this tile in absolute coordinates .
20,951
public Point getOrigin ( ) { if ( this . origin == null ) { double x = MercatorProjection . tileToPixel ( this . tileX , this . tileSize ) ; double y = MercatorProjection . tileToPixel ( this . tileY , this . tileSize ) ; this . origin = new Point ( x , y ) ; } return this . origin ; }
Returns the top - left point of this tile in absolute coordinates .
20,952
public Tile getLeft ( ) { int x = tileX - 1 ; if ( x < 0 ) { x = getMaxTileNumber ( this . zoomLevel ) ; } return new Tile ( x , this . tileY , this . zoomLevel , this . tileSize ) ; }
Returns the tile to the left of this tile .
20,953
public Tile getRight ( ) { int x = tileX + 1 ; if ( x > getMaxTileNumber ( this . zoomLevel ) ) { x = 0 ; } return new Tile ( x , this . tileY , this . zoomLevel , this . tileSize ) ; }
Returns the tile to the right of this tile .
20,954
public Tile getAbove ( ) { int y = tileY - 1 ; if ( y < 0 ) { y = getMaxTileNumber ( this . zoomLevel ) ; } return new Tile ( this . tileX , y , this . zoomLevel , this . tileSize ) ; }
Returns the tile above this tile .
20,955
public Tile getBelow ( ) { int y = tileY + 1 ; if ( y > getMaxTileNumber ( this . zoomLevel ) ) { y = 0 ; } return new Tile ( this . tileX , y , this . zoomLevel , this . tileSize ) ; }
Returns the tile below this tile .
20,956
public Tile getAboveLeft ( ) { int y = tileY - 1 ; int x = tileX - 1 ; if ( y < 0 ) { y = getMaxTileNumber ( this . zoomLevel ) ; } if ( x < 0 ) { x = getMaxTileNumber ( this . zoomLevel ) ; } return new Tile ( x , y , this . zoomLevel , this . tileSize ) ; }
Returns the tile above left
20,957
public void init ( int index , Bitmap bitmap , int horizontalOffset , int verticalOffset ) { this . index = index ; this . groupBitmapHalfHeight = bitmap . getHeight ( ) / 2 ; this . groupBitmapHalfWidth = bitmap . getWidth ( ) / 2 ; this . groupHOffset = horizontalOffset ; this . groupVOffset = verticalOffset ; }
Set group marker parameter . To know index and calculate position on spiral .
20,958
protected void addImplicitRelationInformation ( TDWay tdWay ) { if ( ! this . tagValues ) { return ; } if ( ! this . partRootRelations . containsKey ( tdWay . getId ( ) ) ) { return ; } Long rootId = this . partRootRelations . get ( tdWay . getId ( ) ) ; if ( rootId == null ) { OSMTagMapping mapping = OSMTagMapping . g...
Add tags to ways which describe the geo - inheritance .
20,959
protected void countPoiTags ( TDNode poi ) { if ( poi == null || poi . getTags ( ) == null ) { return ; } for ( short tag : poi . getTags ( ) . keySet ( ) ) { this . histogramPoiTags . adjustOrPutValue ( tag , 1 , 1 ) ; } }
Count tags to optimize order of POI tag data .
20,960
protected void handleImplicitWayRelations ( ) { if ( ! this . tagValues ) { return ; } for ( Map . Entry < TileCoordinate , TLongHashSet > tilePartElementEntry : this . tilesToPartElements . entrySet ( ) ) { TLongHashSet tileRootElementSet = this . tilesToRootElements . get ( tilePartElementEntry . getKey ( ) ) ; if ( ...
Calculate ids of ways whose polygon inherits part elements .
20,961
static void renderText ( GraphicFactory graphicFactory , Tile upperLeft , Tile lowerRight , String text , Display display , int priority , float dy , Paint fill , Paint stroke , boolean repeat , float repeatGap , float repeatStart , boolean rotate , Point [ ] [ ] coordinates , List < MapElementContainer > currentLabels...
Finds the segments of a line along which a name can be drawn and then adds WayTextContainers to the list of drawable items .
20,962
public static final void writeExceptionToParcel ( Parcel reply , Exception e ) { int code = 0 ; boolean logException = true ; if ( e instanceof FileNotFoundException ) { code = 1 ; logException = false ; } else if ( e instanceof IllegalArgumentException ) { code = 2 ; } else if ( e instanceof UnsupportedOperationExcept...
Special function for writing an exception result at the header of a parcel to be used when returning an exception from a transaction . exception will be re - thrown by the function in another process
20,963
public static void cursorFillWindow ( final Cursor cursor , int position , final CursorWindow window ) { if ( position < 0 || position >= cursor . getCount ( ) ) { return ; } final int oldPos = cursor . getPosition ( ) ; final int numColumns = cursor . getColumnCount ( ) ; window . clear ( ) ; window . setStartPosition...
Fills the specified cursor window by iterating over the contents of the cursor . The window is filled until the cursor is exhausted or the window runs out of space .
20,964
public static void appendEscapedSQLString ( StringBuilder sb , String sqlString ) { sb . append ( '\'' ) ; if ( sqlString . indexOf ( '\'' ) != - 1 ) { int length = sqlString . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { char c = sqlString . charAt ( i ) ; if ( c == '\'' ) { sb . append ( '\'' ) ; } sb . appen...
Appends an SQL string to the given StringBuilder including the opening and closing single quotes . Any single quotes internal to sqlString will be escaped .
20,965
public static String sqlEscapeString ( String value ) { StringBuilder escaper = new StringBuilder ( ) ; DatabaseUtils . appendEscapedSQLString ( escaper , value ) ; return escaper . toString ( ) ; }
SQL - escape a string .
20,966
public static final void appendValueToSql ( StringBuilder sql , Object value ) { if ( value == null ) { sql . append ( "NULL" ) ; } else if ( value instanceof Boolean ) { Boolean bool = ( Boolean ) value ; if ( bool ) { sql . append ( '1' ) ; } else { sql . append ( '0' ) ; } } else { appendEscapedSQLString ( sql , val...
Appends an Object to an SQL string with the proper escaping etc .
20,967
public static String concatenateWhere ( String a , String b ) { if ( TextUtils . isEmpty ( a ) ) { return b ; } if ( TextUtils . isEmpty ( b ) ) { return a ; } return "(" + a + ") AND (" + b + ")" ; }
Concatenates two SQL WHERE clauses handling empty or null values .
20,968
public static String getCollationKey ( String name ) { byte [ ] arr = getCollationKeyInBytes ( name ) ; try { return new String ( arr , 0 , getKeyLen ( arr ) , "ISO8859_1" ) ; } catch ( Exception ex ) { return "" ; } }
return the collation key
20,969
public static String getHexCollationKey ( String name ) { byte [ ] arr = getCollationKeyInBytes ( name ) ; char [ ] keys = encodeHex ( arr ) ; return new String ( keys , 0 , getKeyLen ( arr ) * 2 ) ; }
return the collation key in hex format
20,970
public static void dumpCursor ( Cursor cursor , PrintStream stream ) { stream . println ( ">>>>> Dumping cursor " + cursor ) ; if ( cursor != null ) { int startPos = cursor . getPosition ( ) ; cursor . moveToPosition ( - 1 ) ; while ( cursor . moveToNext ( ) ) { dumpCurrentRow ( cursor , stream ) ; } cursor . moveToPos...
Prints the contents of a Cursor to a PrintSteam . The position is restored after printing .
20,971
public static void dumpCursor ( Cursor cursor , StringBuilder sb ) { sb . append ( ">>>>> Dumping cursor " + cursor + "\n" ) ; if ( cursor != null ) { int startPos = cursor . getPosition ( ) ; cursor . moveToPosition ( - 1 ) ; while ( cursor . moveToNext ( ) ) { dumpCurrentRow ( cursor , sb ) ; } cursor . moveToPositio...
Prints the contents of a Cursor to a StringBuilder . The position is restored after printing .
20,972
public static String dumpCursorToString ( Cursor cursor ) { StringBuilder sb = new StringBuilder ( ) ; dumpCursor ( cursor , sb ) ; return sb . toString ( ) ; }
Prints the contents of a Cursor to a String . The position is restored after printing .
20,973
public static void dumpCurrentRow ( Cursor cursor , PrintStream stream ) { String [ ] cols = cursor . getColumnNames ( ) ; stream . println ( "" + cursor . getPosition ( ) + " {" ) ; int length = cols . length ; for ( int i = 0 ; i < length ; i ++ ) { String value ; try { value = cursor . getString ( i ) ; } catch ( SQ...
Prints the contents of a Cursor s current row to a PrintSteam .
20,974
public static void dumpCurrentRow ( Cursor cursor , StringBuilder sb ) { String [ ] cols = cursor . getColumnNames ( ) ; sb . append ( "" + cursor . getPosition ( ) + " {\n" ) ; int length = cols . length ; for ( int i = 0 ; i < length ; i ++ ) { String value ; try { value = cursor . getString ( i ) ; } catch ( SQLiteE...
Prints the contents of a Cursor s current row to a StringBuilder .
20,975
public static String dumpCurrentRowToString ( Cursor cursor ) { StringBuilder sb = new StringBuilder ( ) ; dumpCurrentRow ( cursor , sb ) ; return sb . toString ( ) ; }
Dump the contents of a Cursor s current row to a String .
20,976
public static void cursorStringToInsertHelper ( Cursor cursor , String field , InsertHelper inserter , int index ) { inserter . bind ( index , cursor . getString ( cursor . getColumnIndexOrThrow ( field ) ) ) ; }
Reads a String out of a field in a Cursor and writes it to an InsertHelper .
20,977
public static void cursorIntToContentValues ( Cursor cursor , String field , ContentValues values ) { cursorIntToContentValues ( cursor , field , values , field ) ; }
Reads an Integer out of a field in a Cursor and writes it to a Map .
20,978
public static void cursorIntToContentValues ( Cursor cursor , String field , ContentValues values , String key ) { int colIndex = cursor . getColumnIndex ( field ) ; if ( ! cursor . isNull ( colIndex ) ) { values . put ( key , cursor . getInt ( colIndex ) ) ; } else { values . put ( key , ( Integer ) null ) ; } }
Reads a Integer out of a field in a Cursor and writes it to a Map .
20,979
public static void cursorRowToContentValues ( Cursor cursor , ContentValues values ) { String [ ] columns = cursor . getColumnNames ( ) ; int length = columns . length ; for ( int i = 0 ; i < length ; i ++ ) { if ( cursor . getType ( i ) == Cursor . FIELD_TYPE_BLOB ) { values . put ( columns [ i ] , cursor . getBlob ( ...
Read the entire contents of a cursor row and store them in a ContentValues .
20,980
public static boolean queryIsEmpty ( SQLiteDatabase db , String table ) { long isEmpty = longForQuery ( db , "select exists(select 1 from " + table + ")" , null ) ; return isEmpty == 0 ; }
Query the table to check whether a table is empty or not
20,981
public static ParcelFileDescriptor blobFileDescriptorForQuery ( SQLiteDatabase db , String query , String [ ] selectionArgs ) { SQLiteStatement prog = db . compileStatement ( query ) ; try { return blobFileDescriptorForQuery ( prog , selectionArgs ) ; } finally { prog . close ( ) ; } }
Utility method to run the query on the db and return the blob value in the first column of the first row .
20,982
public static ParcelFileDescriptor blobFileDescriptorForQuery ( SQLiteStatement prog , String [ ] selectionArgs ) { prog . bindAllArgsAsStrings ( selectionArgs ) ; return prog . simpleQueryForBlobFileDescriptor ( ) ; }
Utility method to run the pre - compiled query and return the blob value in the first column of the first row .
20,983
public static void cursorStringToContentValuesIfPresent ( Cursor cursor , ContentValues values , String column ) { final int index = cursor . getColumnIndex ( column ) ; if ( index != - 1 && ! cursor . isNull ( index ) ) { values . put ( column , cursor . getString ( index ) ) ; } }
Reads a String out of a column in a Cursor and writes it to a ContentValues . Adds nothing to the ContentValues if the column isn t present or if its value is null .
20,984
public static void cursorLongToContentValuesIfPresent ( Cursor cursor , ContentValues values , String column ) { final int index = cursor . getColumnIndex ( column ) ; if ( index != - 1 && ! cursor . isNull ( index ) ) { values . put ( column , cursor . getLong ( index ) ) ; } }
Reads a Long out of a column in a Cursor and writes it to a ContentValues . Adds nothing to the ContentValues if the column isn t present or if its value is null .
20,985
public static void cursorShortToContentValuesIfPresent ( Cursor cursor , ContentValues values , String column ) { final int index = cursor . getColumnIndex ( column ) ; if ( index != - 1 && ! cursor . isNull ( index ) ) { values . put ( column , cursor . getShort ( index ) ) ; } }
Reads a Short out of a column in a Cursor and writes it to a ContentValues . Adds nothing to the ContentValues if the column isn t present or if its value is null .
20,986
public static void cursorIntToContentValuesIfPresent ( Cursor cursor , ContentValues values , String column ) { final int index = cursor . getColumnIndex ( column ) ; if ( index != - 1 && ! cursor . isNull ( index ) ) { values . put ( column , cursor . getInt ( index ) ) ; } }
Reads a Integer out of a column in a Cursor and writes it to a ContentValues . Adds nothing to the ContentValues if the column isn t present or if its value is null .
20,987
public static void cursorFloatToContentValuesIfPresent ( Cursor cursor , ContentValues values , String column ) { final int index = cursor . getColumnIndex ( column ) ; if ( index != - 1 && ! cursor . isNull ( index ) ) { values . put ( column , cursor . getFloat ( index ) ) ; } }
Reads a Float out of a column in a Cursor and writes it to a ContentValues . Adds nothing to the ContentValues if the column isn t present or if its value is null .
20,988
public static void cursorDoubleToContentValuesIfPresent ( Cursor cursor , ContentValues values , String column ) { final int index = cursor . getColumnIndex ( column ) ; if ( index != - 1 && ! cursor . isNull ( index ) ) { values . put ( column , cursor . getDouble ( index ) ) ; } }
Reads a Double out of a column in a Cursor and writes it to a ContentValues . Adds nothing to the ContentValues if the column isn t present or if its value is null .
20,989
static public void createDbFromSqlStatements ( Context context , String dbName , int dbVersion , String sqlStatements ) { File f = context . getDatabasePath ( dbName ) ; f . getParentFile ( ) . mkdirs ( ) ; SQLiteDatabase db = SQLiteDatabase . openOrCreateDatabase ( f , null ) ; String [ ] statements = TextUtils . spli...
Creates a db and populates it with the sql statements in sqlStatements .
20,990
public static String [ ] appendSelectionArgs ( String [ ] originalValues , String [ ] newValues ) { if ( originalValues == null || originalValues . length == 0 ) { return newValues ; } String [ ] result = new String [ originalValues . length + newValues . length ] ; System . arraycopy ( originalValues , 0 , result , 0 ...
Appends one set of selection args to another . This is useful when adding a selection argument to a user provided set .
20,991
public static int findRowIdColumnIndex ( String [ ] columnNames ) { int length = columnNames . length ; for ( int i = 0 ; i < length ; i ++ ) { if ( columnNames [ i ] . equals ( "_id" ) ) { return i ; } } return - 1 ; }
Returns column index of _id column or - 1 if not found .
20,992
public static Point getPixelRelativeToTile ( LatLong latLong , Tile tile ) { return getPixelRelative ( latLong , tile . mapSize , tile . getOrigin ( ) ) ; }
Calculates the absolute pixel position for a tile and tile size relative to origin
20,993
public static double metersToPixelsWithScaleFactor ( float meters , double latitude , double scaleFactor , int tileSize ) { return meters / MercatorProjection . calculateGroundResolutionWithScaleFactor ( latitude , scaleFactor , tileSize ) ; }
Converts meters to pixels at latitude for zoom - level .
20,994
public static double pixelXToLongitudeWithScaleFactor ( double pixelX , double scaleFactor , int tileSize ) { long mapSize = getMapSizeWithScaleFactor ( scaleFactor , tileSize ) ; if ( pixelX < 0 || pixelX > mapSize ) { throw new IllegalArgumentException ( "invalid pixelX coordinate at scale " + scaleFactor + ": " + pi...
Converts a pixel X coordinate at a certain scale to a longitude coordinate .
20,995
public static double pixelXToLongitude ( double pixelX , long mapSize ) { if ( pixelX < 0 || pixelX > mapSize ) { throw new IllegalArgumentException ( "invalid pixelX coordinate " + mapSize + ": " + pixelX ) ; } return 360 * ( ( pixelX / mapSize ) - 0.5 ) ; }
Converts a pixel X coordinate at a certain map size to a longitude coordinate .
20,996
public static double pixelYToLatitudeWithScaleFactor ( double pixelY , double scaleFactor , int tileSize ) { long mapSize = getMapSizeWithScaleFactor ( scaleFactor , tileSize ) ; if ( pixelY < 0 || pixelY > mapSize ) { throw new IllegalArgumentException ( "invalid pixelY coordinate at scale " + scaleFactor + ": " + pix...
Converts a pixel Y coordinate at a certain scale to a latitude coordinate .
20,997
public static double pixelYToLatitude ( double pixelY , long mapSize ) { if ( pixelY < 0 || pixelY > mapSize ) { throw new IllegalArgumentException ( "invalid pixelY coordinate " + mapSize + ": " + pixelY ) ; } double y = 0.5 - ( pixelY / mapSize ) ; return 90 - 360 * Math . atan ( Math . exp ( - y * ( 2 * Math . PI ) ...
Converts a pixel Y coordinate at a certain map size to a latitude coordinate .
20,998
public HillsRenderConfig indexOnThread ( ) { ShadeTileSource cache = tileSource ; if ( cache != null ) cache . applyConfiguration ( true ) ; return this ; }
call after initialization after a set of changes to the settable properties or after forceReindex to initiate background indexing
20,999
public static List < WayDataBlock > encode ( List < WayDataBlock > blocks , Encoding encoding ) { if ( blocks == null ) { return null ; } if ( encoding == Encoding . NONE ) { return blocks ; } List < WayDataBlock > results = new ArrayList < > ( ) ; for ( WayDataBlock wayDataBlock : blocks ) { List < Integer > outer = m...
Encodes a list of WayDataBlock objects with the given encoding scheme .