id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28,400 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java | MercatorProjection.pixelXToLongitude | 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);
} | java | 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);
} | [
"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.
@param pixelX the pixel X coordinate that should be converted.
@param mapSize precomputed size of map.
@return the longitude value of the pixel X coordinate.
@throws IllegalArgumentException if the given pixelX coordinate is invalid. | [
"Converts",
"a",
"pixel",
"X",
"coordinate",
"at",
"a",
"certain",
"map",
"size",
"to",
"a",
"longitude",
"coordinate",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java#L353-L358 |
28,401 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java | MercatorProjection.pixelYToLatitudeWithScaleFactor | 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 + ": " + pixelY);
}
double y = 0.5 - (pixelY / mapSize);
return 90 - 360 * Math.atan(Math.exp(-y * (2 * Math.PI))) / Math.PI;
} | java | 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 + ": " + pixelY);
}
double y = 0.5 - (pixelY / mapSize);
return 90 - 360 * Math.atan(Math.exp(-y * (2 * Math.PI))) / Math.PI;
} | [
"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",
"+",
"\": \"",
"+",
"pixelY",
")",
";",
"}",
"double",
"y",
"=",
"0.5",
"-",
"(",
"pixelY",
"/",
"mapSize",
")",
";",
"return",
"90",
"-",
"360",
"*",
"Math",
".",
"atan",
"(",
"Math",
".",
"exp",
"(",
"-",
"y",
"*",
"(",
"2",
"*",
"Math",
".",
"PI",
")",
")",
")",
"/",
"Math",
".",
"PI",
";",
"}"
] | Converts a pixel Y coordinate at a certain scale to a latitude coordinate.
@param pixelY the pixel Y coordinate that should be converted.
@param scaleFactor the scale factor at which the coordinate should be converted.
@return the latitude value of the pixel Y coordinate.
@throws IllegalArgumentException if the given pixelY coordinate is invalid. | [
"Converts",
"a",
"pixel",
"Y",
"coordinate",
"at",
"a",
"certain",
"scale",
"to",
"a",
"latitude",
"coordinate",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java#L390-L397 |
28,402 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java | MercatorProjection.pixelYToLatitude | 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))) / Math.PI;
} | java | 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))) / Math.PI;
} | [
"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",
")",
")",
")",
"/",
"Math",
".",
"PI",
";",
"}"
] | Converts a pixel Y coordinate at a certain map size to a latitude coordinate.
@param pixelY the pixel Y coordinate that should be converted.
@param mapSize precomputed size of map.
@return the latitude value of the pixel Y coordinate.
@throws IllegalArgumentException if the given pixelY coordinate is invalid. | [
"Converts",
"a",
"pixel",
"Y",
"coordinate",
"at",
"a",
"certain",
"map",
"size",
"to",
"a",
"latitude",
"coordinate",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/MercatorProjection.java#L407-L413 |
28,403 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/hills/HillsRenderConfig.java | HillsRenderConfig.indexOnThread | public HillsRenderConfig indexOnThread() {
ShadeTileSource cache = tileSource;
if (cache != null) cache.applyConfiguration(true);
return this;
} | java | public HillsRenderConfig indexOnThread() {
ShadeTileSource cache = tileSource;
if (cache != null) cache.applyConfiguration(true);
return this;
} | [
"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 | [
"call",
"after",
"initialization",
"after",
"a",
"set",
"of",
"changes",
"to",
"the",
"settable",
"properties",
"or",
"after",
"forceReindex",
"to",
"initiate",
"background",
"indexing"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/hills/HillsRenderConfig.java#L49-L53 |
28,404 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/DeltaEncoder.java | DeltaEncoder.encode | 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 = mEncode(wayDataBlock.getOuterWay(), encoding);
List<List<Integer>> inner = null;
if (wayDataBlock.getInnerWays() != null) {
inner = new ArrayList<>();
for (List<Integer> list : wayDataBlock.getInnerWays()) {
inner.add(mEncode(list, encoding));
}
}
results.add(new WayDataBlock(outer, inner, encoding));
}
return results;
} | java | 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 = mEncode(wayDataBlock.getOuterWay(), encoding);
List<List<Integer>> inner = null;
if (wayDataBlock.getInnerWays() != null) {
inner = new ArrayList<>();
for (List<Integer> list : wayDataBlock.getInnerWays()) {
inner.add(mEncode(list, encoding));
}
}
results.add(new WayDataBlock(outer, inner, encoding));
}
return results;
} | [
"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",
"=",
"mEncode",
"(",
"wayDataBlock",
".",
"getOuterWay",
"(",
")",
",",
"encoding",
")",
";",
"List",
"<",
"List",
"<",
"Integer",
">",
">",
"inner",
"=",
"null",
";",
"if",
"(",
"wayDataBlock",
".",
"getInnerWays",
"(",
")",
"!=",
"null",
")",
"{",
"inner",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"for",
"(",
"List",
"<",
"Integer",
">",
"list",
":",
"wayDataBlock",
".",
"getInnerWays",
"(",
")",
")",
"{",
"inner",
".",
"add",
"(",
"mEncode",
"(",
"list",
",",
"encoding",
")",
")",
";",
"}",
"}",
"results",
".",
"add",
"(",
"new",
"WayDataBlock",
"(",
"outer",
",",
"inner",
",",
"encoding",
")",
")",
";",
"}",
"return",
"results",
";",
"}"
] | Encodes a list of WayDataBlock objects with the given encoding scheme.
@param blocks List of WayDataBlock objects to be encoded.
@param encoding The Encoding which is used.
@return A new list of new WayDataBlock objects encoded with the given encoding. The original list is returned in
case the encoding equals NONE. | [
"Encodes",
"a",
"list",
"of",
"WayDataBlock",
"objects",
"with",
"the",
"given",
"encoding",
"scheme",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/DeltaEncoder.java#L36-L60 |
28,405 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/DeltaEncoder.java | DeltaEncoder.simulateSerialization | public static int simulateSerialization(List<WayDataBlock> blocks) {
int sum = 0;
for (WayDataBlock wayDataBlock : blocks) {
sum += mSimulateSerialization(wayDataBlock.getOuterWay());
if (wayDataBlock.getInnerWays() != null) {
for (List<Integer> list : wayDataBlock.getInnerWays()) {
sum += mSimulateSerialization(list);
}
}
}
return sum;
} | java | public static int simulateSerialization(List<WayDataBlock> blocks) {
int sum = 0;
for (WayDataBlock wayDataBlock : blocks) {
sum += mSimulateSerialization(wayDataBlock.getOuterWay());
if (wayDataBlock.getInnerWays() != null) {
for (List<Integer> list : wayDataBlock.getInnerWays()) {
sum += mSimulateSerialization(list);
}
}
}
return sum;
} | [
"public",
"static",
"int",
"simulateSerialization",
"(",
"List",
"<",
"WayDataBlock",
">",
"blocks",
")",
"{",
"int",
"sum",
"=",
"0",
";",
"for",
"(",
"WayDataBlock",
"wayDataBlock",
":",
"blocks",
")",
"{",
"sum",
"+=",
"mSimulateSerialization",
"(",
"wayDataBlock",
".",
"getOuterWay",
"(",
")",
")",
";",
"if",
"(",
"wayDataBlock",
".",
"getInnerWays",
"(",
")",
"!=",
"null",
")",
"{",
"for",
"(",
"List",
"<",
"Integer",
">",
"list",
":",
"wayDataBlock",
".",
"getInnerWays",
"(",
")",
")",
"{",
"sum",
"+=",
"mSimulateSerialization",
"(",
"list",
")",
";",
"}",
"}",
"}",
"return",
"sum",
";",
"}"
] | Computes the size in bytes for storing a list of WayDataBlock objects as unsigned var-bytes.
@param blocks the blocks which should be encoded
@return the number of bytes needed for the encoding | [
"Computes",
"the",
"size",
"in",
"bytes",
"for",
"storing",
"a",
"list",
"of",
"WayDataBlock",
"objects",
"as",
"unsigned",
"var",
"-",
"bytes",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/DeltaEncoder.java#L68-L79 |
28,406 | mapsforge/mapsforge | mapsforge-map-android/src/main/java/org/mapsforge/map/android/graphics/AndroidResourceBitmap.java | AndroidResourceBitmap.clearResourceBitmaps | public static void clearResourceBitmaps() {
if (!AndroidGraphicFactory.KEEP_RESOURCE_BITMAPS) {
return;
}
synchronized (RESOURCE_BITMAPS) {
for (Pair<android.graphics.Bitmap, Integer> p : RESOURCE_BITMAPS.values()) {
p.first.recycle();
if (AndroidGraphicFactory.DEBUG_BITMAPS) {
rInstances.decrementAndGet();
}
}
if (AndroidGraphicFactory.DEBUG_BITMAPS) {
rBitmaps.clear();
}
RESOURCE_BITMAPS.clear();
}
} | java | public static void clearResourceBitmaps() {
if (!AndroidGraphicFactory.KEEP_RESOURCE_BITMAPS) {
return;
}
synchronized (RESOURCE_BITMAPS) {
for (Pair<android.graphics.Bitmap, Integer> p : RESOURCE_BITMAPS.values()) {
p.first.recycle();
if (AndroidGraphicFactory.DEBUG_BITMAPS) {
rInstances.decrementAndGet();
}
}
if (AndroidGraphicFactory.DEBUG_BITMAPS) {
rBitmaps.clear();
}
RESOURCE_BITMAPS.clear();
}
} | [
"public",
"static",
"void",
"clearResourceBitmaps",
"(",
")",
"{",
"if",
"(",
"!",
"AndroidGraphicFactory",
".",
"KEEP_RESOURCE_BITMAPS",
")",
"{",
"return",
";",
"}",
"synchronized",
"(",
"RESOURCE_BITMAPS",
")",
"{",
"for",
"(",
"Pair",
"<",
"android",
".",
"graphics",
".",
"Bitmap",
",",
"Integer",
">",
"p",
":",
"RESOURCE_BITMAPS",
".",
"values",
"(",
")",
")",
"{",
"p",
".",
"first",
".",
"recycle",
"(",
")",
";",
"if",
"(",
"AndroidGraphicFactory",
".",
"DEBUG_BITMAPS",
")",
"{",
"rInstances",
".",
"decrementAndGet",
"(",
")",
";",
"}",
"}",
"if",
"(",
"AndroidGraphicFactory",
".",
"DEBUG_BITMAPS",
")",
"{",
"rBitmaps",
".",
"clear",
"(",
")",
";",
"}",
"RESOURCE_BITMAPS",
".",
"clear",
"(",
")",
";",
"}",
"}"
] | clearResourceBitmaps is called | [
"clearResourceBitmaps",
"is",
"called"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-android/src/main/java/org/mapsforge/map/android/graphics/AndroidResourceBitmap.java#L55-L71 |
28,407 | mapsforge/mapsforge | mapsforge-map-android/src/main/java/org/mapsforge/map/android/graphics/AndroidResourceBitmap.java | AndroidResourceBitmap.destroyBitmap | @Override
protected void destroyBitmap() {
if (this.bitmap != null) {
if (removeBitmap(this.hash)) {
this.bitmap.recycle();
}
this.bitmap = null;
}
} | java | @Override
protected void destroyBitmap() {
if (this.bitmap != null) {
if (removeBitmap(this.hash)) {
this.bitmap.recycle();
}
this.bitmap = null;
}
} | [
"@",
"Override",
"protected",
"void",
"destroyBitmap",
"(",
")",
"{",
"if",
"(",
"this",
".",
"bitmap",
"!=",
"null",
")",
"{",
"if",
"(",
"removeBitmap",
"(",
"this",
".",
"hash",
")",
")",
"{",
"this",
".",
"bitmap",
".",
"recycle",
"(",
")",
";",
"}",
"this",
".",
"bitmap",
"=",
"null",
";",
"}",
"}"
] | and call down into destroyBitmap when the resource bitmap needs to be destroyed | [
"and",
"call",
"down",
"into",
"destroyBitmap",
"when",
"the",
"resource",
"bitmap",
"needs",
"to",
"be",
"destroyed"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-android/src/main/java/org/mapsforge/map/android/graphics/AndroidResourceBitmap.java#L155-L163 |
28,408 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/OSMTag.java | OSMTag.fromOSMTag | public static OSMTag fromOSMTag(OSMTag otherTag, short newID) {
return new OSMTag(newID, otherTag.getKey(), otherTag.getValue(), otherTag.getZoomAppear(),
otherTag.isRenderable(), otherTag.isForcePolygonLine(), otherTag.isLabelPosition());
} | java | public static OSMTag fromOSMTag(OSMTag otherTag, short newID) {
return new OSMTag(newID, otherTag.getKey(), otherTag.getValue(), otherTag.getZoomAppear(),
otherTag.isRenderable(), otherTag.isForcePolygonLine(), otherTag.isLabelPosition());
} | [
"public",
"static",
"OSMTag",
"fromOSMTag",
"(",
"OSMTag",
"otherTag",
",",
"short",
"newID",
")",
"{",
"return",
"new",
"OSMTag",
"(",
"newID",
",",
"otherTag",
".",
"getKey",
"(",
")",
",",
"otherTag",
".",
"getValue",
"(",
")",
",",
"otherTag",
".",
"getZoomAppear",
"(",
")",
",",
"otherTag",
".",
"isRenderable",
"(",
")",
",",
"otherTag",
".",
"isForcePolygonLine",
"(",
")",
",",
"otherTag",
".",
"isLabelPosition",
"(",
")",
")",
";",
"}"
] | Convenience method that constructs a new OSMTag with a new id from another OSMTag.
@param otherTag the OSMTag to copy
@param newID the new id
@return a newly constructed OSMTag with the attributes of otherTag | [
"Convenience",
"method",
"that",
"constructs",
"a",
"new",
"OSMTag",
"with",
"a",
"new",
"id",
"from",
"another",
"OSMTag",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/OSMTag.java#L33-L36 |
28,409 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/DirectRenderer.java | DirectRenderer.executeJob | public TileBitmap executeJob(RendererJob rendererJob) {
RenderContext renderContext = null;
try {
renderContext = new RenderContext(rendererJob, new CanvasRasterer(graphicFactory));
if (renderBitmap(renderContext)) {
TileBitmap bitmap = null;
if (this.mapDataStore != null) {
MapReadResult mapReadResult = this.mapDataStore.readMapData(rendererJob.tile);
processReadMapData(renderContext, mapReadResult);
}
if (!rendererJob.labelsOnly) {
renderContext.renderTheme.matchHillShadings(this, renderContext);
bitmap = this.graphicFactory.createTileBitmap(rendererJob.tile.tileSize, rendererJob.hasAlpha);
bitmap.setTimestamp(rendererJob.mapDataStore.getDataTimestamp(rendererJob.tile));
renderContext.canvasRasterer.setCanvasBitmap(bitmap);
if (!rendererJob.hasAlpha && rendererJob.displayModel.getBackgroundColor() != renderContext.renderTheme.getMapBackground()) {
renderContext.canvasRasterer.fill(renderContext.renderTheme.getMapBackground());
}
renderContext.canvasRasterer.drawWays(renderContext);
}
if (this.renderLabels) {
Set<MapElementContainer> labelsToDraw = processLabels(renderContext);
// now draw the ways and the labels
renderContext.canvasRasterer.drawMapElements(labelsToDraw, rendererJob.tile);
}
if (!rendererJob.labelsOnly && renderContext.renderTheme.hasMapBackgroundOutside()) {
// blank out all areas outside of map
Rectangle insideArea = this.mapDataStore.boundingBox().getPositionRelativeToTile(rendererJob.tile);
if (!rendererJob.hasAlpha) {
renderContext.canvasRasterer.fillOutsideAreas(renderContext.renderTheme.getMapBackgroundOutside(), insideArea);
} else {
renderContext.canvasRasterer.fillOutsideAreas(Color.TRANSPARENT, insideArea);
}
}
return bitmap;
}
// outside of map area
return null;
} catch (Exception e) {
// #1049: message can be null?
LOGGER.warning("Exception: " + e.getMessage());
return null;
} finally {
if (renderContext != null) {
renderContext.destroy();
}
}
} | java | public TileBitmap executeJob(RendererJob rendererJob) {
RenderContext renderContext = null;
try {
renderContext = new RenderContext(rendererJob, new CanvasRasterer(graphicFactory));
if (renderBitmap(renderContext)) {
TileBitmap bitmap = null;
if (this.mapDataStore != null) {
MapReadResult mapReadResult = this.mapDataStore.readMapData(rendererJob.tile);
processReadMapData(renderContext, mapReadResult);
}
if (!rendererJob.labelsOnly) {
renderContext.renderTheme.matchHillShadings(this, renderContext);
bitmap = this.graphicFactory.createTileBitmap(rendererJob.tile.tileSize, rendererJob.hasAlpha);
bitmap.setTimestamp(rendererJob.mapDataStore.getDataTimestamp(rendererJob.tile));
renderContext.canvasRasterer.setCanvasBitmap(bitmap);
if (!rendererJob.hasAlpha && rendererJob.displayModel.getBackgroundColor() != renderContext.renderTheme.getMapBackground()) {
renderContext.canvasRasterer.fill(renderContext.renderTheme.getMapBackground());
}
renderContext.canvasRasterer.drawWays(renderContext);
}
if (this.renderLabels) {
Set<MapElementContainer> labelsToDraw = processLabels(renderContext);
// now draw the ways and the labels
renderContext.canvasRasterer.drawMapElements(labelsToDraw, rendererJob.tile);
}
if (!rendererJob.labelsOnly && renderContext.renderTheme.hasMapBackgroundOutside()) {
// blank out all areas outside of map
Rectangle insideArea = this.mapDataStore.boundingBox().getPositionRelativeToTile(rendererJob.tile);
if (!rendererJob.hasAlpha) {
renderContext.canvasRasterer.fillOutsideAreas(renderContext.renderTheme.getMapBackgroundOutside(), insideArea);
} else {
renderContext.canvasRasterer.fillOutsideAreas(Color.TRANSPARENT, insideArea);
}
}
return bitmap;
}
// outside of map area
return null;
} catch (Exception e) {
// #1049: message can be null?
LOGGER.warning("Exception: " + e.getMessage());
return null;
} finally {
if (renderContext != null) {
renderContext.destroy();
}
}
} | [
"public",
"TileBitmap",
"executeJob",
"(",
"RendererJob",
"rendererJob",
")",
"{",
"RenderContext",
"renderContext",
"=",
"null",
";",
"try",
"{",
"renderContext",
"=",
"new",
"RenderContext",
"(",
"rendererJob",
",",
"new",
"CanvasRasterer",
"(",
"graphicFactory",
")",
")",
";",
"if",
"(",
"renderBitmap",
"(",
"renderContext",
")",
")",
"{",
"TileBitmap",
"bitmap",
"=",
"null",
";",
"if",
"(",
"this",
".",
"mapDataStore",
"!=",
"null",
")",
"{",
"MapReadResult",
"mapReadResult",
"=",
"this",
".",
"mapDataStore",
".",
"readMapData",
"(",
"rendererJob",
".",
"tile",
")",
";",
"processReadMapData",
"(",
"renderContext",
",",
"mapReadResult",
")",
";",
"}",
"if",
"(",
"!",
"rendererJob",
".",
"labelsOnly",
")",
"{",
"renderContext",
".",
"renderTheme",
".",
"matchHillShadings",
"(",
"this",
",",
"renderContext",
")",
";",
"bitmap",
"=",
"this",
".",
"graphicFactory",
".",
"createTileBitmap",
"(",
"rendererJob",
".",
"tile",
".",
"tileSize",
",",
"rendererJob",
".",
"hasAlpha",
")",
";",
"bitmap",
".",
"setTimestamp",
"(",
"rendererJob",
".",
"mapDataStore",
".",
"getDataTimestamp",
"(",
"rendererJob",
".",
"tile",
")",
")",
";",
"renderContext",
".",
"canvasRasterer",
".",
"setCanvasBitmap",
"(",
"bitmap",
")",
";",
"if",
"(",
"!",
"rendererJob",
".",
"hasAlpha",
"&&",
"rendererJob",
".",
"displayModel",
".",
"getBackgroundColor",
"(",
")",
"!=",
"renderContext",
".",
"renderTheme",
".",
"getMapBackground",
"(",
")",
")",
"{",
"renderContext",
".",
"canvasRasterer",
".",
"fill",
"(",
"renderContext",
".",
"renderTheme",
".",
"getMapBackground",
"(",
")",
")",
";",
"}",
"renderContext",
".",
"canvasRasterer",
".",
"drawWays",
"(",
"renderContext",
")",
";",
"}",
"if",
"(",
"this",
".",
"renderLabels",
")",
"{",
"Set",
"<",
"MapElementContainer",
">",
"labelsToDraw",
"=",
"processLabels",
"(",
"renderContext",
")",
";",
"// now draw the ways and the labels",
"renderContext",
".",
"canvasRasterer",
".",
"drawMapElements",
"(",
"labelsToDraw",
",",
"rendererJob",
".",
"tile",
")",
";",
"}",
"if",
"(",
"!",
"rendererJob",
".",
"labelsOnly",
"&&",
"renderContext",
".",
"renderTheme",
".",
"hasMapBackgroundOutside",
"(",
")",
")",
"{",
"// blank out all areas outside of map",
"Rectangle",
"insideArea",
"=",
"this",
".",
"mapDataStore",
".",
"boundingBox",
"(",
")",
".",
"getPositionRelativeToTile",
"(",
"rendererJob",
".",
"tile",
")",
";",
"if",
"(",
"!",
"rendererJob",
".",
"hasAlpha",
")",
"{",
"renderContext",
".",
"canvasRasterer",
".",
"fillOutsideAreas",
"(",
"renderContext",
".",
"renderTheme",
".",
"getMapBackgroundOutside",
"(",
")",
",",
"insideArea",
")",
";",
"}",
"else",
"{",
"renderContext",
".",
"canvasRasterer",
".",
"fillOutsideAreas",
"(",
"Color",
".",
"TRANSPARENT",
",",
"insideArea",
")",
";",
"}",
"}",
"return",
"bitmap",
";",
"}",
"// outside of map area",
"return",
"null",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// #1049: message can be null?",
"LOGGER",
".",
"warning",
"(",
"\"Exception: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"finally",
"{",
"if",
"(",
"renderContext",
"!=",
"null",
")",
"{",
"renderContext",
".",
"destroy",
"(",
")",
";",
"}",
"}",
"}"
] | Called when a job needs to be executed.
@param rendererJob the job that should be executed. | [
"Called",
"when",
"a",
"job",
"needs",
"to",
"be",
"executed",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/DirectRenderer.java#L78-L130 |
28,410 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.getThreadDefaultConnectionFlags | int getThreadDefaultConnectionFlags(boolean readOnly) {
int flags = readOnly ? SQLiteConnectionPool.CONNECTION_FLAG_READ_ONLY :
SQLiteConnectionPool.CONNECTION_FLAG_PRIMARY_CONNECTION_AFFINITY;
if (isMainThread()) {
flags |= SQLiteConnectionPool.CONNECTION_FLAG_INTERACTIVE;
}
return flags;
} | java | int getThreadDefaultConnectionFlags(boolean readOnly) {
int flags = readOnly ? SQLiteConnectionPool.CONNECTION_FLAG_READ_ONLY :
SQLiteConnectionPool.CONNECTION_FLAG_PRIMARY_CONNECTION_AFFINITY;
if (isMainThread()) {
flags |= SQLiteConnectionPool.CONNECTION_FLAG_INTERACTIVE;
}
return flags;
} | [
"int",
"getThreadDefaultConnectionFlags",
"(",
"boolean",
"readOnly",
")",
"{",
"int",
"flags",
"=",
"readOnly",
"?",
"SQLiteConnectionPool",
".",
"CONNECTION_FLAG_READ_ONLY",
":",
"SQLiteConnectionPool",
".",
"CONNECTION_FLAG_PRIMARY_CONNECTION_AFFINITY",
";",
"if",
"(",
"isMainThread",
"(",
")",
")",
"{",
"flags",
"|=",
"SQLiteConnectionPool",
".",
"CONNECTION_FLAG_INTERACTIVE",
";",
"}",
"return",
"flags",
";",
"}"
] | Gets default connection flags that are appropriate for this thread, taking into
account whether the thread is acting on behalf of the UI.
@param readOnly True if the connection should be read-only.
@return The connection flags. | [
"Gets",
"default",
"connection",
"flags",
"that",
"are",
"appropriate",
"for",
"this",
"thread",
"taking",
"into",
"account",
"whether",
"the",
"thread",
"is",
"acting",
"on",
"behalf",
"of",
"the",
"UI",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L382-L389 |
28,411 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.deleteDatabase | public static boolean deleteDatabase(File file) {
if (file == null) {
throw new IllegalArgumentException("file must not be null");
}
boolean deleted = false;
deleted |= file.delete();
deleted |= new File(file.getPath() + "-journal").delete();
deleted |= new File(file.getPath() + "-shm").delete();
deleted |= new File(file.getPath() + "-wal").delete();
File dir = file.getParentFile();
if (dir != null) {
final String prefix = file.getName() + "-mj";
File[] files = dir.listFiles(new FileFilter() {
@Override
public boolean accept(File candidate) {
return candidate.getName().startsWith(prefix);
}
});
if (files != null) {
for (File masterJournal : files) {
deleted |= masterJournal.delete();
}
}
}
return deleted;
} | java | public static boolean deleteDatabase(File file) {
if (file == null) {
throw new IllegalArgumentException("file must not be null");
}
boolean deleted = false;
deleted |= file.delete();
deleted |= new File(file.getPath() + "-journal").delete();
deleted |= new File(file.getPath() + "-shm").delete();
deleted |= new File(file.getPath() + "-wal").delete();
File dir = file.getParentFile();
if (dir != null) {
final String prefix = file.getName() + "-mj";
File[] files = dir.listFiles(new FileFilter() {
@Override
public boolean accept(File candidate) {
return candidate.getName().startsWith(prefix);
}
});
if (files != null) {
for (File masterJournal : files) {
deleted |= masterJournal.delete();
}
}
}
return deleted;
} | [
"public",
"static",
"boolean",
"deleteDatabase",
"(",
"File",
"file",
")",
"{",
"if",
"(",
"file",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"file must not be null\"",
")",
";",
"}",
"boolean",
"deleted",
"=",
"false",
";",
"deleted",
"|=",
"file",
".",
"delete",
"(",
")",
";",
"deleted",
"|=",
"new",
"File",
"(",
"file",
".",
"getPath",
"(",
")",
"+",
"\"-journal\"",
")",
".",
"delete",
"(",
")",
";",
"deleted",
"|=",
"new",
"File",
"(",
"file",
".",
"getPath",
"(",
")",
"+",
"\"-shm\"",
")",
".",
"delete",
"(",
")",
";",
"deleted",
"|=",
"new",
"File",
"(",
"file",
".",
"getPath",
"(",
")",
"+",
"\"-wal\"",
")",
".",
"delete",
"(",
")",
";",
"File",
"dir",
"=",
"file",
".",
"getParentFile",
"(",
")",
";",
"if",
"(",
"dir",
"!=",
"null",
")",
"{",
"final",
"String",
"prefix",
"=",
"file",
".",
"getName",
"(",
")",
"+",
"\"-mj\"",
";",
"File",
"[",
"]",
"files",
"=",
"dir",
".",
"listFiles",
"(",
"new",
"FileFilter",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"accept",
"(",
"File",
"candidate",
")",
"{",
"return",
"candidate",
".",
"getName",
"(",
")",
".",
"startsWith",
"(",
"prefix",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"files",
"!=",
"null",
")",
"{",
"for",
"(",
"File",
"masterJournal",
":",
"files",
")",
"{",
"deleted",
"|=",
"masterJournal",
".",
"delete",
"(",
")",
";",
"}",
"}",
"}",
"return",
"deleted",
";",
"}"
] | Deletes a database including its journal file and other auxiliary files
that may have been created by the database engine.
@param file The database file path.
@return True if the database was successfully deleted. | [
"Deletes",
"a",
"database",
"including",
"its",
"journal",
"file",
"and",
"other",
"auxiliary",
"files",
"that",
"may",
"have",
"been",
"created",
"by",
"the",
"database",
"engine",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L731-L758 |
28,412 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.reopenReadWrite | public void reopenReadWrite() {
synchronized (mLock) {
throwIfNotOpenLocked();
if (!isReadOnlyLocked()) {
return; // nothing to do
}
// Reopen the database in read-write mode.
final int oldOpenFlags = mConfigurationLocked.openFlags;
mConfigurationLocked.openFlags = (mConfigurationLocked.openFlags & ~OPEN_READ_MASK)
| OPEN_READWRITE;
try {
mConnectionPoolLocked.reconfigure(mConfigurationLocked);
} catch (RuntimeException ex) {
mConfigurationLocked.openFlags = oldOpenFlags;
throw ex;
}
}
} | java | public void reopenReadWrite() {
synchronized (mLock) {
throwIfNotOpenLocked();
if (!isReadOnlyLocked()) {
return; // nothing to do
}
// Reopen the database in read-write mode.
final int oldOpenFlags = mConfigurationLocked.openFlags;
mConfigurationLocked.openFlags = (mConfigurationLocked.openFlags & ~OPEN_READ_MASK)
| OPEN_READWRITE;
try {
mConnectionPoolLocked.reconfigure(mConfigurationLocked);
} catch (RuntimeException ex) {
mConfigurationLocked.openFlags = oldOpenFlags;
throw ex;
}
}
} | [
"public",
"void",
"reopenReadWrite",
"(",
")",
"{",
"synchronized",
"(",
"mLock",
")",
"{",
"throwIfNotOpenLocked",
"(",
")",
";",
"if",
"(",
"!",
"isReadOnlyLocked",
"(",
")",
")",
"{",
"return",
";",
"// nothing to do",
"}",
"// Reopen the database in read-write mode.",
"final",
"int",
"oldOpenFlags",
"=",
"mConfigurationLocked",
".",
"openFlags",
";",
"mConfigurationLocked",
".",
"openFlags",
"=",
"(",
"mConfigurationLocked",
".",
"openFlags",
"&",
"~",
"OPEN_READ_MASK",
")",
"|",
"OPEN_READWRITE",
";",
"try",
"{",
"mConnectionPoolLocked",
".",
"reconfigure",
"(",
"mConfigurationLocked",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"ex",
")",
"{",
"mConfigurationLocked",
".",
"openFlags",
"=",
"oldOpenFlags",
";",
"throw",
"ex",
";",
"}",
"}",
"}"
] | Reopens the database in read-write mode.
If the database is already read-write, does nothing.
@throws SQLiteException if the database could not be reopened as requested, in which
case it remains open in read only mode.
@throws IllegalStateException if the database is not open.
@see #isReadOnly()
@hide | [
"Reopens",
"the",
"database",
"in",
"read",
"-",
"write",
"mode",
".",
"If",
"the",
"database",
"is",
"already",
"read",
"-",
"write",
"does",
"nothing",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L771-L790 |
28,413 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.addCustomFunction | public void addCustomFunction(String name, int numArgs, CustomFunction function) {
// Create wrapper (also validates arguments).
SQLiteCustomFunction wrapper = new SQLiteCustomFunction(name, numArgs, function);
synchronized (mLock) {
throwIfNotOpenLocked();
mConfigurationLocked.customFunctions.add(wrapper);
try {
mConnectionPoolLocked.reconfigure(mConfigurationLocked);
} catch (RuntimeException ex) {
mConfigurationLocked.customFunctions.remove(wrapper);
throw ex;
}
}
} | java | public void addCustomFunction(String name, int numArgs, CustomFunction function) {
// Create wrapper (also validates arguments).
SQLiteCustomFunction wrapper = new SQLiteCustomFunction(name, numArgs, function);
synchronized (mLock) {
throwIfNotOpenLocked();
mConfigurationLocked.customFunctions.add(wrapper);
try {
mConnectionPoolLocked.reconfigure(mConfigurationLocked);
} catch (RuntimeException ex) {
mConfigurationLocked.customFunctions.remove(wrapper);
throw ex;
}
}
} | [
"public",
"void",
"addCustomFunction",
"(",
"String",
"name",
",",
"int",
"numArgs",
",",
"CustomFunction",
"function",
")",
"{",
"// Create wrapper (also validates arguments).",
"SQLiteCustomFunction",
"wrapper",
"=",
"new",
"SQLiteCustomFunction",
"(",
"name",
",",
"numArgs",
",",
"function",
")",
";",
"synchronized",
"(",
"mLock",
")",
"{",
"throwIfNotOpenLocked",
"(",
")",
";",
"mConfigurationLocked",
".",
"customFunctions",
".",
"add",
"(",
"wrapper",
")",
";",
"try",
"{",
"mConnectionPoolLocked",
".",
"reconfigure",
"(",
"mConfigurationLocked",
")",
";",
"}",
"catch",
"(",
"RuntimeException",
"ex",
")",
"{",
"mConfigurationLocked",
".",
"customFunctions",
".",
"remove",
"(",
"wrapper",
")",
";",
"throw",
"ex",
";",
"}",
"}",
"}"
] | Registers a CustomFunction callback as a function that can be called from
SQLite database triggers.
@param name the name of the sqlite3 function
@param numArgs the number of arguments for the function
@param function callback to call when the function is executed
@hide | [
"Registers",
"a",
"CustomFunction",
"callback",
"as",
"a",
"function",
"that",
"can",
"be",
"called",
"from",
"SQLite",
"database",
"triggers",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L845-L860 |
28,414 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.setMaximumSize | public long setMaximumSize(long numBytes) {
long pageSize = getPageSize();
long numPages = numBytes / pageSize;
// If numBytes isn't a multiple of pageSize, bump up a page
if ((numBytes % pageSize) != 0) {
numPages++;
}
long newPageCount = DatabaseUtils.longForQuery(this, "PRAGMA max_page_count = " + numPages,
null);
return newPageCount * pageSize;
} | java | public long setMaximumSize(long numBytes) {
long pageSize = getPageSize();
long numPages = numBytes / pageSize;
// If numBytes isn't a multiple of pageSize, bump up a page
if ((numBytes % pageSize) != 0) {
numPages++;
}
long newPageCount = DatabaseUtils.longForQuery(this, "PRAGMA max_page_count = " + numPages,
null);
return newPageCount * pageSize;
} | [
"public",
"long",
"setMaximumSize",
"(",
"long",
"numBytes",
")",
"{",
"long",
"pageSize",
"=",
"getPageSize",
"(",
")",
";",
"long",
"numPages",
"=",
"numBytes",
"/",
"pageSize",
";",
"// If numBytes isn't a multiple of pageSize, bump up a page",
"if",
"(",
"(",
"numBytes",
"%",
"pageSize",
")",
"!=",
"0",
")",
"{",
"numPages",
"++",
";",
"}",
"long",
"newPageCount",
"=",
"DatabaseUtils",
".",
"longForQuery",
"(",
"this",
",",
"\"PRAGMA max_page_count = \"",
"+",
"numPages",
",",
"null",
")",
";",
"return",
"newPageCount",
"*",
"pageSize",
";",
"}"
] | Sets the maximum size the database will grow to. The maximum size cannot
be set below the current size.
@param numBytes the maximum database size, in bytes
@return the new maximum database size | [
"Sets",
"the",
"maximum",
"size",
"the",
"database",
"will",
"grow",
"to",
".",
"The",
"maximum",
"size",
"cannot",
"be",
"set",
"below",
"the",
"current",
"size",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L897-L907 |
28,415 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.findEditTable | public static String findEditTable(String tables) {
if (!TextUtils.isEmpty(tables)) {
// find the first word terminated by either a space or a comma
int spacepos = tables.indexOf(' ');
int commapos = tables.indexOf(',');
if (spacepos > 0 && (spacepos < commapos || commapos < 0)) {
return tables.substring(0, spacepos);
} else if (commapos > 0 && (commapos < spacepos || spacepos < 0) ) {
return tables.substring(0, commapos);
}
return tables;
} else {
throw new IllegalStateException("Invalid tables");
}
} | java | public static String findEditTable(String tables) {
if (!TextUtils.isEmpty(tables)) {
// find the first word terminated by either a space or a comma
int spacepos = tables.indexOf(' ');
int commapos = tables.indexOf(',');
if (spacepos > 0 && (spacepos < commapos || commapos < 0)) {
return tables.substring(0, spacepos);
} else if (commapos > 0 && (commapos < spacepos || spacepos < 0) ) {
return tables.substring(0, commapos);
}
return tables;
} else {
throw new IllegalStateException("Invalid tables");
}
} | [
"public",
"static",
"String",
"findEditTable",
"(",
"String",
"tables",
")",
"{",
"if",
"(",
"!",
"TextUtils",
".",
"isEmpty",
"(",
"tables",
")",
")",
"{",
"// find the first word terminated by either a space or a comma",
"int",
"spacepos",
"=",
"tables",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"int",
"commapos",
"=",
"tables",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"spacepos",
">",
"0",
"&&",
"(",
"spacepos",
"<",
"commapos",
"||",
"commapos",
"<",
"0",
")",
")",
"{",
"return",
"tables",
".",
"substring",
"(",
"0",
",",
"spacepos",
")",
";",
"}",
"else",
"if",
"(",
"commapos",
">",
"0",
"&&",
"(",
"commapos",
"<",
"spacepos",
"||",
"spacepos",
"<",
"0",
")",
")",
"{",
"return",
"tables",
".",
"substring",
"(",
"0",
",",
"commapos",
")",
";",
"}",
"return",
"tables",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Invalid tables\"",
")",
";",
"}",
"}"
] | Finds the name of the first table, which is editable.
@param tables a list of tables
@return the first table listed | [
"Finds",
"the",
"name",
"of",
"the",
"first",
"table",
"which",
"is",
"editable",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L964-L979 |
28,416 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.replaceOrThrow | public long replaceOrThrow(String table, String nullColumnHack,
ContentValues initialValues) throws SQLException {
return insertWithOnConflict(table, nullColumnHack, initialValues,
CONFLICT_REPLACE);
} | java | public long replaceOrThrow(String table, String nullColumnHack,
ContentValues initialValues) throws SQLException {
return insertWithOnConflict(table, nullColumnHack, initialValues,
CONFLICT_REPLACE);
} | [
"public",
"long",
"replaceOrThrow",
"(",
"String",
"table",
",",
"String",
"nullColumnHack",
",",
"ContentValues",
"initialValues",
")",
"throws",
"SQLException",
"{",
"return",
"insertWithOnConflict",
"(",
"table",
",",
"nullColumnHack",
",",
"initialValues",
",",
"CONFLICT_REPLACE",
")",
";",
"}"
] | Convenience method for replacing a row in the database.
Inserts a new row if a row does not already exist.
@param table the table in which to replace the row
@param nullColumnHack optional; may be <code>null</code>.
SQL doesn't allow inserting a completely empty row without
naming at least one column name. If your provided <code>initialValues</code> is
empty, no column names are known and an empty row can't be inserted.
If not set to null, the <code>nullColumnHack</code> parameter
provides the name of nullable column name to explicitly insert a NULL into
in the case where your <code>initialValues</code> is empty.
@param initialValues this map contains the initial column values for
the row. The keys should be the column names and the values the column values.
@throws SQLException
@return the row ID of the newly inserted row, or -1 if an error occurred | [
"Convenience",
"method",
"for",
"replacing",
"a",
"row",
"in",
"the",
"database",
".",
"Inserts",
"a",
"new",
"row",
"if",
"a",
"row",
"does",
"not",
"already",
"exist",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L1417-L1421 |
28,417 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.insertWithOnConflict | public long insertWithOnConflict(String table, String nullColumnHack,
ContentValues initialValues, int conflictAlgorithm) {
acquireReference();
try {
StringBuilder sql = new StringBuilder();
sql.append("INSERT");
sql.append(CONFLICT_VALUES[conflictAlgorithm]);
sql.append(" INTO ");
sql.append(table);
sql.append('(');
Object[] bindArgs = null;
int size = (initialValues != null && initialValues.size() > 0)
? initialValues.size() : 0;
if (size > 0) {
bindArgs = new Object[size];
int i = 0;
for (String colName : initialValues.keySet()) {
sql.append((i > 0) ? "," : "");
sql.append(colName);
bindArgs[i++] = initialValues.get(colName);
}
sql.append(')');
sql.append(" VALUES (");
for (i = 0; i < size; i++) {
sql.append((i > 0) ? ",?" : "?");
}
} else {
sql.append(nullColumnHack + ") VALUES (NULL");
}
sql.append(')');
SQLiteStatement statement = new SQLiteStatement(this, sql.toString(), bindArgs);
try {
return statement.executeInsert();
} finally {
statement.close();
}
} finally {
releaseReference();
}
} | java | public long insertWithOnConflict(String table, String nullColumnHack,
ContentValues initialValues, int conflictAlgorithm) {
acquireReference();
try {
StringBuilder sql = new StringBuilder();
sql.append("INSERT");
sql.append(CONFLICT_VALUES[conflictAlgorithm]);
sql.append(" INTO ");
sql.append(table);
sql.append('(');
Object[] bindArgs = null;
int size = (initialValues != null && initialValues.size() > 0)
? initialValues.size() : 0;
if (size > 0) {
bindArgs = new Object[size];
int i = 0;
for (String colName : initialValues.keySet()) {
sql.append((i > 0) ? "," : "");
sql.append(colName);
bindArgs[i++] = initialValues.get(colName);
}
sql.append(')');
sql.append(" VALUES (");
for (i = 0; i < size; i++) {
sql.append((i > 0) ? ",?" : "?");
}
} else {
sql.append(nullColumnHack + ") VALUES (NULL");
}
sql.append(')');
SQLiteStatement statement = new SQLiteStatement(this, sql.toString(), bindArgs);
try {
return statement.executeInsert();
} finally {
statement.close();
}
} finally {
releaseReference();
}
} | [
"public",
"long",
"insertWithOnConflict",
"(",
"String",
"table",
",",
"String",
"nullColumnHack",
",",
"ContentValues",
"initialValues",
",",
"int",
"conflictAlgorithm",
")",
"{",
"acquireReference",
"(",
")",
";",
"try",
"{",
"StringBuilder",
"sql",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"sql",
".",
"append",
"(",
"\"INSERT\"",
")",
";",
"sql",
".",
"append",
"(",
"CONFLICT_VALUES",
"[",
"conflictAlgorithm",
"]",
")",
";",
"sql",
".",
"append",
"(",
"\" INTO \"",
")",
";",
"sql",
".",
"append",
"(",
"table",
")",
";",
"sql",
".",
"append",
"(",
"'",
"'",
")",
";",
"Object",
"[",
"]",
"bindArgs",
"=",
"null",
";",
"int",
"size",
"=",
"(",
"initialValues",
"!=",
"null",
"&&",
"initialValues",
".",
"size",
"(",
")",
">",
"0",
")",
"?",
"initialValues",
".",
"size",
"(",
")",
":",
"0",
";",
"if",
"(",
"size",
">",
"0",
")",
"{",
"bindArgs",
"=",
"new",
"Object",
"[",
"size",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"String",
"colName",
":",
"initialValues",
".",
"keySet",
"(",
")",
")",
"{",
"sql",
".",
"append",
"(",
"(",
"i",
">",
"0",
")",
"?",
"\",\"",
":",
"\"\"",
")",
";",
"sql",
".",
"append",
"(",
"colName",
")",
";",
"bindArgs",
"[",
"i",
"++",
"]",
"=",
"initialValues",
".",
"get",
"(",
"colName",
")",
";",
"}",
"sql",
".",
"append",
"(",
"'",
"'",
")",
";",
"sql",
".",
"append",
"(",
"\" VALUES (\"",
")",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"size",
";",
"i",
"++",
")",
"{",
"sql",
".",
"append",
"(",
"(",
"i",
">",
"0",
")",
"?",
"\",?\"",
":",
"\"?\"",
")",
";",
"}",
"}",
"else",
"{",
"sql",
".",
"append",
"(",
"nullColumnHack",
"+",
"\") VALUES (NULL\"",
")",
";",
"}",
"sql",
".",
"append",
"(",
"'",
"'",
")",
";",
"SQLiteStatement",
"statement",
"=",
"new",
"SQLiteStatement",
"(",
"this",
",",
"sql",
".",
"toString",
"(",
")",
",",
"bindArgs",
")",
";",
"try",
"{",
"return",
"statement",
".",
"executeInsert",
"(",
")",
";",
"}",
"finally",
"{",
"statement",
".",
"close",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"releaseReference",
"(",
")",
";",
"}",
"}"
] | General method for inserting a row into the database.
@param table the table to insert the row into
@param nullColumnHack optional; may be <code>null</code>.
SQL doesn't allow inserting a completely empty row without
naming at least one column name. If your provided <code>initialValues</code> is
empty, no column names are known and an empty row can't be inserted.
If not set to null, the <code>nullColumnHack</code> parameter
provides the name of nullable column name to explicitly insert a NULL into
in the case where your <code>initialValues</code> is empty.
@param initialValues this map contains the initial column values for the
row. The keys should be the column names and the values the
column values
@param conflictAlgorithm for insert conflict resolver
@return the row ID of the newly inserted row OR <code>-1</code> if either the
input parameter <code>conflictAlgorithm</code> = {@link #CONFLICT_IGNORE}
or an error occurred. | [
"General",
"method",
"for",
"inserting",
"a",
"row",
"into",
"the",
"database",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L1442-L1483 |
28,418 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.dumpAll | static void dumpAll(Printer printer, boolean verbose) {
for (SQLiteDatabase db : getActiveDatabases()) {
db.dump(printer, verbose);
}
} | java | static void dumpAll(Printer printer, boolean verbose) {
for (SQLiteDatabase db : getActiveDatabases()) {
db.dump(printer, verbose);
}
} | [
"static",
"void",
"dumpAll",
"(",
"Printer",
"printer",
",",
"boolean",
"verbose",
")",
"{",
"for",
"(",
"SQLiteDatabase",
"db",
":",
"getActiveDatabases",
"(",
")",
")",
"{",
"db",
".",
"dump",
"(",
"printer",
",",
"verbose",
")",
";",
"}",
"}"
] | Dump detailed information about all open databases in the current process.
Used by bug report. | [
"Dump",
"detailed",
"information",
"about",
"all",
"open",
"databases",
"in",
"the",
"current",
"process",
".",
"Used",
"by",
"bug",
"report",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L2062-L2066 |
28,419 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java | SQLiteDatabase.getAttachedDbs | public List<Pair<String, String>> getAttachedDbs() {
ArrayList<Pair<String, String>> attachedDbs = new ArrayList<Pair<String, String>>();
synchronized (mLock) {
if (mConnectionPoolLocked == null) {
return null; // not open
}
if (!mHasAttachedDbsLocked) {
// No attached databases.
// There is a small window where attached databases exist but this flag is not
// set yet. This can occur when this thread is in a race condition with another
// thread that is executing the SQL statement: "attach database <blah> as <foo>"
// If this thread is NOT ok with such a race condition (and thus possibly not
// receivethe entire list of attached databases), then the caller should ensure
// that no thread is executing any SQL statements while a thread is calling this
// method. Typically, this method is called when 'adb bugreport' is done or the
// caller wants to collect stats on the database and all its attached databases.
attachedDbs.add(new Pair<String, String>("main", mConfigurationLocked.path));
return attachedDbs;
}
acquireReference();
}
try {
// has attached databases. query sqlite to get the list of attached databases.
Cursor c = null;
try {
c = rawQuery("pragma database_list;", null);
while (c.moveToNext()) {
// sqlite returns a row for each database in the returned list of databases.
// in each row,
// 1st column is the database name such as main, or the database
// name specified on the "ATTACH" command
// 2nd column is the database file path.
attachedDbs.add(new Pair<String, String>(c.getString(1), c.getString(2)));
}
} finally {
if (c != null) {
c.close();
}
}
return attachedDbs;
} finally {
releaseReference();
}
} | java | public List<Pair<String, String>> getAttachedDbs() {
ArrayList<Pair<String, String>> attachedDbs = new ArrayList<Pair<String, String>>();
synchronized (mLock) {
if (mConnectionPoolLocked == null) {
return null; // not open
}
if (!mHasAttachedDbsLocked) {
// No attached databases.
// There is a small window where attached databases exist but this flag is not
// set yet. This can occur when this thread is in a race condition with another
// thread that is executing the SQL statement: "attach database <blah> as <foo>"
// If this thread is NOT ok with such a race condition (and thus possibly not
// receivethe entire list of attached databases), then the caller should ensure
// that no thread is executing any SQL statements while a thread is calling this
// method. Typically, this method is called when 'adb bugreport' is done or the
// caller wants to collect stats on the database and all its attached databases.
attachedDbs.add(new Pair<String, String>("main", mConfigurationLocked.path));
return attachedDbs;
}
acquireReference();
}
try {
// has attached databases. query sqlite to get the list of attached databases.
Cursor c = null;
try {
c = rawQuery("pragma database_list;", null);
while (c.moveToNext()) {
// sqlite returns a row for each database in the returned list of databases.
// in each row,
// 1st column is the database name such as main, or the database
// name specified on the "ATTACH" command
// 2nd column is the database file path.
attachedDbs.add(new Pair<String, String>(c.getString(1), c.getString(2)));
}
} finally {
if (c != null) {
c.close();
}
}
return attachedDbs;
} finally {
releaseReference();
}
} | [
"public",
"List",
"<",
"Pair",
"<",
"String",
",",
"String",
">",
">",
"getAttachedDbs",
"(",
")",
"{",
"ArrayList",
"<",
"Pair",
"<",
"String",
",",
"String",
">",
">",
"attachedDbs",
"=",
"new",
"ArrayList",
"<",
"Pair",
"<",
"String",
",",
"String",
">",
">",
"(",
")",
";",
"synchronized",
"(",
"mLock",
")",
"{",
"if",
"(",
"mConnectionPoolLocked",
"==",
"null",
")",
"{",
"return",
"null",
";",
"// not open",
"}",
"if",
"(",
"!",
"mHasAttachedDbsLocked",
")",
"{",
"// No attached databases.",
"// There is a small window where attached databases exist but this flag is not",
"// set yet. This can occur when this thread is in a race condition with another",
"// thread that is executing the SQL statement: \"attach database <blah> as <foo>\"",
"// If this thread is NOT ok with such a race condition (and thus possibly not",
"// receivethe entire list of attached databases), then the caller should ensure",
"// that no thread is executing any SQL statements while a thread is calling this",
"// method. Typically, this method is called when 'adb bugreport' is done or the",
"// caller wants to collect stats on the database and all its attached databases.",
"attachedDbs",
".",
"add",
"(",
"new",
"Pair",
"<",
"String",
",",
"String",
">",
"(",
"\"main\"",
",",
"mConfigurationLocked",
".",
"path",
")",
")",
";",
"return",
"attachedDbs",
";",
"}",
"acquireReference",
"(",
")",
";",
"}",
"try",
"{",
"// has attached databases. query sqlite to get the list of attached databases.",
"Cursor",
"c",
"=",
"null",
";",
"try",
"{",
"c",
"=",
"rawQuery",
"(",
"\"pragma database_list;\"",
",",
"null",
")",
";",
"while",
"(",
"c",
".",
"moveToNext",
"(",
")",
")",
"{",
"// sqlite returns a row for each database in the returned list of databases.",
"// in each row,",
"// 1st column is the database name such as main, or the database",
"// name specified on the \"ATTACH\" command",
"// 2nd column is the database file path.",
"attachedDbs",
".",
"add",
"(",
"new",
"Pair",
"<",
"String",
",",
"String",
">",
"(",
"c",
".",
"getString",
"(",
"1",
")",
",",
"c",
".",
"getString",
"(",
"2",
")",
")",
")",
";",
"}",
"}",
"finally",
"{",
"if",
"(",
"c",
"!=",
"null",
")",
"{",
"c",
".",
"close",
"(",
")",
";",
"}",
"}",
"return",
"attachedDbs",
";",
"}",
"finally",
"{",
"releaseReference",
"(",
")",
";",
"}",
"}"
] | Returns list of full pathnames of all attached databases including the main database
by executing 'pragma database_list' on the database.
@return ArrayList of pairs of (database name, database file path) or null if the database
is not open. | [
"Returns",
"list",
"of",
"full",
"pathnames",
"of",
"all",
"attached",
"databases",
"including",
"the",
"main",
"database",
"by",
"executing",
"pragma",
"database_list",
"on",
"the",
"database",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteDatabase.java#L2084-L2130 |
28,420 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/TDWay.java | TDWay.fromWay | public static TDWay fromWay(Way way, NodeResolver resolver, List<String> preferredLanguages) {
if (way == null)
return null;
SpecialTagExtractionResult ster = OSMUtils.extractSpecialFields(way, preferredLanguages);
Map<Short, Object> knownWayTags = OSMUtils.extractKnownWayTags(way);
// only ways with at least 2 way nodes are valid ways
if (way.getWayNodes().size() >= 2) {
boolean validWay = true;
// retrieve way nodes from data store
TDNode[] waynodes = new TDNode[way.getWayNodes().size()];
int i = 0;
for (WayNode waynode : way.getWayNodes()) {
// TODO adjust interface to support a method getWayNodes()
waynodes[i] = resolver.getNode(waynode.getNodeId());
if (waynodes[i] == null) {
validWay = false;
LOGGER.finer("unknown way node: " + waynode.getNodeId() + " in way " + way.getId());
}
i++;
}
// for a valid way all way nodes must be existent in the input data
if (validWay) {
// mark the way as polygon if the first and the last way node are the same
// and if the way has at least 4 way nodes
byte shape = LINE;
if (waynodes[0].getId() == waynodes[waynodes.length - 1].getId()) {
if (waynodes.length >= GeoUtils.MIN_NODES_POLYGON) {
if (OSMUtils.isArea(way)) {
shape = SIMPLE_POLYGON;
}
} else {
LOGGER.finer("Found closed polygon with fewer than 4 way nodes. Way-id: " + way.getId());
return null;
}
}
return new TDWay(way.getId(), ster.getLayer(), ster.getName(), ster.getHousenumber(), ster.getRef(),
knownWayTags, shape, waynodes);
}
}
return null;
} | java | public static TDWay fromWay(Way way, NodeResolver resolver, List<String> preferredLanguages) {
if (way == null)
return null;
SpecialTagExtractionResult ster = OSMUtils.extractSpecialFields(way, preferredLanguages);
Map<Short, Object> knownWayTags = OSMUtils.extractKnownWayTags(way);
// only ways with at least 2 way nodes are valid ways
if (way.getWayNodes().size() >= 2) {
boolean validWay = true;
// retrieve way nodes from data store
TDNode[] waynodes = new TDNode[way.getWayNodes().size()];
int i = 0;
for (WayNode waynode : way.getWayNodes()) {
// TODO adjust interface to support a method getWayNodes()
waynodes[i] = resolver.getNode(waynode.getNodeId());
if (waynodes[i] == null) {
validWay = false;
LOGGER.finer("unknown way node: " + waynode.getNodeId() + " in way " + way.getId());
}
i++;
}
// for a valid way all way nodes must be existent in the input data
if (validWay) {
// mark the way as polygon if the first and the last way node are the same
// and if the way has at least 4 way nodes
byte shape = LINE;
if (waynodes[0].getId() == waynodes[waynodes.length - 1].getId()) {
if (waynodes.length >= GeoUtils.MIN_NODES_POLYGON) {
if (OSMUtils.isArea(way)) {
shape = SIMPLE_POLYGON;
}
} else {
LOGGER.finer("Found closed polygon with fewer than 4 way nodes. Way-id: " + way.getId());
return null;
}
}
return new TDWay(way.getId(), ster.getLayer(), ster.getName(), ster.getHousenumber(), ster.getRef(),
knownWayTags, shape, waynodes);
}
}
return null;
} | [
"public",
"static",
"TDWay",
"fromWay",
"(",
"Way",
"way",
",",
"NodeResolver",
"resolver",
",",
"List",
"<",
"String",
">",
"preferredLanguages",
")",
"{",
"if",
"(",
"way",
"==",
"null",
")",
"return",
"null",
";",
"SpecialTagExtractionResult",
"ster",
"=",
"OSMUtils",
".",
"extractSpecialFields",
"(",
"way",
",",
"preferredLanguages",
")",
";",
"Map",
"<",
"Short",
",",
"Object",
">",
"knownWayTags",
"=",
"OSMUtils",
".",
"extractKnownWayTags",
"(",
"way",
")",
";",
"// only ways with at least 2 way nodes are valid ways",
"if",
"(",
"way",
".",
"getWayNodes",
"(",
")",
".",
"size",
"(",
")",
">=",
"2",
")",
"{",
"boolean",
"validWay",
"=",
"true",
";",
"// retrieve way nodes from data store",
"TDNode",
"[",
"]",
"waynodes",
"=",
"new",
"TDNode",
"[",
"way",
".",
"getWayNodes",
"(",
")",
".",
"size",
"(",
")",
"]",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"WayNode",
"waynode",
":",
"way",
".",
"getWayNodes",
"(",
")",
")",
"{",
"// TODO adjust interface to support a method getWayNodes()",
"waynodes",
"[",
"i",
"]",
"=",
"resolver",
".",
"getNode",
"(",
"waynode",
".",
"getNodeId",
"(",
")",
")",
";",
"if",
"(",
"waynodes",
"[",
"i",
"]",
"==",
"null",
")",
"{",
"validWay",
"=",
"false",
";",
"LOGGER",
".",
"finer",
"(",
"\"unknown way node: \"",
"+",
"waynode",
".",
"getNodeId",
"(",
")",
"+",
"\" in way \"",
"+",
"way",
".",
"getId",
"(",
")",
")",
";",
"}",
"i",
"++",
";",
"}",
"// for a valid way all way nodes must be existent in the input data",
"if",
"(",
"validWay",
")",
"{",
"// mark the way as polygon if the first and the last way node are the same",
"// and if the way has at least 4 way nodes",
"byte",
"shape",
"=",
"LINE",
";",
"if",
"(",
"waynodes",
"[",
"0",
"]",
".",
"getId",
"(",
")",
"==",
"waynodes",
"[",
"waynodes",
".",
"length",
"-",
"1",
"]",
".",
"getId",
"(",
")",
")",
"{",
"if",
"(",
"waynodes",
".",
"length",
">=",
"GeoUtils",
".",
"MIN_NODES_POLYGON",
")",
"{",
"if",
"(",
"OSMUtils",
".",
"isArea",
"(",
"way",
")",
")",
"{",
"shape",
"=",
"SIMPLE_POLYGON",
";",
"}",
"}",
"else",
"{",
"LOGGER",
".",
"finer",
"(",
"\"Found closed polygon with fewer than 4 way nodes. Way-id: \"",
"+",
"way",
".",
"getId",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"}",
"return",
"new",
"TDWay",
"(",
"way",
".",
"getId",
"(",
")",
",",
"ster",
".",
"getLayer",
"(",
")",
",",
"ster",
".",
"getName",
"(",
")",
",",
"ster",
".",
"getHousenumber",
"(",
")",
",",
"ster",
".",
"getRef",
"(",
")",
",",
"knownWayTags",
",",
"shape",
",",
"waynodes",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Creates a new TDWay from an osmosis way entity using the given NodeResolver.
@param way the way
@param resolver the resolver
@param preferredLanguages the preferred language(s) or null if no preference
@return a new TDWay if it is valid, null otherwise | [
"Creates",
"a",
"new",
"TDWay",
"from",
"an",
"osmosis",
"way",
"entity",
"using",
"the",
"given",
"NodeResolver",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/TDWay.java#L59-L104 |
28,421 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/TDWay.java | TDWay.mergeRelationInformation | public void mergeRelationInformation(TDRelation relation) {
if (relation.hasTags()) {
addTags(relation.getTags());
}
if (getName() == null && relation.getName() != null) {
setName(relation.getName());
}
if (getRef() == null && relation.getRef() != null) {
setRef(relation.getRef());
}
} | java | public void mergeRelationInformation(TDRelation relation) {
if (relation.hasTags()) {
addTags(relation.getTags());
}
if (getName() == null && relation.getName() != null) {
setName(relation.getName());
}
if (getRef() == null && relation.getRef() != null) {
setRef(relation.getRef());
}
} | [
"public",
"void",
"mergeRelationInformation",
"(",
"TDRelation",
"relation",
")",
"{",
"if",
"(",
"relation",
".",
"hasTags",
"(",
")",
")",
"{",
"addTags",
"(",
"relation",
".",
"getTags",
"(",
")",
")",
";",
"}",
"if",
"(",
"getName",
"(",
")",
"==",
"null",
"&&",
"relation",
".",
"getName",
"(",
")",
"!=",
"null",
")",
"{",
"setName",
"(",
"relation",
".",
"getName",
"(",
")",
")",
";",
"}",
"if",
"(",
"getRef",
"(",
")",
"==",
"null",
"&&",
"relation",
".",
"getRef",
"(",
")",
"!=",
"null",
")",
"{",
"setRef",
"(",
"relation",
".",
"getRef",
"(",
")",
")",
";",
"}",
"}"
] | Merges tags from a relation with the tags of this way and puts the result into the way tags of this way.
@param relation the relation | [
"Merges",
"tags",
"from",
"a",
"relation",
"with",
"the",
"tags",
"of",
"this",
"way",
"and",
"puts",
"the",
"result",
"into",
"the",
"way",
"tags",
"of",
"this",
"way",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/TDWay.java#L351-L361 |
28,422 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/TDNode.java | TDNode.fromNode | public static TDNode fromNode(Node node, List<String> preferredLanguages) {
SpecialTagExtractionResult ster = OSMUtils.extractSpecialFields(node, preferredLanguages);
Map<Short, Object> knownWayTags = OSMUtils.extractKnownPOITags(node);
return new TDNode(node.getId(), LatLongUtils.degreesToMicrodegrees(node.getLatitude()),
LatLongUtils.degreesToMicrodegrees(node.getLongitude()), ster.getElevation(), ster.getLayer(),
ster.getHousenumber(), ster.getName(), knownWayTags);
} | java | public static TDNode fromNode(Node node, List<String> preferredLanguages) {
SpecialTagExtractionResult ster = OSMUtils.extractSpecialFields(node, preferredLanguages);
Map<Short, Object> knownWayTags = OSMUtils.extractKnownPOITags(node);
return new TDNode(node.getId(), LatLongUtils.degreesToMicrodegrees(node.getLatitude()),
LatLongUtils.degreesToMicrodegrees(node.getLongitude()), ster.getElevation(), ster.getLayer(),
ster.getHousenumber(), ster.getName(), knownWayTags);
} | [
"public",
"static",
"TDNode",
"fromNode",
"(",
"Node",
"node",
",",
"List",
"<",
"String",
">",
"preferredLanguages",
")",
"{",
"SpecialTagExtractionResult",
"ster",
"=",
"OSMUtils",
".",
"extractSpecialFields",
"(",
"node",
",",
"preferredLanguages",
")",
";",
"Map",
"<",
"Short",
",",
"Object",
">",
"knownWayTags",
"=",
"OSMUtils",
".",
"extractKnownPOITags",
"(",
"node",
")",
";",
"return",
"new",
"TDNode",
"(",
"node",
".",
"getId",
"(",
")",
",",
"LatLongUtils",
".",
"degreesToMicrodegrees",
"(",
"node",
".",
"getLatitude",
"(",
")",
")",
",",
"LatLongUtils",
".",
"degreesToMicrodegrees",
"(",
"node",
".",
"getLongitude",
"(",
")",
")",
",",
"ster",
".",
"getElevation",
"(",
")",
",",
"ster",
".",
"getLayer",
"(",
")",
",",
"ster",
".",
"getHousenumber",
"(",
")",
",",
"ster",
".",
"getName",
"(",
")",
",",
"knownWayTags",
")",
";",
"}"
] | Constructs a new TDNode from a given osmosis node entity. Checks the validity of the entity.
@param node the osmosis entity
@param preferredLanguages the preferred language(s) or null if no preference
@return a new TDNode | [
"Constructs",
"a",
"new",
"TDNode",
"from",
"a",
"given",
"osmosis",
"node",
"entity",
".",
"Checks",
"the",
"validity",
"of",
"the",
"entity",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/TDNode.java#L42-L49 |
28,423 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/RenderContext.java | RenderContext.setScaleStrokeWidth | private void setScaleStrokeWidth(byte zoomLevel) {
int zoomLevelDiff = Math.max(zoomLevel - STROKE_MIN_ZOOM_LEVEL, 0);
this.renderTheme.scaleStrokeWidth((float) Math.pow(STROKE_INCREASE, zoomLevelDiff), this.rendererJob.tile.zoomLevel);
} | java | private void setScaleStrokeWidth(byte zoomLevel) {
int zoomLevelDiff = Math.max(zoomLevel - STROKE_MIN_ZOOM_LEVEL, 0);
this.renderTheme.scaleStrokeWidth((float) Math.pow(STROKE_INCREASE, zoomLevelDiff), this.rendererJob.tile.zoomLevel);
} | [
"private",
"void",
"setScaleStrokeWidth",
"(",
"byte",
"zoomLevel",
")",
"{",
"int",
"zoomLevelDiff",
"=",
"Math",
".",
"max",
"(",
"zoomLevel",
"-",
"STROKE_MIN_ZOOM_LEVEL",
",",
"0",
")",
";",
"this",
".",
"renderTheme",
".",
"scaleStrokeWidth",
"(",
"(",
"float",
")",
"Math",
".",
"pow",
"(",
"STROKE_INCREASE",
",",
"zoomLevelDiff",
")",
",",
"this",
".",
"rendererJob",
".",
"tile",
".",
"zoomLevel",
")",
";",
"}"
] | Sets the scale stroke factor for the given zoom level.
@param zoomLevel the zoom level for which the scale stroke factor should be set. | [
"Sets",
"the",
"scale",
"stroke",
"factor",
"for",
"the",
"given",
"zoom",
"level",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/RenderContext.java#L108-L111 |
28,424 | mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java | MapFile.closeFileChannel | private void closeFileChannel() {
try {
if (this.databaseIndexCache != null) {
this.databaseIndexCache.destroy();
}
if (this.inputChannel != null) {
this.inputChannel.close();
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
} | java | private void closeFileChannel() {
try {
if (this.databaseIndexCache != null) {
this.databaseIndexCache.destroy();
}
if (this.inputChannel != null) {
this.inputChannel.close();
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
} | [
"private",
"void",
"closeFileChannel",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"this",
".",
"databaseIndexCache",
"!=",
"null",
")",
"{",
"this",
".",
"databaseIndexCache",
".",
"destroy",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"inputChannel",
"!=",
"null",
")",
"{",
"this",
".",
"inputChannel",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}"
] | Closes the map file channel and destroys all internal caches.
Has no effect if no map file channel is currently opened. | [
"Closes",
"the",
"map",
"file",
"channel",
"and",
"destroys",
"all",
"internal",
"caches",
".",
"Has",
"no",
"effect",
"if",
"no",
"map",
"file",
"channel",
"is",
"currently",
"opened",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java#L316-L327 |
28,425 | mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java | MapFile.processBlockSignature | private boolean processBlockSignature(ReadBuffer readBuffer) {
if (this.mapFileHeader.getMapFileInfo().debugFile) {
// get and check the block signature
String signatureBlock = readBuffer.readUTF8EncodedString(SIGNATURE_LENGTH_BLOCK);
if (!signatureBlock.startsWith("###TileStart")) {
LOGGER.warning("invalid block signature: " + signatureBlock);
return false;
}
}
return true;
} | java | private boolean processBlockSignature(ReadBuffer readBuffer) {
if (this.mapFileHeader.getMapFileInfo().debugFile) {
// get and check the block signature
String signatureBlock = readBuffer.readUTF8EncodedString(SIGNATURE_LENGTH_BLOCK);
if (!signatureBlock.startsWith("###TileStart")) {
LOGGER.warning("invalid block signature: " + signatureBlock);
return false;
}
}
return true;
} | [
"private",
"boolean",
"processBlockSignature",
"(",
"ReadBuffer",
"readBuffer",
")",
"{",
"if",
"(",
"this",
".",
"mapFileHeader",
".",
"getMapFileInfo",
"(",
")",
".",
"debugFile",
")",
"{",
"// get and check the block signature",
"String",
"signatureBlock",
"=",
"readBuffer",
".",
"readUTF8EncodedString",
"(",
"SIGNATURE_LENGTH_BLOCK",
")",
";",
"if",
"(",
"!",
"signatureBlock",
".",
"startsWith",
"(",
"\"###TileStart\"",
")",
")",
"{",
"LOGGER",
".",
"warning",
"(",
"\"invalid block signature: \"",
"+",
"signatureBlock",
")",
";",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Processes the block signature, if present.
@return true if the block signature could be processed successfully, false otherwise. | [
"Processes",
"the",
"block",
"signature",
"if",
"present",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java#L502-L512 |
28,426 | mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java | MapFile.readLabels | @Override
public MapReadResult readLabels(Tile tile) {
return readMapData(tile, tile, Selector.LABELS);
} | java | @Override
public MapReadResult readLabels(Tile tile) {
return readMapData(tile, tile, Selector.LABELS);
} | [
"@",
"Override",
"public",
"MapReadResult",
"readLabels",
"(",
"Tile",
"tile",
")",
"{",
"return",
"readMapData",
"(",
"tile",
",",
"tile",
",",
"Selector",
".",
"LABELS",
")",
";",
"}"
] | Reads only labels for tile.
@param tile tile for which data is requested.
@return label data for the tile. | [
"Reads",
"only",
"labels",
"for",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java#L837-L840 |
28,427 | mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java | MapFile.readMapData | @Override
public MapReadResult readMapData(Tile tile) {
return readMapData(tile, tile, Selector.ALL);
} | java | @Override
public MapReadResult readMapData(Tile tile) {
return readMapData(tile, tile, Selector.ALL);
} | [
"@",
"Override",
"public",
"MapReadResult",
"readMapData",
"(",
"Tile",
"tile",
")",
"{",
"return",
"readMapData",
"(",
"tile",
",",
"tile",
",",
"Selector",
".",
"ALL",
")",
";",
"}"
] | Reads all map data for the area covered by the given tile at the tile zoom level.
@param tile defines area and zoom level of read map data.
@return the read map data. | [
"Reads",
"all",
"map",
"data",
"for",
"the",
"area",
"covered",
"by",
"the",
"given",
"tile",
"at",
"the",
"tile",
"zoom",
"level",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java#L862-L865 |
28,428 | mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java | MapFile.readPoiData | @Override
public MapReadResult readPoiData(Tile tile) {
return readMapData(tile, tile, Selector.POIS);
} | java | @Override
public MapReadResult readPoiData(Tile tile) {
return readMapData(tile, tile, Selector.POIS);
} | [
"@",
"Override",
"public",
"MapReadResult",
"readPoiData",
"(",
"Tile",
"tile",
")",
"{",
"return",
"readMapData",
"(",
"tile",
",",
"tile",
",",
"Selector",
".",
"POIS",
")",
";",
"}"
] | Reads only POI data for tile.
@param tile tile for which data is requested.
@return POI data for the tile. | [
"Reads",
"only",
"POI",
"data",
"for",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java#L937-L940 |
28,429 | mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java | MapFile.readPoiData | @Override
public MapReadResult readPoiData(Tile upperLeft, Tile lowerRight) {
return readMapData(upperLeft, lowerRight, Selector.POIS);
} | java | @Override
public MapReadResult readPoiData(Tile upperLeft, Tile lowerRight) {
return readMapData(upperLeft, lowerRight, Selector.POIS);
} | [
"@",
"Override",
"public",
"MapReadResult",
"readPoiData",
"(",
"Tile",
"upperLeft",
",",
"Tile",
"lowerRight",
")",
"{",
"return",
"readMapData",
"(",
"upperLeft",
",",
"lowerRight",
",",
"Selector",
".",
"POIS",
")",
";",
"}"
] | Reads POI data for an area defined by the tile in the upper left and the tile in
the lower right corner.
This implementation takes the data storage of a MapFile into account for greater efficiency.
@param upperLeft tile that defines the upper left corner of the requested area.
@param lowerRight tile that defines the lower right corner of the requested area.
@return map data for the tile. | [
"Reads",
"POI",
"data",
"for",
"an",
"area",
"defined",
"by",
"the",
"tile",
"in",
"the",
"upper",
"left",
"and",
"the",
"tile",
"in",
"the",
"lower",
"right",
"corner",
".",
"This",
"implementation",
"takes",
"the",
"data",
"storage",
"of",
"a",
"MapFile",
"into",
"account",
"for",
"greater",
"efficiency",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/MapFile.java#L951-L954 |
28,430 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/cluster/Cluster.java | Cluster.addItem | public synchronized void addItem(T item) {
synchronized (items) {
items.add(item);
}
// clusterMarker.setMarkerBitmap();
if (center == null) {
center = item.getLatLong();
} else {
// computing the centroid
double lat = 0, lon = 0;
int n = 0;
synchronized (items) {
for (T object : items) {
if (object == null) {
throw new NullPointerException("object == null");
}
if (object.getLatLong() == null) {
throw new NullPointerException("object.getLatLong() == null");
}
lat += object.getLatLong().latitude;
lon += object.getLatLong().longitude;
n++;
}
}
center = new LatLong(lat / n, lon / n);
}
} | java | public synchronized void addItem(T item) {
synchronized (items) {
items.add(item);
}
// clusterMarker.setMarkerBitmap();
if (center == null) {
center = item.getLatLong();
} else {
// computing the centroid
double lat = 0, lon = 0;
int n = 0;
synchronized (items) {
for (T object : items) {
if (object == null) {
throw new NullPointerException("object == null");
}
if (object.getLatLong() == null) {
throw new NullPointerException("object.getLatLong() == null");
}
lat += object.getLatLong().latitude;
lon += object.getLatLong().longitude;
n++;
}
}
center = new LatLong(lat / n, lon / n);
}
} | [
"public",
"synchronized",
"void",
"addItem",
"(",
"T",
"item",
")",
"{",
"synchronized",
"(",
"items",
")",
"{",
"items",
".",
"add",
"(",
"item",
")",
";",
"}",
"// clusterMarker.setMarkerBitmap();",
"if",
"(",
"center",
"==",
"null",
")",
"{",
"center",
"=",
"item",
".",
"getLatLong",
"(",
")",
";",
"}",
"else",
"{",
"// computing the centroid",
"double",
"lat",
"=",
"0",
",",
"lon",
"=",
"0",
";",
"int",
"n",
"=",
"0",
";",
"synchronized",
"(",
"items",
")",
"{",
"for",
"(",
"T",
"object",
":",
"items",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"object == null\"",
")",
";",
"}",
"if",
"(",
"object",
".",
"getLatLong",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"object.getLatLong() == null\"",
")",
";",
"}",
"lat",
"+=",
"object",
".",
"getLatLong",
"(",
")",
".",
"latitude",
";",
"lon",
"+=",
"object",
".",
"getLatLong",
"(",
")",
".",
"longitude",
";",
"n",
"++",
";",
"}",
"}",
"center",
"=",
"new",
"LatLong",
"(",
"lat",
"/",
"n",
",",
"lon",
"/",
"n",
")",
";",
"}",
"}"
] | add item to cluster object
@param item GeoItem object to be added. | [
"add",
"item",
"to",
"cluster",
"object"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/cluster/Cluster.java#L73-L99 |
28,431 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/cluster/Cluster.java | Cluster.clear | public void clear() {
if (clusterMarker != null) {
Layers mapOverlays = clusterManager.getMapView().getLayerManager().getLayers();
if (mapOverlays.contains(clusterMarker)) {
mapOverlays.remove(clusterMarker);
}
clusterManager = null;
clusterMarker = null;
}
synchronized (items) {
items.clear();
}
} | java | public void clear() {
if (clusterMarker != null) {
Layers mapOverlays = clusterManager.getMapView().getLayerManager().getLayers();
if (mapOverlays.contains(clusterMarker)) {
mapOverlays.remove(clusterMarker);
}
clusterManager = null;
clusterMarker = null;
}
synchronized (items) {
items.clear();
}
} | [
"public",
"void",
"clear",
"(",
")",
"{",
"if",
"(",
"clusterMarker",
"!=",
"null",
")",
"{",
"Layers",
"mapOverlays",
"=",
"clusterManager",
".",
"getMapView",
"(",
")",
".",
"getLayerManager",
"(",
")",
".",
"getLayers",
"(",
")",
";",
"if",
"(",
"mapOverlays",
".",
"contains",
"(",
"clusterMarker",
")",
")",
"{",
"mapOverlays",
".",
"remove",
"(",
"clusterMarker",
")",
";",
"}",
"clusterManager",
"=",
"null",
";",
"clusterMarker",
"=",
"null",
";",
"}",
"synchronized",
"(",
"items",
")",
"{",
"items",
".",
"clear",
"(",
")",
";",
"}",
"}"
] | clears cluster object and removes the cluster from the layers collection. | [
"clears",
"cluster",
"object",
"and",
"removes",
"the",
"cluster",
"from",
"the",
"layers",
"collection",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/cluster/Cluster.java#L124-L136 |
28,432 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/cluster/Cluster.java | Cluster.redraw | public void redraw() {
Layers mapOverlays = clusterManager.getMapView().getLayerManager().getLayers();
if (clusterMarker != null && !clusterManager.getCurBounds().contains(center)
&& mapOverlays.contains(clusterMarker)) {
mapOverlays.remove(clusterMarker);
return;
}
if (clusterMarker != null
&& mapOverlays.size() > 0
&& !mapOverlays.contains(clusterMarker)
&& !clusterManager.isClustering) {
mapOverlays.add(1, clusterMarker);
}
} | java | public void redraw() {
Layers mapOverlays = clusterManager.getMapView().getLayerManager().getLayers();
if (clusterMarker != null && !clusterManager.getCurBounds().contains(center)
&& mapOverlays.contains(clusterMarker)) {
mapOverlays.remove(clusterMarker);
return;
}
if (clusterMarker != null
&& mapOverlays.size() > 0
&& !mapOverlays.contains(clusterMarker)
&& !clusterManager.isClustering) {
mapOverlays.add(1, clusterMarker);
}
} | [
"public",
"void",
"redraw",
"(",
")",
"{",
"Layers",
"mapOverlays",
"=",
"clusterManager",
".",
"getMapView",
"(",
")",
".",
"getLayerManager",
"(",
")",
".",
"getLayers",
"(",
")",
";",
"if",
"(",
"clusterMarker",
"!=",
"null",
"&&",
"!",
"clusterManager",
".",
"getCurBounds",
"(",
")",
".",
"contains",
"(",
"center",
")",
"&&",
"mapOverlays",
".",
"contains",
"(",
"clusterMarker",
")",
")",
"{",
"mapOverlays",
".",
"remove",
"(",
"clusterMarker",
")",
";",
"return",
";",
"}",
"if",
"(",
"clusterMarker",
"!=",
"null",
"&&",
"mapOverlays",
".",
"size",
"(",
")",
">",
"0",
"&&",
"!",
"mapOverlays",
".",
"contains",
"(",
"clusterMarker",
")",
"&&",
"!",
"clusterManager",
".",
"isClustering",
")",
"{",
"mapOverlays",
".",
"add",
"(",
"1",
",",
"clusterMarker",
")",
";",
"}",
"}"
] | add the ClusterMarker to the Layers if is within Viewport, otherwise remove. | [
"add",
"the",
"ClusterMarker",
"to",
"the",
"Layers",
"if",
"is",
"within",
"Viewport",
"otherwise",
"remove",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/cluster/Cluster.java#L141-L154 |
28,433 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/GeometryUtils.java | GeometryUtils.calculateCenterOfBoundingBox | static Point calculateCenterOfBoundingBox(Point[] coordinates) {
double pointXMin = coordinates[0].x;
double pointXMax = coordinates[0].x;
double pointYMin = coordinates[0].y;
double pointYMax = coordinates[0].y;
for (Point immutablePoint : coordinates) {
if (immutablePoint.x < pointXMin) {
pointXMin = immutablePoint.x;
} else if (immutablePoint.x > pointXMax) {
pointXMax = immutablePoint.x;
}
if (immutablePoint.y < pointYMin) {
pointYMin = immutablePoint.y;
} else if (immutablePoint.y > pointYMax) {
pointYMax = immutablePoint.y;
}
}
return new Point((pointXMin + pointXMax) / 2, (pointYMax + pointYMin) / 2);
} | java | static Point calculateCenterOfBoundingBox(Point[] coordinates) {
double pointXMin = coordinates[0].x;
double pointXMax = coordinates[0].x;
double pointYMin = coordinates[0].y;
double pointYMax = coordinates[0].y;
for (Point immutablePoint : coordinates) {
if (immutablePoint.x < pointXMin) {
pointXMin = immutablePoint.x;
} else if (immutablePoint.x > pointXMax) {
pointXMax = immutablePoint.x;
}
if (immutablePoint.y < pointYMin) {
pointYMin = immutablePoint.y;
} else if (immutablePoint.y > pointYMax) {
pointYMax = immutablePoint.y;
}
}
return new Point((pointXMin + pointXMax) / 2, (pointYMax + pointYMin) / 2);
} | [
"static",
"Point",
"calculateCenterOfBoundingBox",
"(",
"Point",
"[",
"]",
"coordinates",
")",
"{",
"double",
"pointXMin",
"=",
"coordinates",
"[",
"0",
"]",
".",
"x",
";",
"double",
"pointXMax",
"=",
"coordinates",
"[",
"0",
"]",
".",
"x",
";",
"double",
"pointYMin",
"=",
"coordinates",
"[",
"0",
"]",
".",
"y",
";",
"double",
"pointYMax",
"=",
"coordinates",
"[",
"0",
"]",
".",
"y",
";",
"for",
"(",
"Point",
"immutablePoint",
":",
"coordinates",
")",
"{",
"if",
"(",
"immutablePoint",
".",
"x",
"<",
"pointXMin",
")",
"{",
"pointXMin",
"=",
"immutablePoint",
".",
"x",
";",
"}",
"else",
"if",
"(",
"immutablePoint",
".",
"x",
">",
"pointXMax",
")",
"{",
"pointXMax",
"=",
"immutablePoint",
".",
"x",
";",
"}",
"if",
"(",
"immutablePoint",
".",
"y",
"<",
"pointYMin",
")",
"{",
"pointYMin",
"=",
"immutablePoint",
".",
"y",
";",
"}",
"else",
"if",
"(",
"immutablePoint",
".",
"y",
">",
"pointYMax",
")",
"{",
"pointYMax",
"=",
"immutablePoint",
".",
"y",
";",
"}",
"}",
"return",
"new",
"Point",
"(",
"(",
"pointXMin",
"+",
"pointXMax",
")",
"/",
"2",
",",
"(",
"pointYMax",
"+",
"pointYMin",
")",
"/",
"2",
")",
";",
"}"
] | Calculates the center of the minimum bounding rectangle for the given coordinates.
@param coordinates the coordinates for which calculation should be done.
@return the center coordinates of the minimum bounding rectangle. | [
"Calculates",
"the",
"center",
"of",
"the",
"minimum",
"bounding",
"rectangle",
"for",
"the",
"given",
"coordinates",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/renderer/GeometryUtils.java#L26-L47 |
28,434 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/ZoomIntervalConfiguration.java | ZoomIntervalConfiguration.fromString | public static ZoomIntervalConfiguration fromString(String confString) {
String[] splitted = confString.split(",");
if (splitted.length % 3 != 0) {
throw new IllegalArgumentException(
"invalid zoom interval configuration, amount of comma-separated values must be a multiple of 3");
}
byte[][] intervals = new byte[splitted.length / 3][3];
for (int i = 0; i < intervals.length; i++) {
intervals[i][0] = Byte.parseByte(splitted[i * 3]);
intervals[i][1] = Byte.parseByte(splitted[i * 3 + 1]);
intervals[i][2] = Byte.parseByte(splitted[i * 3 + 2]);
}
return ZoomIntervalConfiguration.newInstance(intervals);
} | java | public static ZoomIntervalConfiguration fromString(String confString) {
String[] splitted = confString.split(",");
if (splitted.length % 3 != 0) {
throw new IllegalArgumentException(
"invalid zoom interval configuration, amount of comma-separated values must be a multiple of 3");
}
byte[][] intervals = new byte[splitted.length / 3][3];
for (int i = 0; i < intervals.length; i++) {
intervals[i][0] = Byte.parseByte(splitted[i * 3]);
intervals[i][1] = Byte.parseByte(splitted[i * 3 + 1]);
intervals[i][2] = Byte.parseByte(splitted[i * 3 + 2]);
}
return ZoomIntervalConfiguration.newInstance(intervals);
} | [
"public",
"static",
"ZoomIntervalConfiguration",
"fromString",
"(",
"String",
"confString",
")",
"{",
"String",
"[",
"]",
"splitted",
"=",
"confString",
".",
"split",
"(",
"\",\"",
")",
";",
"if",
"(",
"splitted",
".",
"length",
"%",
"3",
"!=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"invalid zoom interval configuration, amount of comma-separated values must be a multiple of 3\"",
")",
";",
"}",
"byte",
"[",
"]",
"[",
"]",
"intervals",
"=",
"new",
"byte",
"[",
"splitted",
".",
"length",
"/",
"3",
"]",
"[",
"3",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"intervals",
".",
"length",
";",
"i",
"++",
")",
"{",
"intervals",
"[",
"i",
"]",
"[",
"0",
"]",
"=",
"Byte",
".",
"parseByte",
"(",
"splitted",
"[",
"i",
"*",
"3",
"]",
")",
";",
"intervals",
"[",
"i",
"]",
"[",
"1",
"]",
"=",
"Byte",
".",
"parseByte",
"(",
"splitted",
"[",
"i",
"*",
"3",
"+",
"1",
"]",
")",
";",
"intervals",
"[",
"i",
"]",
"[",
"2",
"]",
"=",
"Byte",
".",
"parseByte",
"(",
"splitted",
"[",
"i",
"*",
"3",
"+",
"2",
"]",
")",
";",
"}",
"return",
"ZoomIntervalConfiguration",
".",
"newInstance",
"(",
"intervals",
")",
";",
"}"
] | Create a new ZoomIntervalConfiguration from the given string representation. Checks for validity.
@param confString the string representation of a zoom interval configuration
@return a new zoom interval configuration | [
"Create",
"a",
"new",
"ZoomIntervalConfiguration",
"from",
"the",
"given",
"string",
"representation",
".",
"Checks",
"for",
"validity",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/ZoomIntervalConfiguration.java#L29-L43 |
28,435 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/util/WorkingSetCache.java | WorkingSetCache.setWorkingSet | public void setWorkingSet(Set<K> workingSet) {
synchronized(workingSet) {
for (K key : workingSet) {
this.get(key);
}
}
} | java | public void setWorkingSet(Set<K> workingSet) {
synchronized(workingSet) {
for (K key : workingSet) {
this.get(key);
}
}
} | [
"public",
"void",
"setWorkingSet",
"(",
"Set",
"<",
"K",
">",
"workingSet",
")",
"{",
"synchronized",
"(",
"workingSet",
")",
"{",
"for",
"(",
"K",
"key",
":",
"workingSet",
")",
"{",
"this",
".",
"get",
"(",
"key",
")",
";",
"}",
"}",
"}"
] | Sets the current working set, ensuring that elements in this working set
will not be ejected in the near future.
@param workingSet set of K that makes up the current working set. | [
"Sets",
"the",
"current",
"working",
"set",
"ensuring",
"that",
"elements",
"in",
"this",
"working",
"set",
"will",
"not",
"be",
"ejected",
"in",
"the",
"near",
"future",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/util/WorkingSetCache.java#L40-L46 |
28,436 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/graphics/GraphicUtils.java | GraphicUtils.filterColor | public static int filterColor(int color, Filter filter) {
if (filter == Filter.NONE) {
return color;
}
int a = color >>> 24;
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
switch (filter) {
case GRAYSCALE:
r = g = b = (int) (0.213f * r + 0.715f * g + 0.072f * b);
break;
case GRAYSCALE_INVERT:
r = g = b = 255 - (int) (0.213f * r + 0.715f * g + 0.072f * b);
break;
case INVERT:
r = 255 - r;
g = 255 - g;
b = 255 - b;
break;
}
return (a << 24) | (r << 16) | (g << 8) | b;
} | java | public static int filterColor(int color, Filter filter) {
if (filter == Filter.NONE) {
return color;
}
int a = color >>> 24;
int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF;
int b = color & 0xFF;
switch (filter) {
case GRAYSCALE:
r = g = b = (int) (0.213f * r + 0.715f * g + 0.072f * b);
break;
case GRAYSCALE_INVERT:
r = g = b = 255 - (int) (0.213f * r + 0.715f * g + 0.072f * b);
break;
case INVERT:
r = 255 - r;
g = 255 - g;
b = 255 - b;
break;
}
return (a << 24) | (r << 16) | (g << 8) | b;
} | [
"public",
"static",
"int",
"filterColor",
"(",
"int",
"color",
",",
"Filter",
"filter",
")",
"{",
"if",
"(",
"filter",
"==",
"Filter",
".",
"NONE",
")",
"{",
"return",
"color",
";",
"}",
"int",
"a",
"=",
"color",
">>>",
"24",
";",
"int",
"r",
"=",
"(",
"color",
">>",
"16",
")",
"&",
"0xFF",
";",
"int",
"g",
"=",
"(",
"color",
">>",
"8",
")",
"&",
"0xFF",
";",
"int",
"b",
"=",
"color",
"&",
"0xFF",
";",
"switch",
"(",
"filter",
")",
"{",
"case",
"GRAYSCALE",
":",
"r",
"=",
"g",
"=",
"b",
"=",
"(",
"int",
")",
"(",
"0.213f",
"*",
"r",
"+",
"0.715f",
"*",
"g",
"+",
"0.072f",
"*",
"b",
")",
";",
"break",
";",
"case",
"GRAYSCALE_INVERT",
":",
"r",
"=",
"g",
"=",
"b",
"=",
"255",
"-",
"(",
"int",
")",
"(",
"0.213f",
"*",
"r",
"+",
"0.715f",
"*",
"g",
"+",
"0.072f",
"*",
"b",
")",
";",
"break",
";",
"case",
"INVERT",
":",
"r",
"=",
"255",
"-",
"r",
";",
"g",
"=",
"255",
"-",
"g",
";",
"b",
"=",
"255",
"-",
"b",
";",
"break",
";",
"}",
"return",
"(",
"a",
"<<",
"24",
")",
"|",
"(",
"r",
"<<",
"16",
")",
"|",
"(",
"g",
"<<",
"8",
")",
"|",
"b",
";",
"}"
] | Color filtering.
@param color color value in layout 0xAARRGGBB.
@param filter filter to apply on the color.
@return the filtered color. | [
"Color",
"filtering",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/graphics/GraphicUtils.java#L30-L52 |
28,437 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/graphics/GraphicUtils.java | GraphicUtils.imageSize | public static float[] imageSize(float picWidth, float picHeight, float scaleFactor, int width, int height, int percent) {
float bitmapWidth = picWidth * scaleFactor;
float bitmapHeight = picHeight * scaleFactor;
float aspectRatio = picWidth / picHeight;
if (width != 0 && height != 0) {
// both width and height set, override any other setting
bitmapWidth = width;
bitmapHeight = height;
} else if (width == 0 && height != 0) {
// only width set, calculate from aspect ratio
bitmapWidth = height * aspectRatio;
bitmapHeight = height;
} else if (width != 0 && height == 0) {
// only height set, calculate from aspect ratio
bitmapHeight = width / aspectRatio;
bitmapWidth = width;
}
if (percent != 100) {
bitmapWidth *= percent / 100f;
bitmapHeight *= percent / 100f;
}
return new float[]{bitmapWidth, bitmapHeight};
} | java | public static float[] imageSize(float picWidth, float picHeight, float scaleFactor, int width, int height, int percent) {
float bitmapWidth = picWidth * scaleFactor;
float bitmapHeight = picHeight * scaleFactor;
float aspectRatio = picWidth / picHeight;
if (width != 0 && height != 0) {
// both width and height set, override any other setting
bitmapWidth = width;
bitmapHeight = height;
} else if (width == 0 && height != 0) {
// only width set, calculate from aspect ratio
bitmapWidth = height * aspectRatio;
bitmapHeight = height;
} else if (width != 0 && height == 0) {
// only height set, calculate from aspect ratio
bitmapHeight = width / aspectRatio;
bitmapWidth = width;
}
if (percent != 100) {
bitmapWidth *= percent / 100f;
bitmapHeight *= percent / 100f;
}
return new float[]{bitmapWidth, bitmapHeight};
} | [
"public",
"static",
"float",
"[",
"]",
"imageSize",
"(",
"float",
"picWidth",
",",
"float",
"picHeight",
",",
"float",
"scaleFactor",
",",
"int",
"width",
",",
"int",
"height",
",",
"int",
"percent",
")",
"{",
"float",
"bitmapWidth",
"=",
"picWidth",
"*",
"scaleFactor",
";",
"float",
"bitmapHeight",
"=",
"picHeight",
"*",
"scaleFactor",
";",
"float",
"aspectRatio",
"=",
"picWidth",
"/",
"picHeight",
";",
"if",
"(",
"width",
"!=",
"0",
"&&",
"height",
"!=",
"0",
")",
"{",
"// both width and height set, override any other setting",
"bitmapWidth",
"=",
"width",
";",
"bitmapHeight",
"=",
"height",
";",
"}",
"else",
"if",
"(",
"width",
"==",
"0",
"&&",
"height",
"!=",
"0",
")",
"{",
"// only width set, calculate from aspect ratio",
"bitmapWidth",
"=",
"height",
"*",
"aspectRatio",
";",
"bitmapHeight",
"=",
"height",
";",
"}",
"else",
"if",
"(",
"width",
"!=",
"0",
"&&",
"height",
"==",
"0",
")",
"{",
"// only height set, calculate from aspect ratio",
"bitmapHeight",
"=",
"width",
"/",
"aspectRatio",
";",
"bitmapWidth",
"=",
"width",
";",
"}",
"if",
"(",
"percent",
"!=",
"100",
")",
"{",
"bitmapWidth",
"*=",
"percent",
"/",
"100f",
";",
"bitmapHeight",
"*=",
"percent",
"/",
"100f",
";",
"}",
"return",
"new",
"float",
"[",
"]",
"{",
"bitmapWidth",
",",
"bitmapHeight",
"}",
";",
"}"
] | Given the original image size, as well as width, height, percent parameters,
can compute the final image size.
@param picWidth original image width
@param picHeight original image height
@param scaleFactor scale factor to screen DPI
@param width requested width (0: no change)
@param height requested height (0: no change)
@param percent requested scale percent (100: no change) | [
"Given",
"the",
"original",
"image",
"size",
"as",
"well",
"as",
"width",
"height",
"percent",
"parameters",
"can",
"compute",
"the",
"final",
"image",
"size",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/graphics/GraphicUtils.java#L73-L99 |
28,438 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/MapWriterConfiguration.java | MapWriterConfiguration.validate | public void validate() {
if (this.mapStartPosition != null && this.bboxConfiguration != null
&& !this.bboxConfiguration.contains(this.mapStartPosition)) {
throw new IllegalArgumentException(
"map start position is not valid, must be included in bounding box of the map, bbox: "
+ this.bboxConfiguration.toString() + " - map start position: "
+ this.mapStartPosition.toString());
}
} | java | public void validate() {
if (this.mapStartPosition != null && this.bboxConfiguration != null
&& !this.bboxConfiguration.contains(this.mapStartPosition)) {
throw new IllegalArgumentException(
"map start position is not valid, must be included in bounding box of the map, bbox: "
+ this.bboxConfiguration.toString() + " - map start position: "
+ this.mapStartPosition.toString());
}
} | [
"public",
"void",
"validate",
"(",
")",
"{",
"if",
"(",
"this",
".",
"mapStartPosition",
"!=",
"null",
"&&",
"this",
".",
"bboxConfiguration",
"!=",
"null",
"&&",
"!",
"this",
".",
"bboxConfiguration",
".",
"contains",
"(",
"this",
".",
"mapStartPosition",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"map start position is not valid, must be included in bounding box of the map, bbox: \"",
"+",
"this",
".",
"bboxConfiguration",
".",
"toString",
"(",
")",
"+",
"\" - map start position: \"",
"+",
"this",
".",
"mapStartPosition",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Validates this configuration.
@throws IllegalArgumentException thrown if configuration is invalid | [
"Validates",
"this",
"configuration",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/model/MapWriterConfiguration.java#L548-L556 |
28,439 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/GeoUtils.java | GeoUtils.clipToTile | public static Geometry clipToTile(TDWay way, Geometry geometry, TileCoordinate tileCoordinate,
int enlargementInMeters) {
Geometry tileBBJTS = null;
Geometry ret = null;
// create tile bounding box
tileBBJTS = tileToJTSGeometry(tileCoordinate.getX(), tileCoordinate.getY(), tileCoordinate.getZoomlevel(),
enlargementInMeters);
// clip the geometry by intersection with the bounding box of the tile
// may throw a TopologyException
try {
if (!geometry.isValid()) {
// this should stop the problem of non-noded intersections that trigger an error when
// clipping
LOGGER.warning("invalid geometry prior to tile clipping, trying to repair " + way.getId());
geometry = JTSUtils.repairInvalidPolygon(geometry);
if (!geometry.isValid()) {
LOGGER.warning("invalid geometry even after attempt to fix " + way.getId());
}
}
ret = tileBBJTS.intersection(geometry);
// according to Ludwig (see issue332) valid polygons may become invalid by clipping (at least
// in the Python shapely library
// we need to investigate this more closely and write approriate test cases
// for now, I check whether the resulting polygon is valid and if not try to repair it
if ((ret instanceof Polygon || ret instanceof MultiPolygon) && !ret.isValid()) {
LOGGER.warning("clipped way is not valid, trying to repair it: " + way.getId());
ret = JTSUtils.repairInvalidPolygon(ret);
if (ret == null) {
way.setInvalid(true);
LOGGER.warning("could not repair invalid polygon: " + way.getId());
}
}
} catch (TopologyException e) {
LOGGER.log(Level.WARNING, "JTS cannot clip way, not storing it in data file: " + way.getId(), e);
way.setInvalid(true);
return null;
}
return ret;
} | java | public static Geometry clipToTile(TDWay way, Geometry geometry, TileCoordinate tileCoordinate,
int enlargementInMeters) {
Geometry tileBBJTS = null;
Geometry ret = null;
// create tile bounding box
tileBBJTS = tileToJTSGeometry(tileCoordinate.getX(), tileCoordinate.getY(), tileCoordinate.getZoomlevel(),
enlargementInMeters);
// clip the geometry by intersection with the bounding box of the tile
// may throw a TopologyException
try {
if (!geometry.isValid()) {
// this should stop the problem of non-noded intersections that trigger an error when
// clipping
LOGGER.warning("invalid geometry prior to tile clipping, trying to repair " + way.getId());
geometry = JTSUtils.repairInvalidPolygon(geometry);
if (!geometry.isValid()) {
LOGGER.warning("invalid geometry even after attempt to fix " + way.getId());
}
}
ret = tileBBJTS.intersection(geometry);
// according to Ludwig (see issue332) valid polygons may become invalid by clipping (at least
// in the Python shapely library
// we need to investigate this more closely and write approriate test cases
// for now, I check whether the resulting polygon is valid and if not try to repair it
if ((ret instanceof Polygon || ret instanceof MultiPolygon) && !ret.isValid()) {
LOGGER.warning("clipped way is not valid, trying to repair it: " + way.getId());
ret = JTSUtils.repairInvalidPolygon(ret);
if (ret == null) {
way.setInvalid(true);
LOGGER.warning("could not repair invalid polygon: " + way.getId());
}
}
} catch (TopologyException e) {
LOGGER.log(Level.WARNING, "JTS cannot clip way, not storing it in data file: " + way.getId(), e);
way.setInvalid(true);
return null;
}
return ret;
} | [
"public",
"static",
"Geometry",
"clipToTile",
"(",
"TDWay",
"way",
",",
"Geometry",
"geometry",
",",
"TileCoordinate",
"tileCoordinate",
",",
"int",
"enlargementInMeters",
")",
"{",
"Geometry",
"tileBBJTS",
"=",
"null",
";",
"Geometry",
"ret",
"=",
"null",
";",
"// create tile bounding box",
"tileBBJTS",
"=",
"tileToJTSGeometry",
"(",
"tileCoordinate",
".",
"getX",
"(",
")",
",",
"tileCoordinate",
".",
"getY",
"(",
")",
",",
"tileCoordinate",
".",
"getZoomlevel",
"(",
")",
",",
"enlargementInMeters",
")",
";",
"// clip the geometry by intersection with the bounding box of the tile",
"// may throw a TopologyException",
"try",
"{",
"if",
"(",
"!",
"geometry",
".",
"isValid",
"(",
")",
")",
"{",
"// this should stop the problem of non-noded intersections that trigger an error when",
"// clipping",
"LOGGER",
".",
"warning",
"(",
"\"invalid geometry prior to tile clipping, trying to repair \"",
"+",
"way",
".",
"getId",
"(",
")",
")",
";",
"geometry",
"=",
"JTSUtils",
".",
"repairInvalidPolygon",
"(",
"geometry",
")",
";",
"if",
"(",
"!",
"geometry",
".",
"isValid",
"(",
")",
")",
"{",
"LOGGER",
".",
"warning",
"(",
"\"invalid geometry even after attempt to fix \"",
"+",
"way",
".",
"getId",
"(",
")",
")",
";",
"}",
"}",
"ret",
"=",
"tileBBJTS",
".",
"intersection",
"(",
"geometry",
")",
";",
"// according to Ludwig (see issue332) valid polygons may become invalid by clipping (at least",
"// in the Python shapely library",
"// we need to investigate this more closely and write approriate test cases",
"// for now, I check whether the resulting polygon is valid and if not try to repair it",
"if",
"(",
"(",
"ret",
"instanceof",
"Polygon",
"||",
"ret",
"instanceof",
"MultiPolygon",
")",
"&&",
"!",
"ret",
".",
"isValid",
"(",
")",
")",
"{",
"LOGGER",
".",
"warning",
"(",
"\"clipped way is not valid, trying to repair it: \"",
"+",
"way",
".",
"getId",
"(",
")",
")",
";",
"ret",
"=",
"JTSUtils",
".",
"repairInvalidPolygon",
"(",
"ret",
")",
";",
"if",
"(",
"ret",
"==",
"null",
")",
"{",
"way",
".",
"setInvalid",
"(",
"true",
")",
";",
"LOGGER",
".",
"warning",
"(",
"\"could not repair invalid polygon: \"",
"+",
"way",
".",
"getId",
"(",
")",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"TopologyException",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"JTS cannot clip way, not storing it in data file: \"",
"+",
"way",
".",
"getId",
"(",
")",
",",
"e",
")",
";",
"way",
".",
"setInvalid",
"(",
"true",
")",
";",
"return",
"null",
";",
"}",
"return",
"ret",
";",
"}"
] | Clips a geometry to a tile.
@param way the way
@param geometry the geometry
@param tileCoordinate the tile coordinate
@param enlargementInMeters the bounding box buffer
@return the clipped geometry | [
"Clips",
"a",
"geometry",
"to",
"a",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/GeoUtils.java#L84-L124 |
28,440 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/GeoUtils.java | GeoUtils.simplifyGeometry | public static Geometry simplifyGeometry(TDWay way, Geometry geometry, byte zoomlevel, int tileSize,
double simplificationFactor) {
Geometry ret = null;
Envelope bbox = geometry.getEnvelopeInternal();
// compute maximal absolute latitude (so that we don't need to care if we
// are on northern or southern hemisphere)
double latMax = Math.max(Math.abs(bbox.getMaxY()), Math.abs(bbox.getMinY()));
double deltaLat = deltaLat(simplificationFactor, latMax, zoomlevel, tileSize);
try {
ret = TopologyPreservingSimplifier.simplify(geometry, deltaLat);
} catch (TopologyException e) {
LOGGER.log(Level.FINE,
"JTS cannot simplify way due to an error, not simplifying way with id: " + way.getId(), e);
way.setInvalid(true);
return geometry;
}
return ret;
} | java | public static Geometry simplifyGeometry(TDWay way, Geometry geometry, byte zoomlevel, int tileSize,
double simplificationFactor) {
Geometry ret = null;
Envelope bbox = geometry.getEnvelopeInternal();
// compute maximal absolute latitude (so that we don't need to care if we
// are on northern or southern hemisphere)
double latMax = Math.max(Math.abs(bbox.getMaxY()), Math.abs(bbox.getMinY()));
double deltaLat = deltaLat(simplificationFactor, latMax, zoomlevel, tileSize);
try {
ret = TopologyPreservingSimplifier.simplify(geometry, deltaLat);
} catch (TopologyException e) {
LOGGER.log(Level.FINE,
"JTS cannot simplify way due to an error, not simplifying way with id: " + way.getId(), e);
way.setInvalid(true);
return geometry;
}
return ret;
} | [
"public",
"static",
"Geometry",
"simplifyGeometry",
"(",
"TDWay",
"way",
",",
"Geometry",
"geometry",
",",
"byte",
"zoomlevel",
",",
"int",
"tileSize",
",",
"double",
"simplificationFactor",
")",
"{",
"Geometry",
"ret",
"=",
"null",
";",
"Envelope",
"bbox",
"=",
"geometry",
".",
"getEnvelopeInternal",
"(",
")",
";",
"// compute maximal absolute latitude (so that we don't need to care if we",
"// are on northern or southern hemisphere)",
"double",
"latMax",
"=",
"Math",
".",
"max",
"(",
"Math",
".",
"abs",
"(",
"bbox",
".",
"getMaxY",
"(",
")",
")",
",",
"Math",
".",
"abs",
"(",
"bbox",
".",
"getMinY",
"(",
")",
")",
")",
";",
"double",
"deltaLat",
"=",
"deltaLat",
"(",
"simplificationFactor",
",",
"latMax",
",",
"zoomlevel",
",",
"tileSize",
")",
";",
"try",
"{",
"ret",
"=",
"TopologyPreservingSimplifier",
".",
"simplify",
"(",
"geometry",
",",
"deltaLat",
")",
";",
"}",
"catch",
"(",
"TopologyException",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"JTS cannot simplify way due to an error, not simplifying way with id: \"",
"+",
"way",
".",
"getId",
"(",
")",
",",
"e",
")",
";",
"way",
".",
"setInvalid",
"(",
"true",
")",
";",
"return",
"geometry",
";",
"}",
"return",
"ret",
";",
"}"
] | Simplifies a geometry using the Douglas Peucker algorithm.
@param way the way
@param geometry the geometry
@param zoomlevel the zoom level
@param simplificationFactor the simplification factor
@return the simplified geometry | [
"Simplifies",
"a",
"geometry",
"using",
"the",
"Douglas",
"Peucker",
"algorithm",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/GeoUtils.java#L319-L339 |
28,441 | mapsforge/mapsforge | mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/GeoUtils.java | GeoUtils.deltaLat | private static double deltaLat(double deltaPixel, double lat, byte zoom, int tileSize) {
long mapSize = MercatorProjection.getMapSize(zoom, tileSize);
double pixelY = MercatorProjection.latitudeToPixelY(lat, mapSize);
double lat2 = MercatorProjection.pixelYToLatitude(pixelY + deltaPixel, mapSize);
return Math.abs(lat2 - lat);
} | java | private static double deltaLat(double deltaPixel, double lat, byte zoom, int tileSize) {
long mapSize = MercatorProjection.getMapSize(zoom, tileSize);
double pixelY = MercatorProjection.latitudeToPixelY(lat, mapSize);
double lat2 = MercatorProjection.pixelYToLatitude(pixelY + deltaPixel, mapSize);
return Math.abs(lat2 - lat);
} | [
"private",
"static",
"double",
"deltaLat",
"(",
"double",
"deltaPixel",
",",
"double",
"lat",
",",
"byte",
"zoom",
",",
"int",
"tileSize",
")",
"{",
"long",
"mapSize",
"=",
"MercatorProjection",
".",
"getMapSize",
"(",
"zoom",
",",
"tileSize",
")",
";",
"double",
"pixelY",
"=",
"MercatorProjection",
".",
"latitudeToPixelY",
"(",
"lat",
",",
"mapSize",
")",
";",
"double",
"lat2",
"=",
"MercatorProjection",
".",
"pixelYToLatitude",
"(",
"pixelY",
"+",
"deltaPixel",
",",
"mapSize",
")",
";",
"return",
"Math",
".",
"abs",
"(",
"lat2",
"-",
"lat",
")",
";",
"}"
] | Computes the amount of latitude degrees for a given distance in pixel at a given zoom level. | [
"Computes",
"the",
"amount",
"of",
"latitude",
"degrees",
"for",
"a",
"given",
"distance",
"in",
"pixel",
"at",
"a",
"given",
"zoom",
"level",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-writer/src/main/java/org/mapsforge/map/writer/util/GeoUtils.java#L437-L443 |
28,442 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/model/MapViewPosition.java | MapViewPosition.moveCenterAndZoom | @Override
public void moveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff) {
moveCenterAndZoom(moveHorizontal, moveVertical, zoomLevelDiff, true);
} | java | @Override
public void moveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff) {
moveCenterAndZoom(moveHorizontal, moveVertical, zoomLevelDiff, true);
} | [
"@",
"Override",
"public",
"void",
"moveCenterAndZoom",
"(",
"double",
"moveHorizontal",
",",
"double",
"moveVertical",
",",
"byte",
"zoomLevelDiff",
")",
"{",
"moveCenterAndZoom",
"(",
"moveHorizontal",
",",
"moveVertical",
",",
"zoomLevelDiff",
",",
"true",
")",
";",
"}"
] | Animates the center position of the map by the given amount of pixels.
@param moveHorizontal the amount of pixels to move this MapViewPosition horizontally.
@param moveVertical the amount of pixels to move this MapViewPosition vertically.
@param zoomLevelDiff the difference in desired zoom level. | [
"Animates",
"the",
"center",
"position",
"of",
"the",
"map",
"by",
"the",
"given",
"amount",
"of",
"pixels",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/model/MapViewPosition.java#L304-L307 |
28,443 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/model/MapViewPosition.java | MapViewPosition.moveCenterAndZoom | public void moveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff, boolean animated) {
synchronized (this) {
long mapSize = MercatorProjection.getMapSize(this.zoomLevel, this.displayModel.getTileSize());
double pixelX = MercatorProjection.longitudeToPixelX(this.longitude, mapSize)
- moveHorizontal;
double pixelY = MercatorProjection.latitudeToPixelY(this.latitude, mapSize) - moveVertical;
pixelX = Math.min(Math.max(0, pixelX), mapSize);
pixelY = Math.min(Math.max(0, pixelY), mapSize);
double newLatitude = MercatorProjection.pixelYToLatitude(pixelY, mapSize);
double newLongitude = MercatorProjection.pixelXToLongitude(pixelX, mapSize);
setCenterInternal(newLatitude, newLongitude);
setZoomLevelInternal(this.zoomLevel + zoomLevelDiff, animated);
}
notifyObservers();
} | java | public void moveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff, boolean animated) {
synchronized (this) {
long mapSize = MercatorProjection.getMapSize(this.zoomLevel, this.displayModel.getTileSize());
double pixelX = MercatorProjection.longitudeToPixelX(this.longitude, mapSize)
- moveHorizontal;
double pixelY = MercatorProjection.latitudeToPixelY(this.latitude, mapSize) - moveVertical;
pixelX = Math.min(Math.max(0, pixelX), mapSize);
pixelY = Math.min(Math.max(0, pixelY), mapSize);
double newLatitude = MercatorProjection.pixelYToLatitude(pixelY, mapSize);
double newLongitude = MercatorProjection.pixelXToLongitude(pixelX, mapSize);
setCenterInternal(newLatitude, newLongitude);
setZoomLevelInternal(this.zoomLevel + zoomLevelDiff, animated);
}
notifyObservers();
} | [
"public",
"void",
"moveCenterAndZoom",
"(",
"double",
"moveHorizontal",
",",
"double",
"moveVertical",
",",
"byte",
"zoomLevelDiff",
",",
"boolean",
"animated",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"long",
"mapSize",
"=",
"MercatorProjection",
".",
"getMapSize",
"(",
"this",
".",
"zoomLevel",
",",
"this",
".",
"displayModel",
".",
"getTileSize",
"(",
")",
")",
";",
"double",
"pixelX",
"=",
"MercatorProjection",
".",
"longitudeToPixelX",
"(",
"this",
".",
"longitude",
",",
"mapSize",
")",
"-",
"moveHorizontal",
";",
"double",
"pixelY",
"=",
"MercatorProjection",
".",
"latitudeToPixelY",
"(",
"this",
".",
"latitude",
",",
"mapSize",
")",
"-",
"moveVertical",
";",
"pixelX",
"=",
"Math",
".",
"min",
"(",
"Math",
".",
"max",
"(",
"0",
",",
"pixelX",
")",
",",
"mapSize",
")",
";",
"pixelY",
"=",
"Math",
".",
"min",
"(",
"Math",
".",
"max",
"(",
"0",
",",
"pixelY",
")",
",",
"mapSize",
")",
";",
"double",
"newLatitude",
"=",
"MercatorProjection",
".",
"pixelYToLatitude",
"(",
"pixelY",
",",
"mapSize",
")",
";",
"double",
"newLongitude",
"=",
"MercatorProjection",
".",
"pixelXToLongitude",
"(",
"pixelX",
",",
"mapSize",
")",
";",
"setCenterInternal",
"(",
"newLatitude",
",",
"newLongitude",
")",
";",
"setZoomLevelInternal",
"(",
"this",
".",
"zoomLevel",
"+",
"zoomLevelDiff",
",",
"animated",
")",
";",
"}",
"notifyObservers",
"(",
")",
";",
"}"
] | Moves the center position of the map by the given amount of pixels.
@param moveHorizontal the amount of pixels to move this MapViewPosition horizontally.
@param moveVertical the amount of pixels to move this MapViewPosition vertically.
@param zoomLevelDiff the difference in desired zoom level.
@param animated whether the move should be animated. | [
"Moves",
"the",
"center",
"position",
"of",
"the",
"map",
"by",
"the",
"given",
"amount",
"of",
"pixels",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/model/MapViewPosition.java#L317-L333 |
28,444 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/model/MapViewPosition.java | MapViewPosition.setCenter | @Override
public void setCenter(LatLong latLong) {
synchronized (this) {
setCenterInternal(latLong.latitude, latLong.longitude);
}
notifyObservers();
} | java | @Override
public void setCenter(LatLong latLong) {
synchronized (this) {
setCenterInternal(latLong.latitude, latLong.longitude);
}
notifyObservers();
} | [
"@",
"Override",
"public",
"void",
"setCenter",
"(",
"LatLong",
"latLong",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"setCenterInternal",
"(",
"latLong",
".",
"latitude",
",",
"latLong",
".",
"longitude",
")",
";",
"}",
"notifyObservers",
"(",
")",
";",
"}"
] | Sets the new center position of the map. | [
"Sets",
"the",
"new",
"center",
"position",
"of",
"the",
"map",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/model/MapViewPosition.java#L360-L366 |
28,445 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/model/MapViewPosition.java | MapViewPosition.setMapPosition | @Override
public void setMapPosition(MapPosition mapPosition, boolean animated) {
synchronized (this) {
setCenterInternal(mapPosition.latLong.latitude, mapPosition.latLong.longitude);
setZoomLevelInternal(mapPosition.zoomLevel, animated);
}
notifyObservers();
} | java | @Override
public void setMapPosition(MapPosition mapPosition, boolean animated) {
synchronized (this) {
setCenterInternal(mapPosition.latLong.latitude, mapPosition.latLong.longitude);
setZoomLevelInternal(mapPosition.zoomLevel, animated);
}
notifyObservers();
} | [
"@",
"Override",
"public",
"void",
"setMapPosition",
"(",
"MapPosition",
"mapPosition",
",",
"boolean",
"animated",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"setCenterInternal",
"(",
"mapPosition",
".",
"latLong",
".",
"latitude",
",",
"mapPosition",
".",
"latLong",
".",
"longitude",
")",
";",
"setZoomLevelInternal",
"(",
"mapPosition",
".",
"zoomLevel",
",",
"animated",
")",
";",
"}",
"notifyObservers",
"(",
")",
";",
"}"
] | Sets the new center position and zoom level of the map. | [
"Sets",
"the",
"new",
"center",
"position",
"and",
"zoom",
"level",
"of",
"the",
"map",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/model/MapViewPosition.java#L392-L399 |
28,446 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/model/MapViewPosition.java | MapViewPosition.setZoomLevel | @Override
public void setZoomLevel(byte zoomLevel, boolean animated) {
if (zoomLevel < 0) {
throw new IllegalArgumentException("zoomLevel must not be negative: " + zoomLevel);
}
synchronized (this) {
setZoomLevelInternal(zoomLevel, animated);
}
notifyObservers();
} | java | @Override
public void setZoomLevel(byte zoomLevel, boolean animated) {
if (zoomLevel < 0) {
throw new IllegalArgumentException("zoomLevel must not be negative: " + zoomLevel);
}
synchronized (this) {
setZoomLevelInternal(zoomLevel, animated);
}
notifyObservers();
} | [
"@",
"Override",
"public",
"void",
"setZoomLevel",
"(",
"byte",
"zoomLevel",
",",
"boolean",
"animated",
")",
"{",
"if",
"(",
"zoomLevel",
"<",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"zoomLevel must not be negative: \"",
"+",
"zoomLevel",
")",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"setZoomLevelInternal",
"(",
"zoomLevel",
",",
"animated",
")",
";",
"}",
"notifyObservers",
"(",
")",
";",
"}"
] | Sets the new zoom level of the map
@param zoomLevel desired zoom level
@param animated true if the transition should be animated, false otherwise
@throws IllegalArgumentException if the zoom level is negative. | [
"Sets",
"the",
"new",
"zoom",
"level",
"of",
"the",
"map"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/model/MapViewPosition.java#L453-L462 |
28,447 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/scalebar/MapScaleBar.java | MapScaleBar.calculateScaleBarLengthAndValue | protected ScaleBarLengthAndValue calculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter) {
this.prevMapPosition = this.mapViewPosition.getMapPosition();
double groundResolution = MercatorProjection.calculateGroundResolution(this.prevMapPosition.latLong.latitude,
MercatorProjection.getMapSize(this.prevMapPosition.zoomLevel, this.displayModel.getTileSize()));
groundResolution = groundResolution / unitAdapter.getMeterRatio();
int[] scaleBarValues = unitAdapter.getScaleBarValues();
int scaleBarLength = 0;
int mapScaleValue = 0;
for (int scaleBarValue : scaleBarValues) {
mapScaleValue = scaleBarValue;
scaleBarLength = (int) (mapScaleValue / groundResolution);
if (scaleBarLength < (this.mapScaleBitmap.getWidth() - 10)) {
break;
}
}
return new ScaleBarLengthAndValue(scaleBarLength, mapScaleValue);
} | java | protected ScaleBarLengthAndValue calculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter) {
this.prevMapPosition = this.mapViewPosition.getMapPosition();
double groundResolution = MercatorProjection.calculateGroundResolution(this.prevMapPosition.latLong.latitude,
MercatorProjection.getMapSize(this.prevMapPosition.zoomLevel, this.displayModel.getTileSize()));
groundResolution = groundResolution / unitAdapter.getMeterRatio();
int[] scaleBarValues = unitAdapter.getScaleBarValues();
int scaleBarLength = 0;
int mapScaleValue = 0;
for (int scaleBarValue : scaleBarValues) {
mapScaleValue = scaleBarValue;
scaleBarLength = (int) (mapScaleValue / groundResolution);
if (scaleBarLength < (this.mapScaleBitmap.getWidth() - 10)) {
break;
}
}
return new ScaleBarLengthAndValue(scaleBarLength, mapScaleValue);
} | [
"protected",
"ScaleBarLengthAndValue",
"calculateScaleBarLengthAndValue",
"(",
"DistanceUnitAdapter",
"unitAdapter",
")",
"{",
"this",
".",
"prevMapPosition",
"=",
"this",
".",
"mapViewPosition",
".",
"getMapPosition",
"(",
")",
";",
"double",
"groundResolution",
"=",
"MercatorProjection",
".",
"calculateGroundResolution",
"(",
"this",
".",
"prevMapPosition",
".",
"latLong",
".",
"latitude",
",",
"MercatorProjection",
".",
"getMapSize",
"(",
"this",
".",
"prevMapPosition",
".",
"zoomLevel",
",",
"this",
".",
"displayModel",
".",
"getTileSize",
"(",
")",
")",
")",
";",
"groundResolution",
"=",
"groundResolution",
"/",
"unitAdapter",
".",
"getMeterRatio",
"(",
")",
";",
"int",
"[",
"]",
"scaleBarValues",
"=",
"unitAdapter",
".",
"getScaleBarValues",
"(",
")",
";",
"int",
"scaleBarLength",
"=",
"0",
";",
"int",
"mapScaleValue",
"=",
"0",
";",
"for",
"(",
"int",
"scaleBarValue",
":",
"scaleBarValues",
")",
"{",
"mapScaleValue",
"=",
"scaleBarValue",
";",
"scaleBarLength",
"=",
"(",
"int",
")",
"(",
"mapScaleValue",
"/",
"groundResolution",
")",
";",
"if",
"(",
"scaleBarLength",
"<",
"(",
"this",
".",
"mapScaleBitmap",
".",
"getWidth",
"(",
")",
"-",
"10",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"new",
"ScaleBarLengthAndValue",
"(",
"scaleBarLength",
",",
"mapScaleValue",
")",
";",
"}"
] | Calculates the required length and value of the scalebar
@param unitAdapter the DistanceUnitAdapter to calculate for
@return a {@link ScaleBarLengthAndValue} object containing the required scaleBarLength and scaleBarValue | [
"Calculates",
"the",
"required",
"length",
"and",
"value",
"of",
"the",
"scalebar"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/scalebar/MapScaleBar.java#L205-L225 |
28,448 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/scalebar/MapScaleBar.java | MapScaleBar.isRedrawNecessary | protected boolean isRedrawNecessary() {
if (this.redrawNeeded || this.prevMapPosition == null) {
return true;
}
MapPosition currentMapPosition = this.mapViewPosition.getMapPosition();
if (currentMapPosition.zoomLevel != this.prevMapPosition.zoomLevel) {
return true;
}
double latitudeDiff = Math.abs(currentMapPosition.latLong.latitude - this.prevMapPosition.latLong.latitude);
return latitudeDiff > LATITUDE_REDRAW_THRESHOLD;
} | java | protected boolean isRedrawNecessary() {
if (this.redrawNeeded || this.prevMapPosition == null) {
return true;
}
MapPosition currentMapPosition = this.mapViewPosition.getMapPosition();
if (currentMapPosition.zoomLevel != this.prevMapPosition.zoomLevel) {
return true;
}
double latitudeDiff = Math.abs(currentMapPosition.latLong.latitude - this.prevMapPosition.latLong.latitude);
return latitudeDiff > LATITUDE_REDRAW_THRESHOLD;
} | [
"protected",
"boolean",
"isRedrawNecessary",
"(",
")",
"{",
"if",
"(",
"this",
".",
"redrawNeeded",
"||",
"this",
".",
"prevMapPosition",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"MapPosition",
"currentMapPosition",
"=",
"this",
".",
"mapViewPosition",
".",
"getMapPosition",
"(",
")",
";",
"if",
"(",
"currentMapPosition",
".",
"zoomLevel",
"!=",
"this",
".",
"prevMapPosition",
".",
"zoomLevel",
")",
"{",
"return",
"true",
";",
"}",
"double",
"latitudeDiff",
"=",
"Math",
".",
"abs",
"(",
"currentMapPosition",
".",
"latLong",
".",
"latitude",
"-",
"this",
".",
"prevMapPosition",
".",
"latLong",
".",
"latitude",
")",
";",
"return",
"latitudeDiff",
">",
"LATITUDE_REDRAW_THRESHOLD",
";",
"}"
] | Determines if a redraw is necessary or not
@return true if redraw is necessary, false otherwise | [
"Determines",
"if",
"a",
"redraw",
"is",
"necessary",
"or",
"not"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/scalebar/MapScaleBar.java#L280-L292 |
28,449 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/queue/JobQueue.java | JobQueue.get | public synchronized T get(int maxAssigned) throws InterruptedException {
while (this.queueItems.isEmpty() || this.assignedJobs.size() >= maxAssigned) {
this.wait(200);
if (this.isInterrupted) {
this.isInterrupted = false;
return null;
}
}
if (this.scheduleNeeded) {
this.scheduleNeeded = false;
schedule(displayModel.getTileSize());
}
T job = this.queueItems.remove(0).object;
this.assignedJobs.add(job);
return job;
} | java | public synchronized T get(int maxAssigned) throws InterruptedException {
while (this.queueItems.isEmpty() || this.assignedJobs.size() >= maxAssigned) {
this.wait(200);
if (this.isInterrupted) {
this.isInterrupted = false;
return null;
}
}
if (this.scheduleNeeded) {
this.scheduleNeeded = false;
schedule(displayModel.getTileSize());
}
T job = this.queueItems.remove(0).object;
this.assignedJobs.add(job);
return job;
} | [
"public",
"synchronized",
"T",
"get",
"(",
"int",
"maxAssigned",
")",
"throws",
"InterruptedException",
"{",
"while",
"(",
"this",
".",
"queueItems",
".",
"isEmpty",
"(",
")",
"||",
"this",
".",
"assignedJobs",
".",
"size",
"(",
")",
">=",
"maxAssigned",
")",
"{",
"this",
".",
"wait",
"(",
"200",
")",
";",
"if",
"(",
"this",
".",
"isInterrupted",
")",
"{",
"this",
".",
"isInterrupted",
"=",
"false",
";",
"return",
"null",
";",
"}",
"}",
"if",
"(",
"this",
".",
"scheduleNeeded",
")",
"{",
"this",
".",
"scheduleNeeded",
"=",
"false",
";",
"schedule",
"(",
"displayModel",
".",
"getTileSize",
"(",
")",
")",
";",
"}",
"T",
"job",
"=",
"this",
".",
"queueItems",
".",
"remove",
"(",
"0",
")",
".",
"object",
";",
"this",
".",
"assignedJobs",
".",
"add",
"(",
"job",
")",
";",
"return",
"job",
";",
"}"
] | Returns the most important entry from this queue. The method blocks while this queue is empty
or while there are already a certain number of jobs assigned.
@param maxAssigned the maximum number of jobs that should be assigned at any one point. If there
are already so many jobs assigned, the queue will block. This is to ensure
that the scheduling will continue to work. | [
"Returns",
"the",
"most",
"important",
"entry",
"from",
"this",
"queue",
".",
"The",
"method",
"blocks",
"while",
"this",
"queue",
"is",
"empty",
"or",
"while",
"there",
"are",
"already",
"a",
"certain",
"number",
"of",
"jobs",
"assigned",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/queue/JobQueue.java#L67-L84 |
28,450 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteOpenHelper.java | SQLiteOpenHelper.setWriteAheadLoggingEnabled | public void setWriteAheadLoggingEnabled(boolean enabled) {
synchronized (this) {
if (mEnableWriteAheadLogging != enabled) {
if (mDatabase != null && mDatabase.isOpen() && !mDatabase.isReadOnly()) {
if (enabled) {
mDatabase.enableWriteAheadLogging();
} else {
mDatabase.disableWriteAheadLogging();
}
}
mEnableWriteAheadLogging = enabled;
}
}
} | java | public void setWriteAheadLoggingEnabled(boolean enabled) {
synchronized (this) {
if (mEnableWriteAheadLogging != enabled) {
if (mDatabase != null && mDatabase.isOpen() && !mDatabase.isReadOnly()) {
if (enabled) {
mDatabase.enableWriteAheadLogging();
} else {
mDatabase.disableWriteAheadLogging();
}
}
mEnableWriteAheadLogging = enabled;
}
}
} | [
"public",
"void",
"setWriteAheadLoggingEnabled",
"(",
"boolean",
"enabled",
")",
"{",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"mEnableWriteAheadLogging",
"!=",
"enabled",
")",
"{",
"if",
"(",
"mDatabase",
"!=",
"null",
"&&",
"mDatabase",
".",
"isOpen",
"(",
")",
"&&",
"!",
"mDatabase",
".",
"isReadOnly",
"(",
")",
")",
"{",
"if",
"(",
"enabled",
")",
"{",
"mDatabase",
".",
"enableWriteAheadLogging",
"(",
")",
";",
"}",
"else",
"{",
"mDatabase",
".",
"disableWriteAheadLogging",
"(",
")",
";",
"}",
"}",
"mEnableWriteAheadLogging",
"=",
"enabled",
";",
"}",
"}",
"}"
] | Enables or disables the use of write-ahead logging for the database.
Write-ahead logging cannot be used with read-only databases so the value of
this flag is ignored if the database is opened read-only.
@param enabled True if write-ahead logging should be enabled, false if it
should be disabled.
@see SQLiteDatabase#enableWriteAheadLogging() | [
"Enables",
"or",
"disables",
"the",
"use",
"of",
"write",
"-",
"ahead",
"logging",
"for",
"the",
"database",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteOpenHelper.java#L163-L176 |
28,451 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteOpenHelper.java | SQLiteOpenHelper.close | public synchronized void close() {
if (mIsInitializing) throw new IllegalStateException("Closed during initialization");
if (mDatabase != null && mDatabase.isOpen()) {
mDatabase.close();
mDatabase = null;
}
} | java | public synchronized void close() {
if (mIsInitializing) throw new IllegalStateException("Closed during initialization");
if (mDatabase != null && mDatabase.isOpen()) {
mDatabase.close();
mDatabase = null;
}
} | [
"public",
"synchronized",
"void",
"close",
"(",
")",
"{",
"if",
"(",
"mIsInitializing",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Closed during initialization\"",
")",
";",
"if",
"(",
"mDatabase",
"!=",
"null",
"&&",
"mDatabase",
".",
"isOpen",
"(",
")",
")",
"{",
"mDatabase",
".",
"close",
"(",
")",
";",
"mDatabase",
"=",
"null",
";",
"}",
"}"
] | Close any open database object. | [
"Close",
"any",
"open",
"database",
"object",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteOpenHelper.java#L334-L341 |
28,452 | mapsforge/mapsforge | mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/header/MapFileHeader.java | MapFileHeader.readHeader | public void readHeader(ReadBuffer readBuffer, long fileSize) throws IOException {
RequiredFields.readMagicByte(readBuffer);
RequiredFields.readRemainingHeader(readBuffer);
MapFileInfoBuilder mapFileInfoBuilder = new MapFileInfoBuilder();
RequiredFields.readFileVersion(readBuffer, mapFileInfoBuilder);
RequiredFields.readFileSize(readBuffer, fileSize, mapFileInfoBuilder);
RequiredFields.readMapDate(readBuffer, mapFileInfoBuilder);
RequiredFields.readBoundingBox(readBuffer, mapFileInfoBuilder);
RequiredFields.readTilePixelSize(readBuffer, mapFileInfoBuilder);
RequiredFields.readProjectionName(readBuffer, mapFileInfoBuilder);
OptionalFields.readOptionalFields(readBuffer, mapFileInfoBuilder);
RequiredFields.readPoiTags(readBuffer, mapFileInfoBuilder);
RequiredFields.readWayTags(readBuffer, mapFileInfoBuilder);
readSubFileParameters(readBuffer, fileSize, mapFileInfoBuilder);
this.mapFileInfo = mapFileInfoBuilder.build();
} | java | public void readHeader(ReadBuffer readBuffer, long fileSize) throws IOException {
RequiredFields.readMagicByte(readBuffer);
RequiredFields.readRemainingHeader(readBuffer);
MapFileInfoBuilder mapFileInfoBuilder = new MapFileInfoBuilder();
RequiredFields.readFileVersion(readBuffer, mapFileInfoBuilder);
RequiredFields.readFileSize(readBuffer, fileSize, mapFileInfoBuilder);
RequiredFields.readMapDate(readBuffer, mapFileInfoBuilder);
RequiredFields.readBoundingBox(readBuffer, mapFileInfoBuilder);
RequiredFields.readTilePixelSize(readBuffer, mapFileInfoBuilder);
RequiredFields.readProjectionName(readBuffer, mapFileInfoBuilder);
OptionalFields.readOptionalFields(readBuffer, mapFileInfoBuilder);
RequiredFields.readPoiTags(readBuffer, mapFileInfoBuilder);
RequiredFields.readWayTags(readBuffer, mapFileInfoBuilder);
readSubFileParameters(readBuffer, fileSize, mapFileInfoBuilder);
this.mapFileInfo = mapFileInfoBuilder.build();
} | [
"public",
"void",
"readHeader",
"(",
"ReadBuffer",
"readBuffer",
",",
"long",
"fileSize",
")",
"throws",
"IOException",
"{",
"RequiredFields",
".",
"readMagicByte",
"(",
"readBuffer",
")",
";",
"RequiredFields",
".",
"readRemainingHeader",
"(",
"readBuffer",
")",
";",
"MapFileInfoBuilder",
"mapFileInfoBuilder",
"=",
"new",
"MapFileInfoBuilder",
"(",
")",
";",
"RequiredFields",
".",
"readFileVersion",
"(",
"readBuffer",
",",
"mapFileInfoBuilder",
")",
";",
"RequiredFields",
".",
"readFileSize",
"(",
"readBuffer",
",",
"fileSize",
",",
"mapFileInfoBuilder",
")",
";",
"RequiredFields",
".",
"readMapDate",
"(",
"readBuffer",
",",
"mapFileInfoBuilder",
")",
";",
"RequiredFields",
".",
"readBoundingBox",
"(",
"readBuffer",
",",
"mapFileInfoBuilder",
")",
";",
"RequiredFields",
".",
"readTilePixelSize",
"(",
"readBuffer",
",",
"mapFileInfoBuilder",
")",
";",
"RequiredFields",
".",
"readProjectionName",
"(",
"readBuffer",
",",
"mapFileInfoBuilder",
")",
";",
"OptionalFields",
".",
"readOptionalFields",
"(",
"readBuffer",
",",
"mapFileInfoBuilder",
")",
";",
"RequiredFields",
".",
"readPoiTags",
"(",
"readBuffer",
",",
"mapFileInfoBuilder",
")",
";",
"RequiredFields",
".",
"readWayTags",
"(",
"readBuffer",
",",
"mapFileInfoBuilder",
")",
";",
"readSubFileParameters",
"(",
"readBuffer",
",",
"fileSize",
",",
"mapFileInfoBuilder",
")",
";",
"this",
".",
"mapFileInfo",
"=",
"mapFileInfoBuilder",
".",
"build",
"(",
")",
";",
"}"
] | Reads and validates the header block from the map file.
@param readBuffer the ReadBuffer for the file data.
@param fileSize the size of the map file in bytes.
@throws IOException if an error occurs while reading the file. | [
"Reads",
"and",
"validates",
"the",
"header",
"block",
"from",
"the",
"map",
"file",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-reader/src/main/java/org/mapsforge/map/reader/header/MapFileHeader.java#L86-L113 |
28,453 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/SamplesBaseActivity.java | SamplesBaseActivity.setMapScaleBar | protected void setMapScaleBar() {
String value = this.sharedPreferences.getString(SETTING_SCALEBAR, SETTING_SCALEBAR_BOTH);
if (SETTING_SCALEBAR_NONE.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, null, null);
} else {
if (SETTING_SCALEBAR_BOTH.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, MetricUnitAdapter.INSTANCE, ImperialUnitAdapter.INSTANCE);
} else if (SETTING_SCALEBAR_METRIC.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, MetricUnitAdapter.INSTANCE, null);
} else if (SETTING_SCALEBAR_IMPERIAL.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, ImperialUnitAdapter.INSTANCE, null);
} else if (SETTING_SCALEBAR_NAUTICAL.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, NauticalUnitAdapter.INSTANCE, null);
}
}
} | java | protected void setMapScaleBar() {
String value = this.sharedPreferences.getString(SETTING_SCALEBAR, SETTING_SCALEBAR_BOTH);
if (SETTING_SCALEBAR_NONE.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, null, null);
} else {
if (SETTING_SCALEBAR_BOTH.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, MetricUnitAdapter.INSTANCE, ImperialUnitAdapter.INSTANCE);
} else if (SETTING_SCALEBAR_METRIC.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, MetricUnitAdapter.INSTANCE, null);
} else if (SETTING_SCALEBAR_IMPERIAL.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, ImperialUnitAdapter.INSTANCE, null);
} else if (SETTING_SCALEBAR_NAUTICAL.equals(value)) {
AndroidUtil.setMapScaleBar(this.mapView, NauticalUnitAdapter.INSTANCE, null);
}
}
} | [
"protected",
"void",
"setMapScaleBar",
"(",
")",
"{",
"String",
"value",
"=",
"this",
".",
"sharedPreferences",
".",
"getString",
"(",
"SETTING_SCALEBAR",
",",
"SETTING_SCALEBAR_BOTH",
")",
";",
"if",
"(",
"SETTING_SCALEBAR_NONE",
".",
"equals",
"(",
"value",
")",
")",
"{",
"AndroidUtil",
".",
"setMapScaleBar",
"(",
"this",
".",
"mapView",
",",
"null",
",",
"null",
")",
";",
"}",
"else",
"{",
"if",
"(",
"SETTING_SCALEBAR_BOTH",
".",
"equals",
"(",
"value",
")",
")",
"{",
"AndroidUtil",
".",
"setMapScaleBar",
"(",
"this",
".",
"mapView",
",",
"MetricUnitAdapter",
".",
"INSTANCE",
",",
"ImperialUnitAdapter",
".",
"INSTANCE",
")",
";",
"}",
"else",
"if",
"(",
"SETTING_SCALEBAR_METRIC",
".",
"equals",
"(",
"value",
")",
")",
"{",
"AndroidUtil",
".",
"setMapScaleBar",
"(",
"this",
".",
"mapView",
",",
"MetricUnitAdapter",
".",
"INSTANCE",
",",
"null",
")",
";",
"}",
"else",
"if",
"(",
"SETTING_SCALEBAR_IMPERIAL",
".",
"equals",
"(",
"value",
")",
")",
"{",
"AndroidUtil",
".",
"setMapScaleBar",
"(",
"this",
".",
"mapView",
",",
"ImperialUnitAdapter",
".",
"INSTANCE",
",",
"null",
")",
";",
"}",
"else",
"if",
"(",
"SETTING_SCALEBAR_NAUTICAL",
".",
"equals",
"(",
"value",
")",
")",
"{",
"AndroidUtil",
".",
"setMapScaleBar",
"(",
"this",
".",
"mapView",
",",
"NauticalUnitAdapter",
".",
"INSTANCE",
",",
"null",
")",
";",
"}",
"}",
"}"
] | Sets the scale bar from preferences. | [
"Sets",
"the",
"scale",
"bar",
"from",
"preferences",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/SamplesBaseActivity.java#L324-L340 |
28,454 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/SamplesBaseActivity.java | SamplesBaseActivity.setMaxTextWidthFactor | protected void setMaxTextWidthFactor() {
mapView.getModel().displayModel.setMaxTextWidthFactor(Float.valueOf(sharedPreferences.getString(SamplesApplication.SETTING_TEXTWIDTH, "0.7")));
} | java | protected void setMaxTextWidthFactor() {
mapView.getModel().displayModel.setMaxTextWidthFactor(Float.valueOf(sharedPreferences.getString(SamplesApplication.SETTING_TEXTWIDTH, "0.7")));
} | [
"protected",
"void",
"setMaxTextWidthFactor",
"(",
")",
"{",
"mapView",
".",
"getModel",
"(",
")",
".",
"displayModel",
".",
"setMaxTextWidthFactor",
"(",
"Float",
".",
"valueOf",
"(",
"sharedPreferences",
".",
"getString",
"(",
"SamplesApplication",
".",
"SETTING_TEXTWIDTH",
",",
"\"0.7\"",
")",
")",
")",
";",
"}"
] | sets the value for breaking line text in labels. | [
"sets",
"the",
"value",
"for",
"breaking",
"line",
"text",
"in",
"labels",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/SamplesBaseActivity.java#L345-L347 |
28,455 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/Utils.java | Utils.enableHome | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void enableHome(Activity a) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Show the Up button in the action bar.
a.getActionBar().setDisplayHomeAsUpEnabled(true);
}
} | java | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void enableHome(Activity a) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Show the Up button in the action bar.
a.getActionBar().setDisplayHomeAsUpEnabled(true);
}
} | [
"@",
"TargetApi",
"(",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"public",
"static",
"void",
"enableHome",
"(",
"Activity",
"a",
")",
"{",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"Build",
".",
"VERSION_CODES",
".",
"HONEYCOMB",
")",
"{",
"// Show the Up button in the action bar.",
"a",
".",
"getActionBar",
"(",
")",
".",
"setDisplayHomeAsUpEnabled",
"(",
"true",
")",
";",
"}",
"}"
] | Compatibility method.
@param a the current activity | [
"Compatibility",
"method",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/Utils.java#L46-L52 |
28,456 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/layer/labels/TileBasedLabelStore.java | TileBasedLabelStore.storeMapItems | public synchronized void storeMapItems(Tile tile, List<MapElementContainer> mapItems) {
this.put(tile, LayerUtil.collisionFreeOrdered(mapItems));
this.version += 1;
} | java | public synchronized void storeMapItems(Tile tile, List<MapElementContainer> mapItems) {
this.put(tile, LayerUtil.collisionFreeOrdered(mapItems));
this.version += 1;
} | [
"public",
"synchronized",
"void",
"storeMapItems",
"(",
"Tile",
"tile",
",",
"List",
"<",
"MapElementContainer",
">",
"mapItems",
")",
"{",
"this",
".",
"put",
"(",
"tile",
",",
"LayerUtil",
".",
"collisionFreeOrdered",
"(",
"mapItems",
")",
")",
";",
"this",
".",
"version",
"+=",
"1",
";",
"}"
] | Stores a list of MapElements against a tile.
@param tile tile on which the mapItems reside.
@param mapItems the map elements. | [
"Stores",
"a",
"list",
"of",
"MapElements",
"against",
"a",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/layer/labels/TileBasedLabelStore.java#L53-L56 |
28,457 | mapsforge/mapsforge | mapsforge-poi/src/main/java/org/mapsforge/poi/storage/DoubleLinkedPoiCategory.java | DoubleLinkedPoiCategory.getGraphVizString | public static String getGraphVizString(DoubleLinkedPoiCategory rootNode) {
StringBuilder sb = new StringBuilder();
Stack<PoiCategory> stack = new Stack<>();
stack.push(rootNode);
DoubleLinkedPoiCategory currentNode;
sb.append("// dot test.dot -Tpng > test.png\r\n");
sb.append("digraph Categories {\r\n");
sb.append(" graph [\r\nrankdir = \"LR\"\r\n]\r\n\r\nnode [\r\nshape = \"plaintext\"\r\n]");
while (!stack.isEmpty()) {
currentNode = (DoubleLinkedPoiCategory) stack.pop();
for (PoiCategory childNode : currentNode.childCategories) {
stack.push(childNode);
sb.append("\t\"").append(currentNode.getTitle()).append(" (")
.append(currentNode.getID()).append(")").append("\" -> \"")
.append(childNode.getTitle()).append(" (").append(childNode.getID())
.append(")").append("\"\r\n");
}
}
sb.append("}\r\n");
return sb.toString();
} | java | public static String getGraphVizString(DoubleLinkedPoiCategory rootNode) {
StringBuilder sb = new StringBuilder();
Stack<PoiCategory> stack = new Stack<>();
stack.push(rootNode);
DoubleLinkedPoiCategory currentNode;
sb.append("// dot test.dot -Tpng > test.png\r\n");
sb.append("digraph Categories {\r\n");
sb.append(" graph [\r\nrankdir = \"LR\"\r\n]\r\n\r\nnode [\r\nshape = \"plaintext\"\r\n]");
while (!stack.isEmpty()) {
currentNode = (DoubleLinkedPoiCategory) stack.pop();
for (PoiCategory childNode : currentNode.childCategories) {
stack.push(childNode);
sb.append("\t\"").append(currentNode.getTitle()).append(" (")
.append(currentNode.getID()).append(")").append("\" -> \"")
.append(childNode.getTitle()).append(" (").append(childNode.getID())
.append(")").append("\"\r\n");
}
}
sb.append("}\r\n");
return sb.toString();
} | [
"public",
"static",
"String",
"getGraphVizString",
"(",
"DoubleLinkedPoiCategory",
"rootNode",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"Stack",
"<",
"PoiCategory",
">",
"stack",
"=",
"new",
"Stack",
"<>",
"(",
")",
";",
"stack",
".",
"push",
"(",
"rootNode",
")",
";",
"DoubleLinkedPoiCategory",
"currentNode",
";",
"sb",
".",
"append",
"(",
"\"// dot test.dot -Tpng > test.png\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\"digraph Categories {\\r\\n\"",
")",
";",
"sb",
".",
"append",
"(",
"\" graph [\\r\\nrankdir = \\\"LR\\\"\\r\\n]\\r\\n\\r\\nnode [\\r\\nshape = \\\"plaintext\\\"\\r\\n]\"",
")",
";",
"while",
"(",
"!",
"stack",
".",
"isEmpty",
"(",
")",
")",
"{",
"currentNode",
"=",
"(",
"DoubleLinkedPoiCategory",
")",
"stack",
".",
"pop",
"(",
")",
";",
"for",
"(",
"PoiCategory",
"childNode",
":",
"currentNode",
".",
"childCategories",
")",
"{",
"stack",
".",
"push",
"(",
"childNode",
")",
";",
"sb",
".",
"append",
"(",
"\"\\t\\\"\"",
")",
".",
"append",
"(",
"currentNode",
".",
"getTitle",
"(",
")",
")",
".",
"append",
"(",
"\" (\"",
")",
".",
"append",
"(",
"currentNode",
".",
"getID",
"(",
")",
")",
".",
"append",
"(",
"\")\"",
")",
".",
"append",
"(",
"\"\\\" -> \\\"\"",
")",
".",
"append",
"(",
"childNode",
".",
"getTitle",
"(",
")",
")",
".",
"append",
"(",
"\" (\"",
")",
".",
"append",
"(",
"childNode",
".",
"getID",
"(",
")",
")",
".",
"append",
"(",
"\")\"",
")",
".",
"append",
"(",
"\"\\\"\\r\\n\"",
")",
";",
"}",
"}",
"sb",
".",
"append",
"(",
"\"}\\r\\n\"",
")",
";",
"return",
"sb",
".",
"toString",
"(",
")",
";",
"}"
] | Generates a GraphViz source representation as a tree having the current node as its root.
@param rootNode The resulting graph's root node. (You can use any sub node to get a sub-graph).
@return a GraphViz source representation as a tree having the current node as its root. | [
"Generates",
"a",
"GraphViz",
"source",
"representation",
"as",
"a",
"tree",
"having",
"the",
"current",
"node",
"as",
"its",
"root",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-poi/src/main/java/org/mapsforge/poi/storage/DoubleLinkedPoiCategory.java#L137-L159 |
28,458 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/BoundingBox.java | BoundingBox.fromString | public static BoundingBox fromString(String boundingBoxString) {
double[] coordinates = LatLongUtils.parseCoordinateString(boundingBoxString, 4);
return new BoundingBox(coordinates[0], coordinates[1], coordinates[2], coordinates[3]);
} | java | public static BoundingBox fromString(String boundingBoxString) {
double[] coordinates = LatLongUtils.parseCoordinateString(boundingBoxString, 4);
return new BoundingBox(coordinates[0], coordinates[1], coordinates[2], coordinates[3]);
} | [
"public",
"static",
"BoundingBox",
"fromString",
"(",
"String",
"boundingBoxString",
")",
"{",
"double",
"[",
"]",
"coordinates",
"=",
"LatLongUtils",
".",
"parseCoordinateString",
"(",
"boundingBoxString",
",",
"4",
")",
";",
"return",
"new",
"BoundingBox",
"(",
"coordinates",
"[",
"0",
"]",
",",
"coordinates",
"[",
"1",
"]",
",",
"coordinates",
"[",
"2",
"]",
",",
"coordinates",
"[",
"3",
"]",
")",
";",
"}"
] | Creates a new BoundingBox from a comma-separated string of coordinates in the order minLat, minLon, maxLat,
maxLon. All coordinate values must be in degrees.
@param boundingBoxString the string that describes the BoundingBox.
@return a new BoundingBox with the given coordinates.
@throws IllegalArgumentException if the string cannot be parsed or describes an invalid BoundingBox. | [
"Creates",
"a",
"new",
"BoundingBox",
"from",
"a",
"comma",
"-",
"separated",
"string",
"of",
"coordinates",
"in",
"the",
"order",
"minLat",
"minLon",
"maxLat",
"maxLon",
".",
"All",
"coordinate",
"values",
"must",
"be",
"in",
"degrees",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/BoundingBox.java#L39-L42 |
28,459 | mapsforge/mapsforge | mapsforge-core/src/main/java/org/mapsforge/core/model/BoundingBox.java | BoundingBox.getPositionRelativeToTile | public Rectangle getPositionRelativeToTile(Tile tile) {
Point upperLeft = MercatorProjection.getPixelRelativeToTile(new LatLong(this.maxLatitude, minLongitude), tile);
Point lowerRight = MercatorProjection.getPixelRelativeToTile(new LatLong(this.minLatitude, maxLongitude), tile);
return new Rectangle(upperLeft.x, upperLeft.y, lowerRight.x, lowerRight.y);
} | java | public Rectangle getPositionRelativeToTile(Tile tile) {
Point upperLeft = MercatorProjection.getPixelRelativeToTile(new LatLong(this.maxLatitude, minLongitude), tile);
Point lowerRight = MercatorProjection.getPixelRelativeToTile(new LatLong(this.minLatitude, maxLongitude), tile);
return new Rectangle(upperLeft.x, upperLeft.y, lowerRight.x, lowerRight.y);
} | [
"public",
"Rectangle",
"getPositionRelativeToTile",
"(",
"Tile",
"tile",
")",
"{",
"Point",
"upperLeft",
"=",
"MercatorProjection",
".",
"getPixelRelativeToTile",
"(",
"new",
"LatLong",
"(",
"this",
".",
"maxLatitude",
",",
"minLongitude",
")",
",",
"tile",
")",
";",
"Point",
"lowerRight",
"=",
"MercatorProjection",
".",
"getPixelRelativeToTile",
"(",
"new",
"LatLong",
"(",
"this",
".",
"minLatitude",
",",
"maxLongitude",
")",
",",
"tile",
")",
";",
"return",
"new",
"Rectangle",
"(",
"upperLeft",
".",
"x",
",",
"upperLeft",
".",
"y",
",",
"lowerRight",
".",
"x",
",",
"lowerRight",
".",
"y",
")",
";",
"}"
] | Computes the coordinates of this bounding box relative to a tile.
@param tile the tile to compute the relative position for.
@return rectangle giving the relative position. | [
"Computes",
"the",
"coordinates",
"of",
"this",
"bounding",
"box",
"relative",
"to",
"a",
"tile",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-core/src/main/java/org/mapsforge/core/model/BoundingBox.java#L291-L295 |
28,460 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java | RenderTheme.destroy | public void destroy() {
this.poiMatchingCache.clear();
this.wayMatchingCache.clear();
for (Rule r : this.rulesList) {
r.destroy();
}
} | java | public void destroy() {
this.poiMatchingCache.clear();
this.wayMatchingCache.clear();
for (Rule r : this.rulesList) {
r.destroy();
}
} | [
"public",
"void",
"destroy",
"(",
")",
"{",
"this",
".",
"poiMatchingCache",
".",
"clear",
"(",
")",
";",
"this",
".",
"wayMatchingCache",
".",
"clear",
"(",
")",
";",
"for",
"(",
"Rule",
"r",
":",
"this",
".",
"rulesList",
")",
"{",
"r",
".",
"destroy",
"(",
")",
";",
"}",
"}"
] | Must be called when this RenderTheme gets destroyed to clean up and free resources. | [
"Must",
"be",
"called",
"when",
"this",
"RenderTheme",
"gets",
"destroyed",
"to",
"clean",
"up",
"and",
"free",
"resources",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java#L68-L74 |
28,461 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java | RenderTheme.matchClosedWay | public void matchClosedWay(RenderCallback renderCallback, final RenderContext renderContext, PolylineContainer way) {
matchWay(renderCallback, renderContext, Closed.YES, way);
} | java | public void matchClosedWay(RenderCallback renderCallback, final RenderContext renderContext, PolylineContainer way) {
matchWay(renderCallback, renderContext, Closed.YES, way);
} | [
"public",
"void",
"matchClosedWay",
"(",
"RenderCallback",
"renderCallback",
",",
"final",
"RenderContext",
"renderContext",
",",
"PolylineContainer",
"way",
")",
"{",
"matchWay",
"(",
"renderCallback",
",",
"renderContext",
",",
"Closed",
".",
"YES",
",",
"way",
")",
";",
"}"
] | Matches a closed way with the given parameters against this RenderTheme.
@param renderCallback the callback implementation which will be executed on each match.
@param renderContext
@param way | [
"Matches",
"a",
"closed",
"way",
"with",
"the",
"given",
"parameters",
"against",
"this",
"RenderTheme",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java#L111-L113 |
28,462 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java | RenderTheme.matchLinearWay | public void matchLinearWay(RenderCallback renderCallback, final RenderContext renderContext, PolylineContainer way) {
matchWay(renderCallback, renderContext, Closed.NO, way);
} | java | public void matchLinearWay(RenderCallback renderCallback, final RenderContext renderContext, PolylineContainer way) {
matchWay(renderCallback, renderContext, Closed.NO, way);
} | [
"public",
"void",
"matchLinearWay",
"(",
"RenderCallback",
"renderCallback",
",",
"final",
"RenderContext",
"renderContext",
",",
"PolylineContainer",
"way",
")",
"{",
"matchWay",
"(",
"renderCallback",
",",
"renderContext",
",",
"Closed",
".",
"NO",
",",
"way",
")",
";",
"}"
] | Matches a linear way with the given parameters against this RenderTheme.
@param renderCallback the callback implementation which will be executed on each match.
@param renderContext
@param way | [
"Matches",
"a",
"linear",
"way",
"with",
"the",
"given",
"parameters",
"against",
"this",
"RenderTheme",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java#L122-L124 |
28,463 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java | RenderTheme.matchNode | public synchronized void matchNode(RenderCallback renderCallback, final RenderContext renderContext, PointOfInterest poi) {
MatchingCacheKey matchingCacheKey = new MatchingCacheKey(poi.tags, renderContext.rendererJob.tile.zoomLevel, Closed.NO);
List<RenderInstruction> matchingList = this.poiMatchingCache.get(matchingCacheKey);
if (matchingList != null) {
// cache hit
for (int i = 0, n = matchingList.size(); i < n; ++i) {
matchingList.get(i).renderNode(renderCallback, renderContext, poi);
}
return;
}
// cache miss
matchingList = new ArrayList<RenderInstruction>();
for (int i = 0, n = this.rulesList.size(); i < n; ++i) {
this.rulesList.get(i).matchNode(renderCallback, renderContext, matchingList, poi);
}
this.poiMatchingCache.put(matchingCacheKey, matchingList);
} | java | public synchronized void matchNode(RenderCallback renderCallback, final RenderContext renderContext, PointOfInterest poi) {
MatchingCacheKey matchingCacheKey = new MatchingCacheKey(poi.tags, renderContext.rendererJob.tile.zoomLevel, Closed.NO);
List<RenderInstruction> matchingList = this.poiMatchingCache.get(matchingCacheKey);
if (matchingList != null) {
// cache hit
for (int i = 0, n = matchingList.size(); i < n; ++i) {
matchingList.get(i).renderNode(renderCallback, renderContext, poi);
}
return;
}
// cache miss
matchingList = new ArrayList<RenderInstruction>();
for (int i = 0, n = this.rulesList.size(); i < n; ++i) {
this.rulesList.get(i).matchNode(renderCallback, renderContext, matchingList, poi);
}
this.poiMatchingCache.put(matchingCacheKey, matchingList);
} | [
"public",
"synchronized",
"void",
"matchNode",
"(",
"RenderCallback",
"renderCallback",
",",
"final",
"RenderContext",
"renderContext",
",",
"PointOfInterest",
"poi",
")",
"{",
"MatchingCacheKey",
"matchingCacheKey",
"=",
"new",
"MatchingCacheKey",
"(",
"poi",
".",
"tags",
",",
"renderContext",
".",
"rendererJob",
".",
"tile",
".",
"zoomLevel",
",",
"Closed",
".",
"NO",
")",
";",
"List",
"<",
"RenderInstruction",
">",
"matchingList",
"=",
"this",
".",
"poiMatchingCache",
".",
"get",
"(",
"matchingCacheKey",
")",
";",
"if",
"(",
"matchingList",
"!=",
"null",
")",
"{",
"// cache hit",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"matchingList",
".",
"size",
"(",
")",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"matchingList",
".",
"get",
"(",
"i",
")",
".",
"renderNode",
"(",
"renderCallback",
",",
"renderContext",
",",
"poi",
")",
";",
"}",
"return",
";",
"}",
"// cache miss",
"matchingList",
"=",
"new",
"ArrayList",
"<",
"RenderInstruction",
">",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"this",
".",
"rulesList",
".",
"size",
"(",
")",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"this",
".",
"rulesList",
".",
"get",
"(",
"i",
")",
".",
"matchNode",
"(",
"renderCallback",
",",
"renderContext",
",",
"matchingList",
",",
"poi",
")",
";",
"}",
"this",
".",
"poiMatchingCache",
".",
"put",
"(",
"matchingCacheKey",
",",
"matchingList",
")",
";",
"}"
] | Matches a node with the given parameters against this RenderTheme.
@param renderCallback the callback implementation which will be executed on each match.
@param renderContext
@param poi the point of interest. | [
"Matches",
"a",
"node",
"with",
"the",
"given",
"parameters",
"against",
"this",
"RenderTheme",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java#L133-L152 |
28,464 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java | RenderTheme.scaleStrokeWidth | public synchronized void scaleStrokeWidth(float scaleFactor, byte zoomLevel) {
if (!strokeScales.containsKey(zoomLevel) || scaleFactor != strokeScales.get(zoomLevel)) {
for (int i = 0, n = this.rulesList.size(); i < n; ++i) {
Rule rule = this.rulesList.get(i);
if (rule.zoomMin <= zoomLevel && rule.zoomMax >= zoomLevel) {
rule.scaleStrokeWidth(scaleFactor * this.baseStrokeWidth, zoomLevel);
}
}
strokeScales.put(zoomLevel, scaleFactor);
}
} | java | public synchronized void scaleStrokeWidth(float scaleFactor, byte zoomLevel) {
if (!strokeScales.containsKey(zoomLevel) || scaleFactor != strokeScales.get(zoomLevel)) {
for (int i = 0, n = this.rulesList.size(); i < n; ++i) {
Rule rule = this.rulesList.get(i);
if (rule.zoomMin <= zoomLevel && rule.zoomMax >= zoomLevel) {
rule.scaleStrokeWidth(scaleFactor * this.baseStrokeWidth, zoomLevel);
}
}
strokeScales.put(zoomLevel, scaleFactor);
}
} | [
"public",
"synchronized",
"void",
"scaleStrokeWidth",
"(",
"float",
"scaleFactor",
",",
"byte",
"zoomLevel",
")",
"{",
"if",
"(",
"!",
"strokeScales",
".",
"containsKey",
"(",
"zoomLevel",
")",
"||",
"scaleFactor",
"!=",
"strokeScales",
".",
"get",
"(",
"zoomLevel",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"this",
".",
"rulesList",
".",
"size",
"(",
")",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"Rule",
"rule",
"=",
"this",
".",
"rulesList",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"rule",
".",
"zoomMin",
"<=",
"zoomLevel",
"&&",
"rule",
".",
"zoomMax",
">=",
"zoomLevel",
")",
"{",
"rule",
".",
"scaleStrokeWidth",
"(",
"scaleFactor",
"*",
"this",
".",
"baseStrokeWidth",
",",
"zoomLevel",
")",
";",
"}",
"}",
"strokeScales",
".",
"put",
"(",
"zoomLevel",
",",
"scaleFactor",
")",
";",
"}",
"}"
] | Scales the stroke width of this RenderTheme by the given factor for a given zoom level
@param scaleFactor the factor by which the stroke width should be scaled.
@param zoomLevel the zoom level to which this is applied. | [
"Scales",
"the",
"stroke",
"width",
"of",
"this",
"RenderTheme",
"by",
"the",
"given",
"factor",
"for",
"a",
"given",
"zoom",
"level"
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java#L160-L170 |
28,465 | mapsforge/mapsforge | mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java | RenderTheme.scaleTextSize | public synchronized void scaleTextSize(float scaleFactor, byte zoomLevel) {
if (!textScales.containsKey(zoomLevel) || scaleFactor != textScales.get(zoomLevel)) {
for (int i = 0, n = this.rulesList.size(); i < n; ++i) {
Rule rule = this.rulesList.get(i);
if (rule.zoomMin <= zoomLevel && rule.zoomMax >= zoomLevel) {
rule.scaleTextSize(scaleFactor * this.baseTextSize, zoomLevel);
}
}
textScales.put(zoomLevel, scaleFactor);
}
} | java | public synchronized void scaleTextSize(float scaleFactor, byte zoomLevel) {
if (!textScales.containsKey(zoomLevel) || scaleFactor != textScales.get(zoomLevel)) {
for (int i = 0, n = this.rulesList.size(); i < n; ++i) {
Rule rule = this.rulesList.get(i);
if (rule.zoomMin <= zoomLevel && rule.zoomMax >= zoomLevel) {
rule.scaleTextSize(scaleFactor * this.baseTextSize, zoomLevel);
}
}
textScales.put(zoomLevel, scaleFactor);
}
} | [
"public",
"synchronized",
"void",
"scaleTextSize",
"(",
"float",
"scaleFactor",
",",
"byte",
"zoomLevel",
")",
"{",
"if",
"(",
"!",
"textScales",
".",
"containsKey",
"(",
"zoomLevel",
")",
"||",
"scaleFactor",
"!=",
"textScales",
".",
"get",
"(",
"zoomLevel",
")",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
",",
"n",
"=",
"this",
".",
"rulesList",
".",
"size",
"(",
")",
";",
"i",
"<",
"n",
";",
"++",
"i",
")",
"{",
"Rule",
"rule",
"=",
"this",
".",
"rulesList",
".",
"get",
"(",
"i",
")",
";",
"if",
"(",
"rule",
".",
"zoomMin",
"<=",
"zoomLevel",
"&&",
"rule",
".",
"zoomMax",
">=",
"zoomLevel",
")",
"{",
"rule",
".",
"scaleTextSize",
"(",
"scaleFactor",
"*",
"this",
".",
"baseTextSize",
",",
"zoomLevel",
")",
";",
"}",
"}",
"textScales",
".",
"put",
"(",
"zoomLevel",
",",
"scaleFactor",
")",
";",
"}",
"}"
] | Scales the text size of this RenderTheme by the given factor for a given zoom level.
@param scaleFactor the factor by which the text size should be scaled.
@param zoomLevel the zoom level to which this is applied. | [
"Scales",
"the",
"text",
"size",
"of",
"this",
"RenderTheme",
"by",
"the",
"given",
"factor",
"for",
"a",
"given",
"zoom",
"level",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map/src/main/java/org/mapsforge/map/rendertheme/rule/RenderTheme.java#L178-L188 |
28,466 | mapsforge/mapsforge | mapsforge-map-android/src/main/java/org/mapsforge/map/android/util/MapViewerTemplate.java | MapViewerTemplate.createMapViews | protected void createMapViews() {
mapView = getMapView();
mapView.getModel().init(this.preferencesFacade);
mapView.setClickable(true);
mapView.getMapScaleBar().setVisible(true);
mapView.setBuiltInZoomControls(hasZoomControls());
mapView.getMapZoomControls().setAutoHide(isZoomControlsAutoHide());
mapView.getMapZoomControls().setZoomLevelMin(getZoomLevelMin());
mapView.getMapZoomControls().setZoomLevelMax(getZoomLevelMax());
} | java | protected void createMapViews() {
mapView = getMapView();
mapView.getModel().init(this.preferencesFacade);
mapView.setClickable(true);
mapView.getMapScaleBar().setVisible(true);
mapView.setBuiltInZoomControls(hasZoomControls());
mapView.getMapZoomControls().setAutoHide(isZoomControlsAutoHide());
mapView.getMapZoomControls().setZoomLevelMin(getZoomLevelMin());
mapView.getMapZoomControls().setZoomLevelMax(getZoomLevelMax());
} | [
"protected",
"void",
"createMapViews",
"(",
")",
"{",
"mapView",
"=",
"getMapView",
"(",
")",
";",
"mapView",
".",
"getModel",
"(",
")",
".",
"init",
"(",
"this",
".",
"preferencesFacade",
")",
";",
"mapView",
".",
"setClickable",
"(",
"true",
")",
";",
"mapView",
".",
"getMapScaleBar",
"(",
")",
".",
"setVisible",
"(",
"true",
")",
";",
"mapView",
".",
"setBuiltInZoomControls",
"(",
"hasZoomControls",
"(",
")",
")",
";",
"mapView",
".",
"getMapZoomControls",
"(",
")",
".",
"setAutoHide",
"(",
"isZoomControlsAutoHide",
"(",
")",
")",
";",
"mapView",
".",
"getMapZoomControls",
"(",
")",
".",
"setZoomLevelMin",
"(",
"getZoomLevelMin",
"(",
")",
")",
";",
"mapView",
".",
"getMapZoomControls",
"(",
")",
".",
"setZoomLevelMax",
"(",
"getZoomLevelMax",
"(",
")",
")",
";",
"}"
] | Template method to create the map views. | [
"Template",
"method",
"to",
"create",
"the",
"map",
"views",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-android/src/main/java/org/mapsforge/map/android/util/MapViewerTemplate.java#L133-L142 |
28,467 | mapsforge/mapsforge | mapsforge-map-android/src/main/java/org/mapsforge/map/android/util/MapViewerTemplate.java | MapViewerTemplate.getInitialPosition | protected MapPosition getInitialPosition() {
MapDataStore mapFile = getMapFile();
if (mapFile.startPosition() != null) {
Byte startZoomLevel = mapFile.startZoomLevel();
if (startZoomLevel == null) {
// it is actually possible to have no start zoom level in the file
startZoomLevel = new Byte((byte) 12);
}
return new MapPosition(mapFile.startPosition(), startZoomLevel);
} else {
return getDefaultInitialPosition();
}
} | java | protected MapPosition getInitialPosition() {
MapDataStore mapFile = getMapFile();
if (mapFile.startPosition() != null) {
Byte startZoomLevel = mapFile.startZoomLevel();
if (startZoomLevel == null) {
// it is actually possible to have no start zoom level in the file
startZoomLevel = new Byte((byte) 12);
}
return new MapPosition(mapFile.startPosition(), startZoomLevel);
} else {
return getDefaultInitialPosition();
}
} | [
"protected",
"MapPosition",
"getInitialPosition",
"(",
")",
"{",
"MapDataStore",
"mapFile",
"=",
"getMapFile",
"(",
")",
";",
"if",
"(",
"mapFile",
".",
"startPosition",
"(",
")",
"!=",
"null",
")",
"{",
"Byte",
"startZoomLevel",
"=",
"mapFile",
".",
"startZoomLevel",
"(",
")",
";",
"if",
"(",
"startZoomLevel",
"==",
"null",
")",
"{",
"// it is actually possible to have no start zoom level in the file",
"startZoomLevel",
"=",
"new",
"Byte",
"(",
"(",
"byte",
")",
"12",
")",
";",
"}",
"return",
"new",
"MapPosition",
"(",
"mapFile",
".",
"startPosition",
"(",
")",
",",
"startZoomLevel",
")",
";",
"}",
"else",
"{",
"return",
"getDefaultInitialPosition",
"(",
")",
";",
"}",
"}"
] | Extracts the initial position from the map file, falling back onto the value supplied
by getDefaultInitialPosition if there is no initial position coded into the map file.
You will only need to override this method if you do not want the initial position extracted
from the map file.
@return the initial position encoded in the map file or a fallback value. | [
"Extracts",
"the",
"initial",
"position",
"from",
"the",
"map",
"file",
"falling",
"back",
"onto",
"the",
"value",
"supplied",
"by",
"getDefaultInitialPosition",
"if",
"there",
"is",
"no",
"initial",
"position",
"coded",
"into",
"the",
"map",
"file",
".",
"You",
"will",
"only",
"need",
"to",
"override",
"this",
"method",
"if",
"you",
"do",
"not",
"want",
"the",
"initial",
"position",
"extracted",
"from",
"the",
"map",
"file",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-android/src/main/java/org/mapsforge/map/android/util/MapViewerTemplate.java#L171-L184 |
28,468 | mapsforge/mapsforge | mapsforge-map-android/src/main/java/org/mapsforge/map/android/util/MapViewerTemplate.java | MapViewerTemplate.initializePosition | protected IMapViewPosition initializePosition(IMapViewPosition mvp) {
LatLong center = mvp.getCenter();
if (center.equals(new LatLong(0, 0))) {
mvp.setMapPosition(this.getInitialPosition());
}
mvp.setZoomLevelMax(getZoomLevelMax());
mvp.setZoomLevelMin(getZoomLevelMin());
return mvp;
} | java | protected IMapViewPosition initializePosition(IMapViewPosition mvp) {
LatLong center = mvp.getCenter();
if (center.equals(new LatLong(0, 0))) {
mvp.setMapPosition(this.getInitialPosition());
}
mvp.setZoomLevelMax(getZoomLevelMax());
mvp.setZoomLevelMin(getZoomLevelMin());
return mvp;
} | [
"protected",
"IMapViewPosition",
"initializePosition",
"(",
"IMapViewPosition",
"mvp",
")",
"{",
"LatLong",
"center",
"=",
"mvp",
".",
"getCenter",
"(",
")",
";",
"if",
"(",
"center",
".",
"equals",
"(",
"new",
"LatLong",
"(",
"0",
",",
"0",
")",
")",
")",
"{",
"mvp",
".",
"setMapPosition",
"(",
"this",
".",
"getInitialPosition",
"(",
")",
")",
";",
"}",
"mvp",
".",
"setZoomLevelMax",
"(",
"getZoomLevelMax",
"(",
")",
")",
";",
"mvp",
".",
"setZoomLevelMin",
"(",
"getZoomLevelMin",
"(",
")",
")",
";",
"return",
"mvp",
";",
"}"
] | initializes the map view position.
@param mvp the map view position to be set
@return the mapviewposition set | [
"initializes",
"the",
"map",
"view",
"position",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-android/src/main/java/org/mapsforge/map/android/util/MapViewerTemplate.java#L252-L261 |
28,469 | mapsforge/mapsforge | mapsforge-map-android/src/main/java/org/mapsforge/map/android/util/MapViewerTemplate.java | MapViewerTemplate.onCreate | @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
createSharedPreferences();
createMapViews();
createTileCaches();
checkPermissionsAndCreateLayersAndControls();
} | java | @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
createSharedPreferences();
createMapViews();
createTileCaches();
checkPermissionsAndCreateLayersAndControls();
} | [
"@",
"Override",
"protected",
"void",
"onCreate",
"(",
"Bundle",
"savedInstanceState",
")",
"{",
"super",
".",
"onCreate",
"(",
"savedInstanceState",
")",
";",
"createSharedPreferences",
"(",
")",
";",
"createMapViews",
"(",
")",
";",
"createTileCaches",
"(",
")",
";",
"checkPermissionsAndCreateLayersAndControls",
"(",
")",
";",
"}"
] | Android Activity life cycle method.
@param savedInstanceState | [
"Android",
"Activity",
"life",
"cycle",
"method",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-map-android/src/main/java/org/mapsforge/map/android/util/MapViewerTemplate.java#L276-L283 |
28,470 | mapsforge/mapsforge | mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/group/GroupMarker.java | GroupMarker.onTap | @Override
public boolean onTap(LatLong tapLatLong, Point layerXY, Point tapXY) {
this.expanded = !this.expanded;
double centerX = layerXY.x + this.getHorizontalOffset();
double centerY = layerXY.y + this.getVerticalOffset();
double radiusX = this.getBitmap().getWidth() / 2;
double radiusY = this.getBitmap().getHeight() / 2;
double distX = Math.abs(centerX - tapXY.x);
double distY = Math.abs(centerY - tapXY.y);
if (distX < radiusX && distY < radiusY) {
if (this.expanded) {
// remove all child markers
for (Layer elt : this.layers) {
if (elt instanceof ChildMarker) {
this.layers.remove(elt);
}
}
// begin with (n). than the child marker will be over the line.
int i = this.children.size();
for (ChildMarker marker : this.children) {
marker.init(i, getBitmap(), getHorizontalOffset(), getVerticalOffset());
// add child to layer
this.layers.add(marker);
i--;
}
} else {
// remove all child layers
for (ChildMarker childMarker : this.children) {
this.layers.remove(childMarker);
}
}
return true;
}
return false;
} | java | @Override
public boolean onTap(LatLong tapLatLong, Point layerXY, Point tapXY) {
this.expanded = !this.expanded;
double centerX = layerXY.x + this.getHorizontalOffset();
double centerY = layerXY.y + this.getVerticalOffset();
double radiusX = this.getBitmap().getWidth() / 2;
double radiusY = this.getBitmap().getHeight() / 2;
double distX = Math.abs(centerX - tapXY.x);
double distY = Math.abs(centerY - tapXY.y);
if (distX < radiusX && distY < radiusY) {
if (this.expanded) {
// remove all child markers
for (Layer elt : this.layers) {
if (elt instanceof ChildMarker) {
this.layers.remove(elt);
}
}
// begin with (n). than the child marker will be over the line.
int i = this.children.size();
for (ChildMarker marker : this.children) {
marker.init(i, getBitmap(), getHorizontalOffset(), getVerticalOffset());
// add child to layer
this.layers.add(marker);
i--;
}
} else {
// remove all child layers
for (ChildMarker childMarker : this.children) {
this.layers.remove(childMarker);
}
}
return true;
}
return false;
} | [
"@",
"Override",
"public",
"boolean",
"onTap",
"(",
"LatLong",
"tapLatLong",
",",
"Point",
"layerXY",
",",
"Point",
"tapXY",
")",
"{",
"this",
".",
"expanded",
"=",
"!",
"this",
".",
"expanded",
";",
"double",
"centerX",
"=",
"layerXY",
".",
"x",
"+",
"this",
".",
"getHorizontalOffset",
"(",
")",
";",
"double",
"centerY",
"=",
"layerXY",
".",
"y",
"+",
"this",
".",
"getVerticalOffset",
"(",
")",
";",
"double",
"radiusX",
"=",
"this",
".",
"getBitmap",
"(",
")",
".",
"getWidth",
"(",
")",
"/",
"2",
";",
"double",
"radiusY",
"=",
"this",
".",
"getBitmap",
"(",
")",
".",
"getHeight",
"(",
")",
"/",
"2",
";",
"double",
"distX",
"=",
"Math",
".",
"abs",
"(",
"centerX",
"-",
"tapXY",
".",
"x",
")",
";",
"double",
"distY",
"=",
"Math",
".",
"abs",
"(",
"centerY",
"-",
"tapXY",
".",
"y",
")",
";",
"if",
"(",
"distX",
"<",
"radiusX",
"&&",
"distY",
"<",
"radiusY",
")",
"{",
"if",
"(",
"this",
".",
"expanded",
")",
"{",
"// remove all child markers",
"for",
"(",
"Layer",
"elt",
":",
"this",
".",
"layers",
")",
"{",
"if",
"(",
"elt",
"instanceof",
"ChildMarker",
")",
"{",
"this",
".",
"layers",
".",
"remove",
"(",
"elt",
")",
";",
"}",
"}",
"// begin with (n). than the child marker will be over the line.",
"int",
"i",
"=",
"this",
".",
"children",
".",
"size",
"(",
")",
";",
"for",
"(",
"ChildMarker",
"marker",
":",
"this",
".",
"children",
")",
"{",
"marker",
".",
"init",
"(",
"i",
",",
"getBitmap",
"(",
")",
",",
"getHorizontalOffset",
"(",
")",
",",
"getVerticalOffset",
"(",
")",
")",
";",
"// add child to layer",
"this",
".",
"layers",
".",
"add",
"(",
"marker",
")",
";",
"i",
"--",
";",
"}",
"}",
"else",
"{",
"// remove all child layers",
"for",
"(",
"ChildMarker",
"childMarker",
":",
"this",
".",
"children",
")",
"{",
"this",
".",
"layers",
".",
"remove",
"(",
"childMarker",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Click on group marker shows all children on a spiral. | [
"Click",
"on",
"group",
"marker",
"shows",
"all",
"children",
"on",
"a",
"spiral",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/group/GroupMarker.java#L112-L151 |
28,471 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteConnectionPool.java | SQLiteConnectionPool.shouldYieldConnection | public boolean shouldYieldConnection(SQLiteConnection connection, int connectionFlags) {
synchronized (mLock) {
if (!mAcquiredConnections.containsKey(connection)) {
throw new IllegalStateException("Cannot perform this operation "
+ "because the specified connection was not acquired "
+ "from this pool or has already been released.");
}
if (!mIsOpen) {
return false;
}
return isSessionBlockingImportantConnectionWaitersLocked(
connection.isPrimaryConnection(), connectionFlags);
}
} | java | public boolean shouldYieldConnection(SQLiteConnection connection, int connectionFlags) {
synchronized (mLock) {
if (!mAcquiredConnections.containsKey(connection)) {
throw new IllegalStateException("Cannot perform this operation "
+ "because the specified connection was not acquired "
+ "from this pool or has already been released.");
}
if (!mIsOpen) {
return false;
}
return isSessionBlockingImportantConnectionWaitersLocked(
connection.isPrimaryConnection(), connectionFlags);
}
} | [
"public",
"boolean",
"shouldYieldConnection",
"(",
"SQLiteConnection",
"connection",
",",
"int",
"connectionFlags",
")",
"{",
"synchronized",
"(",
"mLock",
")",
"{",
"if",
"(",
"!",
"mAcquiredConnections",
".",
"containsKey",
"(",
"connection",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Cannot perform this operation \"",
"+",
"\"because the specified connection was not acquired \"",
"+",
"\"from this pool or has already been released.\"",
")",
";",
"}",
"if",
"(",
"!",
"mIsOpen",
")",
"{",
"return",
"false",
";",
"}",
"return",
"isSessionBlockingImportantConnectionWaitersLocked",
"(",
"connection",
".",
"isPrimaryConnection",
"(",
")",
",",
"connectionFlags",
")",
";",
"}",
"}"
] | Returns true if the session should yield the connection due to
contention over available database connections.
@param connection The connection owned by the session.
@param connectionFlags The connection request flags.
@return True if the session should yield its connection.
@throws IllegalStateException if the connection was not acquired
from this pool or if it has already been released. | [
"Returns",
"true",
"if",
"the",
"session",
"should",
"yield",
"the",
"connection",
"due",
"to",
"contention",
"over",
"available",
"database",
"connections",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteConnectionPool.java#L424-L439 |
28,472 | mapsforge/mapsforge | sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteConnectionPool.java | SQLiteConnectionPool.dump | public void dump(Printer printer, boolean verbose) {
Printer indentedPrinter = printer;
synchronized (mLock) {
printer.println("Connection pool for " + mConfiguration.path + ":");
printer.println(" Open: " + mIsOpen);
printer.println(" Max connections: " + mMaxConnectionPoolSize);
printer.println(" Available primary connection:");
if (mAvailablePrimaryConnection != null) {
mAvailablePrimaryConnection.dump(indentedPrinter, verbose);
} else {
indentedPrinter.println("<none>");
}
printer.println(" Available non-primary connections:");
if (!mAvailableNonPrimaryConnections.isEmpty()) {
final int count = mAvailableNonPrimaryConnections.size();
for (int i = 0; i < count; i++) {
mAvailableNonPrimaryConnections.get(i).dump(indentedPrinter, verbose);
}
} else {
indentedPrinter.println("<none>");
}
printer.println(" Acquired connections:");
if (!mAcquiredConnections.isEmpty()) {
for (Map.Entry<SQLiteConnection, AcquiredConnectionStatus> entry :
mAcquiredConnections.entrySet()) {
final SQLiteConnection connection = entry.getKey();
connection.dumpUnsafe(indentedPrinter, verbose);
indentedPrinter.println(" Status: " + entry.getValue());
}
} else {
indentedPrinter.println("<none>");
}
printer.println(" Connection waiters:");
if (mConnectionWaiterQueue != null) {
int i = 0;
final long now = SystemClock.uptimeMillis();
for (ConnectionWaiter waiter = mConnectionWaiterQueue; waiter != null;
waiter = waiter.mNext, i++) {
indentedPrinter.println(i + ": waited for "
+ ((now - waiter.mStartTime) * 0.001f)
+ " ms - thread=" + waiter.mThread
+ ", priority=" + waiter.mPriority
+ ", sql='" + waiter.mSql + "'");
}
} else {
indentedPrinter.println("<none>");
}
}
} | java | public void dump(Printer printer, boolean verbose) {
Printer indentedPrinter = printer;
synchronized (mLock) {
printer.println("Connection pool for " + mConfiguration.path + ":");
printer.println(" Open: " + mIsOpen);
printer.println(" Max connections: " + mMaxConnectionPoolSize);
printer.println(" Available primary connection:");
if (mAvailablePrimaryConnection != null) {
mAvailablePrimaryConnection.dump(indentedPrinter, verbose);
} else {
indentedPrinter.println("<none>");
}
printer.println(" Available non-primary connections:");
if (!mAvailableNonPrimaryConnections.isEmpty()) {
final int count = mAvailableNonPrimaryConnections.size();
for (int i = 0; i < count; i++) {
mAvailableNonPrimaryConnections.get(i).dump(indentedPrinter, verbose);
}
} else {
indentedPrinter.println("<none>");
}
printer.println(" Acquired connections:");
if (!mAcquiredConnections.isEmpty()) {
for (Map.Entry<SQLiteConnection, AcquiredConnectionStatus> entry :
mAcquiredConnections.entrySet()) {
final SQLiteConnection connection = entry.getKey();
connection.dumpUnsafe(indentedPrinter, verbose);
indentedPrinter.println(" Status: " + entry.getValue());
}
} else {
indentedPrinter.println("<none>");
}
printer.println(" Connection waiters:");
if (mConnectionWaiterQueue != null) {
int i = 0;
final long now = SystemClock.uptimeMillis();
for (ConnectionWaiter waiter = mConnectionWaiterQueue; waiter != null;
waiter = waiter.mNext, i++) {
indentedPrinter.println(i + ": waited for "
+ ((now - waiter.mStartTime) * 0.001f)
+ " ms - thread=" + waiter.mThread
+ ", priority=" + waiter.mPriority
+ ", sql='" + waiter.mSql + "'");
}
} else {
indentedPrinter.println("<none>");
}
}
} | [
"public",
"void",
"dump",
"(",
"Printer",
"printer",
",",
"boolean",
"verbose",
")",
"{",
"Printer",
"indentedPrinter",
"=",
"printer",
";",
"synchronized",
"(",
"mLock",
")",
"{",
"printer",
".",
"println",
"(",
"\"Connection pool for \"",
"+",
"mConfiguration",
".",
"path",
"+",
"\":\"",
")",
";",
"printer",
".",
"println",
"(",
"\" Open: \"",
"+",
"mIsOpen",
")",
";",
"printer",
".",
"println",
"(",
"\" Max connections: \"",
"+",
"mMaxConnectionPoolSize",
")",
";",
"printer",
".",
"println",
"(",
"\" Available primary connection:\"",
")",
";",
"if",
"(",
"mAvailablePrimaryConnection",
"!=",
"null",
")",
"{",
"mAvailablePrimaryConnection",
".",
"dump",
"(",
"indentedPrinter",
",",
"verbose",
")",
";",
"}",
"else",
"{",
"indentedPrinter",
".",
"println",
"(",
"\"<none>\"",
")",
";",
"}",
"printer",
".",
"println",
"(",
"\" Available non-primary connections:\"",
")",
";",
"if",
"(",
"!",
"mAvailableNonPrimaryConnections",
".",
"isEmpty",
"(",
")",
")",
"{",
"final",
"int",
"count",
"=",
"mAvailableNonPrimaryConnections",
".",
"size",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
";",
"i",
"++",
")",
"{",
"mAvailableNonPrimaryConnections",
".",
"get",
"(",
"i",
")",
".",
"dump",
"(",
"indentedPrinter",
",",
"verbose",
")",
";",
"}",
"}",
"else",
"{",
"indentedPrinter",
".",
"println",
"(",
"\"<none>\"",
")",
";",
"}",
"printer",
".",
"println",
"(",
"\" Acquired connections:\"",
")",
";",
"if",
"(",
"!",
"mAcquiredConnections",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"SQLiteConnection",
",",
"AcquiredConnectionStatus",
">",
"entry",
":",
"mAcquiredConnections",
".",
"entrySet",
"(",
")",
")",
"{",
"final",
"SQLiteConnection",
"connection",
"=",
"entry",
".",
"getKey",
"(",
")",
";",
"connection",
".",
"dumpUnsafe",
"(",
"indentedPrinter",
",",
"verbose",
")",
";",
"indentedPrinter",
".",
"println",
"(",
"\" Status: \"",
"+",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"indentedPrinter",
".",
"println",
"(",
"\"<none>\"",
")",
";",
"}",
"printer",
".",
"println",
"(",
"\" Connection waiters:\"",
")",
";",
"if",
"(",
"mConnectionWaiterQueue",
"!=",
"null",
")",
"{",
"int",
"i",
"=",
"0",
";",
"final",
"long",
"now",
"=",
"SystemClock",
".",
"uptimeMillis",
"(",
")",
";",
"for",
"(",
"ConnectionWaiter",
"waiter",
"=",
"mConnectionWaiterQueue",
";",
"waiter",
"!=",
"null",
";",
"waiter",
"=",
"waiter",
".",
"mNext",
",",
"i",
"++",
")",
"{",
"indentedPrinter",
".",
"println",
"(",
"i",
"+",
"\": waited for \"",
"+",
"(",
"(",
"now",
"-",
"waiter",
".",
"mStartTime",
")",
"*",
"0.001f",
")",
"+",
"\" ms - thread=\"",
"+",
"waiter",
".",
"mThread",
"+",
"\", priority=\"",
"+",
"waiter",
".",
"mPriority",
"+",
"\", sql='\"",
"+",
"waiter",
".",
"mSql",
"+",
"\"'\"",
")",
";",
"}",
"}",
"else",
"{",
"indentedPrinter",
".",
"println",
"(",
"\"<none>\"",
")",
";",
"}",
"}",
"}"
] | Dumps debugging information about this connection pool.
@param printer The printer to receive the dump, not null.
@param verbose True to dump more verbose information. | [
"Dumps",
"debugging",
"information",
"about",
"this",
"connection",
"pool",
"."
] | c49c83f7f727552f793dff15cefa532ade030842 | https://github.com/mapsforge/mapsforge/blob/c49c83f7f727552f793dff15cefa532ade030842/sqlite-android/src/main/java/org/sqlite/database/sqlite/SQLiteConnectionPool.java#L1015-L1067 |
28,473 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/HandshakeReader.java | HandshakeReader.readStatusLine | private StatusLine readStatusLine(WebSocketInputStream input) throws WebSocketException
{
String line;
try
{
// Read the status line.
line = input.readLine();
}
catch (IOException e)
{
// Failed to read an opening handshake response from the server.
throw new WebSocketException(
WebSocketError.OPENING_HANDSHAKE_RESPONSE_FAILURE,
"Failed to read an opening handshake response from the server: " + e.getMessage(), e);
}
if (line == null || line.length() == 0)
{
// The status line of the opening handshake response is empty.
throw new WebSocketException(
WebSocketError.STATUS_LINE_EMPTY,
"The status line of the opening handshake response is empty.");
}
try
{
// Parse the status line.
return new StatusLine(line);
}
catch (Exception e)
{
// The status line of the opening handshake response is badly formatted.
throw new WebSocketException(
WebSocketError.STATUS_LINE_BAD_FORMAT,
"The status line of the opening handshake response is badly formatted. The status line is: " + line);
}
} | java | private StatusLine readStatusLine(WebSocketInputStream input) throws WebSocketException
{
String line;
try
{
// Read the status line.
line = input.readLine();
}
catch (IOException e)
{
// Failed to read an opening handshake response from the server.
throw new WebSocketException(
WebSocketError.OPENING_HANDSHAKE_RESPONSE_FAILURE,
"Failed to read an opening handshake response from the server: " + e.getMessage(), e);
}
if (line == null || line.length() == 0)
{
// The status line of the opening handshake response is empty.
throw new WebSocketException(
WebSocketError.STATUS_LINE_EMPTY,
"The status line of the opening handshake response is empty.");
}
try
{
// Parse the status line.
return new StatusLine(line);
}
catch (Exception e)
{
// The status line of the opening handshake response is badly formatted.
throw new WebSocketException(
WebSocketError.STATUS_LINE_BAD_FORMAT,
"The status line of the opening handshake response is badly formatted. The status line is: " + line);
}
} | [
"private",
"StatusLine",
"readStatusLine",
"(",
"WebSocketInputStream",
"input",
")",
"throws",
"WebSocketException",
"{",
"String",
"line",
";",
"try",
"{",
"// Read the status line.",
"line",
"=",
"input",
".",
"readLine",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// Failed to read an opening handshake response from the server.",
"throw",
"new",
"WebSocketException",
"(",
"WebSocketError",
".",
"OPENING_HANDSHAKE_RESPONSE_FAILURE",
",",
"\"Failed to read an opening handshake response from the server: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"if",
"(",
"line",
"==",
"null",
"||",
"line",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"// The status line of the opening handshake response is empty.",
"throw",
"new",
"WebSocketException",
"(",
"WebSocketError",
".",
"STATUS_LINE_EMPTY",
",",
"\"The status line of the opening handshake response is empty.\"",
")",
";",
"}",
"try",
"{",
"// Parse the status line.",
"return",
"new",
"StatusLine",
"(",
"line",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// The status line of the opening handshake response is badly formatted.",
"throw",
"new",
"WebSocketException",
"(",
"WebSocketError",
".",
"STATUS_LINE_BAD_FORMAT",
",",
"\"The status line of the opening handshake response is badly formatted. The status line is: \"",
"+",
"line",
")",
";",
"}",
"}"
] | Read a status line from an HTTP server. | [
"Read",
"a",
"status",
"line",
"from",
"an",
"HTTP",
"server",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/HandshakeReader.java#L79-L116 |
28,474 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/HandshakeReader.java | HandshakeReader.readBody | private byte[] readBody(Map<String, List<String>> headers, WebSocketInputStream input)
{
// Get the value of "Content-Length" header.
int length = getContentLength(headers);
if (length <= 0)
{
// Response body is not available.
return null;
}
try
{
// Allocate a byte array of the content length.
byte[] body = new byte[length];
// Read the response body into the byte array.
input.readBytes(body, length);
// Return the content of the response body.
return body;
}
catch (Throwable t)
{
// Response body is not available.
return null;
}
} | java | private byte[] readBody(Map<String, List<String>> headers, WebSocketInputStream input)
{
// Get the value of "Content-Length" header.
int length = getContentLength(headers);
if (length <= 0)
{
// Response body is not available.
return null;
}
try
{
// Allocate a byte array of the content length.
byte[] body = new byte[length];
// Read the response body into the byte array.
input.readBytes(body, length);
// Return the content of the response body.
return body;
}
catch (Throwable t)
{
// Response body is not available.
return null;
}
} | [
"private",
"byte",
"[",
"]",
"readBody",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
",",
"WebSocketInputStream",
"input",
")",
"{",
"// Get the value of \"Content-Length\" header.",
"int",
"length",
"=",
"getContentLength",
"(",
"headers",
")",
";",
"if",
"(",
"length",
"<=",
"0",
")",
"{",
"// Response body is not available.",
"return",
"null",
";",
"}",
"try",
"{",
"// Allocate a byte array of the content length.",
"byte",
"[",
"]",
"body",
"=",
"new",
"byte",
"[",
"length",
"]",
";",
"// Read the response body into the byte array.",
"input",
".",
"readBytes",
"(",
"body",
",",
"length",
")",
";",
"// Return the content of the response body.",
"return",
"body",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"// Response body is not available.",
"return",
"null",
";",
"}",
"}"
] | Read the response body | [
"Read",
"the",
"response",
"body"
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/HandshakeReader.java#L242-L269 |
28,475 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/HandshakeReader.java | HandshakeReader.getContentLength | private int getContentLength(Map<String, List<String>> headers)
{
try
{
return Integer.parseInt(headers.get("Content-Length").get(0));
}
catch (Exception e)
{
return -1;
}
} | java | private int getContentLength(Map<String, List<String>> headers)
{
try
{
return Integer.parseInt(headers.get("Content-Length").get(0));
}
catch (Exception e)
{
return -1;
}
} | [
"private",
"int",
"getContentLength",
"(",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
")",
"{",
"try",
"{",
"return",
"Integer",
".",
"parseInt",
"(",
"headers",
".",
"get",
"(",
"\"Content-Length\"",
")",
".",
"get",
"(",
"0",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"-",
"1",
";",
"}",
"}"
] | Get the value of "Content-Length" header. | [
"Get",
"the",
"value",
"of",
"Content",
"-",
"Length",
"header",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/HandshakeReader.java#L275-L285 |
28,476 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocketExtension.java | WebSocketExtension.setParameter | public WebSocketExtension setParameter(String key, String value)
{
// Check the validity of the key.
if (Token.isValid(key) == false)
{
// The key is not a valid token.
throw new IllegalArgumentException("'key' is not a valid token.");
}
// If the value is not null.
if (value != null)
{
// Check the validity of the value.
if (Token.isValid(value) == false)
{
// The value is not a valid token.
throw new IllegalArgumentException("'value' is not a valid token.");
}
}
mParameters.put(key, value);
return this;
} | java | public WebSocketExtension setParameter(String key, String value)
{
// Check the validity of the key.
if (Token.isValid(key) == false)
{
// The key is not a valid token.
throw new IllegalArgumentException("'key' is not a valid token.");
}
// If the value is not null.
if (value != null)
{
// Check the validity of the value.
if (Token.isValid(value) == false)
{
// The value is not a valid token.
throw new IllegalArgumentException("'value' is not a valid token.");
}
}
mParameters.put(key, value);
return this;
} | [
"public",
"WebSocketExtension",
"setParameter",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"// Check the validity of the key.",
"if",
"(",
"Token",
".",
"isValid",
"(",
"key",
")",
"==",
"false",
")",
"{",
"// The key is not a valid token.",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"'key' is not a valid token.\"",
")",
";",
"}",
"// If the value is not null.",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"// Check the validity of the value.",
"if",
"(",
"Token",
".",
"isValid",
"(",
"value",
")",
"==",
"false",
")",
"{",
"// The value is not a valid token.",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"'value' is not a valid token.\"",
")",
";",
"}",
"}",
"mParameters",
".",
"put",
"(",
"key",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Set a value to the specified parameter.
@param key
The name of the parameter.
@param value
The value of the parameter. If not {@code null}, it must be
a valid token. Note that <a href="http://tools.ietf.org/html/rfc6455"
>RFC 6455</a> says "<i>When using the quoted-string syntax
variant, the value after quoted-string unescaping MUST
conform to the 'token' ABNF.</i>"
@return
{@code this} object.
@throws IllegalArgumentException
<ul>
<li>The key is not a valid token.
<li>The value is not {@code null} and it is not a valid token.
</ul> | [
"Set",
"a",
"value",
"to",
"the",
"specified",
"parameter",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocketExtension.java#L167-L190 |
28,477 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java | WebSocketFrame.setPayload | public WebSocketFrame setPayload(byte[] payload)
{
if (payload != null && payload.length == 0)
{
payload = null;
}
mPayload = payload;
return this;
} | java | public WebSocketFrame setPayload(byte[] payload)
{
if (payload != null && payload.length == 0)
{
payload = null;
}
mPayload = payload;
return this;
} | [
"public",
"WebSocketFrame",
"setPayload",
"(",
"byte",
"[",
"]",
"payload",
")",
"{",
"if",
"(",
"payload",
"!=",
"null",
"&&",
"payload",
".",
"length",
"==",
"0",
")",
"{",
"payload",
"=",
"null",
";",
"}",
"mPayload",
"=",
"payload",
";",
"return",
"this",
";",
"}"
] | Set the unmasked payload.
<p>
Note that the payload length of a <a href="http://tools.ietf.org/html/rfc6455#section-5.5"
>control frame</a> must be 125 bytes or less.
</p>
@param payload
The unmasked payload. {@code null} is accepted.
An empty byte array is treated in the same way
as {@code null}.
@return
{@code this} object. | [
"Set",
"the",
"unmasked",
"payload",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java#L488-L498 |
28,478 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java | WebSocketFrame.setPayload | public WebSocketFrame setPayload(String payload)
{
if (payload == null || payload.length() == 0)
{
return setPayload((byte[])null);
}
return setPayload(Misc.getBytesUTF8(payload));
} | java | public WebSocketFrame setPayload(String payload)
{
if (payload == null || payload.length() == 0)
{
return setPayload((byte[])null);
}
return setPayload(Misc.getBytesUTF8(payload));
} | [
"public",
"WebSocketFrame",
"setPayload",
"(",
"String",
"payload",
")",
"{",
"if",
"(",
"payload",
"==",
"null",
"||",
"payload",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"setPayload",
"(",
"(",
"byte",
"[",
"]",
")",
"null",
")",
";",
"}",
"return",
"setPayload",
"(",
"Misc",
".",
"getBytesUTF8",
"(",
"payload",
")",
")",
";",
"}"
] | Set the payload. The given string is converted to a byte array
in UTF-8 encoding.
<p>
Note that the payload length of a <a href="http://tools.ietf.org/html/rfc6455#section-5.5"
>control frame</a> must be 125 bytes or less.
</p>
@param payload
The unmasked payload. {@code null} is accepted.
An empty string is treated in the same way as
{@code null}.
@return
{@code this} object. | [
"Set",
"the",
"payload",
".",
"The",
"given",
"string",
"is",
"converted",
"to",
"a",
"byte",
"array",
"in",
"UTF",
"-",
"8",
"encoding",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java#L518-L526 |
28,479 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java | WebSocketFrame.setCloseFramePayload | public WebSocketFrame setCloseFramePayload(int closeCode, String reason)
{
// Convert the close code to a 2-byte unsigned integer
// in network byte order.
byte[] encodedCloseCode = new byte[] {
(byte)((closeCode >> 8) & 0xFF),
(byte)((closeCode ) & 0xFF)
};
// If a reason string is not given.
if (reason == null || reason.length() == 0)
{
// Use the close code only.
return setPayload(encodedCloseCode);
}
// Convert the reason into a byte array.
byte[] encodedReason = Misc.getBytesUTF8(reason);
// Concatenate the close code and the reason.
byte[] payload = new byte[2 + encodedReason.length];
System.arraycopy(encodedCloseCode, 0, payload, 0, 2);
System.arraycopy(encodedReason, 0, payload, 2, encodedReason.length);
// Use the concatenated string.
return setPayload(payload);
} | java | public WebSocketFrame setCloseFramePayload(int closeCode, String reason)
{
// Convert the close code to a 2-byte unsigned integer
// in network byte order.
byte[] encodedCloseCode = new byte[] {
(byte)((closeCode >> 8) & 0xFF),
(byte)((closeCode ) & 0xFF)
};
// If a reason string is not given.
if (reason == null || reason.length() == 0)
{
// Use the close code only.
return setPayload(encodedCloseCode);
}
// Convert the reason into a byte array.
byte[] encodedReason = Misc.getBytesUTF8(reason);
// Concatenate the close code and the reason.
byte[] payload = new byte[2 + encodedReason.length];
System.arraycopy(encodedCloseCode, 0, payload, 0, 2);
System.arraycopy(encodedReason, 0, payload, 2, encodedReason.length);
// Use the concatenated string.
return setPayload(payload);
} | [
"public",
"WebSocketFrame",
"setCloseFramePayload",
"(",
"int",
"closeCode",
",",
"String",
"reason",
")",
"{",
"// Convert the close code to a 2-byte unsigned integer",
"// in network byte order.",
"byte",
"[",
"]",
"encodedCloseCode",
"=",
"new",
"byte",
"[",
"]",
"{",
"(",
"byte",
")",
"(",
"(",
"closeCode",
">>",
"8",
")",
"&",
"0xFF",
")",
",",
"(",
"byte",
")",
"(",
"(",
"closeCode",
")",
"&",
"0xFF",
")",
"}",
";",
"// If a reason string is not given.",
"if",
"(",
"reason",
"==",
"null",
"||",
"reason",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"// Use the close code only.",
"return",
"setPayload",
"(",
"encodedCloseCode",
")",
";",
"}",
"// Convert the reason into a byte array.",
"byte",
"[",
"]",
"encodedReason",
"=",
"Misc",
".",
"getBytesUTF8",
"(",
"reason",
")",
";",
"// Concatenate the close code and the reason.",
"byte",
"[",
"]",
"payload",
"=",
"new",
"byte",
"[",
"2",
"+",
"encodedReason",
".",
"length",
"]",
";",
"System",
".",
"arraycopy",
"(",
"encodedCloseCode",
",",
"0",
",",
"payload",
",",
"0",
",",
"2",
")",
";",
"System",
".",
"arraycopy",
"(",
"encodedReason",
",",
"0",
",",
"payload",
",",
"2",
",",
"encodedReason",
".",
"length",
")",
";",
"// Use the concatenated string.",
"return",
"setPayload",
"(",
"payload",
")",
";",
"}"
] | Set the payload that conforms to the payload format of close frames.
<p>
The given parameters are encoded based on the rules described in
"<a href="http://tools.ietf.org/html/rfc6455#section-5.5.1"
>5.5.1. Close</a>" of RFC 6455.
</p>
<p>
Note that the reason should not be too long because the payload
length of a <a href="http://tools.ietf.org/html/rfc6455#section-5.5"
>control frame</a> must be 125 bytes or less.
</p>
@param closeCode
The close code.
@param reason
The reason. {@code null} is accepted. An empty string
is treated in the same way as {@code null}.
@return
{@code this} object.
@see <a href="http://tools.ietf.org/html/rfc6455#section-5.5.1"
>RFC 6455, 5.5.1. Close</a>
@see WebSocketCloseCode | [
"Set",
"the",
"payload",
"that",
"conforms",
"to",
"the",
"payload",
"format",
"of",
"close",
"frames",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java#L559-L585 |
28,480 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java | WebSocketFrame.getCloseCode | public int getCloseCode()
{
if (mPayload == null || mPayload.length < 2)
{
return WebSocketCloseCode.NONE;
}
// A close code is encoded in network byte order.
int closeCode = (((mPayload[0] & 0xFF) << 8) | (mPayload[1] & 0xFF));
return closeCode;
} | java | public int getCloseCode()
{
if (mPayload == null || mPayload.length < 2)
{
return WebSocketCloseCode.NONE;
}
// A close code is encoded in network byte order.
int closeCode = (((mPayload[0] & 0xFF) << 8) | (mPayload[1] & 0xFF));
return closeCode;
} | [
"public",
"int",
"getCloseCode",
"(",
")",
"{",
"if",
"(",
"mPayload",
"==",
"null",
"||",
"mPayload",
".",
"length",
"<",
"2",
")",
"{",
"return",
"WebSocketCloseCode",
".",
"NONE",
";",
"}",
"// A close code is encoded in network byte order.",
"int",
"closeCode",
"=",
"(",
"(",
"(",
"mPayload",
"[",
"0",
"]",
"&",
"0xFF",
")",
"<<",
"8",
")",
"|",
"(",
"mPayload",
"[",
"1",
"]",
"&",
"0xFF",
")",
")",
";",
"return",
"closeCode",
";",
"}"
] | Parse the first two bytes of the payload as a close code.
<p>
If any payload is not set or the length of the payload is less than 2,
this method returns 1005 ({@link WebSocketCloseCode#NONE}).
</p>
<p>
The value returned from this method is meaningless if this frame
is not a close frame.
</p>
@return
The close code.
@see <a href="http://tools.ietf.org/html/rfc6455#section-5.5.1"
>RFC 6455, 5.5.1. Close</a>
@see WebSocketCloseCode | [
"Parse",
"the",
"first",
"two",
"bytes",
"of",
"the",
"payload",
"as",
"a",
"close",
"code",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java#L609-L620 |
28,481 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java | WebSocketFrame.getCloseReason | public String getCloseReason()
{
if (mPayload == null || mPayload.length < 3)
{
return null;
}
return Misc.toStringUTF8(mPayload, 2, mPayload.length - 2);
} | java | public String getCloseReason()
{
if (mPayload == null || mPayload.length < 3)
{
return null;
}
return Misc.toStringUTF8(mPayload, 2, mPayload.length - 2);
} | [
"public",
"String",
"getCloseReason",
"(",
")",
"{",
"if",
"(",
"mPayload",
"==",
"null",
"||",
"mPayload",
".",
"length",
"<",
"3",
")",
"{",
"return",
"null",
";",
"}",
"return",
"Misc",
".",
"toStringUTF8",
"(",
"mPayload",
",",
"2",
",",
"mPayload",
".",
"length",
"-",
"2",
")",
";",
"}"
] | Parse the third and subsequent bytes of the payload as a close reason.
<p>
If any payload is not set or the length of the payload is less than 3,
this method returns {@code null}.
</p>
<p>
The value returned from this method is meaningless if this frame
is not a close frame.
</p>
@return
The close reason. | [
"Parse",
"the",
"third",
"and",
"subsequent",
"bytes",
"of",
"the",
"payload",
"as",
"a",
"close",
"reason",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java#L639-L647 |
28,482 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java | WebSocketFrame.createTextFrame | public static WebSocketFrame createTextFrame(String payload)
{
return new WebSocketFrame()
.setFin(true)
.setOpcode(TEXT)
.setPayload(payload);
} | java | public static WebSocketFrame createTextFrame(String payload)
{
return new WebSocketFrame()
.setFin(true)
.setOpcode(TEXT)
.setPayload(payload);
} | [
"public",
"static",
"WebSocketFrame",
"createTextFrame",
"(",
"String",
"payload",
")",
"{",
"return",
"new",
"WebSocketFrame",
"(",
")",
".",
"setFin",
"(",
"true",
")",
".",
"setOpcode",
"(",
"TEXT",
")",
".",
"setPayload",
"(",
"payload",
")",
";",
"}"
] | Create a text frame.
@param payload
The payload for a newly created frame.
@return
A WebSocket frame whose FIN bit is true, opcode is
{@link WebSocketOpcode#TEXT TEXT} and payload is
the given one. | [
"Create",
"a",
"text",
"frame",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java#L824-L830 |
28,483 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java | WebSocketFrame.createBinaryFrame | public static WebSocketFrame createBinaryFrame(byte[] payload)
{
return new WebSocketFrame()
.setFin(true)
.setOpcode(BINARY)
.setPayload(payload);
} | java | public static WebSocketFrame createBinaryFrame(byte[] payload)
{
return new WebSocketFrame()
.setFin(true)
.setOpcode(BINARY)
.setPayload(payload);
} | [
"public",
"static",
"WebSocketFrame",
"createBinaryFrame",
"(",
"byte",
"[",
"]",
"payload",
")",
"{",
"return",
"new",
"WebSocketFrame",
"(",
")",
".",
"setFin",
"(",
"true",
")",
".",
"setOpcode",
"(",
"BINARY",
")",
".",
"setPayload",
"(",
"payload",
")",
";",
"}"
] | Create a binary frame.
@param payload
The payload for a newly created frame.
@return
A WebSocket frame whose FIN bit is true, opcode is
{@link WebSocketOpcode#BINARY BINARY} and payload is
the given one. | [
"Create",
"a",
"binary",
"frame",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocketFrame.java#L844-L850 |
28,484 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/ByteArray.java | ByteArray.get | public byte get(int index) throws IndexOutOfBoundsException
{
if (index < 0 || mLength <= index)
{
// Bad index.
throw new IndexOutOfBoundsException(
String.format("Bad index: index=%d, length=%d", index, mLength));
}
return mBuffer.get(index);
} | java | public byte get(int index) throws IndexOutOfBoundsException
{
if (index < 0 || mLength <= index)
{
// Bad index.
throw new IndexOutOfBoundsException(
String.format("Bad index: index=%d, length=%d", index, mLength));
}
return mBuffer.get(index);
} | [
"public",
"byte",
"get",
"(",
"int",
"index",
")",
"throws",
"IndexOutOfBoundsException",
"{",
"if",
"(",
"index",
"<",
"0",
"||",
"mLength",
"<=",
"index",
")",
"{",
"// Bad index.",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"String",
".",
"format",
"(",
"\"Bad index: index=%d, length=%d\"",
",",
"index",
",",
"mLength",
")",
")",
";",
"}",
"return",
"mBuffer",
".",
"get",
"(",
"index",
")",
";",
"}"
] | Get a byte at the index. | [
"Get",
"a",
"byte",
"at",
"the",
"index",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/ByteArray.java#L75-L85 |
28,485 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/ByteArray.java | ByteArray.expandBuffer | private void expandBuffer(int newBufferSize)
{
// Allocate a new buffer.
ByteBuffer newBuffer = ByteBuffer.allocate(newBufferSize);
// Copy the content of the current buffer to the new buffer.
int oldPosition = mBuffer.position();
mBuffer.position(0);
newBuffer.put(mBuffer);
newBuffer.position(oldPosition);
// Replace the buffers.
mBuffer = newBuffer;
} | java | private void expandBuffer(int newBufferSize)
{
// Allocate a new buffer.
ByteBuffer newBuffer = ByteBuffer.allocate(newBufferSize);
// Copy the content of the current buffer to the new buffer.
int oldPosition = mBuffer.position();
mBuffer.position(0);
newBuffer.put(mBuffer);
newBuffer.position(oldPosition);
// Replace the buffers.
mBuffer = newBuffer;
} | [
"private",
"void",
"expandBuffer",
"(",
"int",
"newBufferSize",
")",
"{",
"// Allocate a new buffer.",
"ByteBuffer",
"newBuffer",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"newBufferSize",
")",
";",
"// Copy the content of the current buffer to the new buffer.",
"int",
"oldPosition",
"=",
"mBuffer",
".",
"position",
"(",
")",
";",
"mBuffer",
".",
"position",
"(",
"0",
")",
";",
"newBuffer",
".",
"put",
"(",
"mBuffer",
")",
";",
"newBuffer",
".",
"position",
"(",
"oldPosition",
")",
";",
"// Replace the buffers.",
"mBuffer",
"=",
"newBuffer",
";",
"}"
] | Expand the size of the internal buffer. | [
"Expand",
"the",
"size",
"of",
"the",
"internal",
"buffer",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/ByteArray.java#L91-L104 |
28,486 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/ByteArray.java | ByteArray.put | public void put(int data)
{
// If the buffer is small.
if (mBuffer.capacity() < (mLength + 1))
{
expandBuffer(mLength + ADDITIONAL_BUFFER_SIZE);
}
mBuffer.put((byte)data);
++mLength;
} | java | public void put(int data)
{
// If the buffer is small.
if (mBuffer.capacity() < (mLength + 1))
{
expandBuffer(mLength + ADDITIONAL_BUFFER_SIZE);
}
mBuffer.put((byte)data);
++mLength;
} | [
"public",
"void",
"put",
"(",
"int",
"data",
")",
"{",
"// If the buffer is small.",
"if",
"(",
"mBuffer",
".",
"capacity",
"(",
")",
"<",
"(",
"mLength",
"+",
"1",
")",
")",
"{",
"expandBuffer",
"(",
"mLength",
"+",
"ADDITIONAL_BUFFER_SIZE",
")",
";",
"}",
"mBuffer",
".",
"put",
"(",
"(",
"byte",
")",
"data",
")",
";",
"++",
"mLength",
";",
"}"
] | Add a byte at the current position. | [
"Add",
"a",
"byte",
"at",
"the",
"current",
"position",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/ByteArray.java#L110-L120 |
28,487 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/ReadingThread.java | ReadingThread.verifyReservedBit1 | private void verifyReservedBit1(WebSocketFrame frame) throws WebSocketException
{
// If a per-message compression extension has been agreed.
if (mPMCE != null)
{
// Verify the RSV1 bit using the rule described in RFC 7692.
boolean verified = verifyReservedBit1ForPMCE(frame);
if (verified)
{
return;
}
}
if (frame.getRsv1() == false)
{
// No problem.
return;
}
// The RSV1 bit of a frame is set unexpectedly.
throw new WebSocketException(
WebSocketError.UNEXPECTED_RESERVED_BIT, "The RSV1 bit of a frame is set unexpectedly.");
} | java | private void verifyReservedBit1(WebSocketFrame frame) throws WebSocketException
{
// If a per-message compression extension has been agreed.
if (mPMCE != null)
{
// Verify the RSV1 bit using the rule described in RFC 7692.
boolean verified = verifyReservedBit1ForPMCE(frame);
if (verified)
{
return;
}
}
if (frame.getRsv1() == false)
{
// No problem.
return;
}
// The RSV1 bit of a frame is set unexpectedly.
throw new WebSocketException(
WebSocketError.UNEXPECTED_RESERVED_BIT, "The RSV1 bit of a frame is set unexpectedly.");
} | [
"private",
"void",
"verifyReservedBit1",
"(",
"WebSocketFrame",
"frame",
")",
"throws",
"WebSocketException",
"{",
"// If a per-message compression extension has been agreed.",
"if",
"(",
"mPMCE",
"!=",
"null",
")",
"{",
"// Verify the RSV1 bit using the rule described in RFC 7692.",
"boolean",
"verified",
"=",
"verifyReservedBit1ForPMCE",
"(",
"frame",
")",
";",
"if",
"(",
"verified",
")",
"{",
"return",
";",
"}",
"}",
"if",
"(",
"frame",
".",
"getRsv1",
"(",
")",
"==",
"false",
")",
"{",
"// No problem.",
"return",
";",
"}",
"// The RSV1 bit of a frame is set unexpectedly.",
"throw",
"new",
"WebSocketException",
"(",
"WebSocketError",
".",
"UNEXPECTED_RESERVED_BIT",
",",
"\"The RSV1 bit of a frame is set unexpectedly.\"",
")",
";",
"}"
] | Verify the RSV1 bit of a frame. | [
"Verify",
"the",
"RSV1",
"bit",
"of",
"a",
"frame",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/ReadingThread.java#L460-L483 |
28,488 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/ReadingThread.java | ReadingThread.verifyReservedBit2 | private void verifyReservedBit2(WebSocketFrame frame) throws WebSocketException
{
if (frame.getRsv2() == false)
{
// No problem.
return;
}
// The RSV2 bit of a frame is set unexpectedly.
throw new WebSocketException(
WebSocketError.UNEXPECTED_RESERVED_BIT, "The RSV2 bit of a frame is set unexpectedly.");
} | java | private void verifyReservedBit2(WebSocketFrame frame) throws WebSocketException
{
if (frame.getRsv2() == false)
{
// No problem.
return;
}
// The RSV2 bit of a frame is set unexpectedly.
throw new WebSocketException(
WebSocketError.UNEXPECTED_RESERVED_BIT, "The RSV2 bit of a frame is set unexpectedly.");
} | [
"private",
"void",
"verifyReservedBit2",
"(",
"WebSocketFrame",
"frame",
")",
"throws",
"WebSocketException",
"{",
"if",
"(",
"frame",
".",
"getRsv2",
"(",
")",
"==",
"false",
")",
"{",
"// No problem.",
"return",
";",
"}",
"// The RSV2 bit of a frame is set unexpectedly.",
"throw",
"new",
"WebSocketException",
"(",
"WebSocketError",
".",
"UNEXPECTED_RESERVED_BIT",
",",
"\"The RSV2 bit of a frame is set unexpectedly.\"",
")",
";",
"}"
] | Verify the RSV2 bit of a frame. | [
"Verify",
"the",
"RSV2",
"bit",
"of",
"a",
"frame",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/ReadingThread.java#L509-L520 |
28,489 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/ReadingThread.java | ReadingThread.verifyReservedBit3 | private void verifyReservedBit3(WebSocketFrame frame) throws WebSocketException
{
if (frame.getRsv3() == false)
{
// No problem.
return;
}
// The RSV3 bit of a frame is set unexpectedly.
throw new WebSocketException(
WebSocketError.UNEXPECTED_RESERVED_BIT, "The RSV3 bit of a frame is set unexpectedly.");
} | java | private void verifyReservedBit3(WebSocketFrame frame) throws WebSocketException
{
if (frame.getRsv3() == false)
{
// No problem.
return;
}
// The RSV3 bit of a frame is set unexpectedly.
throw new WebSocketException(
WebSocketError.UNEXPECTED_RESERVED_BIT, "The RSV3 bit of a frame is set unexpectedly.");
} | [
"private",
"void",
"verifyReservedBit3",
"(",
"WebSocketFrame",
"frame",
")",
"throws",
"WebSocketException",
"{",
"if",
"(",
"frame",
".",
"getRsv3",
"(",
")",
"==",
"false",
")",
"{",
"// No problem.",
"return",
";",
"}",
"// The RSV3 bit of a frame is set unexpectedly.",
"throw",
"new",
"WebSocketException",
"(",
"WebSocketError",
".",
"UNEXPECTED_RESERVED_BIT",
",",
"\"The RSV3 bit of a frame is set unexpectedly.\"",
")",
";",
"}"
] | Verify the RSV3 bit of a frame. | [
"Verify",
"the",
"RSV3",
"bit",
"of",
"a",
"frame",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/ReadingThread.java#L526-L537 |
28,490 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/ReadingThread.java | ReadingThread.verifyFrameOpcode | private void verifyFrameOpcode(WebSocketFrame frame) throws WebSocketException
{
switch (frame.getOpcode())
{
case CONTINUATION:
case TEXT:
case BINARY:
case CLOSE:
case PING:
case PONG:
// Known opcode
return;
default:
break;
}
// If extended use of web socket frames is allowed.
if (mWebSocket.isExtended())
{
// Allow the unknown opcode.
return;
}
// A frame has an unknown opcode.
throw new WebSocketException(
WebSocketError.UNKNOWN_OPCODE,
"A frame has an unknown opcode: 0x" + Integer.toHexString(frame.getOpcode()));
} | java | private void verifyFrameOpcode(WebSocketFrame frame) throws WebSocketException
{
switch (frame.getOpcode())
{
case CONTINUATION:
case TEXT:
case BINARY:
case CLOSE:
case PING:
case PONG:
// Known opcode
return;
default:
break;
}
// If extended use of web socket frames is allowed.
if (mWebSocket.isExtended())
{
// Allow the unknown opcode.
return;
}
// A frame has an unknown opcode.
throw new WebSocketException(
WebSocketError.UNKNOWN_OPCODE,
"A frame has an unknown opcode: 0x" + Integer.toHexString(frame.getOpcode()));
} | [
"private",
"void",
"verifyFrameOpcode",
"(",
"WebSocketFrame",
"frame",
")",
"throws",
"WebSocketException",
"{",
"switch",
"(",
"frame",
".",
"getOpcode",
"(",
")",
")",
"{",
"case",
"CONTINUATION",
":",
"case",
"TEXT",
":",
"case",
"BINARY",
":",
"case",
"CLOSE",
":",
"case",
"PING",
":",
"case",
"PONG",
":",
"// Known opcode",
"return",
";",
"default",
":",
"break",
";",
"}",
"// If extended use of web socket frames is allowed.",
"if",
"(",
"mWebSocket",
".",
"isExtended",
"(",
")",
")",
"{",
"// Allow the unknown opcode.",
"return",
";",
"}",
"// A frame has an unknown opcode.",
"throw",
"new",
"WebSocketException",
"(",
"WebSocketError",
".",
"UNKNOWN_OPCODE",
",",
"\"A frame has an unknown opcode: 0x\"",
"+",
"Integer",
".",
"toHexString",
"(",
"frame",
".",
"getOpcode",
"(",
")",
")",
")",
";",
"}"
] | Ensure that the opcode of the give frame is a known one.
<blockquote>
<p>From RFC 6455, 5.2. Base Framing Protocol</p>
<p><i>
If an unknown opcode is received, the receiving endpoint MUST
Fail the WebSocket Connection.
</i></p>
</blockquote> | [
"Ensure",
"that",
"the",
"opcode",
"of",
"the",
"give",
"frame",
"is",
"a",
"known",
"one",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/ReadingThread.java#L551-L579 |
28,491 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/ProxySettings.java | ProxySettings.reset | public ProxySettings reset()
{
mSecure = false;
mHost = null;
mPort = -1;
mId = null;
mPassword = null;
mHeaders.clear();
mServerNames = null;
return this;
} | java | public ProxySettings reset()
{
mSecure = false;
mHost = null;
mPort = -1;
mId = null;
mPassword = null;
mHeaders.clear();
mServerNames = null;
return this;
} | [
"public",
"ProxySettings",
"reset",
"(",
")",
"{",
"mSecure",
"=",
"false",
";",
"mHost",
"=",
"null",
";",
"mPort",
"=",
"-",
"1",
";",
"mId",
"=",
"null",
";",
"mPassword",
"=",
"null",
";",
"mHeaders",
".",
"clear",
"(",
")",
";",
"mServerNames",
"=",
"null",
";",
"return",
"this",
";",
"}"
] | Reset the proxy settings. To be concrete, parameter values are
set as shown below.
<blockquote>
<table border="1" cellpadding="5" style="border-collapse: collapse;">
<thead>
<tr>
<th>Name</th>
<th>Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Secure</td>
<td>{@code false}</td>
<td>Use TLS to connect to the proxy server or not.</td>
</tr>
<tr>
<td>Host</td>
<td>{@code null}</td>
<td>The host name of the proxy server.</td>
</tr>
<tr>
<td>Port</td>
<td>{@code -1}</td>
<td>The port number of the proxy server.</td>
</tr>
<tr>
<td>ID</td>
<td>{@code null}</td>
<td>The ID for authentication at the proxy server.</td>
</tr>
<tr>
<td>Password</td>
<td>{@code null}</td>
<td>The password for authentication at the proxy server.</td>
</tr>
<tr>
<td>Headers</td>
<td>Cleared</td>
<td>Additional HTTP headers passed to the proxy server.</td>
</tr>
<tr>
<td>Server Names</td>
<td>{@code null}</td>
<td>Server names for SNI (Server Name Indication).</td>
</tr>
</tbody>
</table>
</blockquote>
@return
{@code this} object. | [
"Reset",
"the",
"proxy",
"settings",
".",
"To",
"be",
"concrete",
"parameter",
"values",
"are",
"set",
"as",
"shown",
"below",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/ProxySettings.java#L169-L180 |
28,492 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/ProxySettings.java | ProxySettings.setServer | public ProxySettings setServer(URI uri)
{
if (uri == null)
{
return this;
}
String scheme = uri.getScheme();
String userInfo = uri.getUserInfo();
String host = uri.getHost();
int port = uri.getPort();
return setServer(scheme, userInfo, host, port);
} | java | public ProxySettings setServer(URI uri)
{
if (uri == null)
{
return this;
}
String scheme = uri.getScheme();
String userInfo = uri.getUserInfo();
String host = uri.getHost();
int port = uri.getPort();
return setServer(scheme, userInfo, host, port);
} | [
"public",
"ProxySettings",
"setServer",
"(",
"URI",
"uri",
")",
"{",
"if",
"(",
"uri",
"==",
"null",
")",
"{",
"return",
"this",
";",
"}",
"String",
"scheme",
"=",
"uri",
".",
"getScheme",
"(",
")",
";",
"String",
"userInfo",
"=",
"uri",
".",
"getUserInfo",
"(",
")",
";",
"String",
"host",
"=",
"uri",
".",
"getHost",
"(",
")",
";",
"int",
"port",
"=",
"uri",
".",
"getPort",
"(",
")",
";",
"return",
"setServer",
"(",
"scheme",
",",
"userInfo",
",",
"host",
",",
"port",
")",
";",
"}"
] | Set the proxy server by a URI. The parameters are updated as
described below.
<blockquote>
<dl>
<dt>Secure</dt>
<dd><p>
If the URI contains the scheme part and its value is
either {@code "http"} or {@code "https"} (case-insensitive),
the {@code secure} parameter is updated to {@code false}
or to {@code true} accordingly. In other cases, the parameter
is not updated.
</p></dd>
<dt>ID & Password</dt>
<dd><p>
If the URI contains the userinfo part and the ID embedded
in the userinfo part is not an empty string, the {@code
id} parameter and the {@code password} parameter are updated
accordingly. In other cases, the parameters are not updated.
</p></dd>
<dt>Host</dt>
<dd><p>
The {@code host} parameter is always updated by the given URI.
</p></dd>
<dt>Port</dt>
<dd><p>
The {@code port} parameter is always updated by the given URI.
</p></dd>
</dl>
</blockquote>
@param uri
The URI of the proxy server. If {@code null} is given,
none of the parameters is updated.
@return
{@code this} object. | [
"Set",
"the",
"proxy",
"server",
"by",
"a",
"URI",
".",
"The",
"parameters",
"are",
"updated",
"as",
"described",
"below",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/ProxySettings.java#L486-L499 |
28,493 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/ProxySettings.java | ProxySettings.addHeader | public ProxySettings addHeader(String name, String value)
{
if (name == null || name.length() == 0)
{
return this;
}
List<String> list = mHeaders.get(name);
if (list == null)
{
list = new ArrayList<String>();
mHeaders.put(name, list);
}
list.add(value);
return this;
} | java | public ProxySettings addHeader(String name, String value)
{
if (name == null || name.length() == 0)
{
return this;
}
List<String> list = mHeaders.get(name);
if (list == null)
{
list = new ArrayList<String>();
mHeaders.put(name, list);
}
list.add(value);
return this;
} | [
"public",
"ProxySettings",
"addHeader",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"if",
"(",
"name",
"==",
"null",
"||",
"name",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"this",
";",
"}",
"List",
"<",
"String",
">",
"list",
"=",
"mHeaders",
".",
"get",
"(",
"name",
")",
";",
"if",
"(",
"list",
"==",
"null",
")",
"{",
"list",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"mHeaders",
".",
"put",
"(",
"name",
",",
"list",
")",
";",
"}",
"list",
".",
"add",
"(",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Add an additional HTTP header passed to the proxy server.
@param name
The name of an HTTP header (case-insensitive).
If {@code null} or an empty string is given,
nothing is added.
@param value
The value of the HTTP header.
@return
{@code this} object. | [
"Add",
"an",
"additional",
"HTTP",
"header",
"passed",
"to",
"the",
"proxy",
"server",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/ProxySettings.java#L591-L609 |
28,494 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/SocketConnector.java | SocketConnector.handshake | private void handshake() throws WebSocketException
{
try
{
// Perform handshake with the proxy server.
mProxyHandshaker.perform();
}
catch (IOException e)
{
// Handshake with the proxy server failed.
String message = String.format(
"Handshake with the proxy server (%s) failed: %s", mAddress, e.getMessage());
// Raise an exception with PROXY_HANDSHAKE_ERROR.
throw new WebSocketException(WebSocketError.PROXY_HANDSHAKE_ERROR, message, e);
}
if (mSSLSocketFactory == null)
{
// SSL handshake with the WebSocket endpoint is not needed.
return;
}
try
{
// Overlay the existing socket.
mSocket = mSSLSocketFactory.createSocket(mSocket, mHost, mPort, true);
}
catch (IOException e)
{
// Failed to overlay an existing socket.
String message = "Failed to overlay an existing socket: " + e.getMessage();
// Raise an exception with SOCKET_OVERLAY_ERROR.
throw new WebSocketException(WebSocketError.SOCKET_OVERLAY_ERROR, message, e);
}
try
{
// Start the SSL handshake manually. As for the reason, see
// http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/samples/sockets/client/SSLSocketClient.java
((SSLSocket)mSocket).startHandshake();
if (mSocket instanceof SSLSocket)
{
// Verify that the proxied hostname matches the certificate here since
// this is not automatically done by the SSLSocket.
verifyHostname((SSLSocket)mSocket, mProxyHandshaker.getProxiedHostname());
}
}
catch (IOException e)
{
// SSL handshake with the WebSocket endpoint failed.
String message = String.format(
"SSL handshake with the WebSocket endpoint (%s) failed: %s", mAddress, e.getMessage());
// Raise an exception with SSL_HANDSHAKE_ERROR.
throw new WebSocketException(WebSocketError.SSL_HANDSHAKE_ERROR, message, e);
}
} | java | private void handshake() throws WebSocketException
{
try
{
// Perform handshake with the proxy server.
mProxyHandshaker.perform();
}
catch (IOException e)
{
// Handshake with the proxy server failed.
String message = String.format(
"Handshake with the proxy server (%s) failed: %s", mAddress, e.getMessage());
// Raise an exception with PROXY_HANDSHAKE_ERROR.
throw new WebSocketException(WebSocketError.PROXY_HANDSHAKE_ERROR, message, e);
}
if (mSSLSocketFactory == null)
{
// SSL handshake with the WebSocket endpoint is not needed.
return;
}
try
{
// Overlay the existing socket.
mSocket = mSSLSocketFactory.createSocket(mSocket, mHost, mPort, true);
}
catch (IOException e)
{
// Failed to overlay an existing socket.
String message = "Failed to overlay an existing socket: " + e.getMessage();
// Raise an exception with SOCKET_OVERLAY_ERROR.
throw new WebSocketException(WebSocketError.SOCKET_OVERLAY_ERROR, message, e);
}
try
{
// Start the SSL handshake manually. As for the reason, see
// http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/samples/sockets/client/SSLSocketClient.java
((SSLSocket)mSocket).startHandshake();
if (mSocket instanceof SSLSocket)
{
// Verify that the proxied hostname matches the certificate here since
// this is not automatically done by the SSLSocket.
verifyHostname((SSLSocket)mSocket, mProxyHandshaker.getProxiedHostname());
}
}
catch (IOException e)
{
// SSL handshake with the WebSocket endpoint failed.
String message = String.format(
"SSL handshake with the WebSocket endpoint (%s) failed: %s", mAddress, e.getMessage());
// Raise an exception with SSL_HANDSHAKE_ERROR.
throw new WebSocketException(WebSocketError.SSL_HANDSHAKE_ERROR, message, e);
}
} | [
"private",
"void",
"handshake",
"(",
")",
"throws",
"WebSocketException",
"{",
"try",
"{",
"// Perform handshake with the proxy server.",
"mProxyHandshaker",
".",
"perform",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// Handshake with the proxy server failed.",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"Handshake with the proxy server (%s) failed: %s\"",
",",
"mAddress",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"// Raise an exception with PROXY_HANDSHAKE_ERROR.",
"throw",
"new",
"WebSocketException",
"(",
"WebSocketError",
".",
"PROXY_HANDSHAKE_ERROR",
",",
"message",
",",
"e",
")",
";",
"}",
"if",
"(",
"mSSLSocketFactory",
"==",
"null",
")",
"{",
"// SSL handshake with the WebSocket endpoint is not needed.",
"return",
";",
"}",
"try",
"{",
"// Overlay the existing socket.",
"mSocket",
"=",
"mSSLSocketFactory",
".",
"createSocket",
"(",
"mSocket",
",",
"mHost",
",",
"mPort",
",",
"true",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// Failed to overlay an existing socket.",
"String",
"message",
"=",
"\"Failed to overlay an existing socket: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
";",
"// Raise an exception with SOCKET_OVERLAY_ERROR.",
"throw",
"new",
"WebSocketException",
"(",
"WebSocketError",
".",
"SOCKET_OVERLAY_ERROR",
",",
"message",
",",
"e",
")",
";",
"}",
"try",
"{",
"// Start the SSL handshake manually. As for the reason, see",
"// http://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/samples/sockets/client/SSLSocketClient.java",
"(",
"(",
"SSLSocket",
")",
"mSocket",
")",
".",
"startHandshake",
"(",
")",
";",
"if",
"(",
"mSocket",
"instanceof",
"SSLSocket",
")",
"{",
"// Verify that the proxied hostname matches the certificate here since",
"// this is not automatically done by the SSLSocket.",
"verifyHostname",
"(",
"(",
"SSLSocket",
")",
"mSocket",
",",
"mProxyHandshaker",
".",
"getProxiedHostname",
"(",
")",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"// SSL handshake with the WebSocket endpoint failed.",
"String",
"message",
"=",
"String",
".",
"format",
"(",
"\"SSL handshake with the WebSocket endpoint (%s) failed: %s\"",
",",
"mAddress",
",",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"// Raise an exception with SSL_HANDSHAKE_ERROR.",
"throw",
"new",
"WebSocketException",
"(",
"WebSocketError",
".",
"SSL_HANDSHAKE_ERROR",
",",
"message",
",",
"e",
")",
";",
"}",
"}"
] | Perform proxy handshake and optionally SSL handshake. | [
"Perform",
"proxy",
"handshake",
"and",
"optionally",
"SSL",
"handshake",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/SocketConnector.java#L178-L237 |
28,495 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocket.java | WebSocket.addHeader | public WebSocket addHeader(String name, String value)
{
mHandshakeBuilder.addHeader(name, value);
return this;
} | java | public WebSocket addHeader(String name, String value)
{
mHandshakeBuilder.addHeader(name, value);
return this;
} | [
"public",
"WebSocket",
"addHeader",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"mHandshakeBuilder",
".",
"addHeader",
"(",
"name",
",",
"value",
")",
";",
"return",
"this",
";",
"}"
] | Add a pair of extra HTTP header.
@param name
An HTTP header name. When {@code null} or an empty
string is given, no header is added.
@param value
The value of the HTTP header.
@return
{@code this} object. | [
"Add",
"a",
"pair",
"of",
"extra",
"HTTP",
"header",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocket.java#L1467-L1472 |
28,496 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocket.java | WebSocket.setUserInfo | public WebSocket setUserInfo(String id, String password)
{
mHandshakeBuilder.setUserInfo(id, password);
return this;
} | java | public WebSocket setUserInfo(String id, String password)
{
mHandshakeBuilder.setUserInfo(id, password);
return this;
} | [
"public",
"WebSocket",
"setUserInfo",
"(",
"String",
"id",
",",
"String",
"password",
")",
"{",
"mHandshakeBuilder",
".",
"setUserInfo",
"(",
"id",
",",
"password",
")",
";",
"return",
"this",
";",
"}"
] | Set the credentials to connect to the WebSocket endpoint.
@param id
The ID.
@param password
The password.
@return
{@code this} object. | [
"Set",
"the",
"credentials",
"to",
"connect",
"to",
"the",
"WebSocket",
"endpoint",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocket.java#L1540-L1545 |
28,497 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocket.java | WebSocket.flush | public WebSocket flush()
{
synchronized (mStateManager)
{
WebSocketState state = mStateManager.getState();
if (state != OPEN && state != CLOSING)
{
return this;
}
}
// Get the reference to the instance of WritingThread.
WritingThread wt = mWritingThread;
// If and only if an instance of WritingThread is available.
if (wt != null)
{
// Request flush.
wt.queueFlush();
}
return this;
} | java | public WebSocket flush()
{
synchronized (mStateManager)
{
WebSocketState state = mStateManager.getState();
if (state != OPEN && state != CLOSING)
{
return this;
}
}
// Get the reference to the instance of WritingThread.
WritingThread wt = mWritingThread;
// If and only if an instance of WritingThread is available.
if (wt != null)
{
// Request flush.
wt.queueFlush();
}
return this;
} | [
"public",
"WebSocket",
"flush",
"(",
")",
"{",
"synchronized",
"(",
"mStateManager",
")",
"{",
"WebSocketState",
"state",
"=",
"mStateManager",
".",
"getState",
"(",
")",
";",
"if",
"(",
"state",
"!=",
"OPEN",
"&&",
"state",
"!=",
"CLOSING",
")",
"{",
"return",
"this",
";",
"}",
"}",
"// Get the reference to the instance of WritingThread.",
"WritingThread",
"wt",
"=",
"mWritingThread",
";",
"// If and only if an instance of WritingThread is available.",
"if",
"(",
"wt",
"!=",
"null",
")",
"{",
"// Request flush.",
"wt",
".",
"queueFlush",
"(",
")",
";",
"}",
"return",
"this",
";",
"}"
] | Flush frames to the server. Flush is performed asynchronously.
@return
{@code this} object.
@since 1.5 | [
"Flush",
"frames",
"to",
"the",
"server",
".",
"Flush",
"is",
"performed",
"asynchronously",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocket.java#L1753-L1776 |
28,498 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocket.java | WebSocket.connect | public WebSocket connect() throws WebSocketException
{
// Change the state to CONNECTING. If the state before
// the change is not CREATED, an exception is thrown.
changeStateOnConnect();
// HTTP headers from the server.
Map<String, List<String>> headers;
try
{
// Connect to the server.
mSocketConnector.connect();
// Perform WebSocket handshake.
headers = shakeHands();
}
catch (WebSocketException e)
{
// Close the socket.
mSocketConnector.closeSilently();
// Change the state to CLOSED.
mStateManager.setState(CLOSED);
// Notify the listener of the state change.
mListenerManager.callOnStateChanged(CLOSED);
// The handshake failed.
throw e;
}
// HTTP headers in the response from the server.
mServerHeaders = headers;
// Extensions.
mPerMessageCompressionExtension = findAgreedPerMessageCompressionExtension();
// Change the state to OPEN.
mStateManager.setState(OPEN);
// Notify the listener of the state change.
mListenerManager.callOnStateChanged(OPEN);
// Start threads that communicate with the server.
startThreads();
return this;
} | java | public WebSocket connect() throws WebSocketException
{
// Change the state to CONNECTING. If the state before
// the change is not CREATED, an exception is thrown.
changeStateOnConnect();
// HTTP headers from the server.
Map<String, List<String>> headers;
try
{
// Connect to the server.
mSocketConnector.connect();
// Perform WebSocket handshake.
headers = shakeHands();
}
catch (WebSocketException e)
{
// Close the socket.
mSocketConnector.closeSilently();
// Change the state to CLOSED.
mStateManager.setState(CLOSED);
// Notify the listener of the state change.
mListenerManager.callOnStateChanged(CLOSED);
// The handshake failed.
throw e;
}
// HTTP headers in the response from the server.
mServerHeaders = headers;
// Extensions.
mPerMessageCompressionExtension = findAgreedPerMessageCompressionExtension();
// Change the state to OPEN.
mStateManager.setState(OPEN);
// Notify the listener of the state change.
mListenerManager.callOnStateChanged(OPEN);
// Start threads that communicate with the server.
startThreads();
return this;
} | [
"public",
"WebSocket",
"connect",
"(",
")",
"throws",
"WebSocketException",
"{",
"// Change the state to CONNECTING. If the state before",
"// the change is not CREATED, an exception is thrown.",
"changeStateOnConnect",
"(",
")",
";",
"// HTTP headers from the server.",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"headers",
";",
"try",
"{",
"// Connect to the server.",
"mSocketConnector",
".",
"connect",
"(",
")",
";",
"// Perform WebSocket handshake.",
"headers",
"=",
"shakeHands",
"(",
")",
";",
"}",
"catch",
"(",
"WebSocketException",
"e",
")",
"{",
"// Close the socket.",
"mSocketConnector",
".",
"closeSilently",
"(",
")",
";",
"// Change the state to CLOSED.",
"mStateManager",
".",
"setState",
"(",
"CLOSED",
")",
";",
"// Notify the listener of the state change.",
"mListenerManager",
".",
"callOnStateChanged",
"(",
"CLOSED",
")",
";",
"// The handshake failed.",
"throw",
"e",
";",
"}",
"// HTTP headers in the response from the server.",
"mServerHeaders",
"=",
"headers",
";",
"// Extensions.",
"mPerMessageCompressionExtension",
"=",
"findAgreedPerMessageCompressionExtension",
"(",
")",
";",
"// Change the state to OPEN.",
"mStateManager",
".",
"setState",
"(",
"OPEN",
")",
";",
"// Notify the listener of the state change.",
"mListenerManager",
".",
"callOnStateChanged",
"(",
"OPEN",
")",
";",
"// Start threads that communicate with the server.",
"startThreads",
"(",
")",
";",
"return",
"this",
";",
"}"
] | Connect to the server, send an opening handshake to the server,
receive the response and then start threads to communicate with
the server.
<p>
As necessary, {@link #addProtocol(String)}, {@link #addExtension(WebSocketExtension)}
{@link #addHeader(String, String)} should be called before you call this
method. It is because the parameters set by these methods are used in the
opening handshake.
</p>
<p>
Also, as necessary, {@link #getSocket()} should be used to set up socket
parameters before you call this method. For example, you can set the
socket timeout like the following.
</p>
<pre>
WebSocket websocket = ......;
websocket.{@link #getSocket() getSocket()}.{@link Socket#setSoTimeout(int)
setSoTimeout}(5000);
</pre>
<p>
If the WebSocket endpoint requires Basic Authentication, you can set
credentials by {@link #setUserInfo(String) setUserInfo(userInfo)} or
{@link #setUserInfo(String, String) setUserInfo(id, password)} before
you call this method.
Note that if the URI passed to {@link WebSocketFactory}{@code
.createSocket} method contains the user-info part, you don't have to
call {@code setUserInfo} method.
</p>
<p>
Note that this method can be called at most only once regardless of
whether this method succeeded or failed. If you want to re-connect to
the WebSocket endpoint, you have to create a new {@code WebSocket}
instance again by calling one of {@code createSocket} methods of a
{@link WebSocketFactory}. You may find {@link #recreate()} method
useful if you want to create a new {@code WebSocket} instance that
has the same settings as this instance. (But settings you made on
the raw socket are not copied.)
</p>
@return
{@code this} object.
@throws WebSocketException
<ul>
<li>The current state of the WebSocket is not {@link
WebSocketState#CREATED CREATED}
<li>Connecting the server failed.
<li>The opening handshake failed.
</ul> | [
"Connect",
"to",
"the",
"server",
"send",
"an",
"opening",
"handshake",
"to",
"the",
"server",
"receive",
"the",
"response",
"and",
"then",
"start",
"threads",
"to",
"communicate",
"with",
"the",
"server",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocket.java#L2295-L2343 |
28,499 | TakahikoKawasaki/nv-websocket-client | src/main/java/com/neovisionaries/ws/client/WebSocket.java | WebSocket.disconnect | public WebSocket disconnect(int closeCode, String reason, long closeDelay)
{
synchronized (mStateManager)
{
switch (mStateManager.getState())
{
case CREATED:
finishAsynchronously();
return this;
case OPEN:
break;
default:
// - CONNECTING
// It won't happen unless the programmer dare call
// open() and disconnect() in parallel.
//
// - CLOSING
// A closing handshake has already been started.
//
// - CLOSED
// The connection has already been closed.
return this;
}
// Change the state to CLOSING.
mStateManager.changeToClosing(CloseInitiator.CLIENT);
// Create a close frame.
WebSocketFrame frame = WebSocketFrame.createCloseFrame(closeCode, reason);
// Send the close frame to the server.
sendFrame(frame);
}
// Notify the listeners of the state change.
mListenerManager.callOnStateChanged(CLOSING);
// If a negative value is given.
if (closeDelay < 0)
{
// Use the default value.
closeDelay = DEFAULT_CLOSE_DELAY;
}
// Request the threads to stop.
stopThreads(closeDelay);
return this;
} | java | public WebSocket disconnect(int closeCode, String reason, long closeDelay)
{
synchronized (mStateManager)
{
switch (mStateManager.getState())
{
case CREATED:
finishAsynchronously();
return this;
case OPEN:
break;
default:
// - CONNECTING
// It won't happen unless the programmer dare call
// open() and disconnect() in parallel.
//
// - CLOSING
// A closing handshake has already been started.
//
// - CLOSED
// The connection has already been closed.
return this;
}
// Change the state to CLOSING.
mStateManager.changeToClosing(CloseInitiator.CLIENT);
// Create a close frame.
WebSocketFrame frame = WebSocketFrame.createCloseFrame(closeCode, reason);
// Send the close frame to the server.
sendFrame(frame);
}
// Notify the listeners of the state change.
mListenerManager.callOnStateChanged(CLOSING);
// If a negative value is given.
if (closeDelay < 0)
{
// Use the default value.
closeDelay = DEFAULT_CLOSE_DELAY;
}
// Request the threads to stop.
stopThreads(closeDelay);
return this;
} | [
"public",
"WebSocket",
"disconnect",
"(",
"int",
"closeCode",
",",
"String",
"reason",
",",
"long",
"closeDelay",
")",
"{",
"synchronized",
"(",
"mStateManager",
")",
"{",
"switch",
"(",
"mStateManager",
".",
"getState",
"(",
")",
")",
"{",
"case",
"CREATED",
":",
"finishAsynchronously",
"(",
")",
";",
"return",
"this",
";",
"case",
"OPEN",
":",
"break",
";",
"default",
":",
"// - CONNECTING",
"// It won't happen unless the programmer dare call",
"// open() and disconnect() in parallel.",
"//",
"// - CLOSING",
"// A closing handshake has already been started.",
"//",
"// - CLOSED",
"// The connection has already been closed.",
"return",
"this",
";",
"}",
"// Change the state to CLOSING.",
"mStateManager",
".",
"changeToClosing",
"(",
"CloseInitiator",
".",
"CLIENT",
")",
";",
"// Create a close frame.",
"WebSocketFrame",
"frame",
"=",
"WebSocketFrame",
".",
"createCloseFrame",
"(",
"closeCode",
",",
"reason",
")",
";",
"// Send the close frame to the server.",
"sendFrame",
"(",
"frame",
")",
";",
"}",
"// Notify the listeners of the state change.",
"mListenerManager",
".",
"callOnStateChanged",
"(",
"CLOSING",
")",
";",
"// If a negative value is given.",
"if",
"(",
"closeDelay",
"<",
"0",
")",
"{",
"// Use the default value.",
"closeDelay",
"=",
"DEFAULT_CLOSE_DELAY",
";",
"}",
"// Request the threads to stop.",
"stopThreads",
"(",
"closeDelay",
")",
";",
"return",
"this",
";",
"}"
] | Disconnect the WebSocket.
@param closeCode
The close code embedded in a <a href=
"https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a>
which this WebSocket client will send to the server.
@param reason
The reason embedded in a <a href=
"https://tools.ietf.org/html/rfc6455#section-5.5.1">close frame</a>
which this WebSocket client will send to the server. Note that
the length of the bytes which represents the given reason must
not exceed 125. In other words, {@code (reason.}{@link
String#getBytes(String) getBytes}{@code ("UTF-8").length <= 125)}
must be true.
@param closeDelay
Delay in milliseconds before calling {@link Socket#close()} forcibly.
This safeguard is needed for the case where the server fails to send
back a close frame. The default value is 10000 (= 10 seconds). When
a negative value is given, the default value is used.
If a very short time (e.g. 0) is given, it is likely to happen either
(1) that this client will fail to send a close frame to the server
(in this case, you will probably see an error message "Flushing frames
to the server failed: Socket closed") or (2) that the WebSocket
connection will be closed before this client receives a close frame
from the server (in this case, the second argument of {@link
WebSocketListener#onDisconnected(WebSocket, WebSocketFrame,
WebSocketFrame, boolean) WebSocketListener.onDisconnected} will be
{@code null}).
@return
{@code this} object.
@see WebSocketCloseCode
@see <a href="https://tools.ietf.org/html/rfc6455#section-5.5.1">RFC 6455, 5.5.1. Close</a>
@since 1.26 | [
"Disconnect",
"the",
"WebSocket",
"."
] | efaec21181d740ad3808313acf679313179e0825 | https://github.com/TakahikoKawasaki/nv-websocket-client/blob/efaec21181d740ad3808313acf679313179e0825/src/main/java/com/neovisionaries/ws/client/WebSocket.java#L2574-L2624 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.