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
36,800
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/BoundedOverlay.java
BoundedOverlay.hasTile
public boolean hasTile(int x, int y, int zoom) { // Check if generating tiles for the zoom level and is within the bounding box boolean hasTile = isWithinBounds(x, y, zoom); if (hasTile) { // Check if there is a tile to retrieve hasTile = hasTileToRetrieve(x, y, zoom); } return hasTile; }
java
public boolean hasTile(int x, int y, int zoom) { // Check if generating tiles for the zoom level and is within the bounding box boolean hasTile = isWithinBounds(x, y, zoom); if (hasTile) { // Check if there is a tile to retrieve hasTile = hasTileToRetrieve(x, y, zoom); } return hasTile; }
[ "public", "boolean", "hasTile", "(", "int", "x", ",", "int", "y", ",", "int", "zoom", ")", "{", "// Check if generating tiles for the zoom level and is within the bounding box", "boolean", "hasTile", "=", "isWithinBounds", "(", "x", ",", "y", ",", "zoom", ")", ";"...
Determine if there is a tile for the x, y, and zoom @param x x coordinate @param y y coordinate @param zoom zoom value @return true if there is a tile @since 1.2.6
[ "Determine", "if", "there", "is", "a", "tile", "for", "the", "x", "y", "and", "zoom" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/BoundedOverlay.java#L151-L161
36,801
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/BoundedOverlay.java
BoundedOverlay.isWithinBounds
public boolean isWithinBounds(int x, int y, int zoom) { return isWithinZoom(zoom) && isWithinBoundingBox(x, y, zoom); }
java
public boolean isWithinBounds(int x, int y, int zoom) { return isWithinZoom(zoom) && isWithinBoundingBox(x, y, zoom); }
[ "public", "boolean", "isWithinBounds", "(", "int", "x", ",", "int", "y", ",", "int", "zoom", ")", "{", "return", "isWithinZoom", "(", "zoom", ")", "&&", "isWithinBoundingBox", "(", "x", ",", "y", ",", "zoom", ")", ";", "}" ]
Is the tile within the zoom and bounding box bounds @param x x coordinate @param y y coordinate @param zoom zoom value @return true if within bounds
[ "Is", "the", "tile", "within", "the", "zoom", "and", "bounding", "box", "bounds" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/BoundedOverlay.java#L191-L193
36,802
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/BoundedOverlay.java
BoundedOverlay.isWithinZoom
public boolean isWithinZoom(float zoom) { return (minZoom == null || zoom >= minZoom) && (maxZoom == null || zoom <= maxZoom); }
java
public boolean isWithinZoom(float zoom) { return (minZoom == null || zoom >= minZoom) && (maxZoom == null || zoom <= maxZoom); }
[ "public", "boolean", "isWithinZoom", "(", "float", "zoom", ")", "{", "return", "(", "minZoom", "==", "null", "||", "zoom", ">=", "minZoom", ")", "&&", "(", "maxZoom", "==", "null", "||", "zoom", "<=", "maxZoom", ")", ";", "}" ]
Check if the zoom is within the overlay zoom range @param zoom zoom value @return true if within zoom
[ "Check", "if", "the", "zoom", "is", "within", "the", "overlay", "zoom", "range" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/BoundedOverlay.java#L201-L203
36,803
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/BoundedOverlay.java
BoundedOverlay.isWithinBoundingBox
public boolean isWithinBoundingBox(int x, int y, int zoom) { boolean withinBounds = true; // If a bounding box is set, check if it overlaps with the request if (webMercatorBoundingBox != null) { // Get the bounding box of the requested tile BoundingBox tileWebMercatorBoundingBox = TileBoundingBoxUtils .getWebMercatorBoundingBox(x, y, zoom); // Adjust the bounding box if needed BoundingBox adjustedWebMercatorBoundingBox = getWebMercatorBoundingBox(tileWebMercatorBoundingBox); // Check if the request overlaps withinBounds = adjustedWebMercatorBoundingBox.intersects( tileWebMercatorBoundingBox, true); } return withinBounds; }
java
public boolean isWithinBoundingBox(int x, int y, int zoom) { boolean withinBounds = true; // If a bounding box is set, check if it overlaps with the request if (webMercatorBoundingBox != null) { // Get the bounding box of the requested tile BoundingBox tileWebMercatorBoundingBox = TileBoundingBoxUtils .getWebMercatorBoundingBox(x, y, zoom); // Adjust the bounding box if needed BoundingBox adjustedWebMercatorBoundingBox = getWebMercatorBoundingBox(tileWebMercatorBoundingBox); // Check if the request overlaps withinBounds = adjustedWebMercatorBoundingBox.intersects( tileWebMercatorBoundingBox, true); } return withinBounds; }
[ "public", "boolean", "isWithinBoundingBox", "(", "int", "x", ",", "int", "y", ",", "int", "zoom", ")", "{", "boolean", "withinBounds", "=", "true", ";", "// If a bounding box is set, check if it overlaps with the request", "if", "(", "webMercatorBoundingBox", "!=", "n...
Check if the tile request is within the desired tile bounds @param x x coordinate @param y y coordinate @param zoom zoom value @return true if within bounds
[ "Check", "if", "the", "tile", "request", "is", "within", "the", "desired", "tile", "bounds" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/BoundedOverlay.java#L213-L232
36,804
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java
FeatureOverlayQuery.isOnAtCurrentZoom
public boolean isOnAtCurrentZoom(GoogleMap map, LatLng latLng) { float zoom = MapUtils.getCurrentZoom(map); boolean on = isOnAtCurrentZoom(zoom, latLng); return on; }
java
public boolean isOnAtCurrentZoom(GoogleMap map, LatLng latLng) { float zoom = MapUtils.getCurrentZoom(map); boolean on = isOnAtCurrentZoom(zoom, latLng); return on; }
[ "public", "boolean", "isOnAtCurrentZoom", "(", "GoogleMap", "map", ",", "LatLng", "latLng", ")", "{", "float", "zoom", "=", "MapUtils", ".", "getCurrentZoom", "(", "map", ")", ";", "boolean", "on", "=", "isOnAtCurrentZoom", "(", "zoom", ",", "latLng", ")", ...
Determine if the the feature overlay is on for the current zoom level of the map at the location @param map google map @param latLng lat lon location @return true if on @since 1.2.6
[ "Determine", "if", "the", "the", "feature", "overlay", "is", "on", "for", "the", "current", "zoom", "level", "of", "the", "map", "at", "the", "location" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java#L173-L177
36,805
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java
FeatureOverlayQuery.isOnAtCurrentZoom
public boolean isOnAtCurrentZoom(double zoom, LatLng latLng) { Point point = new Point(latLng.longitude, latLng.latitude); TileGrid tileGrid = TileBoundingBoxUtils.getTileGridFromWGS84(point, (int) zoom); boolean on = boundedOverlay.hasTile((int) tileGrid.getMinX(), (int) tileGrid.getMinY(), (int) zoom); return on; }
java
public boolean isOnAtCurrentZoom(double zoom, LatLng latLng) { Point point = new Point(latLng.longitude, latLng.latitude); TileGrid tileGrid = TileBoundingBoxUtils.getTileGridFromWGS84(point, (int) zoom); boolean on = boundedOverlay.hasTile((int) tileGrid.getMinX(), (int) tileGrid.getMinY(), (int) zoom); return on; }
[ "public", "boolean", "isOnAtCurrentZoom", "(", "double", "zoom", ",", "LatLng", "latLng", ")", "{", "Point", "point", "=", "new", "Point", "(", "latLng", ".", "longitude", ",", "latLng", ".", "latitude", ")", ";", "TileGrid", "tileGrid", "=", "TileBoundingBo...
Determine if the feature overlay is on for the provided zoom level at the location @param zoom zoom level @param latLng lat lon location @return true if on @since 1.2.6
[ "Determine", "if", "the", "feature", "overlay", "is", "on", "for", "the", "provided", "zoom", "level", "at", "the", "location" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java#L187-L194
36,806
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java
FeatureOverlayQuery.buildClickBoundingBox
public BoundingBox buildClickBoundingBox(LatLng latLng, BoundingBox mapBounds) { // Get the screen width and height a click occurs from a feature double width = TileBoundingBoxMapUtils.getLongitudeDistance(mapBounds) * screenClickPercentage; double height = TileBoundingBoxMapUtils.getLatitudeDistance(mapBounds) * screenClickPercentage; LatLng leftCoordinate = SphericalUtil.computeOffset(latLng, width, 270); LatLng upCoordinate = SphericalUtil.computeOffset(latLng, height, 0); LatLng rightCoordinate = SphericalUtil.computeOffset(latLng, width, 90); LatLng downCoordinate = SphericalUtil.computeOffset(latLng, height, 180); BoundingBox boundingBox = new BoundingBox(leftCoordinate.longitude, downCoordinate.latitude, rightCoordinate.longitude, upCoordinate.latitude); return boundingBox; }
java
public BoundingBox buildClickBoundingBox(LatLng latLng, BoundingBox mapBounds) { // Get the screen width and height a click occurs from a feature double width = TileBoundingBoxMapUtils.getLongitudeDistance(mapBounds) * screenClickPercentage; double height = TileBoundingBoxMapUtils.getLatitudeDistance(mapBounds) * screenClickPercentage; LatLng leftCoordinate = SphericalUtil.computeOffset(latLng, width, 270); LatLng upCoordinate = SphericalUtil.computeOffset(latLng, height, 0); LatLng rightCoordinate = SphericalUtil.computeOffset(latLng, width, 90); LatLng downCoordinate = SphericalUtil.computeOffset(latLng, height, 180); BoundingBox boundingBox = new BoundingBox(leftCoordinate.longitude, downCoordinate.latitude, rightCoordinate.longitude, upCoordinate.latitude); return boundingBox; }
[ "public", "BoundingBox", "buildClickBoundingBox", "(", "LatLng", "latLng", ",", "BoundingBox", "mapBounds", ")", "{", "// Get the screen width and height a click occurs from a feature", "double", "width", "=", "TileBoundingBoxMapUtils", ".", "getLongitudeDistance", "(", "mapBou...
Build a bounding box using the location coordinate click location and map view bounds @param latLng click location @param mapBounds map bounds @return bounding box @since 1.2.7
[ "Build", "a", "bounding", "box", "using", "the", "location", "coordinate", "click", "location", "and", "map", "view", "bounds" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java#L265-L279
36,807
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java
FeatureOverlayQuery.queryFeatures
public FeatureIndexResults queryFeatures(BoundingBox boundingBox) { FeatureIndexResults results = queryFeatures(boundingBox, null); return results; }
java
public FeatureIndexResults queryFeatures(BoundingBox boundingBox) { FeatureIndexResults results = queryFeatures(boundingBox, null); return results; }
[ "public", "FeatureIndexResults", "queryFeatures", "(", "BoundingBox", "boundingBox", ")", "{", "FeatureIndexResults", "results", "=", "queryFeatures", "(", "boundingBox", ",", "null", ")", ";", "return", "results", ";", "}" ]
Query for features in the WGS84 projected bounding box @param boundingBox query bounding box in WGS84 projection @return feature index results, must be closed
[ "Query", "for", "features", "in", "the", "WGS84", "projected", "bounding", "box" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java#L287-L290
36,808
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java
FeatureOverlayQuery.queryFeatures
public FeatureIndexResults queryFeatures(BoundingBox boundingBox, Projection projection) { if (projection == null) { projection = ProjectionFactory.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); } // Query for features FeatureIndexManager indexManager = featureTiles.getIndexManager(); if (indexManager == null) { throw new GeoPackageException("Index Manager is not set on the Feature Tiles and is required to query indexed features"); } FeatureIndexResults results = indexManager.query(boundingBox, projection); return results; }
java
public FeatureIndexResults queryFeatures(BoundingBox boundingBox, Projection projection) { if (projection == null) { projection = ProjectionFactory.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM); } // Query for features FeatureIndexManager indexManager = featureTiles.getIndexManager(); if (indexManager == null) { throw new GeoPackageException("Index Manager is not set on the Feature Tiles and is required to query indexed features"); } FeatureIndexResults results = indexManager.query(boundingBox, projection); return results; }
[ "public", "FeatureIndexResults", "queryFeatures", "(", "BoundingBox", "boundingBox", ",", "Projection", "projection", ")", "{", "if", "(", "projection", "==", "null", ")", "{", "projection", "=", "ProjectionFactory", ".", "getProjection", "(", "ProjectionConstants", ...
Query for features in the bounding box @param boundingBox query bounding box @param projection bounding box projection @return feature index results, must be closed
[ "Query", "for", "features", "in", "the", "bounding", "box" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/FeatureOverlayQuery.java#L299-L312
36,809
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.getToleranceDistance
public static double getToleranceDistance(View view, GoogleMap map) { BoundingBox boundingBox = getBoundingBox(map); double boundingBoxWidth = TileBoundingBoxMapUtils.getLongitudeDistance(boundingBox); double boundingBoxHeight = TileBoundingBoxMapUtils.getLatitudeDistance(boundingBox); int viewWidth = view.getWidth(); int viewHeight = view.getHeight(); double meters = 0; if (viewWidth > 0 && viewHeight > 0) { double widthMeters = boundingBoxWidth / viewWidth; double heightMeters = boundingBoxHeight / viewHeight; meters = Math.min(widthMeters, heightMeters); } return meters; }
java
public static double getToleranceDistance(View view, GoogleMap map) { BoundingBox boundingBox = getBoundingBox(map); double boundingBoxWidth = TileBoundingBoxMapUtils.getLongitudeDistance(boundingBox); double boundingBoxHeight = TileBoundingBoxMapUtils.getLatitudeDistance(boundingBox); int viewWidth = view.getWidth(); int viewHeight = view.getHeight(); double meters = 0; if (viewWidth > 0 && viewHeight > 0) { double widthMeters = boundingBoxWidth / viewWidth; double heightMeters = boundingBoxHeight / viewHeight; meters = Math.min(widthMeters, heightMeters); } return meters; }
[ "public", "static", "double", "getToleranceDistance", "(", "View", "view", ",", "GoogleMap", "map", ")", "{", "BoundingBox", "boundingBox", "=", "getBoundingBox", "(", "map", ")", ";", "double", "boundingBoxWidth", "=", "TileBoundingBoxMapUtils", ".", "getLongitudeD...
Get the tolerance distance meters in the current region of the map @param view view @param map google map @return tolerance distance in meters
[ "Get", "the", "tolerance", "distance", "meters", "in", "the", "current", "region", "of", "the", "map" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L51-L72
36,810
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.getBoundingBox
public static BoundingBox getBoundingBox(GoogleMap map) { LatLngBounds visibleBounds = map.getProjection() .getVisibleRegion().latLngBounds; LatLng southwest = visibleBounds.southwest; LatLng northeast = visibleBounds.northeast; double minLatitude = southwest.latitude; double maxLatitude = northeast.latitude; double minLongitude = southwest.longitude; double maxLongitude = northeast.longitude; if (maxLongitude < minLongitude) { maxLongitude += (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH); } BoundingBox boundingBox = new BoundingBox(minLongitude, minLatitude, maxLongitude, maxLatitude); return boundingBox; }
java
public static BoundingBox getBoundingBox(GoogleMap map) { LatLngBounds visibleBounds = map.getProjection() .getVisibleRegion().latLngBounds; LatLng southwest = visibleBounds.southwest; LatLng northeast = visibleBounds.northeast; double minLatitude = southwest.latitude; double maxLatitude = northeast.latitude; double minLongitude = southwest.longitude; double maxLongitude = northeast.longitude; if (maxLongitude < minLongitude) { maxLongitude += (2 * ProjectionConstants.WGS84_HALF_WORLD_LON_WIDTH); } BoundingBox boundingBox = new BoundingBox(minLongitude, minLatitude, maxLongitude, maxLatitude); return boundingBox; }
[ "public", "static", "BoundingBox", "getBoundingBox", "(", "GoogleMap", "map", ")", "{", "LatLngBounds", "visibleBounds", "=", "map", ".", "getProjection", "(", ")", ".", "getVisibleRegion", "(", ")", ".", "latLngBounds", ";", "LatLng", "southwest", "=", "visible...
Get the WGS84 bounding box of the current map view screen. The max longitude will be larger than the min resulting in values larger than 180.0. @param map google map @return current bounding box
[ "Get", "the", "WGS84", "bounding", "box", "of", "the", "current", "map", "view", "screen", ".", "The", "max", "longitude", "will", "be", "larger", "than", "the", "min", "resulting", "in", "values", "larger", "than", "180", ".", "0", "." ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L81-L100
36,811
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.buildClickBoundingBox
public static BoundingBox buildClickBoundingBox(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) { LatLngBoundingBox latLngBoundingBox = buildClickLatLngBoundingBox(latLng, view, map, screenClickPercentage); // Create the bounding box to query for features BoundingBox boundingBox = new BoundingBox( latLngBoundingBox.getLeftCoordinate().longitude, latLngBoundingBox.getDownCoordinate().latitude, latLngBoundingBox.getRightCoordinate().longitude, latLngBoundingBox.getUpCoordinate().latitude); return boundingBox; }
java
public static BoundingBox buildClickBoundingBox(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) { LatLngBoundingBox latLngBoundingBox = buildClickLatLngBoundingBox(latLng, view, map, screenClickPercentage); // Create the bounding box to query for features BoundingBox boundingBox = new BoundingBox( latLngBoundingBox.getLeftCoordinate().longitude, latLngBoundingBox.getDownCoordinate().latitude, latLngBoundingBox.getRightCoordinate().longitude, latLngBoundingBox.getUpCoordinate().latitude); return boundingBox; }
[ "public", "static", "BoundingBox", "buildClickBoundingBox", "(", "LatLng", "latLng", ",", "View", "view", ",", "GoogleMap", "map", ",", "float", "screenClickPercentage", ")", "{", "LatLngBoundingBox", "latLngBoundingBox", "=", "buildClickLatLngBoundingBox", "(", "latLng...
Build a bounding box using the click location, map view, map, and screen percentage tolerance. The bounding box can be used to query for features that were clicked @param latLng click location @param view view @param map Google map @param screenClickPercentage screen click percentage between 0.0 and 1.0 for how close a feature on the screen must be to be included in a click query @return bounding box
[ "Build", "a", "bounding", "box", "using", "the", "click", "location", "map", "view", "map", "and", "screen", "percentage", "tolerance", ".", "The", "bounding", "box", "can", "be", "used", "to", "query", "for", "features", "that", "were", "clicked" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L113-L125
36,812
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.buildClickLatLngBounds
public static LatLngBounds buildClickLatLngBounds(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) { LatLngBoundingBox latLngBoundingBox = buildClickLatLngBoundingBox(latLng, view, map, screenClickPercentage); double southWestLongitude = Math.min(latLngBoundingBox.getLeftCoordinate().longitude, latLngBoundingBox.getDownCoordinate().longitude); LatLng southWest = new LatLng(latLngBoundingBox.getDownCoordinate().latitude, latLngBoundingBox.getLeftCoordinate().longitude); LatLng northEast = new LatLng(latLngBoundingBox.getUpCoordinate().latitude, latLngBoundingBox.getRightCoordinate().longitude); LatLngBounds latLngBounds = new LatLngBounds(southWest, northEast); return latLngBounds; }
java
public static LatLngBounds buildClickLatLngBounds(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) { LatLngBoundingBox latLngBoundingBox = buildClickLatLngBoundingBox(latLng, view, map, screenClickPercentage); double southWestLongitude = Math.min(latLngBoundingBox.getLeftCoordinate().longitude, latLngBoundingBox.getDownCoordinate().longitude); LatLng southWest = new LatLng(latLngBoundingBox.getDownCoordinate().latitude, latLngBoundingBox.getLeftCoordinate().longitude); LatLng northEast = new LatLng(latLngBoundingBox.getUpCoordinate().latitude, latLngBoundingBox.getRightCoordinate().longitude); LatLngBounds latLngBounds = new LatLngBounds(southWest, northEast); return latLngBounds; }
[ "public", "static", "LatLngBounds", "buildClickLatLngBounds", "(", "LatLng", "latLng", ",", "View", "view", ",", "GoogleMap", "map", ",", "float", "screenClickPercentage", ")", "{", "LatLngBoundingBox", "latLngBoundingBox", "=", "buildClickLatLngBoundingBox", "(", "latL...
Build a lat lng bounds using the click location, map view, map, and screen percentage tolerance. The bounding box can be used to query for features that were clicked @param latLng click location @param view view @param map Google map @param screenClickPercentage screen click percentage between 0.0 and 1.0 for how close a feature on the screen must be to be included in a click query @return bounding box
[ "Build", "a", "lat", "lng", "bounds", "using", "the", "click", "location", "map", "view", "map", "and", "screen", "percentage", "tolerance", ".", "The", "bounding", "box", "can", "be", "used", "to", "query", "for", "features", "that", "were", "clicked" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L138-L150
36,813
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.getToleranceDistance
public static double getToleranceDistance(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) { LatLngBoundingBox latLngBoundingBox = buildClickLatLngBoundingBox(latLng, view, map, screenClickPercentage); double longitudeDistance = SphericalUtil.computeDistanceBetween(latLngBoundingBox.getLeftCoordinate(), latLngBoundingBox.getRightCoordinate()); double latitudeDistance = SphericalUtil.computeDistanceBetween(latLngBoundingBox.getDownCoordinate(), latLngBoundingBox.getUpCoordinate()); double distance = Math.max(longitudeDistance, latitudeDistance); return distance; }
java
public static double getToleranceDistance(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) { LatLngBoundingBox latLngBoundingBox = buildClickLatLngBoundingBox(latLng, view, map, screenClickPercentage); double longitudeDistance = SphericalUtil.computeDistanceBetween(latLngBoundingBox.getLeftCoordinate(), latLngBoundingBox.getRightCoordinate()); double latitudeDistance = SphericalUtil.computeDistanceBetween(latLngBoundingBox.getDownCoordinate(), latLngBoundingBox.getUpCoordinate()); double distance = Math.max(longitudeDistance, latitudeDistance); return distance; }
[ "public", "static", "double", "getToleranceDistance", "(", "LatLng", "latLng", ",", "View", "view", ",", "GoogleMap", "map", ",", "float", "screenClickPercentage", ")", "{", "LatLngBoundingBox", "latLngBoundingBox", "=", "buildClickLatLngBoundingBox", "(", "latLng", "...
Get the allowable tolerance distance in meters from the click location on the map view and map with the screen percentage tolerance. @param latLng click location @param view map view @param map map @param screenClickPercentage screen click percentage between 0.0 and 1.0 for how close a feature on the screen must be to be included in a click query @return tolerance distance in meters
[ "Get", "the", "allowable", "tolerance", "distance", "in", "meters", "from", "the", "click", "location", "on", "the", "map", "view", "and", "map", "with", "the", "screen", "percentage", "tolerance", "." ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L162-L172
36,814
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.buildClickLatLngBoundingBox
public static LatLngBoundingBox buildClickLatLngBoundingBox(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) { // Get the screen width and height a click occurs from a feature int width = (int) Math.round(view.getWidth() * screenClickPercentage); int height = (int) Math.round(view.getHeight() * screenClickPercentage); // Get the screen click location Projection projection = map.getProjection(); android.graphics.Point clickLocation = projection.toScreenLocation(latLng); // Get the screen click locations in each width or height direction android.graphics.Point left = new android.graphics.Point(clickLocation); android.graphics.Point up = new android.graphics.Point(clickLocation); android.graphics.Point right = new android.graphics.Point(clickLocation); android.graphics.Point down = new android.graphics.Point(clickLocation); left.offset(-width, 0); up.offset(0, -height); right.offset(width, 0); down.offset(0, height); // Get the coordinates of the bounding box points LatLng leftCoordinate = projection.fromScreenLocation(left); LatLng upCoordinate = projection.fromScreenLocation(up); LatLng rightCoordinate = projection.fromScreenLocation(right); LatLng downCoordinate = projection.fromScreenLocation(down); LatLngBoundingBox latLngBoundingBox = new LatLngBoundingBox(leftCoordinate, upCoordinate, rightCoordinate, downCoordinate); return latLngBoundingBox; }
java
public static LatLngBoundingBox buildClickLatLngBoundingBox(LatLng latLng, View view, GoogleMap map, float screenClickPercentage) { // Get the screen width and height a click occurs from a feature int width = (int) Math.round(view.getWidth() * screenClickPercentage); int height = (int) Math.round(view.getHeight() * screenClickPercentage); // Get the screen click location Projection projection = map.getProjection(); android.graphics.Point clickLocation = projection.toScreenLocation(latLng); // Get the screen click locations in each width or height direction android.graphics.Point left = new android.graphics.Point(clickLocation); android.graphics.Point up = new android.graphics.Point(clickLocation); android.graphics.Point right = new android.graphics.Point(clickLocation); android.graphics.Point down = new android.graphics.Point(clickLocation); left.offset(-width, 0); up.offset(0, -height); right.offset(width, 0); down.offset(0, height); // Get the coordinates of the bounding box points LatLng leftCoordinate = projection.fromScreenLocation(left); LatLng upCoordinate = projection.fromScreenLocation(up); LatLng rightCoordinate = projection.fromScreenLocation(right); LatLng downCoordinate = projection.fromScreenLocation(down); LatLngBoundingBox latLngBoundingBox = new LatLngBoundingBox(leftCoordinate, upCoordinate, rightCoordinate, downCoordinate); return latLngBoundingBox; }
[ "public", "static", "LatLngBoundingBox", "buildClickLatLngBoundingBox", "(", "LatLng", "latLng", ",", "View", "view", ",", "GoogleMap", "map", ",", "float", "screenClickPercentage", ")", "{", "// Get the screen width and height a click occurs from a feature", "int", "width", ...
Build a lat lng bounding box using the click location, map view, map, and screen percentage tolerance. The bounding box can be used to query for features that were clicked @param latLng click location @param view map view @param map map @param screenClickPercentage screen click percentage between 0.0 and 1.0 for how close a feature on the screen must be to be included in a click query @return lat lng bounding box
[ "Build", "a", "lat", "lng", "bounding", "box", "using", "the", "click", "location", "map", "view", "map", "and", "screen", "percentage", "tolerance", ".", "The", "bounding", "box", "can", "be", "used", "to", "query", "for", "features", "that", "were", "cli...
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L185-L214
36,815
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.isPointOnShape
public static boolean isPointOnShape(LatLng point, GoogleMapShape shape, boolean geodesic, double tolerance) { boolean onShape = false; switch (shape.getShapeType()) { case LAT_LNG: onShape = isPointNearPoint(point, (LatLng) shape.getShape(), tolerance); break; case MARKER_OPTIONS: onShape = isPointNearMarker(point, (MarkerOptions) shape.getShape(), tolerance); break; case POLYLINE_OPTIONS: onShape = isPointOnPolyline(point, (PolylineOptions) shape.getShape(), geodesic, tolerance); break; case POLYGON_OPTIONS: onShape = isPointOnPolygon(point, (PolygonOptions) shape.getShape(), geodesic, tolerance); break; case MULTI_LAT_LNG: onShape = isPointNearMultiLatLng(point, (MultiLatLng) shape.getShape(), tolerance); break; case MULTI_POLYLINE_OPTIONS: onShape = isPointOnMultiPolyline(point, (MultiPolylineOptions) shape.getShape(), geodesic, tolerance); break; case MULTI_POLYGON_OPTIONS: onShape = isPointOnMultiPolygon(point, (MultiPolygonOptions) shape.getShape(), geodesic, tolerance); break; case COLLECTION: @SuppressWarnings("unchecked") List<GoogleMapShape> shapeList = (List<GoogleMapShape>) shape .getShape(); for (GoogleMapShape shapeListItem : shapeList) { onShape = isPointOnShape(point, shapeListItem, geodesic, tolerance); if (onShape) { break; } } break; default: throw new GeoPackageException("Unsupported Shape Type: " + shape.getShapeType()); } return onShape; }
java
public static boolean isPointOnShape(LatLng point, GoogleMapShape shape, boolean geodesic, double tolerance) { boolean onShape = false; switch (shape.getShapeType()) { case LAT_LNG: onShape = isPointNearPoint(point, (LatLng) shape.getShape(), tolerance); break; case MARKER_OPTIONS: onShape = isPointNearMarker(point, (MarkerOptions) shape.getShape(), tolerance); break; case POLYLINE_OPTIONS: onShape = isPointOnPolyline(point, (PolylineOptions) shape.getShape(), geodesic, tolerance); break; case POLYGON_OPTIONS: onShape = isPointOnPolygon(point, (PolygonOptions) shape.getShape(), geodesic, tolerance); break; case MULTI_LAT_LNG: onShape = isPointNearMultiLatLng(point, (MultiLatLng) shape.getShape(), tolerance); break; case MULTI_POLYLINE_OPTIONS: onShape = isPointOnMultiPolyline(point, (MultiPolylineOptions) shape.getShape(), geodesic, tolerance); break; case MULTI_POLYGON_OPTIONS: onShape = isPointOnMultiPolygon(point, (MultiPolygonOptions) shape.getShape(), geodesic, tolerance); break; case COLLECTION: @SuppressWarnings("unchecked") List<GoogleMapShape> shapeList = (List<GoogleMapShape>) shape .getShape(); for (GoogleMapShape shapeListItem : shapeList) { onShape = isPointOnShape(point, shapeListItem, geodesic, tolerance); if (onShape) { break; } } break; default: throw new GeoPackageException("Unsupported Shape Type: " + shape.getShapeType()); } return onShape; }
[ "public", "static", "boolean", "isPointOnShape", "(", "LatLng", "point", ",", "GoogleMapShape", "shape", ",", "boolean", "geodesic", ",", "double", "tolerance", ")", "{", "boolean", "onShape", "=", "false", ";", "switch", "(", "shape", ".", "getShapeType", "("...
Is the point on or near the shape @param point lat lng point @param shape map shape @param geodesic geodesic check flag @param tolerance distance tolerance @return true if point is on shape
[ "Is", "the", "point", "on", "or", "near", "the", "shape" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L225-L271
36,816
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.isPointNearMarker
public static boolean isPointNearMarker(LatLng point, MarkerOptions shapeMarker, double tolerance) { return isPointNearPoint(point, shapeMarker.getPosition(), tolerance); }
java
public static boolean isPointNearMarker(LatLng point, MarkerOptions shapeMarker, double tolerance) { return isPointNearPoint(point, shapeMarker.getPosition(), tolerance); }
[ "public", "static", "boolean", "isPointNearMarker", "(", "LatLng", "point", ",", "MarkerOptions", "shapeMarker", ",", "double", "tolerance", ")", "{", "return", "isPointNearPoint", "(", "point", ",", "shapeMarker", ".", "getPosition", "(", ")", ",", "tolerance", ...
Is the point near the shape marker @param point point @param shapeMarker shape marker @param tolerance distance tolerance @return true if near
[ "Is", "the", "point", "near", "the", "shape", "marker" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L281-L283
36,817
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.isPointNearPoint
public static boolean isPointNearPoint(LatLng point, LatLng shapePoint, double tolerance) { return SphericalUtil.computeDistanceBetween(point, shapePoint) <= tolerance; }
java
public static boolean isPointNearPoint(LatLng point, LatLng shapePoint, double tolerance) { return SphericalUtil.computeDistanceBetween(point, shapePoint) <= tolerance; }
[ "public", "static", "boolean", "isPointNearPoint", "(", "LatLng", "point", ",", "LatLng", "shapePoint", ",", "double", "tolerance", ")", "{", "return", "SphericalUtil", ".", "computeDistanceBetween", "(", "point", ",", "shapePoint", ")", "<=", "tolerance", ";", ...
Is the point near the shape point @param point point @param shapePoint shape point @param tolerance distance tolerance @return true if near
[ "Is", "the", "point", "near", "the", "shape", "point" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L293-L295
36,818
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.isPointNearMultiLatLng
public static boolean isPointNearMultiLatLng(LatLng point, MultiLatLng multiLatLng, double tolerance) { boolean near = false; for (LatLng multiPoint : multiLatLng.getLatLngs()) { near = isPointNearPoint(point, multiPoint, tolerance); if (near) { break; } } return near; }
java
public static boolean isPointNearMultiLatLng(LatLng point, MultiLatLng multiLatLng, double tolerance) { boolean near = false; for (LatLng multiPoint : multiLatLng.getLatLngs()) { near = isPointNearPoint(point, multiPoint, tolerance); if (near) { break; } } return near; }
[ "public", "static", "boolean", "isPointNearMultiLatLng", "(", "LatLng", "point", ",", "MultiLatLng", "multiLatLng", ",", "double", "tolerance", ")", "{", "boolean", "near", "=", "false", ";", "for", "(", "LatLng", "multiPoint", ":", "multiLatLng", ".", "getLatLn...
Is the point near any points in the multi lat lng @param point point @param multiLatLng multi lat lng @param tolerance distance tolerance @return true if near
[ "Is", "the", "point", "near", "any", "points", "in", "the", "multi", "lat", "lng" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L305-L314
36,819
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.isPointOnPolyline
public static boolean isPointOnPolyline(LatLng point, PolylineOptions polyline, boolean geodesic, double tolerance) { return PolyUtil.isLocationOnPath(point, polyline.getPoints(), geodesic, tolerance); }
java
public static boolean isPointOnPolyline(LatLng point, PolylineOptions polyline, boolean geodesic, double tolerance) { return PolyUtil.isLocationOnPath(point, polyline.getPoints(), geodesic, tolerance); }
[ "public", "static", "boolean", "isPointOnPolyline", "(", "LatLng", "point", ",", "PolylineOptions", "polyline", ",", "boolean", "geodesic", ",", "double", "tolerance", ")", "{", "return", "PolyUtil", ".", "isLocationOnPath", "(", "point", ",", "polyline", ".", "...
Is the point on the polyline @param point point @param polyline polyline @param geodesic geodesic check flag @param tolerance distance tolerance @return true if on the line
[ "Is", "the", "point", "on", "the", "polyline" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L325-L327
36,820
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.isPointOnMultiPolyline
public static boolean isPointOnMultiPolyline(LatLng point, MultiPolylineOptions multiPolyline, boolean geodesic, double tolerance) { boolean near = false; for (PolylineOptions polyline : multiPolyline.getPolylineOptions()) { near = isPointOnPolyline(point, polyline, geodesic, tolerance); if (near) { break; } } return near; }
java
public static boolean isPointOnMultiPolyline(LatLng point, MultiPolylineOptions multiPolyline, boolean geodesic, double tolerance) { boolean near = false; for (PolylineOptions polyline : multiPolyline.getPolylineOptions()) { near = isPointOnPolyline(point, polyline, geodesic, tolerance); if (near) { break; } } return near; }
[ "public", "static", "boolean", "isPointOnMultiPolyline", "(", "LatLng", "point", ",", "MultiPolylineOptions", "multiPolyline", ",", "boolean", "geodesic", ",", "double", "tolerance", ")", "{", "boolean", "near", "=", "false", ";", "for", "(", "PolylineOptions", "p...
Is the point on the multi polyline @param point point @param multiPolyline multi polyline @param geodesic geodesic check flag @param tolerance distance tolerance @return true if on the multi line
[ "Is", "the", "point", "on", "the", "multi", "polyline" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L338-L347
36,821
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.isPointOnPolygon
public static boolean isPointOnPolygon(LatLng point, PolygonOptions polygon, boolean geodesic, double tolerance) { boolean onPolygon = PolyUtil.containsLocation(point, polygon.getPoints(), geodesic) || PolyUtil.isLocationOnEdge(point, polygon.getPoints(), geodesic, tolerance); if (onPolygon) { for (List<LatLng> hole : polygon.getHoles()) { if (PolyUtil.containsLocation(point, hole, geodesic)) { onPolygon = false; break; } } } return onPolygon; }
java
public static boolean isPointOnPolygon(LatLng point, PolygonOptions polygon, boolean geodesic, double tolerance) { boolean onPolygon = PolyUtil.containsLocation(point, polygon.getPoints(), geodesic) || PolyUtil.isLocationOnEdge(point, polygon.getPoints(), geodesic, tolerance); if (onPolygon) { for (List<LatLng> hole : polygon.getHoles()) { if (PolyUtil.containsLocation(point, hole, geodesic)) { onPolygon = false; break; } } } return onPolygon; }
[ "public", "static", "boolean", "isPointOnPolygon", "(", "LatLng", "point", ",", "PolygonOptions", "polygon", ",", "boolean", "geodesic", ",", "double", "tolerance", ")", "{", "boolean", "onPolygon", "=", "PolyUtil", ".", "containsLocation", "(", "point", ",", "p...
Is the point of the polygon @param point point @param polygon polygon @param geodesic geodesic check flag @param tolerance distance tolerance @return true if on the polygon
[ "Is", "the", "point", "of", "the", "polygon" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L358-L373
36,822
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java
MapUtils.isPointOnMultiPolygon
public static boolean isPointOnMultiPolygon(LatLng point, MultiPolygonOptions multiPolygon, boolean geodesic, double tolerance) { boolean near = false; for (PolygonOptions polygon : multiPolygon.getPolygonOptions()) { near = isPointOnPolygon(point, polygon, geodesic, tolerance); if (near) { break; } } return near; }
java
public static boolean isPointOnMultiPolygon(LatLng point, MultiPolygonOptions multiPolygon, boolean geodesic, double tolerance) { boolean near = false; for (PolygonOptions polygon : multiPolygon.getPolygonOptions()) { near = isPointOnPolygon(point, polygon, geodesic, tolerance); if (near) { break; } } return near; }
[ "public", "static", "boolean", "isPointOnMultiPolygon", "(", "LatLng", "point", ",", "MultiPolygonOptions", "multiPolygon", ",", "boolean", "geodesic", ",", "double", "tolerance", ")", "{", "boolean", "near", "=", "false", ";", "for", "(", "PolygonOptions", "polyg...
Is the point on the multi polygon @param point point @param multiPolygon multi polygon @param geodesic geodesic check flag @param tolerance distance tolerance @return true if on the multi polygon
[ "Is", "the", "point", "on", "the", "multi", "polygon" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/MapUtils.java#L384-L393
36,823
SimplicityApks/ReminderDatePicker
lib/src/main/java/com/simplicityapks/reminderdatepicker/lib/TimeItem.java
TimeItem.getTime
public Calendar getTime() { Calendar result = Calendar.getInstance(); result.set(Calendar.HOUR_OF_DAY, hour); result.set(Calendar.MINUTE, minute); return result; }
java
public Calendar getTime() { Calendar result = Calendar.getInstance(); result.set(Calendar.HOUR_OF_DAY, hour); result.set(Calendar.MINUTE, minute); return result; }
[ "public", "Calendar", "getTime", "(", ")", "{", "Calendar", "result", "=", "Calendar", ".", "getInstance", "(", ")", ";", "result", ".", "set", "(", "Calendar", ".", "HOUR_OF_DAY", ",", "hour", ")", ";", "result", ".", "set", "(", "Calendar", ".", "MIN...
Gets the current time set in this TimeItem. @return A new Calendar containing the time.
[ "Gets", "the", "current", "time", "set", "in", "this", "TimeItem", "." ]
7596fbac77a5d26f687fec11758935a2b7db156f
https://github.com/SimplicityApks/ReminderDatePicker/blob/7596fbac77a5d26f687fec11758935a2b7db156f/lib/src/main/java/com/simplicityapks/reminderdatepicker/lib/TimeItem.java#L69-L74
36,824
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java
GeoPackageOverlayFactory.getBoundedOverlay
public static BoundedOverlay getBoundedOverlay(TileDao tileDao, float density) { BoundedOverlay overlay = null; if (tileDao.isGoogleTiles()) { overlay = new GoogleAPIGeoPackageOverlay(tileDao); } else { overlay = new GeoPackageOverlay(tileDao, density); } return overlay; }
java
public static BoundedOverlay getBoundedOverlay(TileDao tileDao, float density) { BoundedOverlay overlay = null; if (tileDao.isGoogleTiles()) { overlay = new GoogleAPIGeoPackageOverlay(tileDao); } else { overlay = new GeoPackageOverlay(tileDao, density); } return overlay; }
[ "public", "static", "BoundedOverlay", "getBoundedOverlay", "(", "TileDao", "tileDao", ",", "float", "density", ")", "{", "BoundedOverlay", "overlay", "=", "null", ";", "if", "(", "tileDao", ".", "isGoogleTiles", "(", ")", ")", "{", "overlay", "=", "new", "Go...
Get a Bounded Overlay Tile Provider for the Tile DAO with the display density @param tileDao tile dao @param density display density: {@link android.util.DisplayMetrics#density} @return bounded overlay @since 3.2.0
[ "Get", "a", "Bounded", "Overlay", "Tile", "Provider", "for", "the", "Tile", "DAO", "with", "the", "display", "density" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java#L73-L84
36,825
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java
GeoPackageOverlayFactory.getBoundedOverlay
public static BoundedOverlay getBoundedOverlay(TileDao tileDao, float density, TileScaling scaling) { return new GeoPackageOverlay(tileDao, density, scaling); }
java
public static BoundedOverlay getBoundedOverlay(TileDao tileDao, float density, TileScaling scaling) { return new GeoPackageOverlay(tileDao, density, scaling); }
[ "public", "static", "BoundedOverlay", "getBoundedOverlay", "(", "TileDao", "tileDao", ",", "float", "density", ",", "TileScaling", "scaling", ")", "{", "return", "new", "GeoPackageOverlay", "(", "tileDao", ",", "density", ",", "scaling", ")", ";", "}" ]
Get a Bounded Overlay Tile Provider for the Tile DAO with the display density and tile creator options @param tileDao tile dao @param density display density: {@link android.util.DisplayMetrics#density} @param scaling tile scaling options @return bounded overlay @since 3.2.0
[ "Get", "a", "Bounded", "Overlay", "Tile", "Provider", "for", "the", "Tile", "DAO", "with", "the", "display", "density", "and", "tile", "creator", "options" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java#L107-L109
36,826
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java
GeoPackageOverlayFactory.getCompositeOverlay
public static CompositeOverlay getCompositeOverlay(TileDao tileDao, BoundedOverlay overlay) { List<TileDao> tileDaos = new ArrayList<>(); tileDaos.add(tileDao); return getCompositeOverlay(tileDaos, overlay); }
java
public static CompositeOverlay getCompositeOverlay(TileDao tileDao, BoundedOverlay overlay) { List<TileDao> tileDaos = new ArrayList<>(); tileDaos.add(tileDao); return getCompositeOverlay(tileDaos, overlay); }
[ "public", "static", "CompositeOverlay", "getCompositeOverlay", "(", "TileDao", "tileDao", ",", "BoundedOverlay", "overlay", ")", "{", "List", "<", "TileDao", ">", "tileDaos", "=", "new", "ArrayList", "<>", "(", ")", ";", "tileDaos", ".", "add", "(", "tileDao",...
Create a composite overlay by first adding a tile overlay for the tile DAO followed by the provided overlay @param tileDao tile dao @param overlay bounded overlay @return composite overlay
[ "Create", "a", "composite", "overlay", "by", "first", "adding", "a", "tile", "overlay", "for", "the", "tile", "DAO", "followed", "by", "the", "provided", "overlay" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java#L118-L122
36,827
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java
GeoPackageOverlayFactory.getCompositeOverlay
public static CompositeOverlay getCompositeOverlay(Collection<TileDao> tileDaos, BoundedOverlay overlay) { CompositeOverlay compositeOverlay = getCompositeOverlay(tileDaos); compositeOverlay.addOverlay(overlay); return compositeOverlay; }
java
public static CompositeOverlay getCompositeOverlay(Collection<TileDao> tileDaos, BoundedOverlay overlay) { CompositeOverlay compositeOverlay = getCompositeOverlay(tileDaos); compositeOverlay.addOverlay(overlay); return compositeOverlay; }
[ "public", "static", "CompositeOverlay", "getCompositeOverlay", "(", "Collection", "<", "TileDao", ">", "tileDaos", ",", "BoundedOverlay", "overlay", ")", "{", "CompositeOverlay", "compositeOverlay", "=", "getCompositeOverlay", "(", "tileDaos", ")", ";", "compositeOverla...
Create a composite overlay by first adding tile overlays for the tile DAOs followed by the provided overlay @param tileDaos collection of tile daos @param overlay bounded overlay @return composite overlay
[ "Create", "a", "composite", "overlay", "by", "first", "adding", "tile", "overlays", "for", "the", "tile", "DAOs", "followed", "by", "the", "provided", "overlay" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java#L131-L138
36,828
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java
GeoPackageOverlayFactory.getCompositeOverlay
public static CompositeOverlay getCompositeOverlay(Collection<TileDao> tileDaos) { CompositeOverlay compositeOverlay = new CompositeOverlay(); for (TileDao tileDao : tileDaos) { BoundedOverlay boundedOverlay = GeoPackageOverlayFactory.getBoundedOverlay(tileDao); compositeOverlay.addOverlay(boundedOverlay); } return compositeOverlay; }
java
public static CompositeOverlay getCompositeOverlay(Collection<TileDao> tileDaos) { CompositeOverlay compositeOverlay = new CompositeOverlay(); for (TileDao tileDao : tileDaos) { BoundedOverlay boundedOverlay = GeoPackageOverlayFactory.getBoundedOverlay(tileDao); compositeOverlay.addOverlay(boundedOverlay); } return compositeOverlay; }
[ "public", "static", "CompositeOverlay", "getCompositeOverlay", "(", "Collection", "<", "TileDao", ">", "tileDaos", ")", "{", "CompositeOverlay", "compositeOverlay", "=", "new", "CompositeOverlay", "(", ")", ";", "for", "(", "TileDao", "tileDao", ":", "tileDaos", "...
Create a composite overlay by adding tile overlays for the tile DAOs @param tileDaos collection of tile daos @return composite overlay
[ "Create", "a", "composite", "overlay", "by", "adding", "tile", "overlays", "for", "the", "tile", "DAOs" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java#L146-L156
36,829
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java
GeoPackageOverlayFactory.getLinkedFeatureOverlay
public static BoundedOverlay getLinkedFeatureOverlay(FeatureOverlay featureOverlay, GeoPackage geoPackage) { BoundedOverlay overlay; // Get the linked tile daos FeatureTileTableLinker linker = new FeatureTileTableLinker(geoPackage); List<TileDao> tileDaos = linker.getTileDaosForFeatureTable(featureOverlay.getFeatureTiles().getFeatureDao().getTableName()); if (!tileDaos.isEmpty()) { // Create a composite overlay to search for existing tiles before drawing from features overlay = getCompositeOverlay(tileDaos, featureOverlay); } else { overlay = featureOverlay; } return overlay; }
java
public static BoundedOverlay getLinkedFeatureOverlay(FeatureOverlay featureOverlay, GeoPackage geoPackage) { BoundedOverlay overlay; // Get the linked tile daos FeatureTileTableLinker linker = new FeatureTileTableLinker(geoPackage); List<TileDao> tileDaos = linker.getTileDaosForFeatureTable(featureOverlay.getFeatureTiles().getFeatureDao().getTableName()); if (!tileDaos.isEmpty()) { // Create a composite overlay to search for existing tiles before drawing from features overlay = getCompositeOverlay(tileDaos, featureOverlay); } else { overlay = featureOverlay; } return overlay; }
[ "public", "static", "BoundedOverlay", "getLinkedFeatureOverlay", "(", "FeatureOverlay", "featureOverlay", ",", "GeoPackage", "geoPackage", ")", "{", "BoundedOverlay", "overlay", ";", "// Get the linked tile daos", "FeatureTileTableLinker", "linker", "=", "new", "FeatureTileTa...
Create a composite overlay linking the feature overly with @param featureOverlay feature overlay @param geoPackage GeoPackage @return linked bounded overlay
[ "Create", "a", "composite", "overlay", "linking", "the", "feature", "overly", "with" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java#L165-L181
36,830
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java
GeoPackageOverlayFactory.getTile
public static Tile getTile(GeoPackageTile geoPackageTile) { Tile tile = null; if (geoPackageTile != null) { tile = new Tile(geoPackageTile.getWidth(), geoPackageTile.getHeight(), geoPackageTile.getData()); } return tile; }
java
public static Tile getTile(GeoPackageTile geoPackageTile) { Tile tile = null; if (geoPackageTile != null) { tile = new Tile(geoPackageTile.getWidth(), geoPackageTile.getHeight(), geoPackageTile.getData()); } return tile; }
[ "public", "static", "Tile", "getTile", "(", "GeoPackageTile", "geoPackageTile", ")", "{", "Tile", "tile", "=", "null", ";", "if", "(", "geoPackageTile", "!=", "null", ")", "{", "tile", "=", "new", "Tile", "(", "geoPackageTile", ".", "getWidth", "(", ")", ...
Get a map tile from the GeoPackage tile @param geoPackageTile GeoPackage tile @return tile
[ "Get", "a", "map", "tile", "from", "the", "GeoPackage", "tile" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/overlay/GeoPackageOverlayFactory.java#L190-L196
36,831
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/FeatureInfoBuilder.java
FeatureInfoBuilder.projectGeometry
public void projectGeometry(GeoPackageGeometryData geometryData, Projection projection) { if (geometryData.getGeometry() != null) { try { SpatialReferenceSystemDao srsDao = DaoManager.createDao(featureDao.getDb().getConnectionSource(), SpatialReferenceSystem.class); int srsId = geometryData.getSrsId(); SpatialReferenceSystem srs = srsDao.queryForId((long) srsId); if (!projection.equals(srs.getOrganization(), srs.getOrganizationCoordsysId())) { Projection geomProjection = srs.getProjection(); ProjectionTransform transform = geomProjection.getTransformation(projection); Geometry projectedGeometry = transform.transform(geometryData.getGeometry()); geometryData.setGeometry(projectedGeometry); SpatialReferenceSystem projectionSrs = srsDao.getOrCreateCode(projection.getAuthority(), Long.parseLong(projection.getCode())); geometryData.setSrsId((int) projectionSrs.getSrsId()); } } catch (SQLException e) { throw new GeoPackageException("Failed to project geometry to projection with Authority: " + projection.getAuthority() + ", Code: " + projection.getCode(), e); } } }
java
public void projectGeometry(GeoPackageGeometryData geometryData, Projection projection) { if (geometryData.getGeometry() != null) { try { SpatialReferenceSystemDao srsDao = DaoManager.createDao(featureDao.getDb().getConnectionSource(), SpatialReferenceSystem.class); int srsId = geometryData.getSrsId(); SpatialReferenceSystem srs = srsDao.queryForId((long) srsId); if (!projection.equals(srs.getOrganization(), srs.getOrganizationCoordsysId())) { Projection geomProjection = srs.getProjection(); ProjectionTransform transform = geomProjection.getTransformation(projection); Geometry projectedGeometry = transform.transform(geometryData.getGeometry()); geometryData.setGeometry(projectedGeometry); SpatialReferenceSystem projectionSrs = srsDao.getOrCreateCode(projection.getAuthority(), Long.parseLong(projection.getCode())); geometryData.setSrsId((int) projectionSrs.getSrsId()); } } catch (SQLException e) { throw new GeoPackageException("Failed to project geometry to projection with Authority: " + projection.getAuthority() + ", Code: " + projection.getCode(), e); } } }
[ "public", "void", "projectGeometry", "(", "GeoPackageGeometryData", "geometryData", ",", "Projection", "projection", ")", "{", "if", "(", "geometryData", ".", "getGeometry", "(", ")", "!=", "null", ")", "{", "try", "{", "SpatialReferenceSystemDao", "srsDao", "=", ...
Project the geometry into the provided projection @param geometryData geometry data @param projection projection
[ "Project", "the", "geometry", "into", "the", "provided", "projection" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/FeatureInfoBuilder.java#L528-L553
36,832
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/FeatureInfoBuilder.java
FeatureInfoBuilder.getDataColumnsDao
private DataColumnsDao getDataColumnsDao() { DataColumnsDao dataColumnsDao = null; try { dataColumnsDao = DaoManager.createDao(featureDao.getDb().getConnectionSource(), DataColumns.class); if (!dataColumnsDao.isTableExists()) { dataColumnsDao = null; } } catch (SQLException e) { dataColumnsDao = null; Log.e(FeatureOverlayQuery.class.getSimpleName(), "Failed to get a Data Columns DAO", e); } return dataColumnsDao; }
java
private DataColumnsDao getDataColumnsDao() { DataColumnsDao dataColumnsDao = null; try { dataColumnsDao = DaoManager.createDao(featureDao.getDb().getConnectionSource(), DataColumns.class); if (!dataColumnsDao.isTableExists()) { dataColumnsDao = null; } } catch (SQLException e) { dataColumnsDao = null; Log.e(FeatureOverlayQuery.class.getSimpleName(), "Failed to get a Data Columns DAO", e); } return dataColumnsDao; }
[ "private", "DataColumnsDao", "getDataColumnsDao", "(", ")", "{", "DataColumnsDao", "dataColumnsDao", "=", "null", ";", "try", "{", "dataColumnsDao", "=", "DaoManager", ".", "createDao", "(", "featureDao", ".", "getDb", "(", ")", ".", "getConnectionSource", "(", ...
Get a Data Columns DAO @return data columns dao
[ "Get", "a", "Data", "Columns", "DAO" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/FeatureInfoBuilder.java#L560-L572
36,833
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/FeatureInfoBuilder.java
FeatureInfoBuilder.getColumnName
private String getColumnName(DataColumnsDao dataColumnsDao, FeatureRow featureRow, String columnName) { String newColumnName = columnName; if (dataColumnsDao != null) { try { DataColumns dataColumn = dataColumnsDao.getDataColumn(featureRow.getTable().getTableName(), columnName); if (dataColumn != null) { newColumnName = dataColumn.getName(); } } catch (SQLException e) { Log.e(FeatureOverlayQuery.class.getSimpleName(), "Failed to search for Data Column name for column: " + columnName + ", Feature Table: " + featureRow.getTable().getTableName(), e); } } return newColumnName; }
java
private String getColumnName(DataColumnsDao dataColumnsDao, FeatureRow featureRow, String columnName) { String newColumnName = columnName; if (dataColumnsDao != null) { try { DataColumns dataColumn = dataColumnsDao.getDataColumn(featureRow.getTable().getTableName(), columnName); if (dataColumn != null) { newColumnName = dataColumn.getName(); } } catch (SQLException e) { Log.e(FeatureOverlayQuery.class.getSimpleName(), "Failed to search for Data Column name for column: " + columnName + ", Feature Table: " + featureRow.getTable().getTableName(), e); } } return newColumnName; }
[ "private", "String", "getColumnName", "(", "DataColumnsDao", "dataColumnsDao", ",", "FeatureRow", "featureRow", ",", "String", "columnName", ")", "{", "String", "newColumnName", "=", "columnName", ";", "if", "(", "dataColumnsDao", "!=", "null", ")", "{", "try", ...
Get the column name by checking for a DataColumns name, otherwise returns the provided column name @param dataColumnsDao data columns dao @param featureRow feature row @param columnName column name @return column name
[ "Get", "the", "column", "name", "by", "checking", "for", "a", "DataColumns", "name", "otherwise", "returns", "the", "provided", "column", "name" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/FeatureInfoBuilder.java#L582-L600
36,834
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/FeatureInfoBuilder.java
FeatureInfoBuilder.fineFilterResults
private FeatureIndexResults fineFilterResults(FeatureIndexResults results, double tolerance, LatLng clickLocation) { FeatureIndexResults filteredResults = null; if (ignoreGeometryTypes.contains(geometryType)) { filteredResults = new FeatureIndexListResults(); } else if (clickLocation == null && ignoreGeometryTypes.isEmpty()) { filteredResults = results; } else { FeatureIndexListResults filteredListResults = new FeatureIndexListResults(); GoogleMapShapeConverter converter = new GoogleMapShapeConverter( featureDao.getProjection()); for (FeatureRow featureRow : results) { GeoPackageGeometryData geomData = featureRow.getGeometry(); if (geomData != null) { Geometry geometry = geomData.getGeometry(); if (geometry != null) { if (!ignoreGeometryTypes.contains(geometry.getGeometryType())) { if (clickLocation != null) { GoogleMapShape mapShape = converter.toShape(geometry); if (MapUtils.isPointOnShape(clickLocation, mapShape, geodesic, tolerance)) { filteredListResults.addRow(featureRow); } } else { filteredListResults.addRow(featureRow); } } } } } filteredResults = filteredListResults; } return filteredResults; }
java
private FeatureIndexResults fineFilterResults(FeatureIndexResults results, double tolerance, LatLng clickLocation) { FeatureIndexResults filteredResults = null; if (ignoreGeometryTypes.contains(geometryType)) { filteredResults = new FeatureIndexListResults(); } else if (clickLocation == null && ignoreGeometryTypes.isEmpty()) { filteredResults = results; } else { FeatureIndexListResults filteredListResults = new FeatureIndexListResults(); GoogleMapShapeConverter converter = new GoogleMapShapeConverter( featureDao.getProjection()); for (FeatureRow featureRow : results) { GeoPackageGeometryData geomData = featureRow.getGeometry(); if (geomData != null) { Geometry geometry = geomData.getGeometry(); if (geometry != null) { if (!ignoreGeometryTypes.contains(geometry.getGeometryType())) { if (clickLocation != null) { GoogleMapShape mapShape = converter.toShape(geometry); if (MapUtils.isPointOnShape(clickLocation, mapShape, geodesic, tolerance)) { filteredListResults.addRow(featureRow); } } else { filteredListResults.addRow(featureRow); } } } } } filteredResults = filteredListResults; } return filteredResults; }
[ "private", "FeatureIndexResults", "fineFilterResults", "(", "FeatureIndexResults", "results", ",", "double", "tolerance", ",", "LatLng", "clickLocation", ")", "{", "FeatureIndexResults", "filteredResults", "=", "null", ";", "if", "(", "ignoreGeometryTypes", ".", "contai...
Fine filter the index results verifying the click location is within the tolerance of each feature row @param results feature index results @param tolerance distance tolerance @param clickLocation click location @return filtered feature index results
[ "Fine", "filter", "the", "index", "results", "verifying", "the", "click", "location", "is", "within", "the", "tolerance", "of", "each", "feature", "row" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/FeatureInfoBuilder.java#L610-L655
36,835
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeMarkers.java
GoogleMapShapeMarkers.delete
public boolean delete(Marker marker) { boolean deleted = false; if (contains(marker)) { deleted = true; ShapeMarkers shapeMarkers = shapeMarkersMap.remove(marker.getId()); if (shapeMarkers != null) { shapeMarkers.delete(marker); } marker.remove(); } return deleted; }
java
public boolean delete(Marker marker) { boolean deleted = false; if (contains(marker)) { deleted = true; ShapeMarkers shapeMarkers = shapeMarkersMap.remove(marker.getId()); if (shapeMarkers != null) { shapeMarkers.delete(marker); } marker.remove(); } return deleted; }
[ "public", "boolean", "delete", "(", "Marker", "marker", ")", "{", "boolean", "deleted", "=", "false", ";", "if", "(", "contains", "(", "marker", ")", ")", "{", "deleted", "=", "true", ";", "ShapeMarkers", "shapeMarkers", "=", "shapeMarkersMap", ".", "remov...
Get the shape markers for a marker, only returns a value of shapes that can be edited @param marker marker @return deleted flag
[ "Get", "the", "shape", "markers", "for", "a", "marker", "only", "returns", "a", "value", "of", "shapes", "that", "can", "be", "edited" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeMarkers.java#L166-L177
36,836
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeMarkers.java
GoogleMapShapeMarkers.addMarkerAsPolygon
public static void addMarkerAsPolygon(Marker marker, List<Marker> markers) { LatLng position = marker.getPosition(); int insertLocation = markers.size(); if (markers.size() > 2) { double[] distances = new double[markers.size()]; insertLocation = 0; distances[0] = SphericalUtil.computeDistanceBetween(position, markers.get(0).getPosition()); for (int i = 1; i < markers.size(); i++) { distances[i] = SphericalUtil.computeDistanceBetween(position, markers.get(i).getPosition()); if (distances[i] < distances[insertLocation]) { insertLocation = i; } } int beforeLocation = insertLocation > 0 ? insertLocation - 1 : distances.length - 1; int afterLocation = insertLocation < distances.length - 1 ? insertLocation + 1 : 0; if (distances[beforeLocation] > distances[afterLocation]) { insertLocation = afterLocation; } } markers.add(insertLocation, marker); }
java
public static void addMarkerAsPolygon(Marker marker, List<Marker> markers) { LatLng position = marker.getPosition(); int insertLocation = markers.size(); if (markers.size() > 2) { double[] distances = new double[markers.size()]; insertLocation = 0; distances[0] = SphericalUtil.computeDistanceBetween(position, markers.get(0).getPosition()); for (int i = 1; i < markers.size(); i++) { distances[i] = SphericalUtil.computeDistanceBetween(position, markers.get(i).getPosition()); if (distances[i] < distances[insertLocation]) { insertLocation = i; } } int beforeLocation = insertLocation > 0 ? insertLocation - 1 : distances.length - 1; int afterLocation = insertLocation < distances.length - 1 ? insertLocation + 1 : 0; if (distances[beforeLocation] > distances[afterLocation]) { insertLocation = afterLocation; } } markers.add(insertLocation, marker); }
[ "public", "static", "void", "addMarkerAsPolygon", "(", "Marker", "marker", ",", "List", "<", "Marker", ">", "markers", ")", "{", "LatLng", "position", "=", "marker", ".", "getPosition", "(", ")", ";", "int", "insertLocation", "=", "markers", ".", "size", "...
Polygon add a marker in the list of markers to where it is closest to the the surrounding points @param marker marker @param markers list of markers
[ "Polygon", "add", "a", "marker", "in", "the", "list", "of", "markers", "to", "where", "it", "is", "closest", "to", "the", "the", "surrounding", "points" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/geom/GoogleMapShapeMarkers.java#L217-L244
36,837
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java
StyleUtils.createMarkerOptions
public static MarkerOptions createMarkerOptions(IconRow icon, float density, IconCache iconCache) { MarkerOptions markerOptions = new MarkerOptions(); setIcon(markerOptions, icon, density, iconCache); return markerOptions; }
java
public static MarkerOptions createMarkerOptions(IconRow icon, float density, IconCache iconCache) { MarkerOptions markerOptions = new MarkerOptions(); setIcon(markerOptions, icon, density, iconCache); return markerOptions; }
[ "public", "static", "MarkerOptions", "createMarkerOptions", "(", "IconRow", "icon", ",", "float", "density", ",", "IconCache", "iconCache", ")", "{", "MarkerOptions", "markerOptions", "=", "new", "MarkerOptions", "(", ")", ";", "setIcon", "(", "markerOptions", ","...
Create new marker options populated with the icon @param icon icon row @param density display density: {@link android.util.DisplayMetrics#density} @param iconCache icon cache @return marker options populated with the icon
[ "Create", "new", "marker", "options", "populated", "with", "the", "icon" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java#L235-L241
36,838
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java
StyleUtils.createIcon
public static Bitmap createIcon(IconRow icon, float density, IconCache iconCache) { return iconCache.createIcon(icon, density); }
java
public static Bitmap createIcon(IconRow icon, float density, IconCache iconCache) { return iconCache.createIcon(icon, density); }
[ "public", "static", "Bitmap", "createIcon", "(", "IconRow", "icon", ",", "float", "density", ",", "IconCache", "iconCache", ")", "{", "return", "iconCache", ".", "createIcon", "(", "icon", ",", "density", ")", ";", "}" ]
Create the icon bitmap @param icon icon row @param density display density: {@link android.util.DisplayMetrics#density} @param iconCache icon cache @return icon bitmap
[ "Create", "the", "icon", "bitmap" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java#L303-L305
36,839
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java
StyleUtils.createMarkerOptions
public static MarkerOptions createMarkerOptions(StyleRow style) { MarkerOptions markerOptions = new MarkerOptions(); setStyle(markerOptions, style); return markerOptions; }
java
public static MarkerOptions createMarkerOptions(StyleRow style) { MarkerOptions markerOptions = new MarkerOptions(); setStyle(markerOptions, style); return markerOptions; }
[ "public", "static", "MarkerOptions", "createMarkerOptions", "(", "StyleRow", "style", ")", "{", "MarkerOptions", "markerOptions", "=", "new", "MarkerOptions", "(", ")", ";", "setStyle", "(", "markerOptions", ",", "style", ")", ";", "return", "markerOptions", ";", ...
Create new marker options populated with the style @param style style row @return marker options populated with the style
[ "Create", "new", "marker", "options", "populated", "with", "the", "style" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java#L313-L319
36,840
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java
StyleUtils.setStyle
public static boolean setStyle(MarkerOptions markerOptions, StyleRow style) { boolean styleSet = false; if (style != null) { Color color = style.getColorOrDefault(); float hue = color.getHue(); markerOptions.icon(BitmapDescriptorFactory.defaultMarker(hue)); styleSet = true; } return styleSet; }
java
public static boolean setStyle(MarkerOptions markerOptions, StyleRow style) { boolean styleSet = false; if (style != null) { Color color = style.getColorOrDefault(); float hue = color.getHue(); markerOptions.icon(BitmapDescriptorFactory.defaultMarker(hue)); styleSet = true; } return styleSet; }
[ "public", "static", "boolean", "setStyle", "(", "MarkerOptions", "markerOptions", ",", "StyleRow", "style", ")", "{", "boolean", "styleSet", "=", "false", ";", "if", "(", "style", "!=", "null", ")", "{", "Color", "color", "=", "style", ".", "getColorOrDefaul...
Set the style into the marker options @param markerOptions marker options @param style style row @return true if style was set into the marker options
[ "Set", "the", "style", "into", "the", "marker", "options" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java#L328-L340
36,841
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java
StyleUtils.createPolylineOptions
public static PolylineOptions createPolylineOptions(FeatureStyle featureStyle, float density) { PolylineOptions polylineOptions = new PolylineOptions(); setFeatureStyle(polylineOptions, featureStyle, density); return polylineOptions; }
java
public static PolylineOptions createPolylineOptions(FeatureStyle featureStyle, float density) { PolylineOptions polylineOptions = new PolylineOptions(); setFeatureStyle(polylineOptions, featureStyle, density); return polylineOptions; }
[ "public", "static", "PolylineOptions", "createPolylineOptions", "(", "FeatureStyle", "featureStyle", ",", "float", "density", ")", "{", "PolylineOptions", "polylineOptions", "=", "new", "PolylineOptions", "(", ")", ";", "setFeatureStyle", "(", "polylineOptions", ",", ...
Create new polyline options populated with the feature style @param featureStyle feature style @param density display density: {@link android.util.DisplayMetrics#density} @return polyline options populated with the feature style
[ "Create", "new", "polyline", "options", "populated", "with", "the", "feature", "style" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java#L413-L419
36,842
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java
StyleUtils.createPolylineOptions
public static PolylineOptions createPolylineOptions(StyleRow style, float density) { PolylineOptions polylineOptions = new PolylineOptions(); setStyle(polylineOptions, style, density); return polylineOptions; }
java
public static PolylineOptions createPolylineOptions(StyleRow style, float density) { PolylineOptions polylineOptions = new PolylineOptions(); setStyle(polylineOptions, style, density); return polylineOptions; }
[ "public", "static", "PolylineOptions", "createPolylineOptions", "(", "StyleRow", "style", ",", "float", "density", ")", "{", "PolylineOptions", "polylineOptions", "=", "new", "PolylineOptions", "(", ")", ";", "setStyle", "(", "polylineOptions", ",", "style", ",", ...
Create new polyline options populated with the style @param style style row @param density display density: {@link android.util.DisplayMetrics#density} @return polyline options populated with the style
[ "Create", "new", "polyline", "options", "populated", "with", "the", "style" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java#L449-L455
36,843
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java
StyleUtils.createPolygonOptions
public static PolygonOptions createPolygonOptions(FeatureStyle featureStyle, float density) { PolygonOptions polygonOptions = new PolygonOptions(); setFeatureStyle(polygonOptions, featureStyle, density); return polygonOptions; }
java
public static PolygonOptions createPolygonOptions(FeatureStyle featureStyle, float density) { PolygonOptions polygonOptions = new PolygonOptions(); setFeatureStyle(polygonOptions, featureStyle, density); return polygonOptions; }
[ "public", "static", "PolygonOptions", "createPolygonOptions", "(", "FeatureStyle", "featureStyle", ",", "float", "density", ")", "{", "PolygonOptions", "polygonOptions", "=", "new", "PolygonOptions", "(", ")", ";", "setFeatureStyle", "(", "polygonOptions", ",", "featu...
Create new polygon options populated with the feature style @param featureStyle feature style @param density display density: {@link android.util.DisplayMetrics#density} @return polygon options populated with the feature style
[ "Create", "new", "polygon", "options", "populated", "with", "the", "feature", "style" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java#L551-L557
36,844
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java
StyleUtils.createPolygonOptions
public static PolygonOptions createPolygonOptions(StyleRow style, float density) { PolygonOptions polygonOptions = new PolygonOptions(); setStyle(polygonOptions, style, density); return polygonOptions; }
java
public static PolygonOptions createPolygonOptions(StyleRow style, float density) { PolygonOptions polygonOptions = new PolygonOptions(); setStyle(polygonOptions, style, density); return polygonOptions; }
[ "public", "static", "PolygonOptions", "createPolygonOptions", "(", "StyleRow", "style", ",", "float", "density", ")", "{", "PolygonOptions", "polygonOptions", "=", "new", "PolygonOptions", "(", ")", ";", "setStyle", "(", "polygonOptions", ",", "style", ",", "densi...
Create new polygon options populated with the style @param style style row @param density display density: {@link android.util.DisplayMetrics#density} @return polygon options populated with the style
[ "Create", "new", "polygon", "options", "populated", "with", "the", "style" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/features/StyleUtils.java#L587-L593
36,845
ngageoint/geopackage-android-map
geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/TileBoundingBoxMapUtils.java
TileBoundingBoxMapUtils.getLatitudeDistance
public static double getLatitudeDistance(double minLatitude, double maxLatitude) { LatLng lowerMiddle = new LatLng(minLatitude, 0); LatLng upperMiddle = new LatLng(maxLatitude, 0); double latDistance = SphericalUtil.computeDistanceBetween(lowerMiddle, upperMiddle); return latDistance; }
java
public static double getLatitudeDistance(double minLatitude, double maxLatitude) { LatLng lowerMiddle = new LatLng(minLatitude, 0); LatLng upperMiddle = new LatLng(maxLatitude, 0); double latDistance = SphericalUtil.computeDistanceBetween(lowerMiddle, upperMiddle); return latDistance; }
[ "public", "static", "double", "getLatitudeDistance", "(", "double", "minLatitude", ",", "double", "maxLatitude", ")", "{", "LatLng", "lowerMiddle", "=", "new", "LatLng", "(", "minLatitude", ",", "0", ")", ";", "LatLng", "upperMiddle", "=", "new", "LatLng", "("...
Get the latitude distance @param minLatitude min latitude @param maxLatitude max latitude @return distance
[ "Get", "the", "latitude", "distance" ]
634d78468a5c52d2bc98791cc7ff03981ebf573b
https://github.com/ngageoint/geopackage-android-map/blob/634d78468a5c52d2bc98791cc7ff03981ebf573b/geopackage-map/src/main/java/mil/nga/geopackage/map/tiles/TileBoundingBoxMapUtils.java#L86-L93
36,846
betfair/cougar
cougar-framework/cougar-core-impl/src/main/java/com/betfair/cougar/core/impl/jmx/HtmlAdaptorParser.java
HtmlAdaptorParser.isValid
private boolean isValid(String request) { String tmp = decodePercent(request); if(tmp.indexOf('<') != -1 || tmp.indexOf('>') != -1 ) { return false; } return true; }
java
private boolean isValid(String request) { String tmp = decodePercent(request); if(tmp.indexOf('<') != -1 || tmp.indexOf('>') != -1 ) { return false; } return true; }
[ "private", "boolean", "isValid", "(", "String", "request", ")", "{", "String", "tmp", "=", "decodePercent", "(", "request", ")", ";", "if", "(", "tmp", ".", "indexOf", "(", "'", "'", ")", "!=", "-", "1", "||", "tmp", ".", "indexOf", "(", "'", "'", ...
Validates request string for not containing malicious characters. @param request a request string @return true - if request string is valid, false - otherwise
[ "Validates", "request", "string", "for", "not", "containing", "malicious", "characters", "." ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-core-impl/src/main/java/com/betfair/cougar/core/impl/jmx/HtmlAdaptorParser.java#L218-L227
36,847
betfair/cougar
cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/SessionRecycler.java
SessionRecycler.diff
private List<String> diff(Collection<String> first, Collection<String> second) { final ArrayList<String> list = new ArrayList<String>(first); list.removeAll(second); return list; }
java
private List<String> diff(Collection<String> first, Collection<String> second) { final ArrayList<String> list = new ArrayList<String>(first); list.removeAll(second); return list; }
[ "private", "List", "<", "String", ">", "diff", "(", "Collection", "<", "String", ">", "first", ",", "Collection", "<", "String", ">", "second", ")", "{", "final", "ArrayList", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "("...
Returns a list of elements in the first collection which are not present in the second collection @param first First collection @param second Second collection @return Difference between the two collections
[ "Returns", "a", "list", "of", "elements", "in", "the", "first", "collection", "which", "are", "not", "present", "in", "the", "second", "collection" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/SessionRecycler.java#L147-L151
36,848
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/configuration/PropertyLoader.java
PropertyLoader.buildConsolidatedProperties
public Properties buildConsolidatedProperties() throws IOException { //Cannot use the spring classes here because they a) use the logger early, which //scuppers log4j and b) they're designed to do bean value overriding - not to be //used directly in this fashion Properties properties = new Properties(); //Read them from the list of resources then mix in System for (Resource r : constructResourceList()) { try (InputStream is = r.getInputStream()) { properties.load(is); } } //System for (String propertyName : System.getProperties().stringPropertyNames()) { properties.setProperty(propertyName, System.getProperty(propertyName)); } return properties; }
java
public Properties buildConsolidatedProperties() throws IOException { //Cannot use the spring classes here because they a) use the logger early, which //scuppers log4j and b) they're designed to do bean value overriding - not to be //used directly in this fashion Properties properties = new Properties(); //Read them from the list of resources then mix in System for (Resource r : constructResourceList()) { try (InputStream is = r.getInputStream()) { properties.load(is); } } //System for (String propertyName : System.getProperties().stringPropertyNames()) { properties.setProperty(propertyName, System.getProperty(propertyName)); } return properties; }
[ "public", "Properties", "buildConsolidatedProperties", "(", ")", "throws", "IOException", "{", "//Cannot use the spring classes here because they a) use the logger early, which", "//scuppers log4j and b) they're designed to do bean value overriding - not to be", "//used directly in this fashion"...
This will realise the set of resources returned from @see constructResourcesList and as a fully populated properties object, including System properties @return returns a fully populated Properties object with values from the config, the override and the System (in that order of precedence) @throws IOException
[ "This", "will", "realise", "the", "set", "of", "resources", "returned", "from" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/configuration/PropertyLoader.java#L61-L78
36,849
betfair/cougar
cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/AbstractHttpCommandProcessor.java
AbstractHttpCommandProcessor.bind
@Override public void bind(ServiceBindingDescriptor bindingDescriptor) { String servicePlusMajorVersion=bindingDescriptor.getServiceName() + "-v" + bindingDescriptor.getServiceVersion().getMajor(); if (serviceBindingDescriptors.containsKey(servicePlusMajorVersion)) { throw new PanicInTheCougar("More than one version of service [" + bindingDescriptor.getServiceName() + "] is attempting to be bound for the same major version. The clashing versions are [" + serviceBindingDescriptors.get(servicePlusMajorVersion).getServiceVersion() + ", " + bindingDescriptor.getServiceVersion() + "] - only one instance of a service is permissable for each major version"); } serviceBindingDescriptors.put(servicePlusMajorVersion, bindingDescriptor); }
java
@Override public void bind(ServiceBindingDescriptor bindingDescriptor) { String servicePlusMajorVersion=bindingDescriptor.getServiceName() + "-v" + bindingDescriptor.getServiceVersion().getMajor(); if (serviceBindingDescriptors.containsKey(servicePlusMajorVersion)) { throw new PanicInTheCougar("More than one version of service [" + bindingDescriptor.getServiceName() + "] is attempting to be bound for the same major version. The clashing versions are [" + serviceBindingDescriptors.get(servicePlusMajorVersion).getServiceVersion() + ", " + bindingDescriptor.getServiceVersion() + "] - only one instance of a service is permissable for each major version"); } serviceBindingDescriptors.put(servicePlusMajorVersion, bindingDescriptor); }
[ "@", "Override", "public", "void", "bind", "(", "ServiceBindingDescriptor", "bindingDescriptor", ")", "{", "String", "servicePlusMajorVersion", "=", "bindingDescriptor", ".", "getServiceName", "(", ")", "+", "\"-v\"", "+", "bindingDescriptor", ".", "getServiceVersion", ...
Adds the binding descriptor to a list for binding later. The actual binding occurs onCougarStart, to be implemented by subclasses, when it can be guaranteed that all services have been registered with the EV.
[ "Adds", "the", "binding", "descriptor", "to", "a", "list", "for", "binding", "later", ".", "The", "actual", "binding", "occurs", "onCougarStart", "to", "be", "implemented", "by", "subclasses", "when", "it", "can", "be", "guaranteed", "that", "all", "services",...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/AbstractHttpCommandProcessor.java#L158-L171
36,850
betfair/cougar
cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/AbstractHttpCommandProcessor.java
AbstractHttpCommandProcessor.resolveExecutionContext
protected DehydratedExecutionContext resolveExecutionContext(HttpCommand http, CredentialsContainer cc) { return contextResolution.resolveExecutionContext(protocol, http, cc); }
java
protected DehydratedExecutionContext resolveExecutionContext(HttpCommand http, CredentialsContainer cc) { return contextResolution.resolveExecutionContext(protocol, http, cc); }
[ "protected", "DehydratedExecutionContext", "resolveExecutionContext", "(", "HttpCommand", "http", ",", "CredentialsContainer", "cc", ")", "{", "return", "contextResolution", ".", "resolveExecutionContext", "(", "protocol", ",", "http", ",", "cc", ")", ";", "}" ]
Resolves an HttpCommand to an ExecutionContext, which provides contextual information to the ExecutionVenue that the command will be executed in. @param http contains the HttpServletRequest from which the contextual information is derived @return the ExecutionContext, populated with information from the HttpCommend
[ "Resolves", "an", "HttpCommand", "to", "an", "ExecutionContext", "which", "provides", "contextual", "information", "to", "the", "ExecutionVenue", "that", "the", "command", "will", "be", "executed", "in", "." ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/AbstractHttpCommandProcessor.java#L254-L256
36,851
betfair/cougar
cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/AbstractHttpCommandProcessor.java
AbstractHttpCommandProcessor.writeIdentity
public void writeIdentity(List<IdentityToken> tokens, IdentityTokenIOAdapter ioAdapter) { if (ioAdapter != null && ioAdapter.isRewriteSupported()) { ioAdapter.rewriteIdentityTokens(tokens); } }
java
public void writeIdentity(List<IdentityToken> tokens, IdentityTokenIOAdapter ioAdapter) { if (ioAdapter != null && ioAdapter.isRewriteSupported()) { ioAdapter.rewriteIdentityTokens(tokens); } }
[ "public", "void", "writeIdentity", "(", "List", "<", "IdentityToken", ">", "tokens", ",", "IdentityTokenIOAdapter", "ioAdapter", ")", "{", "if", "(", "ioAdapter", "!=", "null", "&&", "ioAdapter", ".", "isRewriteSupported", "(", ")", ")", "{", "ioAdapter", ".",...
Rewrites the caller's credentials back into the HTTP response. The main use case for this is rewriting SSO tokens, which may change and the client needs to know the new value. @param tokens - the identity tokens to marshall @param ioAdapter - the adapter to detail with the transport specific IO requirements
[ "Rewrites", "the", "caller", "s", "credentials", "back", "into", "the", "HTTP", "response", ".", "The", "main", "use", "case", "for", "this", "is", "rewriting", "SSO", "tokens", "which", "may", "change", "and", "the", "client", "needs", "to", "know", "the"...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/AbstractHttpCommandProcessor.java#L270-L274
36,852
betfair/cougar
cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/AbstractHttpCommandProcessor.java
AbstractHttpCommandProcessor.handleResponseWritingIOException
protected CougarException handleResponseWritingIOException(Exception e, Class resultClass) { String errorMessage = "Exception writing "+ resultClass.getCanonicalName() +" to http stream"; IOException ioe = getIOException(e); if (ioe == null) { CougarException ce; if (e instanceof CougarException) { ce = (CougarException)e; } else { ce = new CougarFrameworkException(errorMessage, e); } return ce; } //We arrive here when the output pipe is broken. Broken network connections are not //really exceptional and should not be reported by dumping the stack trace. //Instead a summary debug level log message with some relevant info incrementIoErrorsEncountered(); LOGGER.debug( "Failed to marshall object of class {} to the output channel. Exception ({}) message is: {}", resultClass.getCanonicalName(), e.getClass().getCanonicalName(), e.getMessage() ); return new CougarServiceException(ServerFaultCode.OutputChannelClosedCantWrite, errorMessage, e); }
java
protected CougarException handleResponseWritingIOException(Exception e, Class resultClass) { String errorMessage = "Exception writing "+ resultClass.getCanonicalName() +" to http stream"; IOException ioe = getIOException(e); if (ioe == null) { CougarException ce; if (e instanceof CougarException) { ce = (CougarException)e; } else { ce = new CougarFrameworkException(errorMessage, e); } return ce; } //We arrive here when the output pipe is broken. Broken network connections are not //really exceptional and should not be reported by dumping the stack trace. //Instead a summary debug level log message with some relevant info incrementIoErrorsEncountered(); LOGGER.debug( "Failed to marshall object of class {} to the output channel. Exception ({}) message is: {}", resultClass.getCanonicalName(), e.getClass().getCanonicalName(), e.getMessage() ); return new CougarServiceException(ServerFaultCode.OutputChannelClosedCantWrite, errorMessage, e); }
[ "protected", "CougarException", "handleResponseWritingIOException", "(", "Exception", "e", ",", "Class", "resultClass", ")", "{", "String", "errorMessage", "=", "\"Exception writing \"", "+", "resultClass", ".", "getCanonicalName", "(", ")", "+", "\" to http stream\"", ...
If an exception is received while writing a response to the client, it might be because the that client has closed their connection. If so, the problem should be ignored.
[ "If", "an", "exception", "is", "received", "while", "writing", "a", "response", "to", "the", "client", "it", "might", "be", "because", "the", "that", "client", "has", "closed", "their", "connection", ".", "If", "so", "the", "problem", "should", "be", "igno...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/AbstractHttpCommandProcessor.java#L280-L304
36,853
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/geolocation/RemoteAddressUtils.java
RemoteAddressUtils.parse
public static List<String> parse(String address, String addresses) { List<String> result; // backwards compatibility - older clients only send a single address in the single address header and don't supply the multi-address header if (addresses == null || addresses.isEmpty()) { addresses = address; } if (addresses == null) { result = Collections.emptyList(); } else { String[] parts = addresses.split(","); result = new ArrayList<String>(parts.length); for (String part : parts) { part = part.trim(); if (NetworkAddress.isValidIPAddress(part)) { result.add(part); } } } return result; }
java
public static List<String> parse(String address, String addresses) { List<String> result; // backwards compatibility - older clients only send a single address in the single address header and don't supply the multi-address header if (addresses == null || addresses.isEmpty()) { addresses = address; } if (addresses == null) { result = Collections.emptyList(); } else { String[] parts = addresses.split(","); result = new ArrayList<String>(parts.length); for (String part : parts) { part = part.trim(); if (NetworkAddress.isValidIPAddress(part)) { result.add(part); } } } return result; }
[ "public", "static", "List", "<", "String", ">", "parse", "(", "String", "address", ",", "String", "addresses", ")", "{", "List", "<", "String", ">", "result", ";", "// backwards compatibility - older clients only send a single address in the single address header and don't ...
Parse a comma separated string of ip addresses into a list Only valid IP address are returned in the list
[ "Parse", "a", "comma", "separated", "string", "of", "ip", "addresses", "into", "a", "list", "Only", "valid", "IP", "address", "are", "returned", "in", "the", "list" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/geolocation/RemoteAddressUtils.java#L102-L122
36,854
betfair/cougar
cougar-framework/cougar-core-impl/src/main/java/com/betfair/cougar/core/impl/ev/ServiceRegistration.java
ServiceRegistration.introduceServiceToTransports
public void introduceServiceToTransports(Iterator<? extends BindingDescriptorRegistrationListener> transports) { while (transports.hasNext()) { BindingDescriptorRegistrationListener t = transports.next(); boolean eventTransport = t instanceof EventTransport; boolean includedEventTransport = false; if (eventTransport) { // if it's an event transport then we only want to notify if we've been told that the developer wanted to // bind to this particular transport (since you can have >1 instance of the event transport currently) if (eventTransports != null && eventTransports.contains(t)) { includedEventTransport = true; } } if (!eventTransport || includedEventTransport) { for (BindingDescriptor bindingDescriptor : getBindingDescriptors()) { t.notify(bindingDescriptor); } } } }
java
public void introduceServiceToTransports(Iterator<? extends BindingDescriptorRegistrationListener> transports) { while (transports.hasNext()) { BindingDescriptorRegistrationListener t = transports.next(); boolean eventTransport = t instanceof EventTransport; boolean includedEventTransport = false; if (eventTransport) { // if it's an event transport then we only want to notify if we've been told that the developer wanted to // bind to this particular transport (since you can have >1 instance of the event transport currently) if (eventTransports != null && eventTransports.contains(t)) { includedEventTransport = true; } } if (!eventTransport || includedEventTransport) { for (BindingDescriptor bindingDescriptor : getBindingDescriptors()) { t.notify(bindingDescriptor); } } } }
[ "public", "void", "introduceServiceToTransports", "(", "Iterator", "<", "?", "extends", "BindingDescriptorRegistrationListener", ">", "transports", ")", "{", "while", "(", "transports", ".", "hasNext", "(", ")", ")", "{", "BindingDescriptorRegistrationListener", "t", ...
Exports each binding descriptor to the supplied collection of transports @param transports
[ "Exports", "each", "binding", "descriptor", "to", "the", "supplied", "collection", "of", "transports" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-core-impl/src/main/java/com/betfair/cougar/core/impl/ev/ServiceRegistration.java#L58-L76
36,855
betfair/cougar
cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/FileUtil.java
FileUtil.resourceToFile
public static void resourceToFile(String resourceName, File dest, Class src) { InputStream is = null; OutputStream os = null; try { is = src.getClassLoader().getResourceAsStream(resourceName); if (is == null) { throw new RuntimeException("Could not load resource: " + resourceName); } dest.getParentFile().mkdirs(); os = new FileOutputStream(dest); IOUtils.copy(is, os); } catch (Exception e) { throw new RuntimeException("Error copying resource '" + resourceName + "' to file '" + dest.getPath() + "': "+ e, e); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(os); } }
java
public static void resourceToFile(String resourceName, File dest, Class src) { InputStream is = null; OutputStream os = null; try { is = src.getClassLoader().getResourceAsStream(resourceName); if (is == null) { throw new RuntimeException("Could not load resource: " + resourceName); } dest.getParentFile().mkdirs(); os = new FileOutputStream(dest); IOUtils.copy(is, os); } catch (Exception e) { throw new RuntimeException("Error copying resource '" + resourceName + "' to file '" + dest.getPath() + "': "+ e, e); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(os); } }
[ "public", "static", "void", "resourceToFile", "(", "String", "resourceName", ",", "File", "dest", ",", "Class", "src", ")", "{", "InputStream", "is", "=", "null", ";", "OutputStream", "os", "=", "null", ";", "try", "{", "is", "=", "src", ".", "getClassLo...
Copy the given resource to the given file. @param resourceName name of resource to copy @param destination file
[ "Copy", "the", "given", "resource", "to", "the", "given", "file", "." ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/FileUtil.java#L34-L56
36,856
betfair/cougar
cougar-codegen-plugin/src/main/java/com/betfair/cougar/transformations/manglers/ResponseToSimpleResponseMangler.java
ResponseToSimpleResponseMangler.getNodeToBeReplaced
private Node getNodeToBeReplaced(Node parametersNode) { Node toBeReplaced = null; int responseCount = 0; NodeList childNodes = parametersNode.getChildNodes(); if (childNodes != null) { for (int j = 0; j < childNodes.getLength(); j++) { Node childNode = childNodes.item(j); String name=childNode.getLocalName(); if ("simpleResponse".equals(name) || "response".equals(name)) { responseCount++; if("response".equals(name)){ //This is the node that will need to be replaced with a copy with a localName of "simpleResponse" toBeReplaced=childNode; } } //If responseCount>1 This implies that both a simpleResponse and response have //been defined - this is allowed by the xsd, but makes no sense if (responseCount > 1) { throw new IllegalArgumentException("Only one of either simpleResponse or response should define the response type"); } } } return toBeReplaced; }
java
private Node getNodeToBeReplaced(Node parametersNode) { Node toBeReplaced = null; int responseCount = 0; NodeList childNodes = parametersNode.getChildNodes(); if (childNodes != null) { for (int j = 0; j < childNodes.getLength(); j++) { Node childNode = childNodes.item(j); String name=childNode.getLocalName(); if ("simpleResponse".equals(name) || "response".equals(name)) { responseCount++; if("response".equals(name)){ //This is the node that will need to be replaced with a copy with a localName of "simpleResponse" toBeReplaced=childNode; } } //If responseCount>1 This implies that both a simpleResponse and response have //been defined - this is allowed by the xsd, but makes no sense if (responseCount > 1) { throw new IllegalArgumentException("Only one of either simpleResponse or response should define the response type"); } } } return toBeReplaced; }
[ "private", "Node", "getNodeToBeReplaced", "(", "Node", "parametersNode", ")", "{", "Node", "toBeReplaced", "=", "null", ";", "int", "responseCount", "=", "0", ";", "NodeList", "childNodes", "=", "parametersNode", ".", "getChildNodes", "(", ")", ";", "if", "(",...
Also ensures only one of the two has been defined
[ "Also", "ensures", "only", "one", "of", "the", "two", "has", "been", "defined" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-codegen-plugin/src/main/java/com/betfair/cougar/transformations/manglers/ResponseToSimpleResponseMangler.java#L92-L115
36,857
betfair/cougar
cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/XmlValidator.java
XmlValidator.validate
public void validate(Document doc) { try { doValidate(doc); } catch (Exception e) { throw new PluginException("Error validating document: " + e, e); } }
java
public void validate(Document doc) { try { doValidate(doc); } catch (Exception e) { throw new PluginException("Error validating document: " + e, e); } }
[ "public", "void", "validate", "(", "Document", "doc", ")", "{", "try", "{", "doValidate", "(", "doc", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "PluginException", "(", "\"Error validating document: \"", "+", "e", ",", "e", ...
Validate the given xmlDocument, using any schemas specified in the document itself. @throws PluginException for any validation or IO errors.
[ "Validate", "the", "given", "xmlDocument", "using", "any", "schemas", "specified", "in", "the", "document", "itself", "." ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/XmlValidator.java#L56-L63
36,858
betfair/cougar
cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/jetty/JettyServerWrapper.java
JettyServerWrapper.setBufferSizes
private void setBufferSizes(HttpConfiguration buffers) { if (requestHeaderSize > 0) { LOGGER.info("Request header size set to {} for {}", requestHeaderSize, buffers.getClass().getCanonicalName()); buffers.setRequestHeaderSize(requestHeaderSize); } if (responseBufferSize > 0) { LOGGER.info("Response buffer size set to {} for {}", responseBufferSize, buffers.getClass().getCanonicalName()); buffers.setOutputBufferSize(responseBufferSize); } if (responseHeaderSize > 0) { LOGGER.info("Response header size set to {} for {}", responseHeaderSize, buffers.getClass().getCanonicalName()); buffers.setResponseHeaderSize(responseHeaderSize); } }
java
private void setBufferSizes(HttpConfiguration buffers) { if (requestHeaderSize > 0) { LOGGER.info("Request header size set to {} for {}", requestHeaderSize, buffers.getClass().getCanonicalName()); buffers.setRequestHeaderSize(requestHeaderSize); } if (responseBufferSize > 0) { LOGGER.info("Response buffer size set to {} for {}", responseBufferSize, buffers.getClass().getCanonicalName()); buffers.setOutputBufferSize(responseBufferSize); } if (responseHeaderSize > 0) { LOGGER.info("Response header size set to {} for {}", responseHeaderSize, buffers.getClass().getCanonicalName()); buffers.setResponseHeaderSize(responseHeaderSize); } }
[ "private", "void", "setBufferSizes", "(", "HttpConfiguration", "buffers", ")", "{", "if", "(", "requestHeaderSize", ">", "0", ")", "{", "LOGGER", ".", "info", "(", "\"Request header size set to {} for {}\"", ",", "requestHeaderSize", ",", "buffers", ".", "getClass",...
Sets the request and header buffer sizex if they are not zero
[ "Sets", "the", "request", "and", "header", "buffer", "sizex", "if", "they", "are", "not", "zero" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/jetty/JettyServerWrapper.java#L223-L237
36,859
betfair/cougar
cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/jetty/JettyHttpTransport.java
JettyHttpTransport.registerHandler
public void registerHandler(HttpServiceBindingDescriptor serviceBindingDescriptor) { for (ProtocolBinding protocolBinding : protocolBindingRegistry.getProtocolBindings()) { if (protocolBinding.getProtocol() == serviceBindingDescriptor.getServiceProtocol()) { String contextPath = protocolBinding.getContextRoot() + serviceBindingDescriptor.getServiceContextPath(); JettyHandlerSpecification handlerSpec = handlerSpecificationMap.get(contextPath); if (handlerSpec == null) { handlerSpec = new JettyHandlerSpecification(protocolBinding.getContextRoot(), protocolBinding.getProtocol(), serviceBindingDescriptor.getServiceContextPath()); handlerSpecificationMap.put(contextPath, handlerSpec); } if (protocolBinding.getIdentityTokenResolver() != null) { handlerSpec.addServiceVersionToTokenResolverEntry(serviceBindingDescriptor.getServiceVersion(), protocolBinding.getIdentityTokenResolver()); } } } commandProcessorFactory.getCommandProcessor(serviceBindingDescriptor.getServiceProtocol()).bind(serviceBindingDescriptor); }
java
public void registerHandler(HttpServiceBindingDescriptor serviceBindingDescriptor) { for (ProtocolBinding protocolBinding : protocolBindingRegistry.getProtocolBindings()) { if (protocolBinding.getProtocol() == serviceBindingDescriptor.getServiceProtocol()) { String contextPath = protocolBinding.getContextRoot() + serviceBindingDescriptor.getServiceContextPath(); JettyHandlerSpecification handlerSpec = handlerSpecificationMap.get(contextPath); if (handlerSpec == null) { handlerSpec = new JettyHandlerSpecification(protocolBinding.getContextRoot(), protocolBinding.getProtocol(), serviceBindingDescriptor.getServiceContextPath()); handlerSpecificationMap.put(contextPath, handlerSpec); } if (protocolBinding.getIdentityTokenResolver() != null) { handlerSpec.addServiceVersionToTokenResolverEntry(serviceBindingDescriptor.getServiceVersion(), protocolBinding.getIdentityTokenResolver()); } } } commandProcessorFactory.getCommandProcessor(serviceBindingDescriptor.getServiceProtocol()).bind(serviceBindingDescriptor); }
[ "public", "void", "registerHandler", "(", "HttpServiceBindingDescriptor", "serviceBindingDescriptor", ")", "{", "for", "(", "ProtocolBinding", "protocolBinding", ":", "protocolBindingRegistry", ".", "getProtocolBindings", "(", ")", ")", "{", "if", "(", "protocolBinding", ...
This method adds the service binding descriptor, and all the appropriate protocol binding combos into the handlerSpecMap, before binding the serviceBindingDescriptor to the appropriate command processor
[ "This", "method", "adds", "the", "service", "binding", "descriptor", "and", "all", "the", "appropriate", "protocol", "binding", "combos", "into", "the", "handlerSpecMap", "before", "binding", "the", "serviceBindingDescriptor", "to", "the", "appropriate", "command", ...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/jetty/JettyHttpTransport.java#L272-L289
36,860
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/X509CertificateUtils.java
X509CertificateUtils.convert
public static java.security.cert.X509Certificate convert(javax.security.cert.X509Certificate cert) { try { byte[] encoded = cert.getEncoded(); ByteArrayInputStream bis = new ByteArrayInputStream(encoded); java.security.cert.CertificateFactory cf = java.security.cert.CertificateFactory.getInstance("X.509"); return (java.security.cert.X509Certificate)cf.generateCertificate(bis); } catch (java.security.cert.CertificateEncodingException e) { } catch (javax.security.cert.CertificateEncodingException e) { } catch (java.security.cert.CertificateException e) { } return null; }
java
public static java.security.cert.X509Certificate convert(javax.security.cert.X509Certificate cert) { try { byte[] encoded = cert.getEncoded(); ByteArrayInputStream bis = new ByteArrayInputStream(encoded); java.security.cert.CertificateFactory cf = java.security.cert.CertificateFactory.getInstance("X.509"); return (java.security.cert.X509Certificate)cf.generateCertificate(bis); } catch (java.security.cert.CertificateEncodingException e) { } catch (javax.security.cert.CertificateEncodingException e) { } catch (java.security.cert.CertificateException e) { } return null; }
[ "public", "static", "java", ".", "security", ".", "cert", ".", "X509Certificate", "convert", "(", "javax", ".", "security", ".", "cert", ".", "X509Certificate", "cert", ")", "{", "try", "{", "byte", "[", "]", "encoded", "=", "cert", ".", "getEncoded", "(...
Converts to java.security
[ "Converts", "to", "java", ".", "security" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/X509CertificateUtils.java#L40-L52
36,861
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/X509CertificateUtils.java
X509CertificateUtils.convert
public static javax.security.cert.X509Certificate convert(java.security.cert.X509Certificate cert) { try { byte[] encoded = cert.getEncoded(); return javax.security.cert.X509Certificate.getInstance(encoded); } catch (java.security.cert.CertificateEncodingException e) { } catch (javax.security.cert.CertificateEncodingException e) { } catch (javax.security.cert.CertificateException e) { } return null; }
java
public static javax.security.cert.X509Certificate convert(java.security.cert.X509Certificate cert) { try { byte[] encoded = cert.getEncoded(); return javax.security.cert.X509Certificate.getInstance(encoded); } catch (java.security.cert.CertificateEncodingException e) { } catch (javax.security.cert.CertificateEncodingException e) { } catch (javax.security.cert.CertificateException e) { } return null; }
[ "public", "static", "javax", ".", "security", ".", "cert", ".", "X509Certificate", "convert", "(", "java", ".", "security", ".", "cert", ".", "X509Certificate", "cert", ")", "{", "try", "{", "byte", "[", "]", "encoded", "=", "cert", ".", "getEncoded", "(...
Converts to javax.security
[ "Converts", "to", "javax", ".", "security" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/X509CertificateUtils.java#L55-L64
36,862
betfair/cougar
cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/jsonrpc/JsonRpcTransportCommandProcessor.java
JsonRpcTransportCommandProcessor.writeErrorResponse
@Override public void writeErrorResponse(HttpCommand command, DehydratedExecutionContext context, CougarException error, boolean traceStarted) { try { incrementErrorsWritten(); final HttpServletResponse response = command.getResponse(); try { long bytesWritten = 0; if(error.getResponseCode() != ResponseCode.CantWriteToSocket) { ResponseCodeMapper.setResponseStatus(response, error.getResponseCode()); ByteCountingOutputStream out = null; try { int jsonErrorCode = mapServerFaultCodeToJsonErrorCode(error.getServerFaultCode()); JsonRpcError rpcError = new JsonRpcError(jsonErrorCode, error.getFault().getErrorCode(), null); JsonRpcErrorResponse jsonRpcErrorResponse = JsonRpcErrorResponse.buildErrorResponse(null, rpcError); out = new ByteCountingOutputStream(response.getOutputStream()); mapper.writeValue(out, jsonRpcErrorResponse); bytesWritten = out.getCount(); } catch (IOException ex) { handleResponseWritingIOException(ex, error.getClass()); } finally { closeStream(out); } } else { LOGGER.debug("Skipping error handling for a request where the output channel/socket has been prematurely closed"); } logAccess(command, resolveContextForErrorHandling(context, command), -1, bytesWritten, MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE, error.getResponseCode()); } finally { command.onComplete(); } } finally { if (context != null && traceStarted) { tracer.end(context.getRequestUUID()); } } }
java
@Override public void writeErrorResponse(HttpCommand command, DehydratedExecutionContext context, CougarException error, boolean traceStarted) { try { incrementErrorsWritten(); final HttpServletResponse response = command.getResponse(); try { long bytesWritten = 0; if(error.getResponseCode() != ResponseCode.CantWriteToSocket) { ResponseCodeMapper.setResponseStatus(response, error.getResponseCode()); ByteCountingOutputStream out = null; try { int jsonErrorCode = mapServerFaultCodeToJsonErrorCode(error.getServerFaultCode()); JsonRpcError rpcError = new JsonRpcError(jsonErrorCode, error.getFault().getErrorCode(), null); JsonRpcErrorResponse jsonRpcErrorResponse = JsonRpcErrorResponse.buildErrorResponse(null, rpcError); out = new ByteCountingOutputStream(response.getOutputStream()); mapper.writeValue(out, jsonRpcErrorResponse); bytesWritten = out.getCount(); } catch (IOException ex) { handleResponseWritingIOException(ex, error.getClass()); } finally { closeStream(out); } } else { LOGGER.debug("Skipping error handling for a request where the output channel/socket has been prematurely closed"); } logAccess(command, resolveContextForErrorHandling(context, command), -1, bytesWritten, MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE, error.getResponseCode()); } finally { command.onComplete(); } } finally { if (context != null && traceStarted) { tracer.end(context.getRequestUUID()); } } }
[ "@", "Override", "public", "void", "writeErrorResponse", "(", "HttpCommand", "command", ",", "DehydratedExecutionContext", "context", ",", "CougarException", "error", ",", "boolean", "traceStarted", ")", "{", "try", "{", "incrementErrorsWritten", "(", ")", ";", "fin...
Please note this should only be used when the JSON rpc call itself fails - the answer will not contain any mention of the requests that caused the failure, nor their ID @param command the command that caused the error @param context @param error @param traceStarted
[ "Please", "note", "this", "should", "only", "be", "used", "when", "the", "JSON", "rpc", "call", "itself", "fails", "-", "the", "answer", "will", "not", "contain", "any", "mention", "of", "the", "requests", "that", "caused", "the", "failure", "nor", "their"...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/jsonrpc/JsonRpcTransportCommandProcessor.java#L406-L446
36,863
betfair/cougar
cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/ExecutionVenueNioClient.java
ExecutionVenueNioClient.start
public synchronized FutureTask<Boolean> start() { this.sessionFactory.start(); if (rpcTimeoutChecker != null) { rpcTimeoutChecker.getThread().start(); } final FutureTask<Boolean> futureTask = new FutureTask<Boolean>( new Callable<Boolean>() { @Override public Boolean call() throws Exception { while (!ExecutionVenueNioClient.this.sessionFactory.isConnected()) { Thread.sleep(50); } return true; } }); final Thread thread = new Thread(futureTask); thread.setDaemon(true); thread.start(); return futureTask; }
java
public synchronized FutureTask<Boolean> start() { this.sessionFactory.start(); if (rpcTimeoutChecker != null) { rpcTimeoutChecker.getThread().start(); } final FutureTask<Boolean> futureTask = new FutureTask<Boolean>( new Callable<Boolean>() { @Override public Boolean call() throws Exception { while (!ExecutionVenueNioClient.this.sessionFactory.isConnected()) { Thread.sleep(50); } return true; } }); final Thread thread = new Thread(futureTask); thread.setDaemon(true); thread.start(); return futureTask; }
[ "public", "synchronized", "FutureTask", "<", "Boolean", ">", "start", "(", ")", "{", "this", ".", "sessionFactory", ".", "start", "(", ")", ";", "if", "(", "rpcTimeoutChecker", "!=", "null", ")", "{", "rpcTimeoutChecker", ".", "getThread", "(", ")", ".", ...
Starts the client @return a Future<Boolean> that is true once the connection is established
[ "Starts", "the", "client" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/ExecutionVenueNioClient.java#L132-L151
36,864
betfair/cougar
cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/ExecutionVenueNioClient.java
ExecutionVenueNioClient.notifyConnectionLost
private synchronized void notifyConnectionLost(final IoSession session) { new Thread("Connection-Closed-Notifier") { @Override public void run() { // todo: sml: should consider rationalising these so they're all HandlerListeners.. if (connectedObjectManager != null) { connectedObjectManager.sessionTerminated(session); } for (HandlerListener listener : handlerListeners) { listener.sessionClosed(session); } RequestResponseManager requestResponseManager = (RequestResponseManager) session.getAttribute(RequestResponseManager.SESSION_KEY); if (requestResponseManager != null) { requestResponseManager.sessionClosed(session); } } }.start(); }
java
private synchronized void notifyConnectionLost(final IoSession session) { new Thread("Connection-Closed-Notifier") { @Override public void run() { // todo: sml: should consider rationalising these so they're all HandlerListeners.. if (connectedObjectManager != null) { connectedObjectManager.sessionTerminated(session); } for (HandlerListener listener : handlerListeners) { listener.sessionClosed(session); } RequestResponseManager requestResponseManager = (RequestResponseManager) session.getAttribute(RequestResponseManager.SESSION_KEY); if (requestResponseManager != null) { requestResponseManager.sessionClosed(session); } } }.start(); }
[ "private", "synchronized", "void", "notifyConnectionLost", "(", "final", "IoSession", "session", ")", "{", "new", "Thread", "(", "\"Connection-Closed-Notifier\"", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "// todo: sml: should consider rationa...
Notify all observers that comms are lost
[ "Notify", "all", "observers", "that", "comms", "are", "lost" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/ExecutionVenueNioClient.java#L400-L417
36,865
betfair/cougar
cougar-framework/cougar-transport-impl/src/main/java/com/betfair/cougar/transport/impl/AbstractCommandProcessor.java
AbstractCommandProcessor.process
public void process(final T command) { boolean traceStarted = false; incrementCommandsProcessed(); DehydratedExecutionContext ctx = null; try { validateCommand(command); CommandResolver<T> resolver = createCommandResolver(command, tracer); ctx = resolver.resolveExecutionContext(); List<ExecutionCommand> executionCommands = resolver.resolveExecutionCommands(); if (executionCommands.size() > 1) { throw new CougarFrameworkException("Resolved >1 command in a non-batch call!"); } ExecutionCommand exec = executionCommands.get(0); tracer.start(ctx.getRequestUUID(), exec.getOperationKey()); traceStarted = true; executeCommand(exec, ctx); } catch(CougarException ce) { executeError(command, ctx, ce, traceStarted); } catch (Exception e) { executeError(command, ctx, new CougarFrameworkException("Unexpected exception while processing transport command", e), traceStarted); } }
java
public void process(final T command) { boolean traceStarted = false; incrementCommandsProcessed(); DehydratedExecutionContext ctx = null; try { validateCommand(command); CommandResolver<T> resolver = createCommandResolver(command, tracer); ctx = resolver.resolveExecutionContext(); List<ExecutionCommand> executionCommands = resolver.resolveExecutionCommands(); if (executionCommands.size() > 1) { throw new CougarFrameworkException("Resolved >1 command in a non-batch call!"); } ExecutionCommand exec = executionCommands.get(0); tracer.start(ctx.getRequestUUID(), exec.getOperationKey()); traceStarted = true; executeCommand(exec, ctx); } catch(CougarException ce) { executeError(command, ctx, ce, traceStarted); } catch (Exception e) { executeError(command, ctx, new CougarFrameworkException("Unexpected exception while processing transport command", e), traceStarted); } }
[ "public", "void", "process", "(", "final", "T", "command", ")", "{", "boolean", "traceStarted", "=", "false", ";", "incrementCommandsProcessed", "(", ")", ";", "DehydratedExecutionContext", "ctx", "=", "null", ";", "try", "{", "validateCommand", "(", "command", ...
Processes a TransportCommand. @param command
[ "Processes", "a", "TransportCommand", "." ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-transport-impl/src/main/java/com/betfair/cougar/transport/impl/AbstractCommandProcessor.java#L87-L108
36,866
betfair/cougar
cougar-framework/cougar-transport-impl/src/main/java/com/betfair/cougar/transport/impl/AbstractCommandProcessor.java
AbstractCommandProcessor.executeCommand
protected void executeCommand(final ExecutionCommand finalExec, final ExecutionContext finalCtx) { executionsProcessed.incrementAndGet(); ev.execute(finalCtx, finalExec.getOperationKey(), finalExec.getArgs(), finalExec, executor, finalExec.getTimeConstraints()); }
java
protected void executeCommand(final ExecutionCommand finalExec, final ExecutionContext finalCtx) { executionsProcessed.incrementAndGet(); ev.execute(finalCtx, finalExec.getOperationKey(), finalExec.getArgs(), finalExec, executor, finalExec.getTimeConstraints()); }
[ "protected", "void", "executeCommand", "(", "final", "ExecutionCommand", "finalExec", ",", "final", "ExecutionContext", "finalCtx", ")", "{", "executionsProcessed", ".", "incrementAndGet", "(", ")", ";", "ev", ".", "execute", "(", "finalCtx", ",", "finalExec", "."...
Execute the supplied command @param finalExec @param finalCtx
[ "Execute", "the", "supplied", "command" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-transport-impl/src/main/java/com/betfair/cougar/transport/impl/AbstractCommandProcessor.java#L130-L138
36,867
betfair/cougar
baseline/baseline-app/src/main/java/com/betfair/cougar/baseline/BaselineServiceImpl.java
BaselineServiceImpl.subscribeToTimeTick
@Override public void subscribeToTimeTick(ExecutionContext ctx, Object[] args, ExecutionObserver executionObserver) { if (getEventTransportIdentity(ctx).getPrincipal().getName().equals(SONIC_TRANSPORT_INSTANCE_ONE)) { this.timeTickPublishingObserver = executionObserver; } }
java
@Override public void subscribeToTimeTick(ExecutionContext ctx, Object[] args, ExecutionObserver executionObserver) { if (getEventTransportIdentity(ctx).getPrincipal().getName().equals(SONIC_TRANSPORT_INSTANCE_ONE)) { this.timeTickPublishingObserver = executionObserver; } }
[ "@", "Override", "public", "void", "subscribeToTimeTick", "(", "ExecutionContext", "ctx", ",", "Object", "[", "]", "args", ",", "ExecutionObserver", "executionObserver", ")", "{", "if", "(", "getEventTransportIdentity", "(", "ctx", ")", ".", "getPrincipal", "(", ...
Please note that this Service method is called by the Execution Venue to establish a communication channel from the transport to the Application to publish events. In essence, the transport subscribes to the app, so this method is called once for each publisher. The application should hold onto the passed in observer, and call onResult on that observer to emit an event. @param ctx @param args @param executionObserver
[ "Please", "note", "that", "this", "Service", "method", "is", "called", "by", "the", "Execution", "Venue", "to", "establish", "a", "communication", "channel", "from", "the", "transport", "to", "the", "Application", "to", "publish", "events", ".", "In", "essence...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/baseline/baseline-app/src/main/java/com/betfair/cougar/baseline/BaselineServiceImpl.java#L1913-L1918
36,868
betfair/cougar
baseline/baseline-app/src/main/java/com/betfair/cougar/baseline/BaselineServiceImpl.java
BaselineServiceImpl.subscribeToMatchedBet
@Override public void subscribeToMatchedBet(ExecutionContext ctx, Object[] args, ExecutionObserver executionObserver) { if (getEventTransportIdentity(ctx).getPrincipal().getName().equals(SONIC_TRANSPORT_INSTANCE_ONE)) { this.matchedBetObserver = executionObserver; } }
java
@Override public void subscribeToMatchedBet(ExecutionContext ctx, Object[] args, ExecutionObserver executionObserver) { if (getEventTransportIdentity(ctx).getPrincipal().getName().equals(SONIC_TRANSPORT_INSTANCE_ONE)) { this.matchedBetObserver = executionObserver; } }
[ "@", "Override", "public", "void", "subscribeToMatchedBet", "(", "ExecutionContext", "ctx", ",", "Object", "[", "]", "args", ",", "ExecutionObserver", "executionObserver", ")", "{", "if", "(", "getEventTransportIdentity", "(", "ctx", ")", ".", "getPrincipal", "(",...
Please note that this Service method is called by the Execution Venue to establish a communication channel from the transport to the Application to publish events. In essence, the transport subscribes to the app, so this method is called once for each publisher at application initialisation. You should never be calling this directly. The application should hold onto the passed in observer, and call onResult on that observer to emit an event. @param ctx @param args @param executionObserver
[ "Please", "note", "that", "this", "Service", "method", "is", "called", "by", "the", "Execution", "Venue", "to", "establish", "a", "communication", "channel", "from", "the", "transport", "to", "the", "Application", "to", "publish", "events", ".", "In", "essence...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/baseline/baseline-app/src/main/java/com/betfair/cougar/baseline/BaselineServiceImpl.java#L1930-L1935
36,869
betfair/cougar
cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/HttpCommandProcessorFactory.java
HttpCommandProcessorFactory.getCommandProcessor
@Override public HttpCommandProcessor getCommandProcessor(Protocol protocol) { String commandProcessorName = commandProcessorNames.get(protocol); if (commandProcessorName == null) { throw new PanicInTheCougar("No HTTP Command Processor has been configured for protocol " + protocol); } HttpCommandProcessor commandProcessor = (HttpCommandProcessor)applicationContext.getBean(commandProcessorName); if (commandProcessor == null) { throw new PanicInTheCougar("No HTTP Command Processor has been configured for the name " + commandProcessorName); } return commandProcessor; }
java
@Override public HttpCommandProcessor getCommandProcessor(Protocol protocol) { String commandProcessorName = commandProcessorNames.get(protocol); if (commandProcessorName == null) { throw new PanicInTheCougar("No HTTP Command Processor has been configured for protocol " + protocol); } HttpCommandProcessor commandProcessor = (HttpCommandProcessor)applicationContext.getBean(commandProcessorName); if (commandProcessor == null) { throw new PanicInTheCougar("No HTTP Command Processor has been configured for the name " + commandProcessorName); } return commandProcessor; }
[ "@", "Override", "public", "HttpCommandProcessor", "getCommandProcessor", "(", "Protocol", "protocol", ")", "{", "String", "commandProcessorName", "=", "commandProcessorNames", ".", "get", "(", "protocol", ")", ";", "if", "(", "commandProcessorName", "==", "null", "...
Returns the command processor assocated with the supplied protocol @param @see Protocol @return returns you the command processor for the supplied protocol @throws PanicInTheCougar if there is no command processor for the requested protocol
[ "Returns", "the", "command", "processor", "assocated", "with", "the", "supplied", "protocol" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/HttpCommandProcessorFactory.java#L42-L57
36,870
betfair/cougar
cougar-framework/jms-transport/src/main/java/com/betfair/cougar/transport/jms/JmsEventTransportImpl.java
JmsEventTransportImpl.publish
public void publish(Event event, String destinationName, EventServiceBindingDescriptor eventServiceBindingDescriptor) throws CougarException { try { EventPublisherRunnable publisherRunnable = new EventPublisherRunnable(event, destinationName, eventServiceBindingDescriptor); threadPool.execute(publisherRunnable); // Publish the event using a thread from the pool publisherRunnable.lock(); if (!publisherRunnable.isSuccess()) { // If publication failed for any reason pass out the exception thrown Exception e = publisherRunnable.getError(); LOGGER.error("Publication exception:", e); throw new CougarFrameworkException("Sonic JMS publication exception", e); } } catch (InterruptedException ex) { // Interrupted while waiting for event to be published LOGGER.error("Publication exception:", ex); throw new CougarFrameworkException("Sonic JMS publication exception", ex); } }
java
public void publish(Event event, String destinationName, EventServiceBindingDescriptor eventServiceBindingDescriptor) throws CougarException { try { EventPublisherRunnable publisherRunnable = new EventPublisherRunnable(event, destinationName, eventServiceBindingDescriptor); threadPool.execute(publisherRunnable); // Publish the event using a thread from the pool publisherRunnable.lock(); if (!publisherRunnable.isSuccess()) { // If publication failed for any reason pass out the exception thrown Exception e = publisherRunnable.getError(); LOGGER.error("Publication exception:", e); throw new CougarFrameworkException("Sonic JMS publication exception", e); } } catch (InterruptedException ex) { // Interrupted while waiting for event to be published LOGGER.error("Publication exception:", ex); throw new CougarFrameworkException("Sonic JMS publication exception", ex); } }
[ "public", "void", "publish", "(", "Event", "event", ",", "String", "destinationName", ",", "EventServiceBindingDescriptor", "eventServiceBindingDescriptor", ")", "throws", "CougarException", "{", "try", "{", "EventPublisherRunnable", "publisherRunnable", "=", "new", "Even...
Publish the supplied event to the destination. The event will be published using a thread from the pool and its associated jms session @param event @throws com.betfair.cougar.core.api.exception.CougarException @see com.betfair.cougar.transport.api.protocol.events.jms.JMSDestinationResolver
[ "Publish", "the", "supplied", "event", "to", "the", "destination", ".", "The", "event", "will", "be", "published", "using", "a", "thread", "from", "the", "pool", "and", "its", "associated", "jms", "session" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jms-transport/src/main/java/com/betfair/cougar/transport/jms/JmsEventTransportImpl.java#L347-L362
36,871
betfair/cougar
cougar-framework/jms-transport/src/main/java/com/betfair/cougar/transport/jms/JmsEventTransportImpl.java
JmsEventTransportImpl.requestConnectionToBroker
public Future<Boolean> requestConnectionToBroker() { FutureTask futureTask = new FutureTask(new Callable<Boolean>() { @Override public Boolean call() throws Exception { boolean ok = false; try { getConnection(); ok = true; } catch (JMSException e) { LOGGER.warn("Error connecting to JMS", e); } return ok; } }); reconnectorService.schedule(futureTask, 0, TimeUnit.SECONDS); return futureTask; }
java
public Future<Boolean> requestConnectionToBroker() { FutureTask futureTask = new FutureTask(new Callable<Boolean>() { @Override public Boolean call() throws Exception { boolean ok = false; try { getConnection(); ok = true; } catch (JMSException e) { LOGGER.warn("Error connecting to JMS", e); } return ok; } }); reconnectorService.schedule(futureTask, 0, TimeUnit.SECONDS); return futureTask; }
[ "public", "Future", "<", "Boolean", ">", "requestConnectionToBroker", "(", ")", "{", "FutureTask", "futureTask", "=", "new", "FutureTask", "(", "new", "Callable", "<", "Boolean", ">", "(", ")", "{", "@", "Override", "public", "Boolean", "call", "(", ")", "...
Requests that this transports attempts to connect to the broker. Occurs asynchronously from the caller initiation.
[ "Requests", "that", "this", "transports", "attempts", "to", "connect", "to", "the", "broker", ".", "Occurs", "asynchronously", "from", "the", "caller", "initiation", "." ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jms-transport/src/main/java/com/betfair/cougar/transport/jms/JmsEventTransportImpl.java#L481-L497
36,872
betfair/cougar
cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/AbstractHttpExecutable.java
AbstractHttpExecutable.isDefinitelyCougarResponse
private boolean isDefinitelyCougarResponse(CougarHttpResponse response) { String ident = response.getServerIdentity(); if (ident != null && ident.contains("Cougar 2")) { return true; } return false; }
java
private boolean isDefinitelyCougarResponse(CougarHttpResponse response) { String ident = response.getServerIdentity(); if (ident != null && ident.contains("Cougar 2")) { return true; } return false; }
[ "private", "boolean", "isDefinitelyCougarResponse", "(", "CougarHttpResponse", "response", ")", "{", "String", "ident", "=", "response", ".", "getServerIdentity", "(", ")", ";", "if", "(", "ident", "!=", "null", "&&", "ident", ".", "contains", "(", "\"Cougar 2\"...
has the responding server identified itself as Cougar Note that due to legacy servers/network infrastructure a 'false negative' is possible. in other words although a 'true' response confirms that the server has identified itself Cougar, a 'false' does not confirm that a server IS NOT Cougar. The cougar header could have been stripped out by network infrastructure, or the server could still be a legacy Cougar which does not provide this header. @param response http response @return boolean has the responding server identified itself as Cougar
[ "has", "the", "responding", "server", "identified", "itself", "as", "Cougar" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/AbstractHttpExecutable.java#L338-L344
36,873
betfair/cougar
cougar-framework/cougar-zipkin-common/src/main/java/com/betfair/cougar/modules/zipkin/impl/ZipkinManager.java
ZipkinManager.setSamplingLevel
@ManagedAttribute public void setSamplingLevel(int samplingLevel) { if (samplingLevel >= MIN_LEVEL && samplingLevel <= MAX_LEVEL) { this.samplingLevel = samplingLevel; } else { throw new IllegalArgumentException("Sampling level " + samplingLevel + " is not in the range [" + MIN_LEVEL + ";" + MAX_LEVEL + "["); } }
java
@ManagedAttribute public void setSamplingLevel(int samplingLevel) { if (samplingLevel >= MIN_LEVEL && samplingLevel <= MAX_LEVEL) { this.samplingLevel = samplingLevel; } else { throw new IllegalArgumentException("Sampling level " + samplingLevel + " is not in the range [" + MIN_LEVEL + ";" + MAX_LEVEL + "["); } }
[ "@", "ManagedAttribute", "public", "void", "setSamplingLevel", "(", "int", "samplingLevel", ")", "{", "if", "(", "samplingLevel", ">=", "MIN_LEVEL", "&&", "samplingLevel", "<=", "MAX_LEVEL", ")", "{", "this", ".", "samplingLevel", "=", "samplingLevel", ";", "}",...
Sets a new sampling level. The sampling level must be within the range 0-1000, representing the permillage of requests to be sampled. Setting the sampling level to 0 disabled sampling. @param samplingLevel The sampling level @throws IllegalArgumentException if the sampling level is off bounds
[ "Sets", "a", "new", "sampling", "level", ".", "The", "sampling", "level", "must", "be", "within", "the", "range", "0", "-", "1000", "representing", "the", "permillage", "of", "requests", "to", "be", "sampled", ".", "Setting", "the", "sampling", "level", "t...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-zipkin-common/src/main/java/com/betfair/cougar/modules/zipkin/impl/ZipkinManager.java#L92-L99
36,874
betfair/cougar
cougar-framework/cougar-zipkin-common/src/main/java/com/betfair/cougar/modules/zipkin/impl/ZipkinManager.java
ZipkinManager.getRandomLong
public static long getRandomLong() { byte[] rndBytes = new byte[8]; SECURE_RANDOM_TL.get().nextBytes(rndBytes); return ByteBuffer.wrap(rndBytes).getLong(); }
java
public static long getRandomLong() { byte[] rndBytes = new byte[8]; SECURE_RANDOM_TL.get().nextBytes(rndBytes); return ByteBuffer.wrap(rndBytes).getLong(); }
[ "public", "static", "long", "getRandomLong", "(", ")", "{", "byte", "[", "]", "rndBytes", "=", "new", "byte", "[", "8", "]", ";", "SECURE_RANDOM_TL", ".", "get", "(", ")", ".", "nextBytes", "(", "rndBytes", ")", ";", "return", "ByteBuffer", ".", "wrap"...
Retrieves a newly generated random long. @return A newly generated random long
[ "Retrieves", "a", "newly", "generated", "random", "long", "." ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-zipkin-common/src/main/java/com/betfair/cougar/modules/zipkin/impl/ZipkinManager.java#L167-L171
36,875
betfair/cougar
cougar-framework/socket-transport/src/main/java/com/betfair/cougar/transport/socket/PooledServerConnectedObjectManager.java
PooledServerConnectedObjectManager.getHeapsForSession
public List<String> getHeapsForSession(IoSession session) { List<String> ret = new ArrayList<String>(); try { subTermLock.lock(); Multiset<String> s = heapsByClient.get(session); if (s != null) { ret.addAll(s.keySet()); } } finally { subTermLock.unlock(); } return ret; }
java
public List<String> getHeapsForSession(IoSession session) { List<String> ret = new ArrayList<String>(); try { subTermLock.lock(); Multiset<String> s = heapsByClient.get(session); if (s != null) { ret.addAll(s.keySet()); } } finally { subTermLock.unlock(); } return ret; }
[ "public", "List", "<", "String", ">", "getHeapsForSession", "(", "IoSession", "session", ")", "{", "List", "<", "String", ">", "ret", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "try", "{", "subTermLock", ".", "lock", "(", ")", ";", "...
used for monitoring
[ "used", "for", "monitoring" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/socket-transport/src/main/java/com/betfair/cougar/transport/socket/PooledServerConnectedObjectManager.java#L110-L122
36,876
betfair/cougar
cougar-framework/socket-transport/src/main/java/com/betfair/cougar/transport/socket/PooledServerConnectedObjectManager.java
PooledServerConnectedObjectManager.processHeapStateCreation
private HeapState processHeapStateCreation(final ConnectedResponse result, final String heapUri) { if (!subTermLock.isHeldByCurrentThread()) { throw new IllegalStateException("You must have the subTermLock before calling this method"); } final HeapState newState = new HeapState(result.getHeap()); // we're safe to lock this out of normal order as the HeapState isn't visible to other threads until the // end of this block. We have to have the lock before we make it visible.. newState.getUpdateLock().lock(); // new heap for this transport UpdateProducingHeapListener listener = new UpdateProducingHeapListener() { @Override protected void doUpdate(Update u) { if (u.getActions().size() > 0) { newState.getQueuedChanges().add(new QueuedHeapChange(u)); // bad luck, we just added the heap and it's just about to get terminated... if (u.getActions().contains(TerminateHeap.INSTANCE)) { newState.getQueuedChanges().add(new HeapTermination()); } heapsWaitingForUpdate.add(heapUri); } } }; newState.setHeapListener(listener); result.getHeap().addListener(listener, false); heapStates.put(heapUri, newState); heapUris.put(newState.getHeapId(), heapUri); return newState; }
java
private HeapState processHeapStateCreation(final ConnectedResponse result, final String heapUri) { if (!subTermLock.isHeldByCurrentThread()) { throw new IllegalStateException("You must have the subTermLock before calling this method"); } final HeapState newState = new HeapState(result.getHeap()); // we're safe to lock this out of normal order as the HeapState isn't visible to other threads until the // end of this block. We have to have the lock before we make it visible.. newState.getUpdateLock().lock(); // new heap for this transport UpdateProducingHeapListener listener = new UpdateProducingHeapListener() { @Override protected void doUpdate(Update u) { if (u.getActions().size() > 0) { newState.getQueuedChanges().add(new QueuedHeapChange(u)); // bad luck, we just added the heap and it's just about to get terminated... if (u.getActions().contains(TerminateHeap.INSTANCE)) { newState.getQueuedChanges().add(new HeapTermination()); } heapsWaitingForUpdate.add(heapUri); } } }; newState.setHeapListener(listener); result.getHeap().addListener(listener, false); heapStates.put(heapUri, newState); heapUris.put(newState.getHeapId(), heapUri); return newState; }
[ "private", "HeapState", "processHeapStateCreation", "(", "final", "ConnectedResponse", "result", ",", "final", "String", "heapUri", ")", "{", "if", "(", "!", "subTermLock", ".", "isHeldByCurrentThread", "(", ")", ")", "{", "throw", "new", "IllegalStateException", ...
note, you must have the subterm lock before calling this method
[ "note", "you", "must", "have", "the", "subterm", "lock", "before", "calling", "this", "method" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/socket-transport/src/main/java/com/betfair/cougar/transport/socket/PooledServerConnectedObjectManager.java#L185-L213
36,877
betfair/cougar
cougar-framework/socket-transport/src/main/java/com/betfair/cougar/transport/socket/PooledServerConnectedObjectManager.java
PooledServerConnectedObjectManager.terminateSubscription
public void terminateSubscription(IoSession session, String heapUri, String subscriptionId, Subscription.CloseReason reason) { Lock heapUpdateLock = null; try { HeapState state = heapStates.get(heapUri); if (state != null) { heapUpdateLock = state.getUpdateLock(); heapUpdateLock.lock(); } subTermLock.lock(); if (state != null) { if (!state.isTerminated()) { state.terminateSubscription(session, subscriptionId, reason); // notify client if (reason == REQUESTED_BY_PUBLISHER || reason == Subscription.CloseReason.REQUESTED_BY_PUBLISHER_ADMINISTRATOR) { try { nioLogger.log(NioLogger.LoggingLevel.TRANSPORT, session, "Notifying client that publisher has terminated subscription %s", subscriptionId); NioUtils.writeEventMessageToSession(session, new TerminateSubscription(state.getHeapId(), subscriptionId, reason.name()), objectIOFactory); } catch (Exception e) { // if we can't tell them about it then something more serious has just happened. // the client will likely find out anyway since this will likely mean a dead session // we'll just log some info to the log to aid any debugging. We won't change the closure reason. LOGGER.info("Error occurred whilst trying to inform client of subscription termination", e); nioLogger.log(NioLogger.LoggingLevel.SESSION, session, "Error occurred whilst trying to inform client of subscription termination, closing session"); // we'll request a closure of the session too to make sure everything gets cleaned up, although chances are it's already closed session.close(); } } if (state.hasSubscriptions()) { terminateSubscriptions(heapUri, reason); } else if (state.getSubscriptions(session).isEmpty()) { terminateSubscriptions(session, heapUri, reason); } } } Multiset<String> heapsForSession = heapsByClient.get(session); if (heapsForSession != null) { heapsForSession.remove(heapUri); if (heapsForSession.isEmpty()) { terminateSubscriptions(session, reason); } } } finally { subTermLock.unlock(); if (heapUpdateLock != null) { heapUpdateLock.unlock(); } } }
java
public void terminateSubscription(IoSession session, String heapUri, String subscriptionId, Subscription.CloseReason reason) { Lock heapUpdateLock = null; try { HeapState state = heapStates.get(heapUri); if (state != null) { heapUpdateLock = state.getUpdateLock(); heapUpdateLock.lock(); } subTermLock.lock(); if (state != null) { if (!state.isTerminated()) { state.terminateSubscription(session, subscriptionId, reason); // notify client if (reason == REQUESTED_BY_PUBLISHER || reason == Subscription.CloseReason.REQUESTED_BY_PUBLISHER_ADMINISTRATOR) { try { nioLogger.log(NioLogger.LoggingLevel.TRANSPORT, session, "Notifying client that publisher has terminated subscription %s", subscriptionId); NioUtils.writeEventMessageToSession(session, new TerminateSubscription(state.getHeapId(), subscriptionId, reason.name()), objectIOFactory); } catch (Exception e) { // if we can't tell them about it then something more serious has just happened. // the client will likely find out anyway since this will likely mean a dead session // we'll just log some info to the log to aid any debugging. We won't change the closure reason. LOGGER.info("Error occurred whilst trying to inform client of subscription termination", e); nioLogger.log(NioLogger.LoggingLevel.SESSION, session, "Error occurred whilst trying to inform client of subscription termination, closing session"); // we'll request a closure of the session too to make sure everything gets cleaned up, although chances are it's already closed session.close(); } } if (state.hasSubscriptions()) { terminateSubscriptions(heapUri, reason); } else if (state.getSubscriptions(session).isEmpty()) { terminateSubscriptions(session, heapUri, reason); } } } Multiset<String> heapsForSession = heapsByClient.get(session); if (heapsForSession != null) { heapsForSession.remove(heapUri); if (heapsForSession.isEmpty()) { terminateSubscriptions(session, reason); } } } finally { subTermLock.unlock(); if (heapUpdateLock != null) { heapUpdateLock.unlock(); } } }
[ "public", "void", "terminateSubscription", "(", "IoSession", "session", ",", "String", "heapUri", ",", "String", "subscriptionId", ",", "Subscription", ".", "CloseReason", "reason", ")", "{", "Lock", "heapUpdateLock", "=", "null", ";", "try", "{", "HeapState", "...
Terminates a single subscription to a single heap
[ "Terminates", "a", "single", "subscription", "to", "a", "single", "heap" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/socket-transport/src/main/java/com/betfair/cougar/transport/socket/PooledServerConnectedObjectManager.java#L357-L407
36,878
betfair/cougar
cougar-framework/socket-transport/src/main/java/com/betfair/cougar/transport/socket/PooledServerConnectedObjectManager.java
PooledServerConnectedObjectManager.terminateSubscriptions
private void terminateSubscriptions(IoSession session, Subscription.CloseReason reason) { Multiset<String> heapsForThisClient; try { subTermLock.lock(); heapsForThisClient = heapsByClient.remove(session); } finally { subTermLock.unlock(); } if (heapsForThisClient != null) { for (String s : heapsForThisClient.keySet()) { terminateSubscriptions(session, s, reason); } } }
java
private void terminateSubscriptions(IoSession session, Subscription.CloseReason reason) { Multiset<String> heapsForThisClient; try { subTermLock.lock(); heapsForThisClient = heapsByClient.remove(session); } finally { subTermLock.unlock(); } if (heapsForThisClient != null) { for (String s : heapsForThisClient.keySet()) { terminateSubscriptions(session, s, reason); } } }
[ "private", "void", "terminateSubscriptions", "(", "IoSession", "session", ",", "Subscription", ".", "CloseReason", "reason", ")", "{", "Multiset", "<", "String", ">", "heapsForThisClient", ";", "try", "{", "subTermLock", ".", "lock", "(", ")", ";", "heapsForThis...
Terminates all subscriptions for a given client
[ "Terminates", "all", "subscriptions", "for", "a", "given", "client" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/socket-transport/src/main/java/com/betfair/cougar/transport/socket/PooledServerConnectedObjectManager.java#L456-L470
36,879
betfair/cougar
cougar-framework/socket-transport/src/main/java/com/betfair/cougar/transport/socket/PooledServerConnectedObjectManager.java
PooledServerConnectedObjectManager.terminateSubscriptions
private void terminateSubscriptions(String heapUri, Subscription.CloseReason reason) { HeapState state = heapStates.get(heapUri); if (state != null) { try { state.getUpdateLock().lock(); subTermLock.lock(); // if someone got here first, don't bother doing the work if (!state.isTerminated()) { heapStates.remove(heapUri); heapUris.remove(state.getHeapId()); List<IoSession> sessions = state.getSessions(); for (IoSession session : sessions) { terminateSubscriptions(session, state, heapUri, reason); } LOGGER.error("Terminating heap state '{}'", heapUri); state.terminate(); state.removeListener(); } } finally { subTermLock.unlock(); state.getUpdateLock().unlock(); } } }
java
private void terminateSubscriptions(String heapUri, Subscription.CloseReason reason) { HeapState state = heapStates.get(heapUri); if (state != null) { try { state.getUpdateLock().lock(); subTermLock.lock(); // if someone got here first, don't bother doing the work if (!state.isTerminated()) { heapStates.remove(heapUri); heapUris.remove(state.getHeapId()); List<IoSession> sessions = state.getSessions(); for (IoSession session : sessions) { terminateSubscriptions(session, state, heapUri, reason); } LOGGER.error("Terminating heap state '{}'", heapUri); state.terminate(); state.removeListener(); } } finally { subTermLock.unlock(); state.getUpdateLock().unlock(); } } }
[ "private", "void", "terminateSubscriptions", "(", "String", "heapUri", ",", "Subscription", ".", "CloseReason", "reason", ")", "{", "HeapState", "state", "=", "heapStates", ".", "get", "(", "heapUri", ")", ";", "if", "(", "state", "!=", "null", ")", "{", "...
Terminates all subscriptions for a given heap
[ "Terminates", "all", "subscriptions", "for", "a", "given", "heap" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/socket-transport/src/main/java/com/betfair/cougar/transport/socket/PooledServerConnectedObjectManager.java#L475-L498
36,880
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/BitmapBuilder.java
BitmapBuilder.pad
private static int[] pad(int[] list) { double m = list.length / (double)WORD_LENGTH; int size = (int)Math.ceil(m); int[] ret = new int[size * WORD_LENGTH]; Arrays.fill(ret, 0); System.arraycopy(list,0,ret,0,list.length); return ret; }
java
private static int[] pad(int[] list) { double m = list.length / (double)WORD_LENGTH; int size = (int)Math.ceil(m); int[] ret = new int[size * WORD_LENGTH]; Arrays.fill(ret, 0); System.arraycopy(list,0,ret,0,list.length); return ret; }
[ "private", "static", "int", "[", "]", "pad", "(", "int", "[", "]", "list", ")", "{", "double", "m", "=", "list", ".", "length", "/", "(", "double", ")", "WORD_LENGTH", ";", "int", "size", "=", "(", "int", ")", "Math", ".", "ceil", "(", "m", ")"...
Increases the array size to a multiple of WORD_LENGTH @param list @return
[ "Increases", "the", "array", "size", "to", "a", "multiple", "of", "WORD_LENGTH" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/BitmapBuilder.java#L31-L38
36,881
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/BitmapBuilder.java
BitmapBuilder.listToMap
public static int[] listToMap(int[] list) { list = pad(list); int[] bitMap = new int[(int)(list.length / WORD_LENGTH)]; Arrays.fill(bitMap, 0); int j = -1; for (int i = 0; i < list.length; i++) { if (i % WORD_LENGTH == 0) { j++; } bitMap[j] |= (list[i] << ((WORD_LENGTH - 1) - (i % WORD_LENGTH))); } return bitMap; }
java
public static int[] listToMap(int[] list) { list = pad(list); int[] bitMap = new int[(int)(list.length / WORD_LENGTH)]; Arrays.fill(bitMap, 0); int j = -1; for (int i = 0; i < list.length; i++) { if (i % WORD_LENGTH == 0) { j++; } bitMap[j] |= (list[i] << ((WORD_LENGTH - 1) - (i % WORD_LENGTH))); } return bitMap; }
[ "public", "static", "int", "[", "]", "listToMap", "(", "int", "[", "]", "list", ")", "{", "list", "=", "pad", "(", "list", ")", ";", "int", "[", "]", "bitMap", "=", "new", "int", "[", "(", "int", ")", "(", "list", ".", "length", "/", "WORD_LENG...
Builds a bit map from the given list. The list should values of 0 or 1s @param list @return
[ "Builds", "a", "bit", "map", "from", "the", "given", "list", ".", "The", "list", "should", "values", "of", "0", "or", "1s" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/BitmapBuilder.java#L46-L58
36,882
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/BitmapBuilder.java
BitmapBuilder.mapToList
public static int[] mapToList(int[] bitMap) { int[] list = new int[(int)(bitMap.length * WORD_LENGTH)]; Arrays.fill(list, 0); int j = -1; for (int i = 0; i < list.length; i++) { if (i % WORD_LENGTH == 0) { j++; } list[i] = (bitMap[j] & (1 << ((WORD_LENGTH - 1) - (i % WORD_LENGTH)))) == 0 ? 0 : 1; } return list; }
java
public static int[] mapToList(int[] bitMap) { int[] list = new int[(int)(bitMap.length * WORD_LENGTH)]; Arrays.fill(list, 0); int j = -1; for (int i = 0; i < list.length; i++) { if (i % WORD_LENGTH == 0) { j++; } list[i] = (bitMap[j] & (1 << ((WORD_LENGTH - 1) - (i % WORD_LENGTH)))) == 0 ? 0 : 1; } return list; }
[ "public", "static", "int", "[", "]", "mapToList", "(", "int", "[", "]", "bitMap", ")", "{", "int", "[", "]", "list", "=", "new", "int", "[", "(", "int", ")", "(", "bitMap", ".", "length", "*", "WORD_LENGTH", ")", "]", ";", "Arrays", ".", "fill", ...
Builds a list from the given bit map. The list will contain values of 0 or 1s @param list @return
[ "Builds", "a", "list", "from", "the", "given", "bit", "map", ".", "The", "list", "will", "contain", "values", "of", "0", "or", "1s" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/BitmapBuilder.java#L67-L78
36,883
betfair/cougar
cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/soap/SoapTransportCommandProcessor.java
SoapTransportCommandProcessor.toEnum
private Object toEnum(ParameterType parameterType, String enumTextValue, String paramName, boolean hardFailEnumDeserialisation) { try { return EnumUtils.readEnum(parameterType.getImplementationClass(), enumTextValue, hardFailEnumDeserialisation); } catch (Exception e) { throw XMLTranscriptionInput.exceptionDuringDeserialisation(parameterType, paramName, e, false); } }
java
private Object toEnum(ParameterType parameterType, String enumTextValue, String paramName, boolean hardFailEnumDeserialisation) { try { return EnumUtils.readEnum(parameterType.getImplementationClass(), enumTextValue, hardFailEnumDeserialisation); } catch (Exception e) { throw XMLTranscriptionInput.exceptionDuringDeserialisation(parameterType, paramName, e, false); } }
[ "private", "Object", "toEnum", "(", "ParameterType", "parameterType", ",", "String", "enumTextValue", ",", "String", "paramName", ",", "boolean", "hardFailEnumDeserialisation", ")", "{", "try", "{", "return", "EnumUtils", ".", "readEnum", "(", "parameterType", ".", ...
Deserialise enums explicitly
[ "Deserialise", "enums", "explicitly" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/jetty-transport/src/main/java/com/betfair/cougar/transport/impl/protocol/http/soap/SoapTransportCommandProcessor.java#L326-L332
36,884
betfair/cougar
cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/IdlToDSMojo.java
IdlToDSMojo.processService
private void processService(Service service) throws Exception { getLog().info(" Service: " + service.getServiceName()); Document iddDoc = parseIddFile(service.getServiceName()); // 1. validate if (!isOffline()) { getLog().debug("Validating XML.."); new XmlValidator(resolver).validate(iddDoc); } // 2. generate outputs generateJavaCode(service, iddDoc); }
java
private void processService(Service service) throws Exception { getLog().info(" Service: " + service.getServiceName()); Document iddDoc = parseIddFile(service.getServiceName()); // 1. validate if (!isOffline()) { getLog().debug("Validating XML.."); new XmlValidator(resolver).validate(iddDoc); } // 2. generate outputs generateJavaCode(service, iddDoc); }
[ "private", "void", "processService", "(", "Service", "service", ")", "throws", "Exception", "{", "getLog", "(", ")", ".", "info", "(", "\" Service: \"", "+", "service", ".", "getServiceName", "(", ")", ")", ";", "Document", "iddDoc", "=", "parseIddFile", "(...
Various steps needing to be done for each IDD
[ "Various", "steps", "needing", "to", "be", "done", "for", "each", "IDD" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/IdlToDSMojo.java#L346-L360
36,885
betfair/cougar
cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/IdlToDSMojo.java
IdlToDSMojo.initOutputDir
private void initOutputDir(File outputDir) { if (!outputDir.exists()) { if (!outputDir.mkdirs()) { throw new IllegalArgumentException("Output Directory "+outputDir+" could not be created"); } } if (!outputDir.isDirectory() || (!outputDir.canWrite())) { throw new IllegalArgumentException("Output Directory "+outputDir+" is not a directory or cannot be written to."); } }
java
private void initOutputDir(File outputDir) { if (!outputDir.exists()) { if (!outputDir.mkdirs()) { throw new IllegalArgumentException("Output Directory "+outputDir+" could not be created"); } } if (!outputDir.isDirectory() || (!outputDir.canWrite())) { throw new IllegalArgumentException("Output Directory "+outputDir+" is not a directory or cannot be written to."); } }
[ "private", "void", "initOutputDir", "(", "File", "outputDir", ")", "{", "if", "(", "!", "outputDir", ".", "exists", "(", ")", ")", "{", "if", "(", "!", "outputDir", ".", "mkdirs", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"...
Set up and validate the creation of the specified output directory
[ "Set", "up", "and", "validate", "the", "creation", "of", "the", "specified", "output", "directory" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/IdlToDSMojo.java#L589-L599
36,886
betfair/cougar
cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/IdlToDSMojo.java
IdlToDSMojo.readNamespaceAttr
private String readNamespaceAttr(Document doc) { // lazy loading is mostly pointless but it keeps things together if (namespaceExpr == null) { namespaceExpr = initNamespaceAttrExpression(); } String s; try { s = namespaceExpr.evaluate(doc); } catch (XPathExpressionException e) { throw new PluginException("Error evaluating namespace XPath expression: " + e, e); } // xpath returns an empty string if not found, null is cleaner for callers return (s == null || s.length() == 0) ? null : s; }
java
private String readNamespaceAttr(Document doc) { // lazy loading is mostly pointless but it keeps things together if (namespaceExpr == null) { namespaceExpr = initNamespaceAttrExpression(); } String s; try { s = namespaceExpr.evaluate(doc); } catch (XPathExpressionException e) { throw new PluginException("Error evaluating namespace XPath expression: " + e, e); } // xpath returns an empty string if not found, null is cleaner for callers return (s == null || s.length() == 0) ? null : s; }
[ "private", "String", "readNamespaceAttr", "(", "Document", "doc", ")", "{", "// lazy loading is mostly pointless but it keeps things together", "if", "(", "namespaceExpr", "==", "null", ")", "{", "namespaceExpr", "=", "initNamespaceAttrExpression", "(", ")", ";", "}", "...
Retrieve 'namespace' attr of interface definition or null if not found
[ "Retrieve", "namespace", "attr", "of", "interface", "definition", "or", "null", "if", "not", "found" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/IdlToDSMojo.java#L653-L668
36,887
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/NetworkAddress.java
NetworkAddress.isValidIPAddress
public static boolean isValidIPAddress(String networkAddress) { if (networkAddress != null) { String[] split = networkAddress.split("\\."); if (split.length == 4) { int[] octets = new int[4]; for (int i=0; i<4; i++) { try { octets[i] = Integer.parseInt(split[i]); } catch (NumberFormatException e) { return false; } if (octets[i] < 0 || octets[i] > 255) { return false; } } return true; } } return false; }
java
public static boolean isValidIPAddress(String networkAddress) { if (networkAddress != null) { String[] split = networkAddress.split("\\."); if (split.length == 4) { int[] octets = new int[4]; for (int i=0; i<4; i++) { try { octets[i] = Integer.parseInt(split[i]); } catch (NumberFormatException e) { return false; } if (octets[i] < 0 || octets[i] > 255) { return false; } } return true; } } return false; }
[ "public", "static", "boolean", "isValidIPAddress", "(", "String", "networkAddress", ")", "{", "if", "(", "networkAddress", "!=", "null", ")", "{", "String", "[", "]", "split", "=", "networkAddress", ".", "split", "(", "\"\\\\.\"", ")", ";", "if", "(", "spl...
Verify if a given string is a valid dotted quad notation IP Address @param networkAddress The address string @return true if its valid, false otherwise
[ "Verify", "if", "a", "given", "string", "is", "a", "valid", "dotted", "quad", "notation", "IP", "Address" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/NetworkAddress.java#L212-L231
36,888
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/NetworkAddress.java
NetworkAddress.parseDottedQuad
private static byte[] parseDottedQuad(String address) { String[] splitString = address.split("\\."); if (splitString.length == 4) { int[] ints = new int[4]; byte[] bytes = new byte[4]; for (int i=0; i<4; i++) { ints[i] = Integer.parseInt(splitString[i]); if (ints[i] < 0 || ints[i] > 255) { throw new IllegalArgumentException("Invalid ip4Address or netmask"); } bytes[i] = toByte(ints[i]); //a pox on java and it's signed bytes } return bytes; } else { throw new IllegalArgumentException("Address must be in dotted quad notation"); } }
java
private static byte[] parseDottedQuad(String address) { String[] splitString = address.split("\\."); if (splitString.length == 4) { int[] ints = new int[4]; byte[] bytes = new byte[4]; for (int i=0; i<4; i++) { ints[i] = Integer.parseInt(splitString[i]); if (ints[i] < 0 || ints[i] > 255) { throw new IllegalArgumentException("Invalid ip4Address or netmask"); } bytes[i] = toByte(ints[i]); //a pox on java and it's signed bytes } return bytes; } else { throw new IllegalArgumentException("Address must be in dotted quad notation"); } }
[ "private", "static", "byte", "[", "]", "parseDottedQuad", "(", "String", "address", ")", "{", "String", "[", "]", "splitString", "=", "address", ".", "split", "(", "\"\\\\.\"", ")", ";", "if", "(", "splitString", ".", "length", "==", "4", ")", "{", "in...
parse ip4 address as dotted quad notation into bytes @param address @return
[ "parse", "ip4", "address", "as", "dotted", "quad", "notation", "into", "bytes" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/NetworkAddress.java#L238-L258
36,889
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/configuration/Sets.java
Sets.fromMap
public static final Set fromMap(Map map, Object... keys) { if (keys != null && map != null) { Set answer = new HashSet(); for (Object key : keys) { if (map.containsKey(key)) { answer.add(map.get(key)); } } return Collections.unmodifiableSet(answer); } return Collections.EMPTY_SET; }
java
public static final Set fromMap(Map map, Object... keys) { if (keys != null && map != null) { Set answer = new HashSet(); for (Object key : keys) { if (map.containsKey(key)) { answer.add(map.get(key)); } } return Collections.unmodifiableSet(answer); } return Collections.EMPTY_SET; }
[ "public", "static", "final", "Set", "fromMap", "(", "Map", "map", ",", "Object", "...", "keys", ")", "{", "if", "(", "keys", "!=", "null", "&&", "map", "!=", "null", ")", "{", "Set", "answer", "=", "new", "HashSet", "(", ")", ";", "for", "(", "Ob...
Given a map and a set of keys, return a set containing the values referred-to by the keys. If the map is null or the keys are null, the EMPTY_SET is returned. If a passed key does not exist in the map, nothing is added to the set. However, if the key is present and maps to null, null is added to the set.
[ "Given", "a", "map", "and", "a", "set", "of", "keys", "return", "a", "set", "containing", "the", "values", "referred", "-", "to", "by", "the", "keys", ".", "If", "the", "map", "is", "null", "or", "the", "keys", "are", "null", "the", "EMPTY_SET", "is"...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/configuration/Sets.java#L29-L40
36,890
betfair/cougar
cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/configuration/Sets.java
Sets.fromCommaSeparatedValues
public static final Set<String> fromCommaSeparatedValues(String csv) { if (csv == null || csv.isEmpty()) { return Collections.EMPTY_SET; } String[] tokens = csv.split(","); return new HashSet<String>(Arrays.asList(tokens)); }
java
public static final Set<String> fromCommaSeparatedValues(String csv) { if (csv == null || csv.isEmpty()) { return Collections.EMPTY_SET; } String[] tokens = csv.split(","); return new HashSet<String>(Arrays.asList(tokens)); }
[ "public", "static", "final", "Set", "<", "String", ">", "fromCommaSeparatedValues", "(", "String", "csv", ")", "{", "if", "(", "csv", "==", "null", "||", "csv", ".", "isEmpty", "(", ")", ")", "{", "return", "Collections", ".", "EMPTY_SET", ";", "}", "S...
Given a comma-separated list of values, return a set of those values. If the passed string is null, the EMPTY_SET is returned. If the passed string is empty, the EMPTY_SET is returned.
[ "Given", "a", "comma", "-", "separated", "list", "of", "values", "return", "a", "set", "of", "those", "values", ".", "If", "the", "passed", "string", "is", "null", "the", "EMPTY_SET", "is", "returned", ".", "If", "the", "passed", "string", "is", "empty",...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-util/src/main/java/com/betfair/cougar/util/configuration/Sets.java#L47-L53
36,891
betfair/cougar
cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/IDLReader.java
IDLReader.mergeExtensionsIntoDocument
private void mergeExtensionsIntoDocument(Node target, Node extensions) throws Exception { final XPathFactory factory = XPathFactory.newInstance(); final NodeList nodes = (NodeList) factory.newXPath().evaluate("//extensions", extensions, XPathConstants.NODESET); for (int i = 0; i < nodes.getLength(); i++) { final Node extensionNode = nodes.item(i); String nameBasedXpath = DomUtils.getNameBasedXPath(extensionNode, false); log.debug("Processing extension node: " + nameBasedXpath); final NodeList targetNodes = (NodeList) factory.newXPath().evaluate(nameBasedXpath, target, XPathConstants.NODESET); if (targetNodes.getLength() != 1) { throw new IllegalArgumentException("XPath "+nameBasedXpath+" not found in target"); } Node targetNode = targetNodes.item(0); Node importedNode = targetNode.getOwnerDocument().importNode(extensionNode, true); targetNode.appendChild(importedNode); } }
java
private void mergeExtensionsIntoDocument(Node target, Node extensions) throws Exception { final XPathFactory factory = XPathFactory.newInstance(); final NodeList nodes = (NodeList) factory.newXPath().evaluate("//extensions", extensions, XPathConstants.NODESET); for (int i = 0; i < nodes.getLength(); i++) { final Node extensionNode = nodes.item(i); String nameBasedXpath = DomUtils.getNameBasedXPath(extensionNode, false); log.debug("Processing extension node: " + nameBasedXpath); final NodeList targetNodes = (NodeList) factory.newXPath().evaluate(nameBasedXpath, target, XPathConstants.NODESET); if (targetNodes.getLength() != 1) { throw new IllegalArgumentException("XPath "+nameBasedXpath+" not found in target"); } Node targetNode = targetNodes.item(0); Node importedNode = targetNode.getOwnerDocument().importNode(extensionNode, true); targetNode.appendChild(importedNode); } }
[ "private", "void", "mergeExtensionsIntoDocument", "(", "Node", "target", ",", "Node", "extensions", ")", "throws", "Exception", "{", "final", "XPathFactory", "factory", "=", "XPathFactory", ".", "newInstance", "(", ")", ";", "final", "NodeList", "nodes", "=", "(...
Weave the extensions defined in the extensions doc into the target.
[ "Weave", "the", "extensions", "defined", "in", "the", "extensions", "doc", "into", "the", "target", "." ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/IDLReader.java#L369-L385
36,892
betfair/cougar
cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/IDLReader.java
IDLReader.removeUndefinedOperations
private void removeUndefinedOperations(Node target, Node extensions) throws Exception { final XPathFactory factory = XPathFactory.newInstance(); final NodeList nodes = (NodeList) factory.newXPath().evaluate("//operation", target, XPathConstants.NODESET); for (int i = 0; i < nodes.getLength(); i++) { final Node targetNode = nodes.item(i); String nameBasedXpath = DomUtils.getNameBasedXPath(targetNode, true); log.debug("Checking operation: " + nameBasedXpath); final NodeList targetNodes = (NodeList) factory.newXPath().evaluate(nameBasedXpath, extensions, XPathConstants.NODESET); if (targetNodes.getLength() == 0) { // This operation is not defined in the extensions doc log.debug("Ignoring IDL defined operation: " + getAttribute(targetNode, "name")); targetNode.getParentNode().removeChild(targetNode); } } }
java
private void removeUndefinedOperations(Node target, Node extensions) throws Exception { final XPathFactory factory = XPathFactory.newInstance(); final NodeList nodes = (NodeList) factory.newXPath().evaluate("//operation", target, XPathConstants.NODESET); for (int i = 0; i < nodes.getLength(); i++) { final Node targetNode = nodes.item(i); String nameBasedXpath = DomUtils.getNameBasedXPath(targetNode, true); log.debug("Checking operation: " + nameBasedXpath); final NodeList targetNodes = (NodeList) factory.newXPath().evaluate(nameBasedXpath, extensions, XPathConstants.NODESET); if (targetNodes.getLength() == 0) { // This operation is not defined in the extensions doc log.debug("Ignoring IDL defined operation: " + getAttribute(targetNode, "name")); targetNode.getParentNode().removeChild(targetNode); } } }
[ "private", "void", "removeUndefinedOperations", "(", "Node", "target", ",", "Node", "extensions", ")", "throws", "Exception", "{", "final", "XPathFactory", "factory", "=", "XPathFactory", ".", "newInstance", "(", ")", ";", "final", "NodeList", "nodes", "=", "(",...
Cycle through the target Node and remove any operations not defined in the extensions document.
[ "Cycle", "through", "the", "target", "Node", "and", "remove", "any", "operations", "not", "defined", "in", "the", "extensions", "document", "." ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-codegen-plugin/src/main/java/com/betfair/cougar/codegen/IDLReader.java#L390-L405
36,893
betfair/cougar
cougar-framework/cougar-core-impl/src/main/java/com/betfair/cougar/core/impl/ev/ServiceRegisterableExecutionVenue.java
ServiceRegisterableExecutionVenue.getNamespaceServiceDefinitionMap
public Map<String, Set<ServiceDefinition>> getNamespaceServiceDefinitionMap() { Map<String, Set<ServiceDefinition>> namespaceServiceDefinitionMap = new HashMap<String, Set<ServiceDefinition>>(); for (String namespace : serviceImplementationMap.keySet()) { Set<ServiceDefinition> serviceDefinitions = new HashSet<ServiceDefinition>(); namespaceServiceDefinitionMap.put(namespace, serviceDefinitions); for (ServiceDefinition sd : serviceImplementationMap.get(namespace).keySet()) { serviceDefinitions.add(sd); } } return Collections.unmodifiableMap(namespaceServiceDefinitionMap); }
java
public Map<String, Set<ServiceDefinition>> getNamespaceServiceDefinitionMap() { Map<String, Set<ServiceDefinition>> namespaceServiceDefinitionMap = new HashMap<String, Set<ServiceDefinition>>(); for (String namespace : serviceImplementationMap.keySet()) { Set<ServiceDefinition> serviceDefinitions = new HashSet<ServiceDefinition>(); namespaceServiceDefinitionMap.put(namespace, serviceDefinitions); for (ServiceDefinition sd : serviceImplementationMap.get(namespace).keySet()) { serviceDefinitions.add(sd); } } return Collections.unmodifiableMap(namespaceServiceDefinitionMap); }
[ "public", "Map", "<", "String", ",", "Set", "<", "ServiceDefinition", ">", ">", "getNamespaceServiceDefinitionMap", "(", ")", "{", "Map", "<", "String", ",", "Set", "<", "ServiceDefinition", ">", ">", "namespaceServiceDefinitionMap", "=", "new", "HashMap", "<", ...
This method returns an unmodifiable map between each namespace and the set of serviceDefinitions bound to that namespace. Note that by default the namespace is null, so there could be a null namespace with services enumerated within @return
[ "This", "method", "returns", "an", "unmodifiable", "map", "between", "each", "namespace", "and", "the", "set", "of", "serviceDefinitions", "bound", "to", "that", "namespace", ".", "Note", "that", "by", "default", "the", "namespace", "is", "null", "so", "there"...
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-core-impl/src/main/java/com/betfair/cougar/core/impl/ev/ServiceRegisterableExecutionVenue.java#L146-L157
36,894
betfair/cougar
cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/IoSessionFactory.java
IoSessionFactory.getCurrentSessionAddresses
public Set<SocketAddress> getCurrentSessionAddresses() { Set<SocketAddress> result = new HashSet<SocketAddress>(); synchronized (lock) { result.addAll(sessions.keySet()); result.addAll(pendingConnections.keySet()); } return result; }
java
public Set<SocketAddress> getCurrentSessionAddresses() { Set<SocketAddress> result = new HashSet<SocketAddress>(); synchronized (lock) { result.addAll(sessions.keySet()); result.addAll(pendingConnections.keySet()); } return result; }
[ "public", "Set", "<", "SocketAddress", ">", "getCurrentSessionAddresses", "(", ")", "{", "Set", "<", "SocketAddress", ">", "result", "=", "new", "HashSet", "<", "SocketAddress", ">", "(", ")", ";", "synchronized", "(", "lock", ")", "{", "result", ".", "add...
Returns a list of all server socket addresses to which sessions are already established or being established @return List of socket addresses
[ "Returns", "a", "list", "of", "all", "server", "socket", "addresses", "to", "which", "sessions", "are", "already", "established", "or", "being", "established" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/IoSessionFactory.java#L108-L115
36,895
betfair/cougar
cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/IoSessionFactory.java
IoSessionFactory.getSession
public IoSession getSession() { synchronized (lock) { if (sessions.isEmpty()) { return null; } else { final Object[] keys = sessions.keySet().toArray(); for (int i = 0; i < sessions.size(); i++) { // counter++; final int pos = Math.abs(counter % sessions.size()); final IoSession session = sessions.get(keys[pos]); if (isAvailable(session)) { return session; } } return null; } } }
java
public IoSession getSession() { synchronized (lock) { if (sessions.isEmpty()) { return null; } else { final Object[] keys = sessions.keySet().toArray(); for (int i = 0; i < sessions.size(); i++) { // counter++; final int pos = Math.abs(counter % sessions.size()); final IoSession session = sessions.get(keys[pos]); if (isAvailable(session)) { return session; } } return null; } } }
[ "public", "IoSession", "getSession", "(", ")", "{", "synchronized", "(", "lock", ")", "{", "if", "(", "sessions", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "final", "Object", "[", "]", "keys", "=", "sessions", ".", ...
Rotates via list of currently established sessions @return an IO session
[ "Rotates", "via", "list", "of", "currently", "established", "sessions" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/IoSessionFactory.java#L157-L174
36,896
betfair/cougar
cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/IoSessionFactory.java
IoSessionFactory.openSession
public void openSession(SocketAddress endpoint) { synchronized (lock) { // Submit a reconnect task for this address if one is not already present if (!pendingConnections.containsKey(endpoint)) { final ReconnectTask task = new ReconnectTask(endpoint); pendingConnections.put(endpoint, task); this.reconnectExecutor.submit(task); } } }
java
public void openSession(SocketAddress endpoint) { synchronized (lock) { // Submit a reconnect task for this address if one is not already present if (!pendingConnections.containsKey(endpoint)) { final ReconnectTask task = new ReconnectTask(endpoint); pendingConnections.put(endpoint, task); this.reconnectExecutor.submit(task); } } }
[ "public", "void", "openSession", "(", "SocketAddress", "endpoint", ")", "{", "synchronized", "(", "lock", ")", "{", "// Submit a reconnect task for this address if one is not already present", "if", "(", "!", "pendingConnections", ".", "containsKey", "(", "endpoint", ")",...
Open a new session to the specified address. If session is being opened does nothing @param endpoint
[ "Open", "a", "new", "session", "to", "the", "specified", "address", ".", "If", "session", "is", "being", "opened", "does", "nothing" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/IoSessionFactory.java#L183-L192
36,897
betfair/cougar
cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/IoSessionFactory.java
IoSessionFactory.closeSession
public void closeSession(SocketAddress endpoint, boolean reconnect) { synchronized (lock) { // Submit a reconnect task for this address if one is not already present if (pendingConnections.containsKey(endpoint)) { final ReconnectTask task = pendingConnections.get(endpoint); if (task != null) { task.stop(); } } else { final IoSession ioSession = sessions.get(endpoint); if (ioSession != null) { close(ioSession, reconnect); } } } }
java
public void closeSession(SocketAddress endpoint, boolean reconnect) { synchronized (lock) { // Submit a reconnect task for this address if one is not already present if (pendingConnections.containsKey(endpoint)) { final ReconnectTask task = pendingConnections.get(endpoint); if (task != null) { task.stop(); } } else { final IoSession ioSession = sessions.get(endpoint); if (ioSession != null) { close(ioSession, reconnect); } } } }
[ "public", "void", "closeSession", "(", "SocketAddress", "endpoint", ",", "boolean", "reconnect", ")", "{", "synchronized", "(", "lock", ")", "{", "// Submit a reconnect task for this address if one is not already present", "if", "(", "pendingConnections", ".", "containsKey"...
If there is an active session to the specified endpoint, it will be closed If not the reconnection task for the endpoint will be stopped @param endpoint @param reconnect whether to reconnect after closing the current session. Only used if the session is active
[ "If", "there", "is", "an", "active", "session", "to", "the", "specified", "endpoint", "it", "will", "be", "closed", "If", "not", "the", "reconnection", "task", "for", "the", "endpoint", "will", "be", "stopped" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-client/src/main/java/com/betfair/cougar/client/socket/IoSessionFactory.java#L202-L217
36,898
betfair/cougar
cougar-framework/cougar-core-api/src/main/java/com/betfair/cougar/core/api/exception/CougarException.java
CougarException.getMessage
@Override public final String getMessage() { String additional = additionalInfo(); return additional == null ? super.getMessage() : super.getMessage() + ": " + additional; }
java
@Override public final String getMessage() { String additional = additionalInfo(); return additional == null ? super.getMessage() : super.getMessage() + ": " + additional; }
[ "@", "Override", "public", "final", "String", "getMessage", "(", ")", "{", "String", "additional", "=", "additionalInfo", "(", ")", ";", "return", "additional", "==", "null", "?", "super", ".", "getMessage", "(", ")", ":", "super", ".", "getMessage", "(", ...
Prevent defined services overriding the exception message
[ "Prevent", "defined", "services", "overriding", "the", "exception", "message" ]
08d1fe338fbd0e8572a9c2305bb5796402d5b1f5
https://github.com/betfair/cougar/blob/08d1fe338fbd0e8572a9c2305bb5796402d5b1f5/cougar-framework/cougar-core-api/src/main/java/com/betfair/cougar/core/api/exception/CougarException.java#L103-L107
36,899
profesorfalken/WMI4Java
src/main/java/com/profesorfalken/wmi4java/WMI4Java.java
WMI4Java.listClasses
public List<String> listClasses() throws WMIException { List<String> wmiClasses = new ArrayList<String>(); String rawData; try { rawData = getWMIStub().listClasses(this.namespace, this.computerName); String[] dataStringLines = rawData.split(NEWLINE_REGEX); for (String line : dataStringLines) { if (!line.isEmpty() && !line.startsWith("_")) { String[] infos = line.split(SPACE_REGEX); wmiClasses.addAll(Arrays.asList(infos)); } } // Normalize results: remove duplicates and sort the list Set<String> hs = new HashSet<String>(); hs.addAll(wmiClasses); wmiClasses.clear(); wmiClasses.addAll(hs); } catch (Exception ex) { Logger.getLogger(WMI4Java.class.getName()).log(Level.SEVERE, GENERIC_ERROR_MSG, ex); throw new WMIException(ex); } return wmiClasses; }
java
public List<String> listClasses() throws WMIException { List<String> wmiClasses = new ArrayList<String>(); String rawData; try { rawData = getWMIStub().listClasses(this.namespace, this.computerName); String[] dataStringLines = rawData.split(NEWLINE_REGEX); for (String line : dataStringLines) { if (!line.isEmpty() && !line.startsWith("_")) { String[] infos = line.split(SPACE_REGEX); wmiClasses.addAll(Arrays.asList(infos)); } } // Normalize results: remove duplicates and sort the list Set<String> hs = new HashSet<String>(); hs.addAll(wmiClasses); wmiClasses.clear(); wmiClasses.addAll(hs); } catch (Exception ex) { Logger.getLogger(WMI4Java.class.getName()).log(Level.SEVERE, GENERIC_ERROR_MSG, ex); throw new WMIException(ex); } return wmiClasses; }
[ "public", "List", "<", "String", ">", "listClasses", "(", ")", "throws", "WMIException", "{", "List", "<", "String", ">", "wmiClasses", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "rawData", ";", "try", "{", "rawData", "=", "g...
Query and list the WMI classes @see <a href= "https://msdn.microsoft.com/fr-fr/library/windows/desktop/aa394554(v=vs.85).aspx">WMI Classes - MSDN</a> @return a list with the name of existing classes in the system
[ "Query", "and", "list", "the", "WMI", "classes" ]
a39b153a84a12b0c4c0583234fd2b32aba7f868c
https://github.com/profesorfalken/WMI4Java/blob/a39b153a84a12b0c4c0583234fd2b32aba7f868c/src/main/java/com/profesorfalken/wmi4java/WMI4Java.java#L174-L201