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
partition
stringclasses
1 value
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
PJsonObject.optBool
@Override public final Boolean optBool(final String key) { if (this.obj.optString(key, null) == null) { return null; } else { return this.obj.optBoolean(key); } }
java
@Override public final Boolean optBool(final String key) { if (this.obj.optString(key, null) == null) { return null; } else { return this.obj.optBoolean(key); } }
[ "@", "Override", "public", "final", "Boolean", "optBool", "(", "final", "String", "key", ")", "{", "if", "(", "this", ".", "obj", ".", "optString", "(", "key", ",", "null", ")", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "retu...
Get a property as a boolean or null. @param key the property name
[ "Get", "a", "property", "as", "a", "boolean", "or", "null", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L106-L113
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
PJsonObject.optJSONObject
public final PJsonObject optJSONObject(final String key) { final JSONObject val = this.obj.optJSONObject(key); return val != null ? new PJsonObject(this, val, key) : null; }
java
public final PJsonObject optJSONObject(final String key) { final JSONObject val = this.obj.optJSONObject(key); return val != null ? new PJsonObject(this, val, key) : null; }
[ "public", "final", "PJsonObject", "optJSONObject", "(", "final", "String", "key", ")", "{", "final", "JSONObject", "val", "=", "this", ".", "obj", ".", "optJSONObject", "(", "key", ")", ";", "return", "val", "!=", "null", "?", "new", "PJsonObject", "(", ...
Get a property as a json object or null. @param key the property name
[ "Get", "a", "property", "as", "a", "json", "object", "or", "null", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L145-L148
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
PJsonObject.getJSONArray
public final PJsonArray getJSONArray(final String key) { final JSONArray val = this.obj.optJSONArray(key); if (val == null) { throw new ObjectMissingException(this, key); } return new PJsonArray(this, val, key); }
java
public final PJsonArray getJSONArray(final String key) { final JSONArray val = this.obj.optJSONArray(key); if (val == null) { throw new ObjectMissingException(this, key); } return new PJsonArray(this, val, key); }
[ "public", "final", "PJsonArray", "getJSONArray", "(", "final", "String", "key", ")", "{", "final", "JSONArray", "val", "=", "this", ".", "obj", ".", "optJSONArray", "(", "key", ")", ";", "if", "(", "val", "==", "null", ")", "{", "throw", "new", "Object...
Get a property as a json array or throw exception. @param key the property name
[ "Get", "a", "property", "as", "a", "json", "array", "or", "throw", "exception", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L168-L174
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
PJsonObject.optJSONArray
public final PJsonArray optJSONArray(final String key, final PJsonArray defaultValue) { PJsonArray result = optJSONArray(key); return result != null ? result : defaultValue; }
java
public final PJsonArray optJSONArray(final String key, final PJsonArray defaultValue) { PJsonArray result = optJSONArray(key); return result != null ? result : defaultValue; }
[ "public", "final", "PJsonArray", "optJSONArray", "(", "final", "String", "key", ",", "final", "PJsonArray", "defaultValue", ")", "{", "PJsonArray", "result", "=", "optJSONArray", "(", "key", ")", ";", "return", "result", "!=", "null", "?", "result", ":", "de...
Get a property as a json array or default. @param key the property name @param defaultValue default
[ "Get", "a", "property", "as", "a", "json", "array", "or", "default", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L195-L198
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java
PJsonObject.has
@Override public final boolean has(final String key) { String result = this.obj.optString(key, null); return result != null; }
java
@Override public final boolean has(final String key) { String result = this.obj.optString(key, null); return result != null; }
[ "@", "Override", "public", "final", "boolean", "has", "(", "final", "String", "key", ")", "{", "String", "result", "=", "this", ".", "obj", ".", "optString", "(", "key", ",", "null", ")", ";", "return", "result", "!=", "null", ";", "}" ]
Check if the object has a property with the key. @param key key to check for.
[ "Check", "if", "the", "object", "has", "a", "property", "with", "the", "key", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/json/PJsonObject.java#L266-L270
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/jasper/DataSourceProcessor.java
DataSourceProcessor.setAttributes
public void setAttributes(final Map<String, Attribute> attributes) { this.internalAttributes = attributes; this.allAttributes.putAll(attributes); }
java
public void setAttributes(final Map<String, Attribute> attributes) { this.internalAttributes = attributes; this.allAttributes.putAll(attributes); }
[ "public", "void", "setAttributes", "(", "final", "Map", "<", "String", ",", "Attribute", ">", "attributes", ")", "{", "this", ".", "internalAttributes", "=", "attributes", ";", "this", ".", "allAttributes", ".", "putAll", "(", "attributes", ")", ";", "}" ]
All the attributes needed either by the processors for each datasource row or by the jasper template. @param attributes the attributes.
[ "All", "the", "attributes", "needed", "either", "by", "the", "processors", "for", "each", "datasource", "row", "or", "by", "the", "jasper", "template", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/jasper/DataSourceProcessor.java#L153-L156
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/jasper/DataSourceProcessor.java
DataSourceProcessor.setAttribute
public void setAttribute(final String name, final Attribute attribute) { if (name.equals("datasource")) { this.allAttributes.putAll(((DataSourceAttribute) attribute).getAttributes()); } else if (this.copyAttributes.contains(name)) { this.allAttributes.put(name, attribute); } }
java
public void setAttribute(final String name, final Attribute attribute) { if (name.equals("datasource")) { this.allAttributes.putAll(((DataSourceAttribute) attribute).getAttributes()); } else if (this.copyAttributes.contains(name)) { this.allAttributes.put(name, attribute); } }
[ "public", "void", "setAttribute", "(", "final", "String", "name", ",", "final", "Attribute", "attribute", ")", "{", "if", "(", "name", ".", "equals", "(", "\"datasource\"", ")", ")", "{", "this", ".", "allAttributes", ".", "putAll", "(", "(", "(", "DataS...
All the sub-level attributes. @param name the attribute name. @param attribute the attribute.
[ "All", "the", "sub", "-", "level", "attributes", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/jasper/DataSourceProcessor.java#L188-L194
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/SmtpConfig.java
SmtpConfig.getBody
@Nonnull public String getBody() { if (body == null) { return storage == null ? DEFAULT_BODY : DEFAULT_BODY_STORAGE; } else { return body; } }
java
@Nonnull public String getBody() { if (body == null) { return storage == null ? DEFAULT_BODY : DEFAULT_BODY_STORAGE; } else { return body; } }
[ "@", "Nonnull", "public", "String", "getBody", "(", ")", "{", "if", "(", "body", "==", "null", ")", "{", "return", "storage", "==", "null", "?", "DEFAULT_BODY", ":", "DEFAULT_BODY_STORAGE", ";", "}", "else", "{", "return", "body", ";", "}", "}" ]
Returns the configured body or the default value.
[ "Returns", "the", "configured", "body", "or", "the", "default", "value", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/SmtpConfig.java#L188-L195
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/tiled/TilePreparationTask.java
TilePreparationTask.isTileVisible
private boolean isTileVisible(final ReferencedEnvelope tileBounds) { if (FloatingPointUtil.equals(this.transformer.getRotation(), 0.0)) { return true; } final GeometryFactory gfac = new GeometryFactory(); final Optional<Geometry> rotatedMapBounds = getRotatedMapBounds(gfac); if (rotatedMapBounds.isPresent()) { return rotatedMapBounds.get().intersects(gfac.toGeometry(tileBounds)); } else { // in case of an error, we simply load the tile return true; } }
java
private boolean isTileVisible(final ReferencedEnvelope tileBounds) { if (FloatingPointUtil.equals(this.transformer.getRotation(), 0.0)) { return true; } final GeometryFactory gfac = new GeometryFactory(); final Optional<Geometry> rotatedMapBounds = getRotatedMapBounds(gfac); if (rotatedMapBounds.isPresent()) { return rotatedMapBounds.get().intersects(gfac.toGeometry(tileBounds)); } else { // in case of an error, we simply load the tile return true; } }
[ "private", "boolean", "isTileVisible", "(", "final", "ReferencedEnvelope", "tileBounds", ")", "{", "if", "(", "FloatingPointUtil", ".", "equals", "(", "this", ".", "transformer", ".", "getRotation", "(", ")", ",", "0.0", ")", ")", "{", "return", "true", ";",...
When using a map rotation, there might be tiles that are outside the rotated map area. To avoid to load these tiles, this method checks if a tile is really required to draw the map.
[ "When", "using", "a", "map", "rotation", "there", "might", "be", "tiles", "that", "are", "outside", "the", "rotated", "map", "area", ".", "To", "avoid", "to", "load", "these", "tiles", "this", "method", "checks", "if", "a", "tile", "is", "really", "requi...
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/TilePreparationTask.java#L169-L183
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/style/json/MapfishJsonStyleVersion1.java
MapfishJsonStyleVersion1.getStyleRules
private List<Rule> getStyleRules(final String styleProperty) { final List<Rule> styleRules = new ArrayList<>(this.json.size()); for (Iterator<String> iterator = this.json.keys(); iterator.hasNext(); ) { String styleKey = iterator.next(); if (styleKey.equals(JSON_STYLE_PROPERTY) || styleKey.equals(MapfishStyleParserPlugin.JSON_VERSION)) { continue; } PJsonObject styleJson = this.json.getJSONObject(styleKey); final List<Rule> currentRules = createStyleRule(styleKey, styleJson, styleProperty); for (Rule currentRule: currentRules) { if (currentRule != null) { styleRules.add(currentRule); } } } return styleRules; }
java
private List<Rule> getStyleRules(final String styleProperty) { final List<Rule> styleRules = new ArrayList<>(this.json.size()); for (Iterator<String> iterator = this.json.keys(); iterator.hasNext(); ) { String styleKey = iterator.next(); if (styleKey.equals(JSON_STYLE_PROPERTY) || styleKey.equals(MapfishStyleParserPlugin.JSON_VERSION)) { continue; } PJsonObject styleJson = this.json.getJSONObject(styleKey); final List<Rule> currentRules = createStyleRule(styleKey, styleJson, styleProperty); for (Rule currentRule: currentRules) { if (currentRule != null) { styleRules.add(currentRule); } } } return styleRules; }
[ "private", "List", "<", "Rule", ">", "getStyleRules", "(", "final", "String", "styleProperty", ")", "{", "final", "List", "<", "Rule", ">", "styleRules", "=", "new", "ArrayList", "<>", "(", "this", ".", "json", ".", "size", "(", ")", ")", ";", "for", ...
Creates SLD rules for each old style.
[ "Creates", "SLD", "rules", "for", "each", "old", "style", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/style/json/MapfishJsonStyleVersion1.java#L74-L93
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/http/ForwardHeadersProcessor.java
ForwardHeadersProcessor.setHeaders
public void setHeaders(final Set<String> names) { // transform to lower-case because header names should be case-insensitive Set<String> lowerCaseNames = new HashSet<>(); for (String name: names) { lowerCaseNames.add(name.toLowerCase()); } this.headerNames = lowerCaseNames; }
java
public void setHeaders(final Set<String> names) { // transform to lower-case because header names should be case-insensitive Set<String> lowerCaseNames = new HashSet<>(); for (String name: names) { lowerCaseNames.add(name.toLowerCase()); } this.headerNames = lowerCaseNames; }
[ "public", "void", "setHeaders", "(", "final", "Set", "<", "String", ">", "names", ")", "{", "// transform to lower-case because header names should be case-insensitive", "Set", "<", "String", ">", "lowerCaseNames", "=", "new", "HashSet", "<>", "(", ")", ";", "for", ...
Set the header names to forward from the request. Should not be defined if all is set to true @param names the header names.
[ "Set", "the", "header", "names", "to", "forward", "from", "the", "request", ".", "Should", "not", "be", "defined", "if", "all", "is", "set", "to", "true" ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/ForwardHeadersProcessor.java#L56-L63
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/tiled/osm/OsmLayerParam.java
OsmLayerParam.convertToMultiMap
public static Multimap<String, String> convertToMultiMap(final PObject objectParams) { Multimap<String, String> params = HashMultimap.create(); if (objectParams != null) { Iterator<String> customParamsIter = objectParams.keys(); while (customParamsIter.hasNext()) { String key = customParamsIter.next(); if (objectParams.isArray(key)) { final PArray array = objectParams.optArray(key); for (int i = 0; i < array.size(); i++) { params.put(key, array.getString(i)); } } else { params.put(key, objectParams.optString(key, "")); } } } return params; }
java
public static Multimap<String, String> convertToMultiMap(final PObject objectParams) { Multimap<String, String> params = HashMultimap.create(); if (objectParams != null) { Iterator<String> customParamsIter = objectParams.keys(); while (customParamsIter.hasNext()) { String key = customParamsIter.next(); if (objectParams.isArray(key)) { final PArray array = objectParams.optArray(key); for (int i = 0; i < array.size(); i++) { params.put(key, array.getString(i)); } } else { params.put(key, objectParams.optString(key, "")); } } } return params; }
[ "public", "static", "Multimap", "<", "String", ",", "String", ">", "convertToMultiMap", "(", "final", "PObject", "objectParams", ")", "{", "Multimap", "<", "String", ",", "String", ">", "params", "=", "HashMultimap", ".", "create", "(", ")", ";", "if", "("...
convert a param object to a multimap. @param objectParams the parameters to convert. @return the corresponding Multimap.
[ "convert", "a", "param", "object", "to", "a", "multimap", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/osm/OsmLayerParam.java#L117-L135
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/tiled/osm/OsmLayerParam.java
OsmLayerParam.getMaxExtent
public Envelope getMaxExtent() { final int minX = 0; final int maxX = 1; final int minY = 2; final int maxY = 3; return new Envelope(this.maxExtent[minX], this.maxExtent[minY], this.maxExtent[maxX], this.maxExtent[maxY]); }
java
public Envelope getMaxExtent() { final int minX = 0; final int maxX = 1; final int minY = 2; final int maxY = 3; return new Envelope(this.maxExtent[minX], this.maxExtent[minY], this.maxExtent[maxX], this.maxExtent[maxY]); }
[ "public", "Envelope", "getMaxExtent", "(", ")", "{", "final", "int", "minX", "=", "0", ";", "final", "int", "maxX", "=", "1", ";", "final", "int", "minY", "=", "2", ";", "final", "int", "maxY", "=", "3", ";", "return", "new", "Envelope", "(", "this...
Get the max extent as a envelop object.
[ "Get", "the", "max", "extent", "as", "a", "envelop", "object", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/osm/OsmLayerParam.java#L176-L183
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/ServletMapPrinterFactory.java
ServletMapPrinterFactory.setConfigurationFiles
public final void setConfigurationFiles(final Map<String, String> configurationFiles) throws URISyntaxException { this.configurationFiles.clear(); this.configurationFileLastModifiedTimes.clear(); for (Map.Entry<String, String> entry: configurationFiles.entrySet()) { if (!entry.getValue().contains(":/")) { // assume is a file this.configurationFiles.put(entry.getKey(), new File(entry.getValue()).toURI()); } else { this.configurationFiles.put(entry.getKey(), new URI(entry.getValue())); } } if (this.configFileLoader != null) { this.validateConfigurationFiles(); } }
java
public final void setConfigurationFiles(final Map<String, String> configurationFiles) throws URISyntaxException { this.configurationFiles.clear(); this.configurationFileLastModifiedTimes.clear(); for (Map.Entry<String, String> entry: configurationFiles.entrySet()) { if (!entry.getValue().contains(":/")) { // assume is a file this.configurationFiles.put(entry.getKey(), new File(entry.getValue()).toURI()); } else { this.configurationFiles.put(entry.getKey(), new URI(entry.getValue())); } } if (this.configFileLoader != null) { this.validateConfigurationFiles(); } }
[ "public", "final", "void", "setConfigurationFiles", "(", "final", "Map", "<", "String", ",", "String", ">", "configurationFiles", ")", "throws", "URISyntaxException", "{", "this", ".", "configurationFiles", ".", "clear", "(", ")", ";", "this", ".", "configuratio...
The setter for setting configuration file. It will convert the value to a URI. @param configurationFiles the configuration file map.
[ "The", "setter", "for", "setting", "configuration", "file", ".", "It", "will", "convert", "the", "value", "to", "a", "URI", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/ServletMapPrinterFactory.java#L149-L165
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/ZoomToFeatures.java
ZoomToFeatures.copy
public final ZoomToFeatures copy() { ZoomToFeatures obj = new ZoomToFeatures(); obj.zoomType = this.zoomType; obj.minScale = this.minScale; obj.minMargin = this.minMargin; return obj; }
java
public final ZoomToFeatures copy() { ZoomToFeatures obj = new ZoomToFeatures(); obj.zoomType = this.zoomType; obj.minScale = this.minScale; obj.minMargin = this.minMargin; return obj; }
[ "public", "final", "ZoomToFeatures", "copy", "(", ")", "{", "ZoomToFeatures", "obj", "=", "new", "ZoomToFeatures", "(", ")", ";", "obj", ".", "zoomType", "=", "this", ".", "zoomType", ";", "obj", ".", "minScale", "=", "this", ".", "minScale", ";", "obj",...
Make a copy.
[ "Make", "a", "copy", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/ZoomToFeatures.java#L45-L51
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/url/data/DataUrlConnection.java
DataUrlConnection.getFullContentType
public String getFullContentType() { final String url = this.url.toExternalForm().substring("data:".length()); final int endIndex = url.indexOf(','); if (endIndex >= 0) { final String contentType = url.substring(0, endIndex); if (!contentType.isEmpty()) { return contentType; } } return "text/plain;charset=US-ASCII"; }
java
public String getFullContentType() { final String url = this.url.toExternalForm().substring("data:".length()); final int endIndex = url.indexOf(','); if (endIndex >= 0) { final String contentType = url.substring(0, endIndex); if (!contentType.isEmpty()) { return contentType; } } return "text/plain;charset=US-ASCII"; }
[ "public", "String", "getFullContentType", "(", ")", "{", "final", "String", "url", "=", "this", ".", "url", ".", "toExternalForm", "(", ")", ".", "substring", "(", "\"data:\"", ".", "length", "(", ")", ")", ";", "final", "int", "endIndex", "=", "url", ...
Get the content-type, including the optional ";base64".
[ "Get", "the", "content", "-", "type", "including", "the", "optional", ";", "base64", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/url/data/DataUrlConnection.java#L61-L71
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/http/matcher/DnsHostMatcher.java
DnsHostMatcher.tryOverrideValidation
@Override public final Optional<Boolean> tryOverrideValidation(final MatchInfo matchInfo) throws SocketException, UnknownHostException, MalformedURLException { for (AddressHostMatcher addressHostMatcher: this.matchersForHost) { if (addressHostMatcher.matches(matchInfo)) { return Optional.empty(); } } return Optional.of(false); }
java
@Override public final Optional<Boolean> tryOverrideValidation(final MatchInfo matchInfo) throws SocketException, UnknownHostException, MalformedURLException { for (AddressHostMatcher addressHostMatcher: this.matchersForHost) { if (addressHostMatcher.matches(matchInfo)) { return Optional.empty(); } } return Optional.of(false); }
[ "@", "Override", "public", "final", "Optional", "<", "Boolean", ">", "tryOverrideValidation", "(", "final", "MatchInfo", "matchInfo", ")", "throws", "SocketException", ",", "UnknownHostException", ",", "MalformedURLException", "{", "for", "(", "AddressHostMatcher", "a...
Check the given URI to see if it matches. @param matchInfo the matchInfo to validate. @return True if it matches.
[ "Check", "the", "given", "URI", "to", "see", "if", "it", "matches", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/matcher/DnsHostMatcher.java#L58-L68
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/http/matcher/DnsHostMatcher.java
DnsHostMatcher.setHost
public final void setHost(final String host) throws UnknownHostException { this.host = host; final InetAddress[] inetAddresses = InetAddress.getAllByName(host); for (InetAddress address: inetAddresses) { final AddressHostMatcher matcher = new AddressHostMatcher(); matcher.setIp(address.getHostAddress()); this.matchersForHost.add(matcher); } }
java
public final void setHost(final String host) throws UnknownHostException { this.host = host; final InetAddress[] inetAddresses = InetAddress.getAllByName(host); for (InetAddress address: inetAddresses) { final AddressHostMatcher matcher = new AddressHostMatcher(); matcher.setIp(address.getHostAddress()); this.matchersForHost.add(matcher); } }
[ "public", "final", "void", "setHost", "(", "final", "String", "host", ")", "throws", "UnknownHostException", "{", "this", ".", "host", "=", "host", ";", "final", "InetAddress", "[", "]", "inetAddresses", "=", "InetAddress", ".", "getAllByName", "(", "host", ...
Set the host. @param host the host
[ "Set", "the", "host", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/matcher/DnsHostMatcher.java#L82-L91
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorDependencyGraph.java
ProcessorDependencyGraph.getAllRequiredAttributes
@SuppressWarnings("unchecked") public Multimap<String, Processor> getAllRequiredAttributes() { Multimap<String, Processor> requiredInputs = HashMultimap.create(); for (ProcessorGraphNode root: this.roots) { final BiMap<String, String> inputMapper = root.getInputMapper(); for (String attr: inputMapper.keySet()) { requiredInputs.put(attr, root.getProcessor()); } final Object inputParameter = root.getProcessor().createInputParameter(); if (inputParameter instanceof Values) { continue; } else if (inputParameter != null) { final Class<?> inputParameterClass = inputParameter.getClass(); final Set<String> requiredAttributesDefinedInInputParameter = getAttributeNames(inputParameterClass, FILTER_ONLY_REQUIRED_ATTRIBUTES); for (String attName: requiredAttributesDefinedInInputParameter) { try { if (inputParameterClass.getField(attName).getType() == Values.class) { continue; } } catch (NoSuchFieldException e) { throw new RuntimeException(e); } String mappedName = ProcessorUtils.getInputValueName( root.getProcessor().getInputPrefix(), inputMapper, attName); requiredInputs.put(mappedName, root.getProcessor()); } } } return requiredInputs; }
java
@SuppressWarnings("unchecked") public Multimap<String, Processor> getAllRequiredAttributes() { Multimap<String, Processor> requiredInputs = HashMultimap.create(); for (ProcessorGraphNode root: this.roots) { final BiMap<String, String> inputMapper = root.getInputMapper(); for (String attr: inputMapper.keySet()) { requiredInputs.put(attr, root.getProcessor()); } final Object inputParameter = root.getProcessor().createInputParameter(); if (inputParameter instanceof Values) { continue; } else if (inputParameter != null) { final Class<?> inputParameterClass = inputParameter.getClass(); final Set<String> requiredAttributesDefinedInInputParameter = getAttributeNames(inputParameterClass, FILTER_ONLY_REQUIRED_ATTRIBUTES); for (String attName: requiredAttributesDefinedInInputParameter) { try { if (inputParameterClass.getField(attName).getType() == Values.class) { continue; } } catch (NoSuchFieldException e) { throw new RuntimeException(e); } String mappedName = ProcessorUtils.getInputValueName( root.getProcessor().getInputPrefix(), inputMapper, attName); requiredInputs.put(mappedName, root.getProcessor()); } } } return requiredInputs; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Multimap", "<", "String", ",", "Processor", ">", "getAllRequiredAttributes", "(", ")", "{", "Multimap", "<", "String", ",", "Processor", ">", "requiredInputs", "=", "HashMultimap", ".", "create", "("...
Get all the names of inputs that are required to be in the Values object when this graph is executed.
[ "Get", "all", "the", "names", "of", "inputs", "that", "are", "required", "to", "be", "in", "the", "Values", "object", "when", "this", "graph", "is", "executed", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorDependencyGraph.java#L104-L137
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorDependencyGraph.java
ProcessorDependencyGraph.getAllProcessors
public Set<Processor<?, ?>> getAllProcessors() { IdentityHashMap<Processor<?, ?>, Void> all = new IdentityHashMap<>(); for (ProcessorGraphNode<?, ?> root: this.roots) { for (Processor p: root.getAllProcessors()) { all.put(p, null); } } return all.keySet(); }
java
public Set<Processor<?, ?>> getAllProcessors() { IdentityHashMap<Processor<?, ?>, Void> all = new IdentityHashMap<>(); for (ProcessorGraphNode<?, ?> root: this.roots) { for (Processor p: root.getAllProcessors()) { all.put(p, null); } } return all.keySet(); }
[ "public", "Set", "<", "Processor", "<", "?", ",", "?", ">", ">", "getAllProcessors", "(", ")", "{", "IdentityHashMap", "<", "Processor", "<", "?", ",", "?", ">", ",", "Void", ">", "all", "=", "new", "IdentityHashMap", "<>", "(", ")", ";", "for", "(...
Create a set containing all the processors in the graph.
[ "Create", "a", "set", "containing", "all", "the", "processors", "in", "the", "graph", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorDependencyGraph.java#L170-L178
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/http/matcher/UriMatchers.java
UriMatchers.validate
public void validate(final List<Throwable> validationErrors) { if (this.matchers == null) { validationErrors.add(new IllegalArgumentException( "Matchers cannot be null. There should be at least a !acceptAll matcher")); } if (this.matchers != null && this.matchers.isEmpty()) { validationErrors.add(new IllegalArgumentException( "There are no url matchers defined. There should be at least a " + "!acceptAll matcher")); } }
java
public void validate(final List<Throwable> validationErrors) { if (this.matchers == null) { validationErrors.add(new IllegalArgumentException( "Matchers cannot be null. There should be at least a !acceptAll matcher")); } if (this.matchers != null && this.matchers.isEmpty()) { validationErrors.add(new IllegalArgumentException( "There are no url matchers defined. There should be at least a " + "!acceptAll matcher")); } }
[ "public", "void", "validate", "(", "final", "List", "<", "Throwable", ">", "validationErrors", ")", "{", "if", "(", "this", ".", "matchers", "==", "null", ")", "{", "validationErrors", ".", "add", "(", "new", "IllegalArgumentException", "(", "\"Matchers cannot...
Validate the configuration. @param validationErrors where to put the errors.
[ "Validate", "the", "configuration", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/http/matcher/UriMatchers.java#L83-L93
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/metrics/StatsDReporterInit.java
StatsDReporterInit.init
@PostConstruct public final void init() throws URISyntaxException { final String address = getConfig(ADDRESS, null); if (address != null) { final URI uri = new URI("udp://" + address); final String prefix = getConfig(PREFIX, "mapfish-print").replace("%h", getHostname()); final int period = Integer.parseInt(getConfig(PERIOD, "10")); LOGGER.info("Starting a StatsD reporter targeting {} with prefix {} and period {}s", uri, prefix, period); this.reporter = StatsDReporter.forRegistry(this.metricRegistry) .prefixedWith(prefix) .build(uri.getHost(), uri.getPort()); this.reporter.start(period, TimeUnit.SECONDS); } }
java
@PostConstruct public final void init() throws URISyntaxException { final String address = getConfig(ADDRESS, null); if (address != null) { final URI uri = new URI("udp://" + address); final String prefix = getConfig(PREFIX, "mapfish-print").replace("%h", getHostname()); final int period = Integer.parseInt(getConfig(PERIOD, "10")); LOGGER.info("Starting a StatsD reporter targeting {} with prefix {} and period {}s", uri, prefix, period); this.reporter = StatsDReporter.forRegistry(this.metricRegistry) .prefixedWith(prefix) .build(uri.getHost(), uri.getPort()); this.reporter.start(period, TimeUnit.SECONDS); } }
[ "@", "PostConstruct", "public", "final", "void", "init", "(", ")", "throws", "URISyntaxException", "{", "final", "String", "address", "=", "getConfig", "(", "ADDRESS", ",", "null", ")", ";", "if", "(", "address", "!=", "null", ")", "{", "final", "URI", "...
Start the StatsD reporter, if configured. @throws URISyntaxException
[ "Start", "the", "StatsD", "reporter", "if", "configured", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/metrics/StatsDReporterInit.java#L63-L77
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java
CreateMapProcessor.adjustBoundsToScaleAndMapSize
public static MapBounds adjustBoundsToScaleAndMapSize( final GenericMapAttributeValues mapValues, final Rectangle paintArea, final MapBounds bounds, final double dpi) { MapBounds newBounds = bounds; if (mapValues.isUseNearestScale()) { newBounds = newBounds.adjustBoundsToNearestScale( mapValues.getZoomLevels(), mapValues.getZoomSnapTolerance(), mapValues.getZoomLevelSnapStrategy(), mapValues.getZoomSnapGeodetic(), paintArea, dpi); } newBounds = new BBoxMapBounds(newBounds.toReferencedEnvelope(paintArea)); if (mapValues.isUseAdjustBounds()) { newBounds = newBounds.adjustedEnvelope(paintArea); } return newBounds; }
java
public static MapBounds adjustBoundsToScaleAndMapSize( final GenericMapAttributeValues mapValues, final Rectangle paintArea, final MapBounds bounds, final double dpi) { MapBounds newBounds = bounds; if (mapValues.isUseNearestScale()) { newBounds = newBounds.adjustBoundsToNearestScale( mapValues.getZoomLevels(), mapValues.getZoomSnapTolerance(), mapValues.getZoomLevelSnapStrategy(), mapValues.getZoomSnapGeodetic(), paintArea, dpi); } newBounds = new BBoxMapBounds(newBounds.toReferencedEnvelope(paintArea)); if (mapValues.isUseAdjustBounds()) { newBounds = newBounds.adjustedEnvelope(paintArea); } return newBounds; }
[ "public", "static", "MapBounds", "adjustBoundsToScaleAndMapSize", "(", "final", "GenericMapAttributeValues", "mapValues", ",", "final", "Rectangle", "paintArea", ",", "final", "MapBounds", "bounds", ",", "final", "double", "dpi", ")", "{", "MapBounds", "newBounds", "=...
If requested, adjust the bounds to the nearest scale and the map size. @param mapValues Map parameters. @param paintArea The size of the painting area. @param bounds The map bounds. @param dpi the DPI.
[ "If", "requested", "adjust", "the", "bounds", "to", "the", "nearest", "scale", "and", "the", "map", "size", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java#L161-L182
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java
CreateMapProcessor.createSvgGraphics
public static SVGGraphics2D createSvgGraphics(final Dimension size) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.getDOMImplementation().createDocument(null, "svg", null); SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document); ctx.setStyleHandler(new OpacityAdjustingStyleHandler()); ctx.setComment("Generated by GeoTools2 with Batik SVG Generator"); SVGGraphics2D g2d = new SVGGraphics2D(ctx, true); g2d.setSVGCanvasSize(size); return g2d; }
java
public static SVGGraphics2D createSvgGraphics(final Dimension size) throws ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document document = db.getDOMImplementation().createDocument(null, "svg", null); SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document); ctx.setStyleHandler(new OpacityAdjustingStyleHandler()); ctx.setComment("Generated by GeoTools2 with Batik SVG Generator"); SVGGraphics2D g2d = new SVGGraphics2D(ctx, true); g2d.setSVGCanvasSize(size); return g2d; }
[ "public", "static", "SVGGraphics2D", "createSvgGraphics", "(", "final", "Dimension", "size", ")", "throws", "ParserConfigurationException", "{", "DocumentBuilderFactory", "dbf", "=", "DocumentBuilderFactory", ".", "newInstance", "(", ")", ";", "DocumentBuilder", "db", "...
Create a SVG graphic with the give dimensions. @param size The size of the SVG graphic.
[ "Create", "a", "SVG", "graphic", "with", "the", "give", "dimensions", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java#L189-L203
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java
CreateMapProcessor.saveSvgFile
public static void saveSvgFile(final SVGGraphics2D graphics2d, final File path) throws IOException { try (FileOutputStream fs = new FileOutputStream(path); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fs, StandardCharsets.UTF_8); Writer osw = new BufferedWriter(outputStreamWriter) ) { graphics2d.stream(osw, true); } }
java
public static void saveSvgFile(final SVGGraphics2D graphics2d, final File path) throws IOException { try (FileOutputStream fs = new FileOutputStream(path); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fs, StandardCharsets.UTF_8); Writer osw = new BufferedWriter(outputStreamWriter) ) { graphics2d.stream(osw, true); } }
[ "public", "static", "void", "saveSvgFile", "(", "final", "SVGGraphics2D", "graphics2d", ",", "final", "File", "path", ")", "throws", "IOException", "{", "try", "(", "FileOutputStream", "fs", "=", "new", "FileOutputStream", "(", "path", ")", ";", "OutputStreamWri...
Save a SVG graphic to the given path. @param graphics2d The SVG graphic to save. @param path The file.
[ "Save", "a", "SVG", "graphic", "to", "the", "given", "path", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java#L211-L218
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java
CreateMapProcessor.getFeatureBounds
@Nonnull private ReferencedEnvelope getFeatureBounds( final MfClientHttpRequestFactory clientHttpRequestFactory, final MapAttributeValues mapValues, final ExecutionContext context) { final MapfishMapContext mapContext = createMapContext(mapValues); String layerName = mapValues.zoomToFeatures.layer; ReferencedEnvelope bounds = new ReferencedEnvelope(); for (MapLayer layer: mapValues.getLayers()) { context.stopIfCanceled(); if ((!StringUtils.isEmpty(layerName) && layerName.equals(layer.getName())) || (StringUtils.isEmpty(layerName) && layer instanceof AbstractFeatureSourceLayer)) { AbstractFeatureSourceLayer featureLayer = (AbstractFeatureSourceLayer) layer; FeatureSource<?, ?> featureSource = featureLayer.getFeatureSource(clientHttpRequestFactory, mapContext); FeatureCollection<?, ?> features; try { features = featureSource.getFeatures(); } catch (IOException e) { throw ExceptionUtils.getRuntimeException(e); } if (!features.isEmpty()) { final ReferencedEnvelope curBounds = features.getBounds(); bounds.expandToInclude(curBounds); } } } return bounds; }
java
@Nonnull private ReferencedEnvelope getFeatureBounds( final MfClientHttpRequestFactory clientHttpRequestFactory, final MapAttributeValues mapValues, final ExecutionContext context) { final MapfishMapContext mapContext = createMapContext(mapValues); String layerName = mapValues.zoomToFeatures.layer; ReferencedEnvelope bounds = new ReferencedEnvelope(); for (MapLayer layer: mapValues.getLayers()) { context.stopIfCanceled(); if ((!StringUtils.isEmpty(layerName) && layerName.equals(layer.getName())) || (StringUtils.isEmpty(layerName) && layer instanceof AbstractFeatureSourceLayer)) { AbstractFeatureSourceLayer featureLayer = (AbstractFeatureSourceLayer) layer; FeatureSource<?, ?> featureSource = featureLayer.getFeatureSource(clientHttpRequestFactory, mapContext); FeatureCollection<?, ?> features; try { features = featureSource.getFeatures(); } catch (IOException e) { throw ExceptionUtils.getRuntimeException(e); } if (!features.isEmpty()) { final ReferencedEnvelope curBounds = features.getBounds(); bounds.expandToInclude(curBounds); } } } return bounds; }
[ "@", "Nonnull", "private", "ReferencedEnvelope", "getFeatureBounds", "(", "final", "MfClientHttpRequestFactory", "clientHttpRequestFactory", ",", "final", "MapAttributeValues", "mapValues", ",", "final", "ExecutionContext", "context", ")", "{", "final", "MapfishMapContext", ...
Get the bounding-box containing all features of all layers.
[ "Get", "the", "bounding", "-", "box", "containing", "all", "features", "of", "all", "layers", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/CreateMapProcessor.java#L591-L622
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/WorkingDirectories.java
WorkingDirectories.getJasperCompilation
public final File getJasperCompilation(final Configuration configuration) { File jasperCompilation = new File(getWorking(configuration), "jasper-bin"); createIfMissing(jasperCompilation, "Jasper Compilation"); return jasperCompilation; }
java
public final File getJasperCompilation(final Configuration configuration) { File jasperCompilation = new File(getWorking(configuration), "jasper-bin"); createIfMissing(jasperCompilation, "Jasper Compilation"); return jasperCompilation; }
[ "public", "final", "File", "getJasperCompilation", "(", "final", "Configuration", "configuration", ")", "{", "File", "jasperCompilation", "=", "new", "File", "(", "getWorking", "(", "configuration", ")", ",", "\"jasper-bin\"", ")", ";", "createIfMissing", "(", "ja...
Get the directory where the compiled jasper reports should be put. @param configuration the configuration for the current app.
[ "Get", "the", "directory", "where", "the", "compiled", "jasper", "reports", "should", "be", "put", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/WorkingDirectories.java#L81-L85
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/WorkingDirectories.java
WorkingDirectories.getTaskDirectory
public final File getTaskDirectory() { createIfMissing(this.working, "Working"); try { return Files.createTempDirectory(this.working.toPath(), TASK_DIR_PREFIX).toFile(); } catch (IOException e) { throw new AssertionError("Unable to create temporary directory in '" + this.working + "'"); } }
java
public final File getTaskDirectory() { createIfMissing(this.working, "Working"); try { return Files.createTempDirectory(this.working.toPath(), TASK_DIR_PREFIX).toFile(); } catch (IOException e) { throw new AssertionError("Unable to create temporary directory in '" + this.working + "'"); } }
[ "public", "final", "File", "getTaskDirectory", "(", ")", "{", "createIfMissing", "(", "this", ".", "working", ",", "\"Working\"", ")", ";", "try", "{", "return", "Files", ".", "createTempDirectory", "(", "this", ".", "working", ".", "toPath", "(", ")", ","...
Creates and returns a temporary directory for a printing task.
[ "Creates", "and", "returns", "a", "temporary", "directory", "for", "a", "printing", "task", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/WorkingDirectories.java#L99-L106
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/WorkingDirectories.java
WorkingDirectories.removeDirectory
public final void removeDirectory(final File directory) { try { FileUtils.deleteDirectory(directory); } catch (IOException e) { LOGGER.error("Unable to delete directory '{}'", directory); } }
java
public final void removeDirectory(final File directory) { try { FileUtils.deleteDirectory(directory); } catch (IOException e) { LOGGER.error("Unable to delete directory '{}'", directory); } }
[ "public", "final", "void", "removeDirectory", "(", "final", "File", "directory", ")", "{", "try", "{", "FileUtils", ".", "deleteDirectory", "(", "directory", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "error", "(", "\"Unable ...
Deletes the given directory. @param directory The directory to delete.
[ "Deletes", "the", "given", "directory", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/WorkingDirectories.java#L113-L119
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/config/WorkingDirectories.java
WorkingDirectories.getBuildFileFor
public final File getBuildFileFor( final Configuration configuration, final File jasperFileXml, final String extension, final Logger logger) { final String configurationAbsolutePath = configuration.getDirectory().getPath(); final int prefixToConfiguration = configurationAbsolutePath.length() + 1; final String parentDir = jasperFileXml.getAbsoluteFile().getParent(); final String relativePathToFile; if (configurationAbsolutePath.equals(parentDir)) { relativePathToFile = FilenameUtils.getBaseName(jasperFileXml.getName()); } else { final String relativePathToContainingDirectory = parentDir.substring(prefixToConfiguration); relativePathToFile = relativePathToContainingDirectory + File.separator + FilenameUtils.getBaseName(jasperFileXml.getName()); } final File buildFile = new File(getJasperCompilation(configuration), relativePathToFile + extension); if (!buildFile.getParentFile().exists() && !buildFile.getParentFile().mkdirs()) { logger.error("Unable to create directory for containing compiled jasper report templates: {}", buildFile.getParentFile()); } return buildFile; }
java
public final File getBuildFileFor( final Configuration configuration, final File jasperFileXml, final String extension, final Logger logger) { final String configurationAbsolutePath = configuration.getDirectory().getPath(); final int prefixToConfiguration = configurationAbsolutePath.length() + 1; final String parentDir = jasperFileXml.getAbsoluteFile().getParent(); final String relativePathToFile; if (configurationAbsolutePath.equals(parentDir)) { relativePathToFile = FilenameUtils.getBaseName(jasperFileXml.getName()); } else { final String relativePathToContainingDirectory = parentDir.substring(prefixToConfiguration); relativePathToFile = relativePathToContainingDirectory + File.separator + FilenameUtils.getBaseName(jasperFileXml.getName()); } final File buildFile = new File(getJasperCompilation(configuration), relativePathToFile + extension); if (!buildFile.getParentFile().exists() && !buildFile.getParentFile().mkdirs()) { logger.error("Unable to create directory for containing compiled jasper report templates: {}", buildFile.getParentFile()); } return buildFile; }
[ "public", "final", "File", "getBuildFileFor", "(", "final", "Configuration", "configuration", ",", "final", "File", "jasperFileXml", ",", "final", "String", "extension", ",", "final", "Logger", "logger", ")", "{", "final", "String", "configurationAbsolutePath", "=",...
Calculate the file to compile a jasper report template to. @param configuration the configuration for the current app. @param jasperFileXml the jasper report template in xml format. @param extension the extension of the compiled report template. @param logger the logger to log errors to if an occur.
[ "Calculate", "the", "file", "to", "compile", "a", "jasper", "report", "template", "to", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/config/WorkingDirectories.java#L139-L161
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/tiled/wmts/WMTSLayer.java
WMTSLayer.createRestURI
public static URI createRestURI( final String matrixId, final int row, final int col, final WMTSLayerParam layerParam) throws URISyntaxException { String path = layerParam.baseURL; if (layerParam.dimensions != null) { for (int i = 0; i < layerParam.dimensions.length; i++) { String dimension = layerParam.dimensions[i]; String value = layerParam.dimensionParams.optString(dimension); if (value == null) { value = layerParam.dimensionParams.getString(dimension.toUpperCase()); } path = path.replace("{" + dimension + "}", value); } } path = path.replace("{TileMatrixSet}", layerParam.matrixSet); path = path.replace("{TileMatrix}", matrixId); path = path.replace("{TileRow}", String.valueOf(row)); path = path.replace("{TileCol}", String.valueOf(col)); path = path.replace("{style}", layerParam.style); path = path.replace("{Layer}", layerParam.layer); return new URI(path); }
java
public static URI createRestURI( final String matrixId, final int row, final int col, final WMTSLayerParam layerParam) throws URISyntaxException { String path = layerParam.baseURL; if (layerParam.dimensions != null) { for (int i = 0; i < layerParam.dimensions.length; i++) { String dimension = layerParam.dimensions[i]; String value = layerParam.dimensionParams.optString(dimension); if (value == null) { value = layerParam.dimensionParams.getString(dimension.toUpperCase()); } path = path.replace("{" + dimension + "}", value); } } path = path.replace("{TileMatrixSet}", layerParam.matrixSet); path = path.replace("{TileMatrix}", matrixId); path = path.replace("{TileRow}", String.valueOf(row)); path = path.replace("{TileCol}", String.valueOf(col)); path = path.replace("{style}", layerParam.style); path = path.replace("{Layer}", layerParam.layer); return new URI(path); }
[ "public", "static", "URI", "createRestURI", "(", "final", "String", "matrixId", ",", "final", "int", "row", ",", "final", "int", "col", ",", "final", "WMTSLayerParam", "layerParam", ")", "throws", "URISyntaxException", "{", "String", "path", "=", "layerParam", ...
Prepare the baseURL to make a request. @param matrixId matrixId @param row row @param col cold @param layerParam layerParam
[ "Prepare", "the", "baseURL", "to", "make", "a", "request", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/tiled/wmts/WMTSLayer.java#L66-L88
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PElement.java
PElement.getPath
public final String getPath(final String key) { StringBuilder result = new StringBuilder(); addPathTo(result); result.append("."); result.append(getPathElement(key)); return result.toString(); }
java
public final String getPath(final String key) { StringBuilder result = new StringBuilder(); addPathTo(result); result.append("."); result.append(getPathElement(key)); return result.toString(); }
[ "public", "final", "String", "getPath", "(", "final", "String", "key", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", ")", ";", "addPathTo", "(", "result", ")", ";", "result", ".", "append", "(", "\".\"", ")", ";", "result", ".", ...
Gets the string representation of the path to the current JSON element. @param key the leaf key
[ "Gets", "the", "string", "representation", "of", "the", "path", "to", "the", "current", "JSON", "element", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PElement.java#L39-L45
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/PElement.java
PElement.addPathTo
protected final void addPathTo(final StringBuilder result) { if (this.parent != null) { this.parent.addPathTo(result); if (!(this.parent instanceof PJsonArray)) { result.append("."); } } result.append(getPathElement(this.contextName)); }
java
protected final void addPathTo(final StringBuilder result) { if (this.parent != null) { this.parent.addPathTo(result); if (!(this.parent instanceof PJsonArray)) { result.append("."); } } result.append(getPathElement(this.contextName)); }
[ "protected", "final", "void", "addPathTo", "(", "final", "StringBuilder", "result", ")", "{", "if", "(", "this", ".", "parent", "!=", "null", ")", "{", "this", ".", "parent", ".", "addPathTo", "(", "result", ")", ";", "if", "(", "!", "(", "this", "."...
Append the path to the StringBuilder. @param result the string builder to add the path to.
[ "Append", "the", "path", "to", "the", "StringBuilder", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/PElement.java#L65-L73
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/WaitDB.java
WaitDB.main
public static void main(final String[] args) { if (System.getProperty("db.name") == null) { System.out.println("Not running in multi-instance mode: no DB to connect to"); System.exit(1); } while (true) { try { Class.forName("org.postgresql.Driver"); DriverManager.getConnection("jdbc:postgresql://" + System.getProperty("db.host") + ":5432/" + System.getProperty("db.name"), System.getProperty("db.username"), System.getProperty("db.password")); System.out.println("Opened database successfully. Running in multi-instance mode"); System.exit(0); return; } catch (Exception e) { System.out.println("Failed to connect to the DB: " + e.toString()); try { Thread.sleep(1000); } catch (InterruptedException e1) { //ignored } } } }
java
public static void main(final String[] args) { if (System.getProperty("db.name") == null) { System.out.println("Not running in multi-instance mode: no DB to connect to"); System.exit(1); } while (true) { try { Class.forName("org.postgresql.Driver"); DriverManager.getConnection("jdbc:postgresql://" + System.getProperty("db.host") + ":5432/" + System.getProperty("db.name"), System.getProperty("db.username"), System.getProperty("db.password")); System.out.println("Opened database successfully. Running in multi-instance mode"); System.exit(0); return; } catch (Exception e) { System.out.println("Failed to connect to the DB: " + e.toString()); try { Thread.sleep(1000); } catch (InterruptedException e1) { //ignored } } } }
[ "public", "static", "void", "main", "(", "final", "String", "[", "]", "args", ")", "{", "if", "(", "System", ".", "getProperty", "(", "\"db.name\"", ")", "==", "null", ")", "{", "System", ".", "out", ".", "println", "(", "\"Not running in multi-instance mo...
A comment. @param args the parameters
[ "A", "comment", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/WaitDB.java#L16-L40
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java
ProcessorExecutionContext.started
private void started(final ProcessorGraphNode processorGraphNode) { this.processorLock.lock(); try { this.runningProcessors.put(processorGraphNode.getProcessor(), null); } finally { this.processorLock.unlock(); } }
java
private void started(final ProcessorGraphNode processorGraphNode) { this.processorLock.lock(); try { this.runningProcessors.put(processorGraphNode.getProcessor(), null); } finally { this.processorLock.unlock(); } }
[ "private", "void", "started", "(", "final", "ProcessorGraphNode", "processorGraphNode", ")", "{", "this", ".", "processorLock", ".", "lock", "(", ")", ";", "try", "{", "this", ".", "runningProcessors", ".", "put", "(", "processorGraphNode", ".", "getProcessor", ...
Flag that the processor has started execution. @param processorGraphNode the node that has started.
[ "Flag", "that", "the", "processor", "has", "started", "execution", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java#L71-L78
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java
ProcessorExecutionContext.isRunning
public boolean isRunning(final ProcessorGraphNode processorGraphNode) { this.processorLock.lock(); try { return this.runningProcessors.containsKey(processorGraphNode.getProcessor()); } finally { this.processorLock.unlock(); } }
java
public boolean isRunning(final ProcessorGraphNode processorGraphNode) { this.processorLock.lock(); try { return this.runningProcessors.containsKey(processorGraphNode.getProcessor()); } finally { this.processorLock.unlock(); } }
[ "public", "boolean", "isRunning", "(", "final", "ProcessorGraphNode", "processorGraphNode", ")", "{", "this", ".", "processorLock", ".", "lock", "(", ")", ";", "try", "{", "return", "this", ".", "runningProcessors", ".", "containsKey", "(", "processorGraphNode", ...
Return true if the processor of the node is currently being executed. @param processorGraphNode the node to test.
[ "Return", "true", "if", "the", "processor", "of", "the", "node", "is", "currently", "being", "executed", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java#L85-L92
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java
ProcessorExecutionContext.isFinished
public boolean isFinished(final ProcessorGraphNode processorGraphNode) { this.processorLock.lock(); try { return this.executedProcessors.containsKey(processorGraphNode.getProcessor()); } finally { this.processorLock.unlock(); } }
java
public boolean isFinished(final ProcessorGraphNode processorGraphNode) { this.processorLock.lock(); try { return this.executedProcessors.containsKey(processorGraphNode.getProcessor()); } finally { this.processorLock.unlock(); } }
[ "public", "boolean", "isFinished", "(", "final", "ProcessorGraphNode", "processorGraphNode", ")", "{", "this", ".", "processorLock", ".", "lock", "(", ")", ";", "try", "{", "return", "this", ".", "executedProcessors", ".", "containsKey", "(", "processorGraphNode",...
Return true if the processor of the node has previously been executed. @param processorGraphNode the node to test.
[ "Return", "true", "if", "the", "processor", "of", "the", "node", "has", "previously", "been", "executed", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java#L99-L106
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java
ProcessorExecutionContext.finished
public void finished(final ProcessorGraphNode processorGraphNode) { this.processorLock.lock(); try { this.runningProcessors.remove(processorGraphNode.getProcessor()); this.executedProcessors.put(processorGraphNode.getProcessor(), null); } finally { this.processorLock.unlock(); } }
java
public void finished(final ProcessorGraphNode processorGraphNode) { this.processorLock.lock(); try { this.runningProcessors.remove(processorGraphNode.getProcessor()); this.executedProcessors.put(processorGraphNode.getProcessor(), null); } finally { this.processorLock.unlock(); } }
[ "public", "void", "finished", "(", "final", "ProcessorGraphNode", "processorGraphNode", ")", "{", "this", ".", "processorLock", ".", "lock", "(", ")", ";", "try", "{", "this", ".", "runningProcessors", ".", "remove", "(", "processorGraphNode", ".", "getProcessor...
Flag that the processor has completed execution. @param processorGraphNode the node that has finished.
[ "Flag", "that", "the", "processor", "has", "completed", "execution", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/ProcessorExecutionContext.java#L113-L121
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarDrawer.java
ScalebarDrawer.draw
public final void draw() { AffineTransform transform = new AffineTransform(this.transform); transform.concatenate(getAlignmentTransform()); // draw the background box this.graphics2d.setTransform(transform); this.graphics2d.setColor(this.params.getBackgroundColor()); this.graphics2d.fillRect(0, 0, this.settings.getSize().width, this.settings.getSize().height); //draw the labels this.graphics2d.setColor(this.params.getFontColor()); drawLabels(transform, this.params.getOrientation(), this.params.getLabelRotation()); //sets the transformation for drawing the bar and do it final AffineTransform lineTransform = new AffineTransform(transform); setLineTranslate(lineTransform); if (this.params.getOrientation() == Orientation.VERTICAL_LABELS_LEFT || this.params.getOrientation() == Orientation.VERTICAL_LABELS_RIGHT) { final AffineTransform rotate = AffineTransform.getQuadrantRotateInstance(1); lineTransform.concatenate(rotate); } this.graphics2d.setTransform(lineTransform); this.graphics2d.setStroke(new BasicStroke(this.settings.getLineWidth())); this.graphics2d.setColor(this.params.getColor()); drawBar(); }
java
public final void draw() { AffineTransform transform = new AffineTransform(this.transform); transform.concatenate(getAlignmentTransform()); // draw the background box this.graphics2d.setTransform(transform); this.graphics2d.setColor(this.params.getBackgroundColor()); this.graphics2d.fillRect(0, 0, this.settings.getSize().width, this.settings.getSize().height); //draw the labels this.graphics2d.setColor(this.params.getFontColor()); drawLabels(transform, this.params.getOrientation(), this.params.getLabelRotation()); //sets the transformation for drawing the bar and do it final AffineTransform lineTransform = new AffineTransform(transform); setLineTranslate(lineTransform); if (this.params.getOrientation() == Orientation.VERTICAL_LABELS_LEFT || this.params.getOrientation() == Orientation.VERTICAL_LABELS_RIGHT) { final AffineTransform rotate = AffineTransform.getQuadrantRotateInstance(1); lineTransform.concatenate(rotate); } this.graphics2d.setTransform(lineTransform); this.graphics2d.setStroke(new BasicStroke(this.settings.getLineWidth())); this.graphics2d.setColor(this.params.getColor()); drawBar(); }
[ "public", "final", "void", "draw", "(", ")", "{", "AffineTransform", "transform", "=", "new", "AffineTransform", "(", "this", ".", "transform", ")", ";", "transform", ".", "concatenate", "(", "getAlignmentTransform", "(", ")", ")", ";", "// draw the background b...
Start the rendering of the scalebar.
[ "Start", "the", "rendering", "of", "the", "scalebar", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarDrawer.java#L43-L70
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarDrawer.java
ScalebarDrawer.getAlignmentTransform
private AffineTransform getAlignmentTransform() { final int offsetX; switch (this.settings.getParams().getAlign()) { case LEFT: offsetX = 0; break; case RIGHT: offsetX = this.settings.getMaxSize().width - this.settings.getSize().width; break; case CENTER: default: offsetX = (int) Math .floor(this.settings.getMaxSize().width / 2.0 - this.settings.getSize().width / 2.0); break; } final int offsetY; switch (this.settings.getParams().getVerticalAlign()) { case TOP: offsetY = 0; break; case BOTTOM: offsetY = this.settings.getMaxSize().height - this.settings.getSize().height; break; case MIDDLE: default: offsetY = (int) Math.floor(this.settings.getMaxSize().height / 2.0 - this.settings.getSize().height / 2.0); break; } return AffineTransform.getTranslateInstance(Math.round(offsetX), Math.round(offsetY)); }
java
private AffineTransform getAlignmentTransform() { final int offsetX; switch (this.settings.getParams().getAlign()) { case LEFT: offsetX = 0; break; case RIGHT: offsetX = this.settings.getMaxSize().width - this.settings.getSize().width; break; case CENTER: default: offsetX = (int) Math .floor(this.settings.getMaxSize().width / 2.0 - this.settings.getSize().width / 2.0); break; } final int offsetY; switch (this.settings.getParams().getVerticalAlign()) { case TOP: offsetY = 0; break; case BOTTOM: offsetY = this.settings.getMaxSize().height - this.settings.getSize().height; break; case MIDDLE: default: offsetY = (int) Math.floor(this.settings.getMaxSize().height / 2.0 - this.settings.getSize().height / 2.0); break; } return AffineTransform.getTranslateInstance(Math.round(offsetX), Math.round(offsetY)); }
[ "private", "AffineTransform", "getAlignmentTransform", "(", ")", "{", "final", "int", "offsetX", ";", "switch", "(", "this", ".", "settings", ".", "getParams", "(", ")", ".", "getAlign", "(", ")", ")", "{", "case", "LEFT", ":", "offsetX", "=", "0", ";", ...
Create a transformation which takes the alignment settings into account.
[ "Create", "a", "transformation", "which", "takes", "the", "alignment", "settings", "into", "account", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/scalebar/ScalebarDrawer.java#L75-L107
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/AbstractGeotoolsLayer.java
AbstractGeotoolsLayer.getLayerTransformer
protected final MapfishMapContext getLayerTransformer(final MapfishMapContext transformer) { MapfishMapContext layerTransformer = transformer; if (!FloatingPointUtil.equals(transformer.getRotation(), 0.0) && !this.supportsNativeRotation()) { // if a rotation is set and the rotation can not be handled natively // by the layer, we have to adjust the bounds and map size layerTransformer = new MapfishMapContext( transformer, transformer.getRotatedBoundsAdjustedForPreciseRotatedMapSize(), transformer.getRotatedMapSize(), 0, transformer.getDPI(), transformer.isForceLongitudeFirst(), transformer.isDpiSensitiveStyle()); } return layerTransformer; }
java
protected final MapfishMapContext getLayerTransformer(final MapfishMapContext transformer) { MapfishMapContext layerTransformer = transformer; if (!FloatingPointUtil.equals(transformer.getRotation(), 0.0) && !this.supportsNativeRotation()) { // if a rotation is set and the rotation can not be handled natively // by the layer, we have to adjust the bounds and map size layerTransformer = new MapfishMapContext( transformer, transformer.getRotatedBoundsAdjustedForPreciseRotatedMapSize(), transformer.getRotatedMapSize(), 0, transformer.getDPI(), transformer.isForceLongitudeFirst(), transformer.isDpiSensitiveStyle()); } return layerTransformer; }
[ "protected", "final", "MapfishMapContext", "getLayerTransformer", "(", "final", "MapfishMapContext", "transformer", ")", "{", "MapfishMapContext", "layerTransformer", "=", "transformer", ";", "if", "(", "!", "FloatingPointUtil", ".", "equals", "(", "transformer", ".", ...
If the layer transformer has not been prepared yet, do it. @param transformer the transformer
[ "If", "the", "layer", "transformer", "has", "not", "been", "prepared", "yet", "do", "it", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/AbstractGeotoolsLayer.java#L186-L203
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/output/ValuesLogger.java
ValuesLogger.log
public static void log(final String templateName, final Template template, final Values values) { new ValuesLogger().doLog(templateName, template, values); }
java
public static void log(final String templateName, final Template template, final Values values) { new ValuesLogger().doLog(templateName, template, values); }
[ "public", "static", "void", "log", "(", "final", "String", "templateName", ",", "final", "Template", "template", ",", "final", "Values", "values", ")", "{", "new", "ValuesLogger", "(", ")", ".", "doLog", "(", "templateName", ",", "template", ",", "values", ...
Log the values for the provided template. @param templateName the name of the template the values came from @param template the template object @param values the resultant values
[ "Log", "the", "values", "for", "the", "provided", "template", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/output/ValuesLogger.java#L34-L36
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java
PrintJob.getFileName
private static String getFileName(@Nullable final MapPrinter mapPrinter, final PJsonObject spec) { String fileName = spec.optString(Constants.OUTPUT_FILENAME_KEY); if (fileName != null) { return fileName; } if (mapPrinter != null) { final Configuration config = mapPrinter.getConfiguration(); final String templateName = spec.getString(Constants.JSON_LAYOUT_KEY); final Template template = config.getTemplate(templateName); if (template.getOutputFilename() != null) { return template.getOutputFilename(); } if (config.getOutputFilename() != null) { return config.getOutputFilename(); } } return "mapfish-print-report"; }
java
private static String getFileName(@Nullable final MapPrinter mapPrinter, final PJsonObject spec) { String fileName = spec.optString(Constants.OUTPUT_FILENAME_KEY); if (fileName != null) { return fileName; } if (mapPrinter != null) { final Configuration config = mapPrinter.getConfiguration(); final String templateName = spec.getString(Constants.JSON_LAYOUT_KEY); final Template template = config.getTemplate(templateName); if (template.getOutputFilename() != null) { return template.getOutputFilename(); } if (config.getOutputFilename() != null) { return config.getOutputFilename(); } } return "mapfish-print-report"; }
[ "private", "static", "String", "getFileName", "(", "@", "Nullable", "final", "MapPrinter", "mapPrinter", ",", "final", "PJsonObject", "spec", ")", "{", "String", "fileName", "=", "spec", ".", "optString", "(", "Constants", ".", "OUTPUT_FILENAME_KEY", ")", ";", ...
Read filename from spec.
[ "Read", "filename", "from", "spec", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java#L72-L93
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java
PrintJob.withOpenOutputStream
protected PrintResult withOpenOutputStream(final PrintAction function) throws Exception { final File reportFile = getReportFile(); final Processor.ExecutionContext executionContext; try (FileOutputStream out = new FileOutputStream(reportFile); BufferedOutputStream bout = new BufferedOutputStream(out)) { executionContext = function.run(bout); } return new PrintResult(reportFile.length(), executionContext); }
java
protected PrintResult withOpenOutputStream(final PrintAction function) throws Exception { final File reportFile = getReportFile(); final Processor.ExecutionContext executionContext; try (FileOutputStream out = new FileOutputStream(reportFile); BufferedOutputStream bout = new BufferedOutputStream(out)) { executionContext = function.run(bout); } return new PrintResult(reportFile.length(), executionContext); }
[ "protected", "PrintResult", "withOpenOutputStream", "(", "final", "PrintAction", "function", ")", "throws", "Exception", "{", "final", "File", "reportFile", "=", "getReportFile", "(", ")", ";", "final", "Processor", ".", "ExecutionContext", "executionContext", ";", ...
Open an OutputStream and execute the function using the OutputStream. @param function the function to execute @return the URI and the file size
[ "Open", "an", "OutputStream", "and", "execute", "the", "function", "using", "the", "OutputStream", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/PrintJob.java#L113-L121
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/grid/PointGridStyle.java
PointGridStyle.get
static Style get(final GridParam params) { final StyleBuilder builder = new StyleBuilder(); final Symbolizer pointSymbolizer = crossSymbolizer("shape://plus", builder, CROSS_SIZE, params.gridColor); final Style style = builder.createStyle(pointSymbolizer); final List<Symbolizer> symbolizers = style.featureTypeStyles().get(0).rules().get(0).symbolizers(); if (params.haloRadius > 0.0) { Symbolizer halo = crossSymbolizer("cross", builder, CROSS_SIZE + params.haloRadius * 2.0, params.haloColor); symbolizers.add(0, halo); } return style; }
java
static Style get(final GridParam params) { final StyleBuilder builder = new StyleBuilder(); final Symbolizer pointSymbolizer = crossSymbolizer("shape://plus", builder, CROSS_SIZE, params.gridColor); final Style style = builder.createStyle(pointSymbolizer); final List<Symbolizer> symbolizers = style.featureTypeStyles().get(0).rules().get(0).symbolizers(); if (params.haloRadius > 0.0) { Symbolizer halo = crossSymbolizer("cross", builder, CROSS_SIZE + params.haloRadius * 2.0, params.haloColor); symbolizers.add(0, halo); } return style; }
[ "static", "Style", "get", "(", "final", "GridParam", "params", ")", "{", "final", "StyleBuilder", "builder", "=", "new", "StyleBuilder", "(", ")", ";", "final", "Symbolizer", "pointSymbolizer", "=", "crossSymbolizer", "(", "\"shape://plus\"", ",", "builder", ","...
Create the Grid Point style.
[ "Create", "the", "Grid", "Point", "style", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/grid/PointGridStyle.java#L27-L42
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/ZoomLevels.java
ZoomLevels.get
public Scale get(final int index, final DistanceUnit unit) { return new Scale(this.scaleDenominators[index], unit, PDF_DPI); }
java
public Scale get(final int index, final DistanceUnit unit) { return new Scale(this.scaleDenominators[index], unit, PDF_DPI); }
[ "public", "Scale", "get", "(", "final", "int", "index", ",", "final", "DistanceUnit", "unit", ")", "{", "return", "new", "Scale", "(", "this", ".", "scaleDenominators", "[", "index", "]", ",", "unit", ",", "PDF_DPI", ")", ";", "}" ]
Get the scale at the given index. @param index the index of the zoom level to access. @param unit the unit.
[ "Get", "the", "scale", "at", "the", "given", "index", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/ZoomLevels.java#L76-L78
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/ZoomLevels.java
ZoomLevels.getScaleDenominators
public double[] getScaleDenominators() { double[] dest = new double[this.scaleDenominators.length]; System.arraycopy(this.scaleDenominators, 0, dest, 0, this.scaleDenominators.length); return dest; }
java
public double[] getScaleDenominators() { double[] dest = new double[this.scaleDenominators.length]; System.arraycopy(this.scaleDenominators, 0, dest, 0, this.scaleDenominators.length); return dest; }
[ "public", "double", "[", "]", "getScaleDenominators", "(", ")", "{", "double", "[", "]", "dest", "=", "new", "double", "[", "this", ".", "scaleDenominators", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "this", ".", "scaleDenominators", ",", ...
Return a copy of the zoom level scale denominators. Scales are sorted greatest to least.
[ "Return", "a", "copy", "of", "the", "zoom", "level", "scale", "denominators", ".", "Scales", "are", "sorted", "greatest", "to", "least", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/ZoomLevels.java#L117-L121
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java
FeaturesParser.autoTreat
public final SimpleFeatureCollection autoTreat(final Template template, final String features) throws IOException { SimpleFeatureCollection featuresCollection = treatStringAsURL(template, features); if (featuresCollection == null) { featuresCollection = treatStringAsGeoJson(features); } return featuresCollection; }
java
public final SimpleFeatureCollection autoTreat(final Template template, final String features) throws IOException { SimpleFeatureCollection featuresCollection = treatStringAsURL(template, features); if (featuresCollection == null) { featuresCollection = treatStringAsGeoJson(features); } return featuresCollection; }
[ "public", "final", "SimpleFeatureCollection", "autoTreat", "(", "final", "Template", "template", ",", "final", "String", "features", ")", "throws", "IOException", "{", "SimpleFeatureCollection", "featuresCollection", "=", "treatStringAsURL", "(", "template", ",", "featu...
Get the features collection from a GeoJson inline string or URL. @param template the template @param features what to parse @return the feature collection @throws IOException
[ "Get", "the", "features", "collection", "from", "a", "GeoJson", "inline", "string", "or", "URL", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java#L151-L158
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java
FeaturesParser.treatStringAsURL
public final SimpleFeatureCollection treatStringAsURL(final Template template, final String geoJsonUrl) throws IOException { URL url; try { url = FileUtils.testForLegalFileUrl(template.getConfiguration(), new URL(geoJsonUrl)); } catch (MalformedURLException e) { return null; } final String geojsonString; if (url.getProtocol().equalsIgnoreCase("file")) { geojsonString = IOUtils.toString(url, Constants.DEFAULT_CHARSET.name()); } else { geojsonString = URIUtils.toString(this.httpRequestFactory, url); } return treatStringAsGeoJson(geojsonString); }
java
public final SimpleFeatureCollection treatStringAsURL(final Template template, final String geoJsonUrl) throws IOException { URL url; try { url = FileUtils.testForLegalFileUrl(template.getConfiguration(), new URL(geoJsonUrl)); } catch (MalformedURLException e) { return null; } final String geojsonString; if (url.getProtocol().equalsIgnoreCase("file")) { geojsonString = IOUtils.toString(url, Constants.DEFAULT_CHARSET.name()); } else { geojsonString = URIUtils.toString(this.httpRequestFactory, url); } return treatStringAsGeoJson(geojsonString); }
[ "public", "final", "SimpleFeatureCollection", "treatStringAsURL", "(", "final", "Template", "template", ",", "final", "String", "geoJsonUrl", ")", "throws", "IOException", "{", "URL", "url", ";", "try", "{", "url", "=", "FileUtils", ".", "testForLegalFileUrl", "("...
Get the features collection from a GeoJson URL. @param template the template @param geoJsonUrl what to parse @return the feature collection
[ "Get", "the", "features", "collection", "from", "a", "GeoJson", "URL", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/FeaturesParser.java#L167-L184
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/image/wms/WmsLayer.java
WmsLayer.supportsNativeRotation
@Override public boolean supportsNativeRotation() { return this.params.useNativeAngle && (this.params.serverType == WmsLayerParam.ServerType.MAPSERVER || this.params.serverType == WmsLayerParam.ServerType.GEOSERVER); }
java
@Override public boolean supportsNativeRotation() { return this.params.useNativeAngle && (this.params.serverType == WmsLayerParam.ServerType.MAPSERVER || this.params.serverType == WmsLayerParam.ServerType.GEOSERVER); }
[ "@", "Override", "public", "boolean", "supportsNativeRotation", "(", ")", "{", "return", "this", ".", "params", ".", "useNativeAngle", "&&", "(", "this", ".", "params", ".", "serverType", "==", "WmsLayerParam", ".", "ServerType", ".", "MAPSERVER", "||", "this"...
If supported by the WMS server, a parameter "angle" can be set on "customParams" or "mergeableParams". In this case the rotation will be done natively by the WMS.
[ "If", "supported", "by", "the", "WMS", "server", "a", "parameter", "angle", "can", "be", "set", "on", "customParams", "or", "mergeableParams", ".", "In", "this", "case", "the", "rotation", "will", "be", "done", "natively", "by", "the", "WMS", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/image/wms/WmsLayer.java#L72-L77
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/fileloader/AbstractFileConfigFileLoader.java
AbstractFileConfigFileLoader.platformIndependentUriToFile
protected static File platformIndependentUriToFile(final URI fileURI) { File file; try { file = new File(fileURI); } catch (IllegalArgumentException e) { if (fileURI.toString().startsWith("file://")) { file = new File(fileURI.toString().substring("file://".length())); } else { throw e; } } return file; }
java
protected static File platformIndependentUriToFile(final URI fileURI) { File file; try { file = new File(fileURI); } catch (IllegalArgumentException e) { if (fileURI.toString().startsWith("file://")) { file = new File(fileURI.toString().substring("file://".length())); } else { throw e; } } return file; }
[ "protected", "static", "File", "platformIndependentUriToFile", "(", "final", "URI", "fileURI", ")", "{", "File", "file", ";", "try", "{", "file", "=", "new", "File", "(", "fileURI", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "i...
Convert a url to a file object. No checks are made to see if file exists but there are some hacks that are needed to convert uris to files across platforms. @param fileURI the uri to convert
[ "Convert", "a", "url", "to", "a", "file", "object", ".", "No", "checks", "are", "made", "to", "see", "if", "file", "exists", "but", "there", "are", "some", "hacks", "that", "are", "needed", "to", "convert", "uris", "to", "files", "across", "platforms", ...
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/fileloader/AbstractFileConfigFileLoader.java#L29-L41
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/multi/PMultiObject.java
PMultiObject.getContext
public static String getContext(final PObject[] objs) { StringBuilder result = new StringBuilder("("); boolean first = true; for (PObject obj: objs) { if (!first) { result.append('|'); } first = false; result.append(obj.getCurrentPath()); } result.append(')'); return result.toString(); }
java
public static String getContext(final PObject[] objs) { StringBuilder result = new StringBuilder("("); boolean first = true; for (PObject obj: objs) { if (!first) { result.append('|'); } first = false; result.append(obj.getCurrentPath()); } result.append(')'); return result.toString(); }
[ "public", "static", "String", "getContext", "(", "final", "PObject", "[", "]", "objs", ")", "{", "StringBuilder", "result", "=", "new", "StringBuilder", "(", "\"(\"", ")", ";", "boolean", "first", "=", "true", ";", "for", "(", "PObject", "obj", ":", "obj...
Build the context name. @param objs the objects @return the global context name
[ "Build", "the", "context", "name", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/multi/PMultiObject.java#L36-L48
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.save
public final void save(final PrintJobStatusExtImpl entry) { getSession().merge(entry); getSession().flush(); getSession().evict(entry); }
java
public final void save(final PrintJobStatusExtImpl entry) { getSession().merge(entry); getSession().flush(); getSession().evict(entry); }
[ "public", "final", "void", "save", "(", "final", "PrintJobStatusExtImpl", "entry", ")", "{", "getSession", "(", ")", ".", "merge", "(", "entry", ")", ";", "getSession", "(", ")", ".", "flush", "(", ")", ";", "getSession", "(", ")", ".", "evict", "(", ...
Save Job Record. @param entry the entry
[ "Save", "Job", "Record", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L49-L53
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.getValue
public final Object getValue(final String id, final String property) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<Object> criteria = builder.createQuery(Object.class); final Root<PrintJobStatusExtImpl> root = criteria.from(PrintJobStatusExtImpl.class); criteria.select(root.get(property)); criteria.where(builder.equal(root.get("referenceId"), id)); return getSession().createQuery(criteria).uniqueResult(); }
java
public final Object getValue(final String id, final String property) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<Object> criteria = builder.createQuery(Object.class); final Root<PrintJobStatusExtImpl> root = criteria.from(PrintJobStatusExtImpl.class); criteria.select(root.get(property)); criteria.where(builder.equal(root.get("referenceId"), id)); return getSession().createQuery(criteria).uniqueResult(); }
[ "public", "final", "Object", "getValue", "(", "final", "String", "id", ",", "final", "String", "property", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaQuery", "<", ...
get specific property value of job. @param id the id @param property the property name/path @return the property value
[ "get", "specific", "property", "value", "of", "job", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L104-L111
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.cancelOld
public final void cancelOld( final long starttimeThreshold, final long checkTimeThreshold, final String message) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaUpdate<PrintJobStatusExtImpl> update = builder.createCriteriaUpdate(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = update.from(PrintJobStatusExtImpl.class); update.where(builder.and( builder.equal(root.get("status"), PrintJobStatus.Status.WAITING), builder.or( builder.lessThan(root.get("entry").get("startTime"), starttimeThreshold), builder.and(builder.isNotNull(root.get("lastCheckTime")), builder.lessThan(root.get("lastCheckTime"), checkTimeThreshold)) ) )); update.set(root.get("status"), PrintJobStatus.Status.CANCELLED); update.set(root.get("error"), message); getSession().createQuery(update).executeUpdate(); }
java
public final void cancelOld( final long starttimeThreshold, final long checkTimeThreshold, final String message) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaUpdate<PrintJobStatusExtImpl> update = builder.createCriteriaUpdate(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = update.from(PrintJobStatusExtImpl.class); update.where(builder.and( builder.equal(root.get("status"), PrintJobStatus.Status.WAITING), builder.or( builder.lessThan(root.get("entry").get("startTime"), starttimeThreshold), builder.and(builder.isNotNull(root.get("lastCheckTime")), builder.lessThan(root.get("lastCheckTime"), checkTimeThreshold)) ) )); update.set(root.get("status"), PrintJobStatus.Status.CANCELLED); update.set(root.get("error"), message); getSession().createQuery(update).executeUpdate(); }
[ "public", "final", "void", "cancelOld", "(", "final", "long", "starttimeThreshold", ",", "final", "long", "checkTimeThreshold", ",", "final", "String", "message", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilde...
Cancel old waiting jobs. @param starttimeThreshold threshold for start time @param checkTimeThreshold threshold for last check time @param message the error message
[ "Cancel", "old", "waiting", "jobs", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L164-L181
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.updateLastCheckTime
public final void updateLastCheckTime(final String id, final long lastCheckTime) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaUpdate<PrintJobStatusExtImpl> update = builder.createCriteriaUpdate(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = update.from(PrintJobStatusExtImpl.class); update.where(builder.equal(root.get("referenceId"), id)); update.set(root.get("lastCheckTime"), lastCheckTime); getSession().createQuery(update).executeUpdate(); }
java
public final void updateLastCheckTime(final String id, final long lastCheckTime) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaUpdate<PrintJobStatusExtImpl> update = builder.createCriteriaUpdate(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = update.from(PrintJobStatusExtImpl.class); update.where(builder.equal(root.get("referenceId"), id)); update.set(root.get("lastCheckTime"), lastCheckTime); getSession().createQuery(update).executeUpdate(); }
[ "public", "final", "void", "updateLastCheckTime", "(", "final", "String", "id", ",", "final", "long", "lastCheckTime", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaUpdat...
Update the lastCheckTime of the given record. @param id the id @param lastCheckTime the new value
[ "Update", "the", "lastCheckTime", "of", "the", "given", "record", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L189-L197
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.deleteOld
public final int deleteOld(final long checkTimeThreshold) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaDelete<PrintJobStatusExtImpl> delete = builder.createCriteriaDelete(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = delete.from(PrintJobStatusExtImpl.class); delete.where(builder.and(builder.isNotNull(root.get("lastCheckTime")), builder.lessThan(root.get("lastCheckTime"), checkTimeThreshold))); return getSession().createQuery(delete).executeUpdate(); }
java
public final int deleteOld(final long checkTimeThreshold) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaDelete<PrintJobStatusExtImpl> delete = builder.createCriteriaDelete(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = delete.from(PrintJobStatusExtImpl.class); delete.where(builder.and(builder.isNotNull(root.get("lastCheckTime")), builder.lessThan(root.get("lastCheckTime"), checkTimeThreshold))); return getSession().createQuery(delete).executeUpdate(); }
[ "public", "final", "int", "deleteOld", "(", "final", "long", "checkTimeThreshold", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaDelete", "<", "PrintJobStatusExtImpl", ">",...
Delete old jobs. @param checkTimeThreshold threshold for last check time @return the number of jobs deleted
[ "Delete", "old", "jobs", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L205-L213
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.poll
public final List<PrintJobStatusExtImpl> poll(final int size) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<PrintJobStatusExtImpl> criteria = builder.createQuery(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = criteria.from(PrintJobStatusExtImpl.class); root.alias("pj"); criteria.where(builder.equal(root.get("status"), PrintJobStatus.Status.WAITING)); criteria.orderBy(builder.asc(root.get("entry").get("startTime"))); final Query<PrintJobStatusExtImpl> query = getSession().createQuery(criteria); query.setMaxResults(size); // LOCK but don't wait for release (since this is run continuously // anyway, no wait prevents deadlock) query.setLockMode("pj", LockMode.UPGRADE_NOWAIT); try { return query.getResultList(); } catch (PessimisticLockException ex) { // Another process was polling at the same time. We can ignore this error return Collections.emptyList(); } }
java
public final List<PrintJobStatusExtImpl> poll(final int size) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<PrintJobStatusExtImpl> criteria = builder.createQuery(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = criteria.from(PrintJobStatusExtImpl.class); root.alias("pj"); criteria.where(builder.equal(root.get("status"), PrintJobStatus.Status.WAITING)); criteria.orderBy(builder.asc(root.get("entry").get("startTime"))); final Query<PrintJobStatusExtImpl> query = getSession().createQuery(criteria); query.setMaxResults(size); // LOCK but don't wait for release (since this is run continuously // anyway, no wait prevents deadlock) query.setLockMode("pj", LockMode.UPGRADE_NOWAIT); try { return query.getResultList(); } catch (PessimisticLockException ex) { // Another process was polling at the same time. We can ignore this error return Collections.emptyList(); } }
[ "public", "final", "List", "<", "PrintJobStatusExtImpl", ">", "poll", "(", "final", "int", "size", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaQuery", "<", "PrintJobS...
Poll for the next N waiting jobs in line. @param size maximum amount of jobs to poll for @return up to "size" jobs
[ "Poll", "for", "the", "next", "N", "waiting", "jobs", "in", "line", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L221-L240
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.getResult
public final PrintJobResultExtImpl getResult(final URI reportURI) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<PrintJobResultExtImpl> criteria = builder.createQuery(PrintJobResultExtImpl.class); final Root<PrintJobResultExtImpl> root = criteria.from(PrintJobResultExtImpl.class); criteria.where(builder.equal(root.get("reportURI"), reportURI.toString())); return getSession().createQuery(criteria).uniqueResult(); }
java
public final PrintJobResultExtImpl getResult(final URI reportURI) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaQuery<PrintJobResultExtImpl> criteria = builder.createQuery(PrintJobResultExtImpl.class); final Root<PrintJobResultExtImpl> root = criteria.from(PrintJobResultExtImpl.class); criteria.where(builder.equal(root.get("reportURI"), reportURI.toString())); return getSession().createQuery(criteria).uniqueResult(); }
[ "public", "final", "PrintJobResultExtImpl", "getResult", "(", "final", "URI", "reportURI", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaQuery", "<", "PrintJobResultExtImpl",...
Get result report. @param reportURI the URI of the report @return the result report.
[ "Get", "result", "report", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L248-L255
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java
PrintJobDao.delete
public void delete(final String referenceId) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaDelete<PrintJobStatusExtImpl> delete = builder.createCriteriaDelete(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = delete.from(PrintJobStatusExtImpl.class); delete.where(builder.equal(root.get("referenceId"), referenceId)); getSession().createQuery(delete).executeUpdate(); }
java
public void delete(final String referenceId) { final CriteriaBuilder builder = getSession().getCriteriaBuilder(); final CriteriaDelete<PrintJobStatusExtImpl> delete = builder.createCriteriaDelete(PrintJobStatusExtImpl.class); final Root<PrintJobStatusExtImpl> root = delete.from(PrintJobStatusExtImpl.class); delete.where(builder.equal(root.get("referenceId"), referenceId)); getSession().createQuery(delete).executeUpdate(); }
[ "public", "void", "delete", "(", "final", "String", "referenceId", ")", "{", "final", "CriteriaBuilder", "builder", "=", "getSession", "(", ")", ".", "getCriteriaBuilder", "(", ")", ";", "final", "CriteriaDelete", "<", "PrintJobStatusExtImpl", ">", "delete", "="...
Delete a record. @param referenceId the reference ID.
[ "Delete", "a", "record", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/hibernate/PrintJobDao.java#L262-L269
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/PrintJobEntryImpl.java
PrintJobEntryImpl.configureAccess
public final void configureAccess(final Template template, final ApplicationContext context) { final Configuration configuration = template.getConfiguration(); AndAccessAssertion accessAssertion = context.getBean(AndAccessAssertion.class); accessAssertion.setPredicates(configuration.getAccessAssertion(), template.getAccessAssertion()); this.access = accessAssertion; }
java
public final void configureAccess(final Template template, final ApplicationContext context) { final Configuration configuration = template.getConfiguration(); AndAccessAssertion accessAssertion = context.getBean(AndAccessAssertion.class); accessAssertion.setPredicates(configuration.getAccessAssertion(), template.getAccessAssertion()); this.access = accessAssertion; }
[ "public", "final", "void", "configureAccess", "(", "final", "Template", "template", ",", "final", "ApplicationContext", "context", ")", "{", "final", "Configuration", "configuration", "=", "template", ".", "getConfiguration", "(", ")", ";", "AndAccessAssertion", "ac...
Configure the access permissions required to access this print job. @param template the containing print template which should have sufficient information to configure the access. @param context the application context
[ "Configure", "the", "access", "permissions", "required", "to", "access", "this", "print", "job", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/PrintJobEntryImpl.java#L144-L150
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/geotools/AbstractGridCoverageLayerPlugin.java
AbstractGridCoverageLayerPlugin.createStyleSupplier
protected final <T> StyleSupplier<T> createStyleSupplier( final Template template, final String styleRef) { return new StyleSupplier<T>() { @Override public Style load( final MfClientHttpRequestFactory requestFactory, final T featureSource) { final StyleParser parser = AbstractGridCoverageLayerPlugin.this.styleParser; return OptionalUtils.or( () -> template.getStyle(styleRef), () -> parser.loadStyle(template.getConfiguration(), requestFactory, styleRef)) .orElse(template.getConfiguration().getDefaultStyle(NAME)); } }; }
java
protected final <T> StyleSupplier<T> createStyleSupplier( final Template template, final String styleRef) { return new StyleSupplier<T>() { @Override public Style load( final MfClientHttpRequestFactory requestFactory, final T featureSource) { final StyleParser parser = AbstractGridCoverageLayerPlugin.this.styleParser; return OptionalUtils.or( () -> template.getStyle(styleRef), () -> parser.loadStyle(template.getConfiguration(), requestFactory, styleRef)) .orElse(template.getConfiguration().getDefaultStyle(NAME)); } }; }
[ "protected", "final", "<", "T", ">", "StyleSupplier", "<", "T", ">", "createStyleSupplier", "(", "final", "Template", "template", ",", "final", "String", "styleRef", ")", "{", "return", "new", "StyleSupplier", "<", "T", ">", "(", ")", "{", "@", "Override",...
Common method for creating styles. @param template the template that the map is part of @param styleRef the style ref identifying the style @param <T> the source type
[ "Common", "method", "for", "creating", "styles", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/geotools/AbstractGridCoverageLayerPlugin.java#L27-L42
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/job/impl/RegistryJobQueue.java
RegistryJobQueue.store
private void store(final PrintJobStatus printJobStatus) throws JSONException { JSONObject metadata = new JSONObject(); metadata.put(JSON_REQUEST_DATA, printJobStatus.getEntry().getRequestData().getInternalObj()); metadata.put(JSON_STATUS, printJobStatus.getStatus().toString()); metadata.put(JSON_START_DATE, printJobStatus.getStartTime()); metadata.put(JSON_REQUEST_COUNT, printJobStatus.getRequestCount()); if (printJobStatus.getCompletionDate() != null) { metadata.put(JSON_COMPLETION_DATE, printJobStatus.getCompletionTime()); } metadata.put(JSON_ACCESS_ASSERTION, this.assertionPersister.marshal(printJobStatus.getAccess())); if (printJobStatus.getError() != null) { metadata.put(JSON_ERROR, printJobStatus.getError()); } if (printJobStatus.getResult() != null) { metadata.put(JSON_REPORT_URI, printJobStatus.getResult().getReportURIString()); metadata.put(JSON_FILENAME, printJobStatus.getResult().getFileName()); metadata.put(JSON_FILE_EXT, printJobStatus.getResult().getFileExtension()); metadata.put(JSON_MIME_TYPE, printJobStatus.getResult().getMimeType()); } this.registry.put(RESULT_METADATA + printJobStatus.getReferenceId(), metadata); }
java
private void store(final PrintJobStatus printJobStatus) throws JSONException { JSONObject metadata = new JSONObject(); metadata.put(JSON_REQUEST_DATA, printJobStatus.getEntry().getRequestData().getInternalObj()); metadata.put(JSON_STATUS, printJobStatus.getStatus().toString()); metadata.put(JSON_START_DATE, printJobStatus.getStartTime()); metadata.put(JSON_REQUEST_COUNT, printJobStatus.getRequestCount()); if (printJobStatus.getCompletionDate() != null) { metadata.put(JSON_COMPLETION_DATE, printJobStatus.getCompletionTime()); } metadata.put(JSON_ACCESS_ASSERTION, this.assertionPersister.marshal(printJobStatus.getAccess())); if (printJobStatus.getError() != null) { metadata.put(JSON_ERROR, printJobStatus.getError()); } if (printJobStatus.getResult() != null) { metadata.put(JSON_REPORT_URI, printJobStatus.getResult().getReportURIString()); metadata.put(JSON_FILENAME, printJobStatus.getResult().getFileName()); metadata.put(JSON_FILE_EXT, printJobStatus.getResult().getFileExtension()); metadata.put(JSON_MIME_TYPE, printJobStatus.getResult().getMimeType()); } this.registry.put(RESULT_METADATA + printJobStatus.getReferenceId(), metadata); }
[ "private", "void", "store", "(", "final", "PrintJobStatus", "printJobStatus", ")", "throws", "JSONException", "{", "JSONObject", "metadata", "=", "new", "JSONObject", "(", ")", ";", "metadata", ".", "put", "(", "JSON_REQUEST_DATA", ",", "printJobStatus", ".", "g...
Store the data of a print job in the registry. @param printJobStatus the print job status
[ "Store", "the", "data", "of", "a", "print", "job", "in", "the", "registry", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/job/impl/RegistryJobQueue.java#L226-L246
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/style/json/ColorParser.java
ColorParser.canParseColor
public static boolean canParseColor(final String colorString) { try { return ColorParser.toColor(colorString) != null; } catch (Exception exc) { return false; } }
java
public static boolean canParseColor(final String colorString) { try { return ColorParser.toColor(colorString) != null; } catch (Exception exc) { return false; } }
[ "public", "static", "boolean", "canParseColor", "(", "final", "String", "colorString", ")", "{", "try", "{", "return", "ColorParser", ".", "toColor", "(", "colorString", ")", "!=", "null", ";", "}", "catch", "(", "Exception", "exc", ")", "{", "return", "fa...
Check if the given color string can be parsed. @param colorString The color to parse.
[ "Check", "if", "the", "given", "color", "string", "can", "be", "parsed", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/style/json/ColorParser.java#L283-L289
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/processor/map/SetTiledWmsProcessor.java
SetTiledWmsProcessor.adaptTileDimensions
private static Dimension adaptTileDimensions( final Dimension pixels, final int maxWidth, final int maxHeight) { return new Dimension(adaptTileDimension(pixels.width, maxWidth), adaptTileDimension(pixels.height, maxHeight)); }
java
private static Dimension adaptTileDimensions( final Dimension pixels, final int maxWidth, final int maxHeight) { return new Dimension(adaptTileDimension(pixels.width, maxWidth), adaptTileDimension(pixels.height, maxHeight)); }
[ "private", "static", "Dimension", "adaptTileDimensions", "(", "final", "Dimension", "pixels", ",", "final", "int", "maxWidth", ",", "final", "int", "maxHeight", ")", "{", "return", "new", "Dimension", "(", "adaptTileDimension", "(", "pixels", ".", "width", ",", ...
Adapt the size of the tiles so that we have the same amount of tiles as we would have had with maxWidth and maxHeight, but with the smallest tiles as possible.
[ "Adapt", "the", "size", "of", "the", "tiles", "so", "that", "we", "have", "the", "same", "amount", "of", "tiles", "as", "we", "would", "have", "had", "with", "maxWidth", "and", "maxHeight", "but", "with", "the", "smallest", "tiles", "as", "possible", "."...
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/processor/map/SetTiledWmsProcessor.java#L67-L71
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/URIUtils.java
URIUtils.getParameters
public static Multimap<String, String> getParameters(final String rawQuery) { Multimap<String, String> result = HashMultimap.create(); if (rawQuery == null) { return result; } StringTokenizer tokens = new StringTokenizer(rawQuery, "&"); while (tokens.hasMoreTokens()) { String pair = tokens.nextToken(); int pos = pair.indexOf('='); String key; String value; if (pos == -1) { key = pair; value = ""; } else { try { key = URLDecoder.decode(pair.substring(0, pos), "UTF-8"); value = URLDecoder.decode(pair.substring(pos + 1), "UTF-8"); } catch (UnsupportedEncodingException e) { throw ExceptionUtils.getRuntimeException(e); } } result.put(key, value); } return result; }
java
public static Multimap<String, String> getParameters(final String rawQuery) { Multimap<String, String> result = HashMultimap.create(); if (rawQuery == null) { return result; } StringTokenizer tokens = new StringTokenizer(rawQuery, "&"); while (tokens.hasMoreTokens()) { String pair = tokens.nextToken(); int pos = pair.indexOf('='); String key; String value; if (pos == -1) { key = pair; value = ""; } else { try { key = URLDecoder.decode(pair.substring(0, pos), "UTF-8"); value = URLDecoder.decode(pair.substring(pos + 1), "UTF-8"); } catch (UnsupportedEncodingException e) { throw ExceptionUtils.getRuntimeException(e); } } result.put(key, value); } return result; }
[ "public", "static", "Multimap", "<", "String", ",", "String", ">", "getParameters", "(", "final", "String", "rawQuery", ")", "{", "Multimap", "<", "String", ",", "String", ">", "result", "=", "HashMultimap", ".", "create", "(", ")", ";", "if", "(", "rawQ...
Parse the URI and get all the parameters in map form. Query name -&gt; List of Query values. @param rawQuery query portion of the uri to analyze.
[ "Parse", "the", "URI", "and", "get", "all", "the", "parameters", "in", "map", "form", ".", "Query", "name", "-", "&gt", ";", "List", "of", "Query", "values", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/URIUtils.java#L44-L72
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/URIUtils.java
URIUtils.setQueryParams
public static URI setQueryParams(final URI initialUri, final Multimap<String, String> queryParams) { StringBuilder queryString = new StringBuilder(); for (Map.Entry<String, String> entry: queryParams.entries()) { if (queryString.length() > 0) { queryString.append("&"); } queryString.append(entry.getKey()).append("=").append(entry.getValue()); } try { if (initialUri.getHost() == null && initialUri.getAuthority() != null) { return new URI(initialUri.getScheme(), initialUri.getAuthority(), initialUri.getPath(), queryString.toString(), initialUri.getFragment()); } else { return new URI(initialUri.getScheme(), initialUri.getUserInfo(), initialUri.getHost(), initialUri.getPort(), initialUri.getPath(), queryString.toString(), initialUri.getFragment()); } } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } }
java
public static URI setQueryParams(final URI initialUri, final Multimap<String, String> queryParams) { StringBuilder queryString = new StringBuilder(); for (Map.Entry<String, String> entry: queryParams.entries()) { if (queryString.length() > 0) { queryString.append("&"); } queryString.append(entry.getKey()).append("=").append(entry.getValue()); } try { if (initialUri.getHost() == null && initialUri.getAuthority() != null) { return new URI(initialUri.getScheme(), initialUri.getAuthority(), initialUri.getPath(), queryString.toString(), initialUri.getFragment()); } else { return new URI(initialUri.getScheme(), initialUri.getUserInfo(), initialUri.getHost(), initialUri.getPort(), initialUri.getPath(), queryString.toString(), initialUri.getFragment()); } } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } }
[ "public", "static", "URI", "setQueryParams", "(", "final", "URI", "initialUri", ",", "final", "Multimap", "<", "String", ",", "String", ">", "queryParams", ")", "{", "StringBuilder", "queryString", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Map...
Construct a new uri by replacing query parameters in initialUri with the query parameters provided. @param initialUri the initial/template URI @param queryParams the new query parameters.
[ "Construct", "a", "new", "uri", "by", "replacing", "query", "parameters", "in", "initialUri", "with", "the", "query", "parameters", "provided", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/URIUtils.java#L200-L222
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/URIUtils.java
URIUtils.setPath
public static URI setPath(final URI initialUri, final String path) { String finalPath = path; if (!finalPath.startsWith("/")) { finalPath = '/' + path; } try { if (initialUri.getHost() == null && initialUri.getAuthority() != null) { return new URI(initialUri.getScheme(), initialUri.getAuthority(), finalPath, initialUri.getQuery(), initialUri.getFragment()); } else { return new URI(initialUri.getScheme(), initialUri.getUserInfo(), initialUri.getHost(), initialUri.getPort(), finalPath, initialUri.getQuery(), initialUri.getFragment()); } } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } }
java
public static URI setPath(final URI initialUri, final String path) { String finalPath = path; if (!finalPath.startsWith("/")) { finalPath = '/' + path; } try { if (initialUri.getHost() == null && initialUri.getAuthority() != null) { return new URI(initialUri.getScheme(), initialUri.getAuthority(), finalPath, initialUri.getQuery(), initialUri.getFragment()); } else { return new URI(initialUri.getScheme(), initialUri.getUserInfo(), initialUri.getHost(), initialUri.getPort(), finalPath, initialUri.getQuery(), initialUri.getFragment()); } } catch (URISyntaxException e) { throw ExceptionUtils.getRuntimeException(e); } }
[ "public", "static", "URI", "setPath", "(", "final", "URI", "initialUri", ",", "final", "String", "path", ")", "{", "String", "finalPath", "=", "path", ";", "if", "(", "!", "finalPath", ".", "startsWith", "(", "\"/\"", ")", ")", "{", "finalPath", "=", "...
Set the replace of the uri and return the new URI. @param initialUri the starting URI, the URI to update @param path the path to set on the baeURI
[ "Set", "the", "replace", "of", "the", "uri", "and", "return", "the", "new", "URI", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/URIUtils.java#L260-L278
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/wrapper/yaml/PYamlArray.java
PYamlArray.toJSON
public final PJsonArray toJSON() { JSONArray jsonArray = new JSONArray(); final int size = this.array.size(); for (int i = 0; i < size; i++) { final Object o = get(i); if (o instanceof PYamlObject) { PYamlObject pYamlObject = (PYamlObject) o; jsonArray.put(pYamlObject.toJSON().getInternalObj()); } else if (o instanceof PYamlArray) { PYamlArray pYamlArray = (PYamlArray) o; jsonArray.put(pYamlArray.toJSON().getInternalArray()); } else { jsonArray.put(o); } } return new PJsonArray(null, jsonArray, getContextName()); }
java
public final PJsonArray toJSON() { JSONArray jsonArray = new JSONArray(); final int size = this.array.size(); for (int i = 0; i < size; i++) { final Object o = get(i); if (o instanceof PYamlObject) { PYamlObject pYamlObject = (PYamlObject) o; jsonArray.put(pYamlObject.toJSON().getInternalObj()); } else if (o instanceof PYamlArray) { PYamlArray pYamlArray = (PYamlArray) o; jsonArray.put(pYamlArray.toJSON().getInternalArray()); } else { jsonArray.put(o); } } return new PJsonArray(null, jsonArray, getContextName()); }
[ "public", "final", "PJsonArray", "toJSON", "(", ")", "{", "JSONArray", "jsonArray", "=", "new", "JSONArray", "(", ")", ";", "final", "int", "size", "=", "this", ".", "array", ".", "size", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", ...
Convert this object to a json array.
[ "Convert", "this", "object", "to", "a", "json", "array", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/wrapper/yaml/PYamlArray.java#L125-L142
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/fileloader/ConfigFileLoaderManager.java
ConfigFileLoaderManager.checkUniqueSchemes
@PostConstruct public void checkUniqueSchemes() { Multimap<String, ConfigFileLoaderPlugin> schemeToPluginMap = HashMultimap.create(); for (ConfigFileLoaderPlugin plugin: getLoaderPlugins()) { schemeToPluginMap.put(plugin.getUriScheme(), plugin); } StringBuilder violations = new StringBuilder(); for (String scheme: schemeToPluginMap.keySet()) { final Collection<ConfigFileLoaderPlugin> plugins = schemeToPluginMap.get(scheme); if (plugins.size() > 1) { violations.append("\n\n* ").append("There are has multiple ") .append(ConfigFileLoaderPlugin.class.getSimpleName()) .append(" plugins that support the scheme: '").append(scheme).append('\'') .append(":\n\t").append(plugins); } } if (violations.length() > 0) { throw new IllegalStateException(violations.toString()); } }
java
@PostConstruct public void checkUniqueSchemes() { Multimap<String, ConfigFileLoaderPlugin> schemeToPluginMap = HashMultimap.create(); for (ConfigFileLoaderPlugin plugin: getLoaderPlugins()) { schemeToPluginMap.put(plugin.getUriScheme(), plugin); } StringBuilder violations = new StringBuilder(); for (String scheme: schemeToPluginMap.keySet()) { final Collection<ConfigFileLoaderPlugin> plugins = schemeToPluginMap.get(scheme); if (plugins.size() > 1) { violations.append("\n\n* ").append("There are has multiple ") .append(ConfigFileLoaderPlugin.class.getSimpleName()) .append(" plugins that support the scheme: '").append(scheme).append('\'') .append(":\n\t").append(plugins); } } if (violations.length() > 0) { throw new IllegalStateException(violations.toString()); } }
[ "@", "PostConstruct", "public", "void", "checkUniqueSchemes", "(", ")", "{", "Multimap", "<", "String", ",", "ConfigFileLoaderPlugin", ">", "schemeToPluginMap", "=", "HashMultimap", ".", "create", "(", ")", ";", "for", "(", "ConfigFileLoaderPlugin", "plugin", ":",...
Method is called by spring and verifies that there is only one plugin per URI scheme.
[ "Method", "is", "called", "by", "spring", "and", "verifies", "that", "there", "is", "only", "one", "plugin", "per", "URI", "scheme", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/fileloader/ConfigFileLoaderManager.java#L34-L56
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/servlet/fileloader/ConfigFileLoaderManager.java
ConfigFileLoaderManager.getSupportedUriSchemes
public Set<String> getSupportedUriSchemes() { Set<String> schemes = new HashSet<>(); for (ConfigFileLoaderPlugin loaderPlugin: this.getLoaderPlugins()) { schemes.add(loaderPlugin.getUriScheme()); } return schemes; }
java
public Set<String> getSupportedUriSchemes() { Set<String> schemes = new HashSet<>(); for (ConfigFileLoaderPlugin loaderPlugin: this.getLoaderPlugins()) { schemes.add(loaderPlugin.getUriScheme()); } return schemes; }
[ "public", "Set", "<", "String", ">", "getSupportedUriSchemes", "(", ")", "{", "Set", "<", "String", ">", "schemes", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "ConfigFileLoaderPlugin", "loaderPlugin", ":", "this", ".", "getLoaderPlugins", "(", ...
Return all URI schemes that are supported in the system.
[ "Return", "all", "URI", "schemes", "that", "are", "supported", "in", "the", "system", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/servlet/fileloader/ConfigFileLoaderManager.java#L79-L87
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/GenericMapAttribute.java
GenericMapAttribute.parseProjection
public static CoordinateReferenceSystem parseProjection( final String projection, final Boolean longitudeFirst) { try { if (longitudeFirst == null) { return CRS.decode(projection); } else { return CRS.decode(projection, longitudeFirst); } } catch (NoSuchAuthorityCodeException e) { throw new RuntimeException(projection + " was not recognized as a crs code", e); } catch (FactoryException e) { throw new RuntimeException("Error occurred while parsing: " + projection, e); } }
java
public static CoordinateReferenceSystem parseProjection( final String projection, final Boolean longitudeFirst) { try { if (longitudeFirst == null) { return CRS.decode(projection); } else { return CRS.decode(projection, longitudeFirst); } } catch (NoSuchAuthorityCodeException e) { throw new RuntimeException(projection + " was not recognized as a crs code", e); } catch (FactoryException e) { throw new RuntimeException("Error occurred while parsing: " + projection, e); } }
[ "public", "static", "CoordinateReferenceSystem", "parseProjection", "(", "final", "String", "projection", ",", "final", "Boolean", "longitudeFirst", ")", "{", "try", "{", "if", "(", "longitudeFirst", "==", "null", ")", "{", "return", "CRS", ".", "decode", "(", ...
Parse the given projection. @param projection The projection string. @param longitudeFirst longitudeFirst
[ "Parse", "the", "given", "projection", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/GenericMapAttribute.java#L84-L97
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/attribute/map/GenericMapAttribute.java
GenericMapAttribute.getDpiSuggestions
public final double[] getDpiSuggestions() { if (this.dpiSuggestions == null) { List<Double> list = new ArrayList<>(); for (double suggestion: DEFAULT_DPI_VALUES) { if (suggestion <= this.maxDpi) { list.add(suggestion); } } double[] suggestions = new double[list.size()]; for (int i = 0; i < suggestions.length; i++) { suggestions[i] = list.get(i); } return suggestions; } return this.dpiSuggestions; }
java
public final double[] getDpiSuggestions() { if (this.dpiSuggestions == null) { List<Double> list = new ArrayList<>(); for (double suggestion: DEFAULT_DPI_VALUES) { if (suggestion <= this.maxDpi) { list.add(suggestion); } } double[] suggestions = new double[list.size()]; for (int i = 0; i < suggestions.length; i++) { suggestions[i] = list.get(i); } return suggestions; } return this.dpiSuggestions; }
[ "public", "final", "double", "[", "]", "getDpiSuggestions", "(", ")", "{", "if", "(", "this", ".", "dpiSuggestions", "==", "null", ")", "{", "List", "<", "Double", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "double", "sugg...
Get DPI suggestions. @return DPI suggestions
[ "Get", "DPI", "suggestions", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/attribute/map/GenericMapAttribute.java#L119-L134
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java
AbstractSingleImageLayer.createErrorImage
protected BufferedImage createErrorImage(final Rectangle area) { final BufferedImage bufferedImage = new BufferedImage(area.width, area.height, TYPE_INT_ARGB_PRE); final Graphics2D graphics = bufferedImage.createGraphics(); try { graphics.setBackground(ColorParser.toColor(this.configuration.getTransparentTileErrorColor())); graphics.clearRect(0, 0, area.width, area.height); return bufferedImage; } finally { graphics.dispose(); } }
java
protected BufferedImage createErrorImage(final Rectangle area) { final BufferedImage bufferedImage = new BufferedImage(area.width, area.height, TYPE_INT_ARGB_PRE); final Graphics2D graphics = bufferedImage.createGraphics(); try { graphics.setBackground(ColorParser.toColor(this.configuration.getTransparentTileErrorColor())); graphics.clearRect(0, 0, area.width, area.height); return bufferedImage; } finally { graphics.dispose(); } }
[ "protected", "BufferedImage", "createErrorImage", "(", "final", "Rectangle", "area", ")", "{", "final", "BufferedImage", "bufferedImage", "=", "new", "BufferedImage", "(", "area", ".", "width", ",", "area", ".", "height", ",", "TYPE_INT_ARGB_PRE", ")", ";", "fin...
Create an error image. @param area The size of the image
[ "Create", "an", "error", "image", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java#L133-L143
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java
AbstractSingleImageLayer.fetchImage
protected BufferedImage fetchImage( @Nonnull final ClientHttpRequest request, @Nonnull final MapfishMapContext transformer) throws IOException { final String baseMetricName = getClass().getName() + ".read." + StatsUtils.quotePart(request.getURI().getHost()); final Timer.Context timerDownload = this.registry.timer(baseMetricName).time(); try (ClientHttpResponse httpResponse = request.execute()) { if (httpResponse.getStatusCode() != HttpStatus.OK) { final String message = String.format( "Invalid status code for %s (%d!=%d). The response was: '%s'", request.getURI(), httpResponse.getStatusCode().value(), HttpStatus.OK.value(), httpResponse.getStatusText()); this.registry.counter(baseMetricName + ".error").inc(); if (getFailOnError()) { throw new RuntimeException(message); } else { LOGGER.info(message); return createErrorImage(transformer.getPaintArea()); } } final List<String> contentType = httpResponse.getHeaders().get("Content-Type"); if (contentType == null || contentType.size() != 1) { LOGGER.debug("The image {} didn't return a valid content type header.", request.getURI()); } else if (!contentType.get(0).startsWith("image/")) { final byte[] data; try (InputStream body = httpResponse.getBody()) { data = IOUtils.toByteArray(body); } LOGGER.debug("We get a wrong image for {}, content type: {}\nresult:\n{}", request.getURI(), contentType.get(0), new String(data, StandardCharsets.UTF_8)); this.registry.counter(baseMetricName + ".error").inc(); return createErrorImage(transformer.getPaintArea()); } final BufferedImage image = ImageIO.read(httpResponse.getBody()); if (image == null) { LOGGER.warn("Cannot read image from %a", request.getURI()); this.registry.counter(baseMetricName + ".error").inc(); if (getFailOnError()) { throw new RuntimeException("Cannot read image from " + request.getURI()); } else { return createErrorImage(transformer.getPaintArea()); } } timerDownload.stop(); return image; } catch (Throwable e) { this.registry.counter(baseMetricName + ".error").inc(); throw e; } }
java
protected BufferedImage fetchImage( @Nonnull final ClientHttpRequest request, @Nonnull final MapfishMapContext transformer) throws IOException { final String baseMetricName = getClass().getName() + ".read." + StatsUtils.quotePart(request.getURI().getHost()); final Timer.Context timerDownload = this.registry.timer(baseMetricName).time(); try (ClientHttpResponse httpResponse = request.execute()) { if (httpResponse.getStatusCode() != HttpStatus.OK) { final String message = String.format( "Invalid status code for %s (%d!=%d). The response was: '%s'", request.getURI(), httpResponse.getStatusCode().value(), HttpStatus.OK.value(), httpResponse.getStatusText()); this.registry.counter(baseMetricName + ".error").inc(); if (getFailOnError()) { throw new RuntimeException(message); } else { LOGGER.info(message); return createErrorImage(transformer.getPaintArea()); } } final List<String> contentType = httpResponse.getHeaders().get("Content-Type"); if (contentType == null || contentType.size() != 1) { LOGGER.debug("The image {} didn't return a valid content type header.", request.getURI()); } else if (!contentType.get(0).startsWith("image/")) { final byte[] data; try (InputStream body = httpResponse.getBody()) { data = IOUtils.toByteArray(body); } LOGGER.debug("We get a wrong image for {}, content type: {}\nresult:\n{}", request.getURI(), contentType.get(0), new String(data, StandardCharsets.UTF_8)); this.registry.counter(baseMetricName + ".error").inc(); return createErrorImage(transformer.getPaintArea()); } final BufferedImage image = ImageIO.read(httpResponse.getBody()); if (image == null) { LOGGER.warn("Cannot read image from %a", request.getURI()); this.registry.counter(baseMetricName + ".error").inc(); if (getFailOnError()) { throw new RuntimeException("Cannot read image from " + request.getURI()); } else { return createErrorImage(transformer.getPaintArea()); } } timerDownload.stop(); return image; } catch (Throwable e) { this.registry.counter(baseMetricName + ".error").inc(); throw e; } }
[ "protected", "BufferedImage", "fetchImage", "(", "@", "Nonnull", "final", "ClientHttpRequest", "request", ",", "@", "Nonnull", "final", "MapfishMapContext", "transformer", ")", "throws", "IOException", "{", "final", "String", "baseMetricName", "=", "getClass", "(", ...
Fetch the given image from the web. @param request The request @param transformer The transformer @return The image
[ "Fetch", "the", "given", "image", "from", "the", "web", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/map/image/AbstractSingleImageLayer.java#L152-L205
train
mapfish/mapfish-print
core/src/main/java/org/mapfish/print/SetsUtils.java
SetsUtils.create
@SafeVarargs public static <T> Set<T> create(final T... values) { Set<T> result = new HashSet<>(values.length); Collections.addAll(result, values); return result; }
java
@SafeVarargs public static <T> Set<T> create(final T... values) { Set<T> result = new HashSet<>(values.length); Collections.addAll(result, values); return result; }
[ "@", "SafeVarargs", "public", "static", "<", "T", ">", "Set", "<", "T", ">", "create", "(", "final", "T", "...", "values", ")", "{", "Set", "<", "T", ">", "result", "=", "new", "HashSet", "<>", "(", "values", ".", "length", ")", ";", "Collections",...
Create a HashSet with the given initial values. @param values The values @param <T> The type.
[ "Create", "a", "HashSet", "with", "the", "given", "initial", "values", "." ]
25a452cb39f592bd8a53b20db1037703898e1e22
https://github.com/mapfish/mapfish-print/blob/25a452cb39f592bd8a53b20db1037703898e1e22/core/src/main/java/org/mapfish/print/SetsUtils.java#L20-L25
train
mjiderhamn/classloader-leak-prevention
classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/ShutdownHookCleanUp.java
ShutdownHookCleanUp.removeShutdownHook
@SuppressWarnings({"deprecation", "WeakerAccess"}) protected void removeShutdownHook(ClassLoaderLeakPreventor preventor, Thread shutdownHook) { final String displayString = "'" + shutdownHook + "' of type " + shutdownHook.getClass().getName(); preventor.error("Removing shutdown hook: " + displayString); Runtime.getRuntime().removeShutdownHook(shutdownHook); if(executeShutdownHooks) { // Shutdown hooks should be executed preventor.info("Executing shutdown hook now: " + displayString); // Make sure it's from protected ClassLoader shutdownHook.start(); // Run cleanup immediately if(shutdownHookWaitMs > 0) { // Wait for shutdown hook to finish try { shutdownHook.join(shutdownHookWaitMs); // Wait for thread to run } catch (InterruptedException e) { // Do nothing } if(shutdownHook.isAlive()) { preventor.warn(shutdownHook + "still running after " + shutdownHookWaitMs + " ms - Stopping!"); shutdownHook.stop(); } } } }
java
@SuppressWarnings({"deprecation", "WeakerAccess"}) protected void removeShutdownHook(ClassLoaderLeakPreventor preventor, Thread shutdownHook) { final String displayString = "'" + shutdownHook + "' of type " + shutdownHook.getClass().getName(); preventor.error("Removing shutdown hook: " + displayString); Runtime.getRuntime().removeShutdownHook(shutdownHook); if(executeShutdownHooks) { // Shutdown hooks should be executed preventor.info("Executing shutdown hook now: " + displayString); // Make sure it's from protected ClassLoader shutdownHook.start(); // Run cleanup immediately if(shutdownHookWaitMs > 0) { // Wait for shutdown hook to finish try { shutdownHook.join(shutdownHookWaitMs); // Wait for thread to run } catch (InterruptedException e) { // Do nothing } if(shutdownHook.isAlive()) { preventor.warn(shutdownHook + "still running after " + shutdownHookWaitMs + " ms - Stopping!"); shutdownHook.stop(); } } } }
[ "@", "SuppressWarnings", "(", "{", "\"deprecation\"", ",", "\"WeakerAccess\"", "}", ")", "protected", "void", "removeShutdownHook", "(", "ClassLoaderLeakPreventor", "preventor", ",", "Thread", "shutdownHook", ")", "{", "final", "String", "displayString", "=", "\"'\"",...
Deregister shutdown hook and execute it immediately
[ "Deregister", "shutdown", "hook", "and", "execute", "it", "immediately" ]
eea8e3cef64f8096dbbb87552df0a1bd272bcb63
https://github.com/mjiderhamn/classloader-leak-prevention/blob/eea8e3cef64f8096dbbb87552df0a1bd272bcb63/classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/ShutdownHookCleanUp.java#L65-L90
train
mjiderhamn/classloader-leak-prevention
classloader-leak-prevention/classloader-leak-prevention-servlet/src/main/java/se/jiderhamn/classloader/leak/prevention/ClassLoaderLeakPreventorListener.java
ClassLoaderLeakPreventorListener.getIntInitParameter
protected static int getIntInitParameter(ServletContext servletContext, String parameterName, int defaultValue) { final String parameterString = servletContext.getInitParameter(parameterName); if(parameterString != null && parameterString.trim().length() > 0) { try { return Integer.parseInt(parameterString); } catch (NumberFormatException e) { // Do nothing, return default value } } return defaultValue; }
java
protected static int getIntInitParameter(ServletContext servletContext, String parameterName, int defaultValue) { final String parameterString = servletContext.getInitParameter(parameterName); if(parameterString != null && parameterString.trim().length() > 0) { try { return Integer.parseInt(parameterString); } catch (NumberFormatException e) { // Do nothing, return default value } } return defaultValue; }
[ "protected", "static", "int", "getIntInitParameter", "(", "ServletContext", "servletContext", ",", "String", "parameterName", ",", "int", "defaultValue", ")", "{", "final", "String", "parameterString", "=", "servletContext", ".", "getInitParameter", "(", "parameterName"...
Parse init parameter for integer value, returning default if not found or invalid
[ "Parse", "init", "parameter", "for", "integer", "value", "returning", "default", "if", "not", "found", "or", "invalid" ]
eea8e3cef64f8096dbbb87552df0a1bd272bcb63
https://github.com/mjiderhamn/classloader-leak-prevention/blob/eea8e3cef64f8096dbbb87552df0a1bd272bcb63/classloader-leak-prevention/classloader-leak-prevention-servlet/src/main/java/se/jiderhamn/classloader/leak/prevention/ClassLoaderLeakPreventorListener.java#L255-L266
train
mjiderhamn/classloader-leak-prevention
classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/RmiTargetsCleanUp.java
RmiTargetsCleanUp.clearRmiTargetsMap
@SuppressWarnings("WeakerAccess") protected void clearRmiTargetsMap(ClassLoaderLeakPreventor preventor, Map<?, ?> rmiTargetsMap) { try { final Field cclField = preventor.findFieldOfClass("sun.rmi.transport.Target", "ccl"); preventor.debug("Looping " + rmiTargetsMap.size() + " RMI Targets to find leaks"); for(Iterator<?> iter = rmiTargetsMap.values().iterator(); iter.hasNext(); ) { Object target = iter.next(); // sun.rmi.transport.Target ClassLoader ccl = (ClassLoader) cclField.get(target); if(preventor.isClassLoaderOrChild(ccl)) { preventor.warn("Removing RMI Target: " + target); iter.remove(); } } } catch (Exception ex) { preventor.error(ex); } }
java
@SuppressWarnings("WeakerAccess") protected void clearRmiTargetsMap(ClassLoaderLeakPreventor preventor, Map<?, ?> rmiTargetsMap) { try { final Field cclField = preventor.findFieldOfClass("sun.rmi.transport.Target", "ccl"); preventor.debug("Looping " + rmiTargetsMap.size() + " RMI Targets to find leaks"); for(Iterator<?> iter = rmiTargetsMap.values().iterator(); iter.hasNext(); ) { Object target = iter.next(); // sun.rmi.transport.Target ClassLoader ccl = (ClassLoader) cclField.get(target); if(preventor.isClassLoaderOrChild(ccl)) { preventor.warn("Removing RMI Target: " + target); iter.remove(); } } } catch (Exception ex) { preventor.error(ex); } }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "protected", "void", "clearRmiTargetsMap", "(", "ClassLoaderLeakPreventor", "preventor", ",", "Map", "<", "?", ",", "?", ">", "rmiTargetsMap", ")", "{", "try", "{", "final", "Field", "cclField", "=", "preven...
Iterate RMI Targets Map and remove entries loaded by protected ClassLoader
[ "Iterate", "RMI", "Targets", "Map", "and", "remove", "entries", "loaded", "by", "protected", "ClassLoader" ]
eea8e3cef64f8096dbbb87552df0a1bd272bcb63
https://github.com/mjiderhamn/classloader-leak-prevention/blob/eea8e3cef64f8096dbbb87552df0a1bd272bcb63/classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/RmiTargetsCleanUp.java#L30-L47
train
mjiderhamn/classloader-leak-prevention
classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/MBeanCleanUp.java
MBeanCleanUp.isJettyWithJMX
@SuppressWarnings("WeakerAccess") protected boolean isJettyWithJMX(ClassLoaderLeakPreventor preventor) { final ClassLoader classLoader = preventor.getClassLoader(); try { // If package org.eclipse.jetty is found, we may be running under jetty if (classLoader.getResource("org/eclipse/jetty") == null) { return false; } Class.forName("org.eclipse.jetty.jmx.MBeanContainer", false, classLoader.getParent()); // JMX enabled? Class.forName("org.eclipse.jetty.webapp.WebAppContext", false, classLoader.getParent()); } catch(Exception ex) { // For example ClassNotFoundException return false; } // Seems we are running in Jetty with JMX enabled return true; }
java
@SuppressWarnings("WeakerAccess") protected boolean isJettyWithJMX(ClassLoaderLeakPreventor preventor) { final ClassLoader classLoader = preventor.getClassLoader(); try { // If package org.eclipse.jetty is found, we may be running under jetty if (classLoader.getResource("org/eclipse/jetty") == null) { return false; } Class.forName("org.eclipse.jetty.jmx.MBeanContainer", false, classLoader.getParent()); // JMX enabled? Class.forName("org.eclipse.jetty.webapp.WebAppContext", false, classLoader.getParent()); } catch(Exception ex) { // For example ClassNotFoundException return false; } // Seems we are running in Jetty with JMX enabled return true; }
[ "@", "SuppressWarnings", "(", "\"WeakerAccess\"", ")", "protected", "boolean", "isJettyWithJMX", "(", "ClassLoaderLeakPreventor", "preventor", ")", "{", "final", "ClassLoader", "classLoader", "=", "preventor", ".", "getClassLoader", "(", ")", ";", "try", "{", "// If...
Are we running in Jetty with JMX enabled?
[ "Are", "we", "running", "in", "Jetty", "with", "JMX", "enabled?" ]
eea8e3cef64f8096dbbb87552df0a1bd272bcb63
https://github.com/mjiderhamn/classloader-leak-prevention/blob/eea8e3cef64f8096dbbb87552df0a1bd272bcb63/classloader-leak-prevention/classloader-leak-prevention-core/src/main/java/se/jiderhamn/classloader/leak/prevention/cleanup/MBeanCleanUp.java#L71-L89
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashMap.java
LongHashMap.keys
public long[] keys() { long[] values = new long[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { values[idx++] = entry.key; entry = entry.next; } } return values; }
java
public long[] keys() { long[] values = new long[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { values[idx++] = entry.key; entry = entry.next; } } return values; }
[ "public", "long", "[", "]", "keys", "(", ")", "{", "long", "[", "]", "values", "=", "new", "long", "[", "size", "]", ";", "int", "idx", "=", "0", ";", "for", "(", "Entry", "entry", ":", "table", ")", "{", "while", "(", "entry", "!=", "null", ...
Returns all keys in no particular order.
[ "Returns", "all", "keys", "in", "no", "particular", "order", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashMap.java#L136-L146
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashMap.java
LongHashMap.entries
public Entry<T>[] entries() { @SuppressWarnings("unchecked") Entry<T>[] entries = new Entry[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { entries[idx++] = entry; entry = entry.next; } } return entries; }
java
public Entry<T>[] entries() { @SuppressWarnings("unchecked") Entry<T>[] entries = new Entry[size]; int idx = 0; for (Entry entry : table) { while (entry != null) { entries[idx++] = entry; entry = entry.next; } } return entries; }
[ "public", "Entry", "<", "T", ">", "[", "]", "entries", "(", ")", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Entry", "<", "T", ">", "[", "]", "entries", "=", "new", "Entry", "[", "size", "]", ";", "int", "idx", "=", "0", ";", "for",...
Returns all entries in no particular order.
[ "Returns", "all", "entries", "in", "no", "particular", "order", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashMap.java#L151-L162
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashSet.java
LongHashSet.add
public boolean add(long key) { final int index = ((((int) (key >>> 32)) ^ ((int) (key))) & 0x7fffffff) % capacity; final Entry entryOriginal = table[index]; for (Entry entry = entryOriginal; entry != null; entry = entry.next) { if (entry.key == key) { return false; } } table[index] = new Entry(key, entryOriginal); size++; if (size > threshold) { setCapacity(2 * capacity); } return true; }
java
public boolean add(long key) { final int index = ((((int) (key >>> 32)) ^ ((int) (key))) & 0x7fffffff) % capacity; final Entry entryOriginal = table[index]; for (Entry entry = entryOriginal; entry != null; entry = entry.next) { if (entry.key == key) { return false; } } table[index] = new Entry(key, entryOriginal); size++; if (size > threshold) { setCapacity(2 * capacity); } return true; }
[ "public", "boolean", "add", "(", "long", "key", ")", "{", "final", "int", "index", "=", "(", "(", "(", "(", "int", ")", "(", "key", ">>>", "32", ")", ")", "^", "(", "(", "int", ")", "(", "key", ")", ")", ")", "&", "0x7fffffff", ")", "%", "c...
Adds the given value to the set. @return true if the value was actually new
[ "Adds", "the", "given", "value", "to", "the", "set", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashSet.java#L88-L102
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashSet.java
LongHashSet.remove
public boolean remove(long key) { int index = ((((int) (key >>> 32)) ^ ((int) (key))) & 0x7fffffff) % capacity; Entry previous = null; Entry entry = table[index]; while (entry != null) { Entry next = entry.next; if (entry.key == key) { if (previous == null) { table[index] = next; } else { previous.next = next; } size--; return true; } previous = entry; entry = next; } return false; }
java
public boolean remove(long key) { int index = ((((int) (key >>> 32)) ^ ((int) (key))) & 0x7fffffff) % capacity; Entry previous = null; Entry entry = table[index]; while (entry != null) { Entry next = entry.next; if (entry.key == key) { if (previous == null) { table[index] = next; } else { previous.next = next; } size--; return true; } previous = entry; entry = next; } return false; }
[ "public", "boolean", "remove", "(", "long", "key", ")", "{", "int", "index", "=", "(", "(", "(", "(", "int", ")", "(", "key", ">>>", "32", ")", ")", "^", "(", "(", "int", ")", "(", "key", ")", ")", ")", "&", "0x7fffffff", ")", "%", "capacity"...
Removes the given value to the set. @return true if the value was actually removed
[ "Removes", "the", "given", "value", "to", "the", "set", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/collections/LongHashSet.java#L109-L128
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java
ObjectCache.put
public VALUE put(KEY key, VALUE object) { CacheEntry<VALUE> entry; if (referenceType == ReferenceType.WEAK) { entry = new CacheEntry<>(new WeakReference<>(object), null); } else if (referenceType == ReferenceType.SOFT) { entry = new CacheEntry<>(new SoftReference<>(object), null); } else { entry = new CacheEntry<>(null, object); } countPutCountSinceEviction++; countPut++; if (isExpiring && nextCleanUpTimestamp == 0) { nextCleanUpTimestamp = System.currentTimeMillis() + expirationMillis + 1; } CacheEntry<VALUE> oldEntry; synchronized (this) { if (values.size() >= maxSize) { evictToTargetSize(maxSize - 1); } oldEntry = values.put(key, entry); } return getValueForRemoved(oldEntry); }
java
public VALUE put(KEY key, VALUE object) { CacheEntry<VALUE> entry; if (referenceType == ReferenceType.WEAK) { entry = new CacheEntry<>(new WeakReference<>(object), null); } else if (referenceType == ReferenceType.SOFT) { entry = new CacheEntry<>(new SoftReference<>(object), null); } else { entry = new CacheEntry<>(null, object); } countPutCountSinceEviction++; countPut++; if (isExpiring && nextCleanUpTimestamp == 0) { nextCleanUpTimestamp = System.currentTimeMillis() + expirationMillis + 1; } CacheEntry<VALUE> oldEntry; synchronized (this) { if (values.size() >= maxSize) { evictToTargetSize(maxSize - 1); } oldEntry = values.put(key, entry); } return getValueForRemoved(oldEntry); }
[ "public", "VALUE", "put", "(", "KEY", "key", ",", "VALUE", "object", ")", "{", "CacheEntry", "<", "VALUE", ">", "entry", ";", "if", "(", "referenceType", "==", "ReferenceType", ".", "WEAK", ")", "{", "entry", "=", "new", "CacheEntry", "<>", "(", "new",...
Stores an new entry in the cache.
[ "Stores", "an", "new", "entry", "in", "the", "cache", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java#L91-L115
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java
ObjectCache.putAll
public void putAll(Map<KEY, VALUE> mapDataToPut) { int targetSize = maxSize - mapDataToPut.size(); if (maxSize > 0 && values.size() > targetSize) { evictToTargetSize(targetSize); } Set<Entry<KEY, VALUE>> entries = mapDataToPut.entrySet(); for (Entry<KEY, VALUE> entry : entries) { put(entry.getKey(), entry.getValue()); } }
java
public void putAll(Map<KEY, VALUE> mapDataToPut) { int targetSize = maxSize - mapDataToPut.size(); if (maxSize > 0 && values.size() > targetSize) { evictToTargetSize(targetSize); } Set<Entry<KEY, VALUE>> entries = mapDataToPut.entrySet(); for (Entry<KEY, VALUE> entry : entries) { put(entry.getKey(), entry.getValue()); } }
[ "public", "void", "putAll", "(", "Map", "<", "KEY", ",", "VALUE", ">", "mapDataToPut", ")", "{", "int", "targetSize", "=", "maxSize", "-", "mapDataToPut", ".", "size", "(", ")", ";", "if", "(", "maxSize", ">", "0", "&&", "values", ".", "size", "(", ...
Stores all entries contained in the given map in the cache.
[ "Stores", "all", "entries", "contained", "in", "the", "given", "map", "in", "the", "cache", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java#L147-L156
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java
ObjectCache.get
public VALUE get(KEY key) { CacheEntry<VALUE> entry; synchronized (this) { entry = values.get(key); } VALUE value; if (entry != null) { if (isExpiring) { long age = System.currentTimeMillis() - entry.timeCreated; if (age < expirationMillis) { value = getValue(key, entry); } else { countExpired++; synchronized (this) { values.remove(key); } value = null; } } else { value = getValue(key, entry); } } else { value = null; } if (value != null) { countHit++; } else { countMiss++; } return value; }
java
public VALUE get(KEY key) { CacheEntry<VALUE> entry; synchronized (this) { entry = values.get(key); } VALUE value; if (entry != null) { if (isExpiring) { long age = System.currentTimeMillis() - entry.timeCreated; if (age < expirationMillis) { value = getValue(key, entry); } else { countExpired++; synchronized (this) { values.remove(key); } value = null; } } else { value = getValue(key, entry); } } else { value = null; } if (value != null) { countHit++; } else { countMiss++; } return value; }
[ "public", "VALUE", "get", "(", "KEY", "key", ")", "{", "CacheEntry", "<", "VALUE", ">", "entry", ";", "synchronized", "(", "this", ")", "{", "entry", "=", "values", ".", "get", "(", "key", ")", ";", "}", "VALUE", "value", ";", "if", "(", "entry", ...
Get the cached entry or null if no valid cached entry is found.
[ "Get", "the", "cached", "entry", "or", "null", "if", "no", "valid", "cached", "entry", "is", "found", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/ObjectCache.java#L159-L189
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/IoUtils.java
IoUtils.copyAllBytes
public static int copyAllBytes(InputStream in, OutputStream out) throws IOException { int byteCount = 0; byte[] buffer = new byte[BUFFER_SIZE]; while (true) { int read = in.read(buffer); if (read == -1) { break; } out.write(buffer, 0, read); byteCount += read; } return byteCount; }
java
public static int copyAllBytes(InputStream in, OutputStream out) throws IOException { int byteCount = 0; byte[] buffer = new byte[BUFFER_SIZE]; while (true) { int read = in.read(buffer); if (read == -1) { break; } out.write(buffer, 0, read); byteCount += read; } return byteCount; }
[ "public", "static", "int", "copyAllBytes", "(", "InputStream", "in", ",", "OutputStream", "out", ")", "throws", "IOException", "{", "int", "byteCount", "=", "0", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "BUFFER_SIZE", "]", ";", "while", ...
Copies all available data from in to out without closing any stream. @return number of bytes copied
[ "Copies", "all", "available", "data", "from", "in", "to", "out", "without", "closing", "any", "stream", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/IoUtils.java#L130-L142
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java
CircularByteBuffer.get
public synchronized int get() { if (available == 0) { return -1; } byte value = buffer[idxGet]; idxGet = (idxGet + 1) % capacity; available--; return value; }
java
public synchronized int get() { if (available == 0) { return -1; } byte value = buffer[idxGet]; idxGet = (idxGet + 1) % capacity; available--; return value; }
[ "public", "synchronized", "int", "get", "(", ")", "{", "if", "(", "available", "==", "0", ")", "{", "return", "-", "1", ";", "}", "byte", "value", "=", "buffer", "[", "idxGet", "]", ";", "idxGet", "=", "(", "idxGet", "+", "1", ")", "%", "capacity...
Gets a single byte return or -1 if no data is available.
[ "Gets", "a", "single", "byte", "return", "or", "-", "1", "if", "no", "data", "is", "available", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java#L56-L64
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java
CircularByteBuffer.get
public synchronized int get(byte[] dst, int off, int len) { if (available == 0) { return 0; } // limit is last index to read + 1 int limit = idxGet < idxPut ? idxPut : capacity; int count = Math.min(limit - idxGet, len); System.arraycopy(buffer, idxGet, dst, off, count); idxGet += count; if (idxGet == capacity) { // Array end reached, check if we have more int count2 = Math.min(len - count, idxPut); if (count2 > 0) { System.arraycopy(buffer, 0, dst, off + count, count2); idxGet = count2; count += count2; } else { idxGet = 0; } } available -= count; return count; }
java
public synchronized int get(byte[] dst, int off, int len) { if (available == 0) { return 0; } // limit is last index to read + 1 int limit = idxGet < idxPut ? idxPut : capacity; int count = Math.min(limit - idxGet, len); System.arraycopy(buffer, idxGet, dst, off, count); idxGet += count; if (idxGet == capacity) { // Array end reached, check if we have more int count2 = Math.min(len - count, idxPut); if (count2 > 0) { System.arraycopy(buffer, 0, dst, off + count, count2); idxGet = count2; count += count2; } else { idxGet = 0; } } available -= count; return count; }
[ "public", "synchronized", "int", "get", "(", "byte", "[", "]", "dst", ",", "int", "off", ",", "int", "len", ")", "{", "if", "(", "available", "==", "0", ")", "{", "return", "0", ";", "}", "// limit is last index to read + 1", "int", "limit", "=", "idxG...
Gets as many of the requested bytes as available from this buffer. @return number of bytes actually got from this buffer (0 if no bytes are available)
[ "Gets", "as", "many", "of", "the", "requested", "bytes", "as", "available", "from", "this", "buffer", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java#L80-L104
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java
CircularByteBuffer.put
public synchronized boolean put(byte value) { if (available == capacity) { return false; } buffer[idxPut] = value; idxPut = (idxPut + 1) % capacity; available++; return true; }
java
public synchronized boolean put(byte value) { if (available == capacity) { return false; } buffer[idxPut] = value; idxPut = (idxPut + 1) % capacity; available++; return true; }
[ "public", "synchronized", "boolean", "put", "(", "byte", "value", ")", "{", "if", "(", "available", "==", "capacity", ")", "{", "return", "false", ";", "}", "buffer", "[", "idxPut", "]", "=", "value", ";", "idxPut", "=", "(", "idxPut", "+", "1", ")",...
Puts a single byte if the buffer is not yet full. @return true if the byte was put, or false if the buffer is full
[ "Puts", "a", "single", "byte", "if", "the", "buffer", "is", "not", "yet", "full", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java#L112-L120
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java
CircularByteBuffer.put
public synchronized int put(byte[] src, int off, int len) { if (available == capacity) { return 0; } // limit is last index to put + 1 int limit = idxPut < idxGet ? idxGet : capacity; int count = Math.min(limit - idxPut, len); System.arraycopy(src, off, buffer, idxPut, count); idxPut += count; if (idxPut == capacity) { // Array end reached, check if we have more int count2 = Math.min(len - count, idxGet); if (count2 > 0) { System.arraycopy(src, off + count, buffer, 0, count2); idxPut = count2; count += count2; } else { idxPut = 0; } } available += count; return count; }
java
public synchronized int put(byte[] src, int off, int len) { if (available == capacity) { return 0; } // limit is last index to put + 1 int limit = idxPut < idxGet ? idxGet : capacity; int count = Math.min(limit - idxPut, len); System.arraycopy(src, off, buffer, idxPut, count); idxPut += count; if (idxPut == capacity) { // Array end reached, check if we have more int count2 = Math.min(len - count, idxGet); if (count2 > 0) { System.arraycopy(src, off + count, buffer, 0, count2); idxPut = count2; count += count2; } else { idxPut = 0; } } available += count; return count; }
[ "public", "synchronized", "int", "put", "(", "byte", "[", "]", "src", ",", "int", "off", ",", "int", "len", ")", "{", "if", "(", "available", "==", "capacity", ")", "{", "return", "0", ";", "}", "// limit is last index to put + 1", "int", "limit", "=", ...
Puts as many of the given bytes as possible into this buffer. @return number of bytes actually put into this buffer (0 if the buffer is full)
[ "Puts", "as", "many", "of", "the", "given", "bytes", "as", "possible", "into", "this", "buffer", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java#L136-L160
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java
CircularByteBuffer.skip
public synchronized int skip(int count) { if (count > available) { count = available; } idxGet = (idxGet + count) % capacity; available -= count; return count; }
java
public synchronized int skip(int count) { if (count > available) { count = available; } idxGet = (idxGet + count) % capacity; available -= count; return count; }
[ "public", "synchronized", "int", "skip", "(", "int", "count", ")", "{", "if", "(", "count", ">", "available", ")", "{", "count", "=", "available", ";", "}", "idxGet", "=", "(", "idxGet", "+", "count", ")", "%", "capacity", ";", "available", "-=", "co...
Skips the given count of bytes, but at most the currently available count. @return number of bytes actually skipped from this buffer (0 if no bytes are available)
[ "Skips", "the", "given", "count", "of", "bytes", "but", "at", "most", "the", "currently", "available", "count", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/CircularByteBuffer.java#L174-L181
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/FileUtils.java
FileUtils.readObject
public static Object readObject(File file) throws IOException, ClassNotFoundException { FileInputStream fileIn = new FileInputStream(file); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(fileIn)); try { return in.readObject(); } finally { IoUtils.safeClose(in); } }
java
public static Object readObject(File file) throws IOException, ClassNotFoundException { FileInputStream fileIn = new FileInputStream(file); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(fileIn)); try { return in.readObject(); } finally { IoUtils.safeClose(in); } }
[ "public", "static", "Object", "readObject", "(", "File", "file", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "FileInputStream", "fileIn", "=", "new", "FileInputStream", "(", "file", ")", ";", "ObjectInputStream", "in", "=", "new", "ObjectInpu...
To read an object in a quick & dirty way. Prepare to handle failures when object serialization changes!
[ "To", "read", "an", "object", "in", "a", "quick", "&", "dirty", "way", ".", "Prepare", "to", "handle", "failures", "when", "object", "serialization", "changes!" ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/FileUtils.java#L99-L108
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/io/FileUtils.java
FileUtils.writeObject
public static void writeObject(File file, Object object) throws IOException { FileOutputStream fileOut = new FileOutputStream(file); ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(fileOut)); try { out.writeObject(object); out.flush(); // Force sync fileOut.getFD().sync(); } finally { IoUtils.safeClose(out); } }
java
public static void writeObject(File file, Object object) throws IOException { FileOutputStream fileOut = new FileOutputStream(file); ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(fileOut)); try { out.writeObject(object); out.flush(); // Force sync fileOut.getFD().sync(); } finally { IoUtils.safeClose(out); } }
[ "public", "static", "void", "writeObject", "(", "File", "file", ",", "Object", "object", ")", "throws", "IOException", "{", "FileOutputStream", "fileOut", "=", "new", "FileOutputStream", "(", "file", ")", ";", "ObjectOutputStream", "out", "=", "new", "ObjectOutp...
To store an object in a quick & dirty way.
[ "To", "store", "an", "object", "in", "a", "quick", "&", "dirty", "way", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/io/FileUtils.java#L111-L122
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java
DateUtils.setTime
public static void setTime(Calendar calendar, int hourOfDay, int minute, int second, int millisecond) { calendar.set(Calendar.HOUR_OF_DAY, hourOfDay); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, second); calendar.set(Calendar.MILLISECOND, millisecond); }
java
public static void setTime(Calendar calendar, int hourOfDay, int minute, int second, int millisecond) { calendar.set(Calendar.HOUR_OF_DAY, hourOfDay); calendar.set(Calendar.MINUTE, minute); calendar.set(Calendar.SECOND, second); calendar.set(Calendar.MILLISECOND, millisecond); }
[ "public", "static", "void", "setTime", "(", "Calendar", "calendar", ",", "int", "hourOfDay", ",", "int", "minute", ",", "int", "second", ",", "int", "millisecond", ")", "{", "calendar", ".", "set", "(", "Calendar", ".", "HOUR_OF_DAY", ",", "hourOfDay", ")"...
Sets hour, minutes, seconds and milliseconds to the given values. Leaves date info untouched.
[ "Sets", "hour", "minutes", "seconds", "and", "milliseconds", "to", "the", "given", "values", ".", "Leaves", "date", "info", "untouched", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java#L51-L56
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java
DateUtils.getDayAsReadableInt
public static int getDayAsReadableInt(long time) { Calendar cal = calendarThreadLocal.get(); cal.setTimeInMillis(time); return getDayAsReadableInt(cal); }
java
public static int getDayAsReadableInt(long time) { Calendar cal = calendarThreadLocal.get(); cal.setTimeInMillis(time); return getDayAsReadableInt(cal); }
[ "public", "static", "int", "getDayAsReadableInt", "(", "long", "time", ")", "{", "Calendar", "cal", "=", "calendarThreadLocal", ".", "get", "(", ")", ";", "cal", ".", "setTimeInMillis", "(", "time", ")", ";", "return", "getDayAsReadableInt", "(", "cal", ")",...
Readable yyyyMMdd int representation of a day, which is also sortable.
[ "Readable", "yyyyMMdd", "int", "representation", "of", "a", "day", "which", "is", "also", "sortable", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java#L59-L63
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java
DateUtils.getDayAsReadableInt
public static int getDayAsReadableInt(Calendar calendar) { int day = calendar.get(Calendar.DAY_OF_MONTH); int month = calendar.get(Calendar.MONTH) + 1; int year = calendar.get(Calendar.YEAR); return year * 10000 + month * 100 + day; }
java
public static int getDayAsReadableInt(Calendar calendar) { int day = calendar.get(Calendar.DAY_OF_MONTH); int month = calendar.get(Calendar.MONTH) + 1; int year = calendar.get(Calendar.YEAR); return year * 10000 + month * 100 + day; }
[ "public", "static", "int", "getDayAsReadableInt", "(", "Calendar", "calendar", ")", "{", "int", "day", "=", "calendar", ".", "get", "(", "Calendar", ".", "DAY_OF_MONTH", ")", ";", "int", "month", "=", "calendar", ".", "get", "(", "Calendar", ".", "MONTH", ...
Readable yyyyMMdd representation of a day, which is also sortable.
[ "Readable", "yyyyMMdd", "representation", "of", "a", "day", "which", "is", "also", "sortable", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/DateUtils.java#L66-L71
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java
StringUtils.encodeUrlIso
public static String encodeUrlIso(String stringToEncode) { try { return URLEncoder.encode(stringToEncode, "ISO-8859-1"); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } }
java
public static String encodeUrlIso(String stringToEncode) { try { return URLEncoder.encode(stringToEncode, "ISO-8859-1"); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } }
[ "public", "static", "String", "encodeUrlIso", "(", "String", "stringToEncode", ")", "{", "try", "{", "return", "URLEncoder", ".", "encode", "(", "stringToEncode", ",", "\"ISO-8859-1\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e1", ")", "{",...
URL-encodes a given string using ISO-8859-1, which may work better with web pages and umlauts compared to UTF-8. No UnsupportedEncodingException to handle as it is dealt with in this method.
[ "URL", "-", "encodes", "a", "given", "string", "using", "ISO", "-", "8859", "-", "1", "which", "may", "work", "better", "with", "web", "pages", "and", "umlauts", "compared", "to", "UTF", "-", "8", ".", "No", "UnsupportedEncodingException", "to", "handle", ...
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java#L80-L86
train
greenrobot/essentials
java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java
StringUtils.decodeUrl
public static String decodeUrl(String stringToDecode) { try { return URLDecoder.decode(stringToDecode, "UTF-8"); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } }
java
public static String decodeUrl(String stringToDecode) { try { return URLDecoder.decode(stringToDecode, "UTF-8"); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } }
[ "public", "static", "String", "decodeUrl", "(", "String", "stringToDecode", ")", "{", "try", "{", "return", "URLDecoder", ".", "decode", "(", "stringToDecode", ",", "\"UTF-8\"", ")", ";", "}", "catch", "(", "UnsupportedEncodingException", "e1", ")", "{", "thro...
URL-Decodes a given string using UTF-8. No UnsupportedEncodingException to handle as it is dealt with in this method.
[ "URL", "-", "Decodes", "a", "given", "string", "using", "UTF", "-", "8", ".", "No", "UnsupportedEncodingException", "to", "handle", "as", "it", "is", "dealt", "with", "in", "this", "method", "." ]
31eaaeb410174004196c9ef9c9469e0d02afd94b
https://github.com/greenrobot/essentials/blob/31eaaeb410174004196c9ef9c9469e0d02afd94b/java-essentials/src/main/java/org/greenrobot/essentials/StringUtils.java#L92-L98
train