code
stringlengths
23
201k
docstring
stringlengths
17
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
72
path
stringlengths
11
317
url
stringlengths
57
377
license
stringclasses
7 values
@Override public List<String> remove(Object key) { return delegate.remove(key); }
A simple class implementing HTTP headers as a MultiValueMap. This own implementation is necessary to remove the dependency to the class with the same name from org.springframework:spring-web. Under the hood is uses a {@link LinkedCaseInsensitiveMap}. @author Peter-Josef Meisch @since 5.0
remove
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
@Override public void putAll(Map<? extends String, ? extends List<String>> m) { Assert.notNull(m, "m must not be null"); delegate.putAll(m); }
A simple class implementing HTTP headers as a MultiValueMap. This own implementation is necessary to remove the dependency to the class with the same name from org.springframework:spring-web. Under the hood is uses a {@link LinkedCaseInsensitiveMap}. @author Peter-Josef Meisch @since 5.0
putAll
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
@Override public void clear() { delegate.clear(); }
A simple class implementing HTTP headers as a MultiValueMap. This own implementation is necessary to remove the dependency to the class with the same name from org.springframework:spring-web. Under the hood is uses a {@link LinkedCaseInsensitiveMap}. @author Peter-Josef Meisch @since 5.0
clear
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
@Override public Set<String> keySet() { return delegate.keySet(); }
A simple class implementing HTTP headers as a MultiValueMap. This own implementation is necessary to remove the dependency to the class with the same name from org.springframework:spring-web. Under the hood is uses a {@link LinkedCaseInsensitiveMap}. @author Peter-Josef Meisch @since 5.0
keySet
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
@Override public Collection<List<String>> values() { return delegate.values(); }
A simple class implementing HTTP headers as a MultiValueMap. This own implementation is necessary to remove the dependency to the class with the same name from org.springframework:spring-web. Under the hood is uses a {@link LinkedCaseInsensitiveMap}. @author Peter-Josef Meisch @since 5.0
values
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
@Override public Set<Entry<String, List<String>>> entrySet() { return delegate.entrySet(); }
A simple class implementing HTTP headers as a MultiValueMap. This own implementation is necessary to remove the dependency to the class with the same name from org.springframework:spring-web. Under the hood is uses a {@link LinkedCaseInsensitiveMap}. @author Peter-Josef Meisch @since 5.0
entrySet
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override public boolean equals(Object o) { return delegate.equals(o); }
A simple class implementing HTTP headers as a MultiValueMap. This own implementation is necessary to remove the dependency to the class with the same name from org.springframework:spring-web. Under the hood is uses a {@link LinkedCaseInsensitiveMap}. @author Peter-Josef Meisch @since 5.0
equals
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
@Override public int hashCode() { return delegate.hashCode(); }
A simple class implementing HTTP headers as a MultiValueMap. This own implementation is necessary to remove the dependency to the class with the same name from org.springframework:spring-web. Under the hood is uses a {@link LinkedCaseInsensitiveMap}. @author Peter-Josef Meisch @since 5.0
hashCode
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
public void setBasicAuth(String username, String password) { Assert.notNull(username, "username must not be null"); Assert.notNull(password, "password must not be null"); set(AUTHORIZATION, "Basic " + encodeBasicAuth(username, password)); }
A simple class implementing HTTP headers as a MultiValueMap. This own implementation is necessary to remove the dependency to the class with the same name from org.springframework:spring-web. Under the hood is uses a {@link LinkedCaseInsensitiveMap}. @author Peter-Josef Meisch @since 5.0
setBasicAuth
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
public static String encodeBasicAuth(String username, String password) { return encodeBasicAuth(username, password, null); }
Encode a username and password to be used in basic authorization. Code copied from the spring-web HttpHeaders class. @param username the username, must not contain a colon @param password the password @return the encoded value
encodeBasicAuth
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
public static String encodeBasicAuth(String username, String password, @Nullable Charset charset) { Assert.notNull(username, "Username must not be null"); Assert.doesNotContain(username, ":", "Username must not contain a colon"); Assert.notNull(password, "Password must not be null"); if (charset == null) { c...
Encode a username and password to be used in basic authorization. Code copied from the spring-web HttpHeaders class. @param username the username, must not contain a colon @param password the password @param charset charset for the encoding, if {@literal null} StandardCharsets.ISO_8859_1 is used @return the encoded va...
encodeBasicAuth
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/HttpHeaders.java
Apache-2.0
default M append(String key, Object value) { Assert.notNull(key, "Key must not be null"); put(key, value); // noinspection unchecked return (M) this; }
{@link #put(Object, Object)} the {@code key}/{@code value} tuple and return {@code this} object. @param key key with which the specified value is to be associated. must not be {@literal null}. @param value value to be associated with the specified key. @return {@code this} object.
append
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
@Nullable default <T> T get(Object key, Class<T> type) { Assert.notNull(key, "Key must not be null"); Assert.notNull(type, "Type must not be null"); return type.cast(get(key)); }
Returns the value to which the specified {@code key} is mapped, or {@literal null} if this document contains no mapping for the key. The value is casted within the method which makes it useful for calling code as it does not require casting on the calling side. If the value type is not assignable to {@code type}, then ...
get
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
@Nullable default Boolean getBoolean(String key) { return get(key, Boolean.class); }
Returns the value to which the specified {@code key} is mapped, or {@literal null} if this document contains no mapping for the key. If the value type is not a {@link Boolean}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the value to which the...
getBoolean
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
default boolean getBooleanOrDefault(String key, boolean defaultValue) { return getBooleanOrDefault(key, () -> defaultValue); }
Returns the value to which the specified {@code key} is mapped or {@code defaultValue} if this document contains no mapping for the key. If the value type is not a {@link Boolean}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the value to which...
getBooleanOrDefault
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
default boolean getBooleanOrDefault(String key, BooleanSupplier defaultValue) { Boolean value = getBoolean(key); return value == null ? defaultValue.getAsBoolean() : value; }
Returns the value to which the specified {@code key} is mapped or the value from {@code defaultValue} if this document contains no mapping for the key. If the value type is not a {@link Boolean}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the...
getBooleanOrDefault
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
@Nullable default Integer getInt(String key) { return get(key, Integer.class); }
Returns the value to which the specified {@code key} is mapped, or {@literal null} if this document contains no mapping for the key. If the value type is not a {@link Integer}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the value to which the...
getInt
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
default int getIntOrDefault(String key, int defaultValue) { return getIntOrDefault(key, () -> defaultValue); }
Returns the value to which the specified {@code key} is mapped or {@code defaultValue} if this document contains no mapping for the key. If the value type is not a {@link Integer}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the value to which...
getIntOrDefault
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
default int getIntOrDefault(String key, IntSupplier defaultValue) { Integer value = getInt(key); return value == null ? defaultValue.getAsInt() : value; }
Returns the value to which the specified {@code key} is mapped or the value from {@code defaultValue} if this document contains no mapping for the key. If the value type is not a {@link Integer}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the...
getIntOrDefault
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
@Nullable default Long getLong(String key) { return get(key, Long.class); }
Returns the value to which the specified {@code key} is mapped, or {@literal null} if this document contains no mapping for the key. If the value type is not a {@link Long}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the value to which the sp...
getLong
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
default long getLongOrDefault(String key, long defaultValue) { return getLongOrDefault(key, () -> defaultValue); }
Returns the value to which the specified {@code key} is mapped or {@code defaultValue} if this document contains no mapping for the key. If the value type is not a {@link Long}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the value to which th...
getLongOrDefault
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
default long getLongOrDefault(String key, LongSupplier defaultValue) { Long value = getLong(key); return value == null ? defaultValue.getAsLong() : value; }
Returns the value to which the specified {@code key} is mapped or the value from {@code defaultValue} if this document contains no mapping for the key. If the value type is not a {@link Long}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the va...
getLongOrDefault
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
@Nullable default String getString(String key) { return get(key, String.class); }
Returns the value to which the specified {@code key} is mapped, or {@literal null} if this document contains no mapping for the key. If the value type is not a {@link String}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the value to which the ...
getString
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
default String getStringOrDefault(String key, String defaultValue) { return getStringOrDefault(key, () -> defaultValue); }
Returns the value to which the specified {@code key} is mapped or {@code defaultValue} if this document contains no mapping for the key. If the value type is not a {@link String}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the value to which ...
getStringOrDefault
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
default String getStringOrDefault(String key, Supplier<String> defaultValue) { String value = getString(key); return value == null ? defaultValue.get() : value; }
Returns the value to which the specified {@code key} is mapped or the value from {@code defaultValue} if this document contains no mapping for the key. If the value type is not a {@link String}, then this method throws {@link ClassCastException}. @param key the key whose associated value is to be returned @return the ...
getStringOrDefault
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/StringObjectMap.java
Apache-2.0
@Override public String toString() { return major + "." + minor + '.' + revision; }
A version defined by 3 parts: major minor and revision number. @author Peter-Josef Meisch @since 4.3
toString
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/Version.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/Version.java
Apache-2.0
public static Version fromString(String s) { Assert.notNull(s, "s must not be null"); Matcher matcher = PATTERN.matcher(s); if (!matcher.matches()) { throw new IllegalArgumentException("invalid input pattern"); } int major = Integer.parseInt(matcher.group(1)); int minor = matcher.group(3) != null ? I...
Creates a version from a String that matches {@link #PATTERN}; major, minor and revision numbers separated by dots with optional trailing characters. A missing revision is treated as 0. @param s the String to parse @return the Version @throws IllegalArgumentException if the input is null or cannot be parsed.
fromString
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/Version.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/Version.java
Apache-2.0
public static Properties versionProperties() { return versionProperties; }
This class is used to log the versions of Spring Data Elasticsearch, the Elasticsearch client libs used to built, the Elasticsearch client libs currently used and of the Elasticsearch cluster. If differences greater than a patchlevel are detected, these are logged as warnings. @author Peter-Josef Meisch @since 4.0
versionProperties
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/VersionInfo.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/VersionInfo.java
Apache-2.0
public static void logVersions(String vendor, String runtimeLibraryVersion, @Nullable String clusterVersion) { try { String versionSpringDataElasticsearch = versionProperties.getProperty(VERSION_SPRING_DATA_ELASTICSEARCH); Version versionBuiltLibraryES = Version.fromString(versionProperties.getProperty(VERSION...
logs the relevant version info. @param clusterVersion the version of the cluster
logVersions
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/VersionInfo.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/VersionInfo.java
Apache-2.0
private static Properties loadVersionProperties() throws IOException { InputStream resource = VersionInfo.class.getClassLoader().getResourceAsStream(VERSION_PROPERTIES); if (resource != null) { Properties properties = new Properties(); properties.load(resource); return properties; } else { throw new I...
gets the version properties from the classpath resource. @return version properties @throws IOException when an error occurs
loadVersionProperties
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/VersionInfo.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/VersionInfo.java
Apache-2.0
private static boolean differInMajorOrMinor(Version version1, Version version2) { return version1.major() != version2.major() || version1.minor() != version2.minor(); }
gets the version properties from the classpath resource. @return version properties @throws IOException when an error occurs
differInMajorOrMinor
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/support/VersionInfo.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/support/VersionInfo.java
Apache-2.0
public static long interleave(int even, int odd) { long v1 = 0x00000000FFFFFFFFL & even; long v2 = 0x00000000FFFFFFFFL & odd; v1 = (v1 | (v1 << SHIFT[4])) & MAGIC[4]; v1 = (v1 | (v1 << SHIFT[3])) & MAGIC[3]; v1 = (v1 | (v1 << SHIFT[2])) & MAGIC[2]; v1 = (v1 | (v1 << SHIFT[1])) & MAGIC[1]; v1 = (v1 | (v1 <...
Interleaves the first 32 bits of each long value Adapted from: https://graphics.stanford.edu/~seander/bithacks.html#InterleaveBMN
interleave
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/BitUtil.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/BitUtil.java
Apache-2.0
public static long deinterleave(long b) { b &= MAGIC[0]; b = (b ^ (b >>> SHIFT[0])) & MAGIC[1]; b = (b ^ (b >>> SHIFT[1])) & MAGIC[2]; b = (b ^ (b >>> SHIFT[2])) & MAGIC[3]; b = (b ^ (b >>> SHIFT[3])) & MAGIC[4]; b = (b ^ (b >>> SHIFT[4])) & MAGIC[5]; return b; }
Extract just the even-bits value as a long from the bit-interleaved value
deinterleave
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/BitUtil.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/BitUtil.java
Apache-2.0
public static long flipFlop(final long b) { return ((b & MAGIC[6]) >>> 1) | ((b & MAGIC[0]) << 1); }
flip flops odd with even bits
flipFlop
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/BitUtil.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/BitUtil.java
Apache-2.0
public static Point toPoint(final String geohash) throws IllegalArgumentException { final long hash = mortonEncode(geohash); return new Point(decodeLongitude(hash), decodeLatitude(hash)); }
Returns a {@link Point} instance from a geohash string
toPoint
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static String toLatLon(final String geohash) { Assert.notNull(geohash, "geohash must not be null"); var point = Geohash.toPoint(geohash); return String.format(Locale.ROOT, "%f,%f", point.getLat(), point.getLon()); }
Converts a geohash to a string in the format "lat,lon" @param geohash the geohash to convert @return the lat lon pair in a String @since 5.3
toLatLon
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static Rectangle toBoundingBox(final String geohash) { // bottom left is the coordinate Point bottomLeft = toPoint(geohash); int len = Math.min(12, geohash.length()); long ghLong = longEncode(geohash, len); // shift away the level ghLong >>>= 4; // deinterleave long lon = BitUtil.deinterleave(ghL...
Computes the bounding box coordinates from a given geohash @param geohash Geohash of the defined cell @return GeoRect rectangle defining the bounding box
toBoundingBox
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static String[] getSubGeohashes(String baseGeohash) { String[] hashes = new String[BASE_32.length]; for (int i = 0; i < BASE_32.length; i++) {// note: already sorted char c = BASE_32[i]; hashes[i] = baseGeohash + c; } return hashes; }
Array of geohashes one level below the baseGeohash. Sorted.
getSubGeohashes
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static Collection<? extends CharSequence> getNeighbors(String geohash) { return addNeighborsAtLevel(geohash, geohash.length(), new ArrayList<CharSequence>(8)); }
Calculate all neighbors of a given geohash cell. @param geohash Geohash of the defined cell @return geohashes of all neighbor cells
getNeighbors
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static <E extends Collection<? super String>> E addNeighbors(String geohash, E neighbors) { return addNeighborsAtLevel(geohash, geohash.length(), neighbors); }
Add all geohashes of the cells next to a given geohash to a list. @param geohash Geohash of a specified cell @param neighbors list to add the neighbors to @return the given list
addNeighbors
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static <E extends Collection<? super String>> E addNeighborsAtLevel(String geohash, int level, E neighbors) { String south = getNeighbor(geohash, level, 0, -1); String north = getNeighbor(geohash, level, 0, +1); if (north != null) { neighbors.add(getNeighbor(north, level, -1, 0)); neighbors.add(no...
Add all geohashes of the cells next to a given geohash to a list. @param geohash Geohash of a specified cell @param level level of the given geohash @param neighbors list to add the neighbors to @return the given list
addNeighborsAtLevel
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static String getNeighbor(String geohash, int level, int dx, int dy) { int cell = BASE_32_STRING.indexOf(geohash.charAt(level - 1)); // Decoding the Geohash bit pattern to determine grid coordinates int x0 = cell & 1; // first bit of x int y0 = cell & 2; // first bit of y int x1 = cell & 4; // second ...
Calculate the geohash of a neighbor of a geohash @param geohash the geohash of a cell @param level level of the geohash @param dx delta of the first grid coordinate (must be -1, 0 or +1) @param dy delta of the second grid coordinate (must be -1, 0 or +1) @return geohash of the defined cell
getNeighbor
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static long longEncode(String hash) { return longEncode(hash, hash.length()); }
Encode a string geohash to the geohash based long format (lon/lat interleaved, 4 least significant bits = level)
longEncode
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static long longEncode(final double lon, final double lat, final int level) { // shift to appropriate level final short msf = (short) (((12 - level) * 5) + (MORTON_OFFSET - 2)); return ((encodeLatLon(lat, lon) >>> msf) << 4) | level; }
Encode lon/lat to the geohash based long format (lon/lat interleaved, 4 least significant bits = level)
longEncode
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static String stringEncode(final double lon, final double lat) { return stringEncode(lon, lat, 12); }
Encode to a geohash string from full resolution longitude, latitude)
stringEncode
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static String stringEncode(final double lon, final double lat, final int level) { // convert to geohashlong long interleaved = encodeLatLon(lat, lon); interleaved >>>= (((PRECISION - level) * 5) + (MORTON_OFFSET - 2)); final long geohash = (interleaved << 4) | level; return stringEncode(geohash); }
Encode to a level specific geohash string from full resolution longitude, latitude
stringEncode
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static String stringEncode(long geoHashLong) { int level = (int) geoHashLong & 15; geoHashLong >>>= 4; char[] chars = new char[level]; do { chars[--level] = BASE_32[(int) (geoHashLong & 31L)]; geoHashLong >>>= 5; } while (level > 0); return new String(chars); }
Encode to a geohash string from the geohash based long format
stringEncode
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
private static char encodeBase32(int x, int y) { return BASE_32[((x & 1) + ((y & 1) * 2) + ((x & 2) * 2) + ((y & 2) * 4) + ((x & 4) * 4)) % 32]; }
base32 encode at the given grid coordinate
encodeBase32
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
private static long longEncode(final String hash, int length) { int level = length - 1; long b; long l = 0L; for (char c : hash.toCharArray()) { b = (long) (BASE_32_STRING.indexOf(c)); l |= (b << (level-- * 5)); if (level < 0) { // We cannot handle more than 12 levels break; } } return (...
Encode from geohash string to the geohash based long format (lon/lat interleaved, 4 least significant bits = level)
longEncode
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static long mortonEncode(final String hash) { if (hash.isEmpty()) { throw new IllegalArgumentException("empty geohash"); } int level = 11; long b; long l = 0L; for (char c : hash.toCharArray()) { b = (long) (BASE_32_STRING.indexOf(c)); if (b < 0) { throw new IllegalArgumentException("uns...
Encode to a morton long value from a given geohash string
mortonEncode
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static double lonWidthInDegrees(int precision) { return precisionToLonWidth[precision]; }
approximate width of geohash tile for a specific precision in degrees
lonWidthInDegrees
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static double latHeightInDegrees(int precision) { return precisionToLatHeight[precision]; }
approximate height of geohash tile for a specific precision in degrees
latHeightInDegrees
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
private static long encodeLatLon(final double lat, final double lon) { // encode lat/lon flipping the sign bit so negative ints sort before positive ints final int latEnc = encodeLatitude(lat) ^ 0x80000000; final int lonEnc = encodeLongitude(lon) ^ 0x80000000; return BitUtil.interleave(latEnc, lonEnc) >>> 2; }
approximate height of geohash tile for a specific precision in degrees
encodeLatLon
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static double decodeLatitude(final String geohash) { return decodeLatitude(Geohash.mortonEncode(geohash)); }
returns the latitude value from the string based geohash
decodeLatitude
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static double decodeLongitude(final String geohash) { return decodeLongitude(Geohash.mortonEncode(geohash)); }
returns the latitude value from the string based geohash
decodeLongitude
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static double decodeLongitude(final long hash) { return unscaleLon(BitUtil.deinterleave(hash)); }
decode longitude value from morton encoded geo point
decodeLongitude
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public static double decodeLatitude(final long hash) { return unscaleLat(BitUtil.deinterleave(hash >>> 1)); }
decode latitude value from morton encoded geo point
decodeLatitude
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
private static double unscaleLon(final long val) { return (val / LON_SCALE) - 180; }
decode latitude value from morton encoded geo point
unscaleLon
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
private static double unscaleLat(final long val) { return (val / LAT_SCALE) - 90; }
decode latitude value from morton encoded geo point
unscaleLat
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Geohash.java
Apache-2.0
public double getMinY() { return minY; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMinY
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMinX() { return minX; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMinX
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMinZ() { return minZ; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMinZ
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMaxY() { return maxY; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMaxY
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMaxX() { return maxX; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMaxX
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMaxZ() { return maxZ; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMaxZ
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMinLat() { return minY; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMinLat
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMinLon() { return minX; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMinLon
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMinAlt() { return minZ; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMinAlt
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMaxLat() { return maxY; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMaxLat
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMaxLon() { return maxX; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMaxLon
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public double getMaxAlt() { return maxZ; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
getMaxAlt
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
@Override public ShapeType type() { return ShapeType.ENVELOPE; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
type
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
@Override public String toString() { return WellKnownText.INSTANCE.toWKT(this); }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
toString
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Rectangle rectangle = (Rectangle) o; if (Double.compare(rectangle.minY, minY) != 0) return false; if (Double.compare(rectangle.minX, minX) != 0) return false; if ...
Constructs a bounding box by first validating the provided latitude and longitude coordinates
equals
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
@Override public int hashCode() { int result; long temp; temp = Double.doubleToLongBits(minY); result = (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(minX); result = 31 * result + (int) (temp ^ (temp >>> 32)); temp = Double.doubleToLongBits(maxY); result = 31 * result + (int) (temp ^ (te...
Constructs a bounding box by first validating the provided latitude and longitude coordinates
hashCode
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
@Override public <T, E extends Exception> T visit(GeometryVisitor<T, E> visitor) throws E { return visitor.visit(this); }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
visit
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
@Override public boolean isEmpty() { return empty; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
isEmpty
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
@Override public boolean hasZ() { return Double.isNaN(maxZ) == false; }
Constructs a bounding box by first validating the provided latitude and longitude coordinates
hasZ
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/Rectangle.java
Apache-2.0
public String toWKT(Geometry geometry) { StringBuilder builder = new StringBuilder(); toWKT(geometry, builder); return builder.toString(); }
Utility class for converting to and from WKT
toWKT
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
public void toWKT(Geometry geometry, StringBuilder sb) { sb.append(getWKTName(geometry)); sb.append(SPACE); if (geometry.isEmpty()) { sb.append(EMPTY); } else { geometry.visit(new GeometryVisitor<Void, RuntimeException>() { @Override public Void visit(Point point) { if (point.isEmpty()) { ...
Utility class for converting to and from WKT
toWKT
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
@Override public Void visit(Point point) { if (point.isEmpty()) { sb.append(EMPTY); } else { sb.append(LPAREN); visitPoint(point.getX(), point.getY(), point.getZ()); sb.append(RPAREN); } return null; }
Utility class for converting to and from WKT
visit
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
private void visitPoint(double lon, double lat, double alt) { sb.append(lon).append(SPACE).append(lat); if (!Double.isNaN(alt)) { sb.append(SPACE).append(alt); } }
Utility class for converting to and from WKT
visitPoint
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
@Override public Void visit(Rectangle rectangle) { sb.append(LPAREN); // minX, maxX, maxY, minY sb.append(rectangle.getMinX()); sb.append(COMMA); sb.append(SPACE); sb.append(rectangle.getMaxX()); sb.append(COMMA); sb.append(SPACE); sb.append(rectangle.getMaxY()); sb...
Utility class for converting to and from WKT
visit
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
public Geometry fromWKT(String wkt) throws IOException, ParseException { try (StringReader reader = new StringReader(wkt)) { // setup the tokenizer; configured to read words w/o numbers StreamTokenizer tokenizer = new StreamTokenizer(reader); tokenizer.resetSyntax(); tokenizer.wordChars('a', 'z'); toke...
Utility class for converting to and from WKT
fromWKT
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
private Geometry parseGeometry(StreamTokenizer stream) throws IOException, ParseException { final String type = nextWord(stream).toLowerCase(Locale.ROOT); return switch (type) { case "point" -> parsePoint(stream); case "bbox" -> parseBBox(stream); default -> throw new IllegalArgumentException("Unknown geom...
parse geometry from the stream tokenizer
parseGeometry
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
private Point parsePoint(StreamTokenizer stream) throws IOException, ParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return Point.EMPTY; } double lon = nextNumber(stream); double lat = nextNumber(stream); Point pt; if (isNumberNext(stream)) { pt = new Point(lon, lat, nextNumber(stream));...
parse geometry from the stream tokenizer
parsePoint
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
private void parseCoordinates(StreamTokenizer stream, ArrayList<Double> lats, ArrayList<Double> lons, ArrayList<Double> alts) throws IOException, ParseException { parseCoordinate(stream, lats, lons, alts); while (nextCloserOrComma(stream).equals(COMMA)) { parseCoordinate(stream, lats, lons, alts); } }
parse geometry from the stream tokenizer
parseCoordinates
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
private void parseCoordinate(StreamTokenizer stream, ArrayList<Double> lats, ArrayList<Double> lons, ArrayList<Double> alts) throws IOException, ParseException { lons.add(nextNumber(stream)); lats.add(nextNumber(stream)); if (isNumberNext(stream)) { alts.add(nextNumber(stream)); } if (!alts.isEmpty() &&...
parse geometry from the stream tokenizer
parseCoordinate
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
private Rectangle parseBBox(StreamTokenizer stream) throws IOException, ParseException { if (nextEmptyOrOpen(stream).equals(EMPTY)) { return Rectangle.EMPTY; } double minLon = nextNumber(stream); nextComma(stream); double maxLon = nextNumber(stream); nextComma(stream); double maxLat = nextNumber(stream...
parse geometry from the stream tokenizer
parseBBox
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/utils/geohash/WellKnownText.java
Apache-2.0
public static Set<URL> parseClassPath() { return Collections.emptySet(); }
Empty stub. Leave it here or you will die a slow and painful death. @return
parseClassPath
java
spring-projects/spring-data-elasticsearch
src/test/java/org/elasticsearch/bootstrap/JarHell.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/elasticsearch/bootstrap/JarHell.java
Apache-2.0
@Test // DATAES-628 public void shouldCreateNewDocument() { Document document = Document.create().append("key", "value"); assertThat(document).containsEntry("key", "value"); }
Unit tests for {@link Document}. @author Mark Paluch
shouldCreateNewDocument
java
spring-projects/spring-data-elasticsearch
src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
Apache-2.0
@Test // DATAES-628 public void shouldCreateNewDocumentFromMap() { Document document = Document.from(Collections.singletonMap("key", "value")); assertThat(document).containsEntry("key", "value"); }
Unit tests for {@link Document}. @author Mark Paluch
shouldCreateNewDocumentFromMap
java
spring-projects/spring-data-elasticsearch
src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
Apache-2.0
@Test // DATAES-628 public void shouldRenderDocumentToJson() { Document document = Document.from(Collections.singletonMap("key", "value")); assertThat(document.toJson()).isEqualTo("{\"key\":\"value\"}"); }
Unit tests for {@link Document}. @author Mark Paluch
shouldRenderDocumentToJson
java
spring-projects/spring-data-elasticsearch
src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
Apache-2.0
@Test // DATAES-628 public void shouldParseDocumentFromJson() { Document document = Document.parse("{\"key\":\"value\"}"); assertThat(document).containsEntry("key", "value"); }
Unit tests for {@link Document}. @author Mark Paluch
shouldParseDocumentFromJson
java
spring-projects/spring-data-elasticsearch
src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
Apache-2.0
@Test // DATAES-628 public void shouldReturnContainsKey() { Document document = Document.create().append("string", "value").append("bool", true).append("int", 43) .append("long", 42L); assertThat(document.containsKey("string")).isTrue(); assertThat(document.containsKey("not-set")).isFalse(); }
Unit tests for {@link Document}. @author Mark Paluch
shouldReturnContainsKey
java
spring-projects/spring-data-elasticsearch
src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
Apache-2.0
@Test // DATAES-628 public void shouldReturnContainsValue() { Document document = Document.create().append("string", "value").append("bool", Arrays.asList(true, true, false)) .append("int", 43).append("long", 42L); assertThat(document.containsValue("value")).isTrue(); assertThat(document.containsValue(43))...
Unit tests for {@link Document}. @author Mark Paluch
shouldReturnContainsValue
java
spring-projects/spring-data-elasticsearch
src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
Apache-2.0
@Test // DATAES-628 public void shouldReturnTypedValue() { Document document = Document.create().append("string", "value").append("bool", true).append("int", 43) .append("long", 42L); assertThat(document.get("string")).isEqualTo("value"); assertThat(document.getString("string")).isEqualTo("value"); asse...
Unit tests for {@link Document}. @author Mark Paluch
shouldReturnTypedValue
java
spring-projects/spring-data-elasticsearch
src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
Apache-2.0
@Test // DATAES-628 public void shouldReturnTypedValueString() { Document document = Document.create().append("string", "value").append("bool", true).append("int", 43) .append("long", 42L); assertThat(document.getString("string")).isEqualTo("value"); assertThat(document.getStringOrDefault("not-set", "defau...
Unit tests for {@link Document}. @author Mark Paluch
shouldReturnTypedValueString
java
spring-projects/spring-data-elasticsearch
src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
Apache-2.0
@Test // DATAES-628 public void shouldReturnTypedValueBoolean() { Document document = Document.create().append("string", "value").append("bool", true).append("int", 43) .append("long", 42L); assertThat(document.getBoolean("bool")).isTrue(); assertThat(document.getBooleanOrDefault("not-set", true)).isTrue()...
Unit tests for {@link Document}. @author Mark Paluch
shouldReturnTypedValueBoolean
java
spring-projects/spring-data-elasticsearch
src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
Apache-2.0
@Test // DATAES-628 public void shouldReturnTypedValueInt() { Document document = Document.create().append("string", "value").append("bool", true).append("int", 43) .append("long", 42L); assertThat(document.getInt("int")).isEqualTo(43); assertThat(document.getIntOrDefault("not-set", 44)).isEqualTo(44); a...
Unit tests for {@link Document}. @author Mark Paluch
shouldReturnTypedValueInt
java
spring-projects/spring-data-elasticsearch
src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/test/java/org/springframework/data/elasticsearch/DocumentUnitTests.java
Apache-2.0