Merge pull request #18533 from rmuir/painless_more_whitelisting

improve painless whitelist coverage of java api
This commit is contained in:
Robert Muir 2016-05-23 20:40:45 -04:00
commit b4c81080b0
12 changed files with 3621 additions and 529 deletions

View File

@ -37,8 +37,15 @@ import java.util.Objects;
* methods and fields during at both compile-time and runtime.
*/
public final class Definition {
private static final String DEFINITION_FILE = "definition.txt";
private static final List<String> DEFINITION_FILES = Collections.unmodifiableList(
Arrays.asList("org.elasticsearch.txt",
"java.lang.txt",
"java.math.txt",
"java.text.txt",
"java.util.txt",
"java.util.function.txt",
"java.util.stream.txt"));
private static final Definition INSTANCE = new Definition();
@ -158,15 +165,13 @@ public final class Definition {
public final Struct owner;
public final List<Type> arguments;
public final org.objectweb.asm.commons.Method method;
public final java.lang.reflect.Constructor<?> reflect;
private Constructor(final String name, final Struct owner, final List<Type> arguments,
final org.objectweb.asm.commons.Method method, final java.lang.reflect.Constructor<?> reflect) {
private Constructor(String name, Struct owner, List<Type> arguments,
org.objectweb.asm.commons.Method method) {
this.name = name;
this.owner = owner;
this.arguments = Collections.unmodifiableList(arguments);
this.method = method;
this.reflect = reflect;
}
}
@ -176,18 +181,17 @@ public final class Definition {
public final Type rtn;
public final List<Type> arguments;
public final org.objectweb.asm.commons.Method method;
public final java.lang.reflect.Method reflect;
public final int modifiers;
public final MethodHandle handle;
private Method(final String name, final Struct owner, final Type rtn, final List<Type> arguments,
final org.objectweb.asm.commons.Method method, final java.lang.reflect.Method reflect,
final MethodHandle handle) {
private Method(String name, Struct owner, Type rtn, List<Type> arguments,
org.objectweb.asm.commons.Method method, int modifiers, MethodHandle handle) {
this.name = name;
this.owner = owner;
this.rtn = rtn;
this.arguments = Collections.unmodifiableList(arguments);
this.method = method;
this.reflect = reflect;
this.modifiers = modifiers;
this.handle = handle;
}
}
@ -196,16 +200,17 @@ public final class Definition {
public final String name;
public final Struct owner;
public final Type type;
public final java.lang.reflect.Field reflect;
public final MethodHandle getter;
public final MethodHandle setter;
public final String javaName;
public final int modifiers;
private final MethodHandle getter;
private final MethodHandle setter;
private Field(final String name, final Struct owner, final Type type,
final java.lang.reflect.Field reflect, final MethodHandle getter, final MethodHandle setter) {
private Field(String name, String javaName, Struct owner, Type type, int modifiers, MethodHandle getter, MethodHandle setter) {
this.name = name;
this.javaName = javaName;
this.owner = owner;
this.type = type;
this.reflect = reflect;
this.modifiers = modifiers;
this.getter = getter;
this.setter = setter;
}
@ -436,102 +441,106 @@ public final class Definition {
/** adds classes from definition. returns hierarchy */
private Map<String,List<String>> addStructs() {
final Map<String,List<String>> hierarchy = new HashMap<>();
int currentLine = -1;
try {
try (InputStream stream = Definition.class.getResourceAsStream(DEFINITION_FILE);
LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
String line = null;
while ((line = reader.readLine()) != null) {
currentLine = reader.getLineNumber();
line = line.trim();
if (line.length() == 0 || line.charAt(0) == '#') {
continue;
}
if (line.startsWith("class ")) {
String elements[] = line.split("\u0020");
assert elements[2].equals("->");
if (elements.length == 7) {
hierarchy.put(elements[1], Arrays.asList(elements[5].split(",")));
} else {
assert elements.length == 5;
for (String file : DEFINITION_FILES) {
int currentLine = -1;
try {
try (InputStream stream = Definition.class.getResourceAsStream(file);
LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
String line = null;
while ((line = reader.readLine()) != null) {
currentLine = reader.getLineNumber();
line = line.trim();
if (line.length() == 0 || line.charAt(0) == '#') {
continue;
}
String className = elements[1];
String javaPeer = elements[3];
final Class<?> javaClazz;
switch (javaPeer) {
case "void":
javaClazz = void.class;
break;
case "boolean":
javaClazz = boolean.class;
break;
case "byte":
javaClazz = byte.class;
break;
case "short":
javaClazz = short.class;
break;
case "char":
javaClazz = char.class;
break;
case "int":
javaClazz = int.class;
break;
case "long":
javaClazz = long.class;
break;
case "float":
javaClazz = float.class;
break;
case "double":
javaClazz = double.class;
break;
default:
javaClazz = Class.forName(javaPeer);
break;
if (line.startsWith("class ")) {
String elements[] = line.split("\u0020");
assert elements[2].equals("->");
if (elements.length == 7) {
hierarchy.put(elements[1], Arrays.asList(elements[5].split(",")));
} else {
assert elements.length == 5;
}
String className = elements[1];
String javaPeer = elements[3];
final Class<?> javaClazz;
switch (javaPeer) {
case "void":
javaClazz = void.class;
break;
case "boolean":
javaClazz = boolean.class;
break;
case "byte":
javaClazz = byte.class;
break;
case "short":
javaClazz = short.class;
break;
case "char":
javaClazz = char.class;
break;
case "int":
javaClazz = int.class;
break;
case "long":
javaClazz = long.class;
break;
case "float":
javaClazz = float.class;
break;
case "double":
javaClazz = double.class;
break;
default:
javaClazz = Class.forName(javaPeer);
break;
}
addStruct(className, javaClazz);
}
addStruct(className, javaClazz);
}
}
} catch (Exception e) {
throw new RuntimeException("syntax error in " + file + ", line: " + currentLine, e);
}
} catch (Exception e) {
throw new RuntimeException("syntax error in definition line: " + currentLine, e);
}
return hierarchy;
}
/** adds class methods/fields/ctors */
private void addElements() {
int currentLine = -1;
try {
try (InputStream stream = Definition.class.getResourceAsStream(DEFINITION_FILE);
LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
String line = null;
String currentClass = null;
while ((line = reader.readLine()) != null) {
currentLine = reader.getLineNumber();
line = line.trim();
if (line.length() == 0 || line.charAt(0) == '#') {
continue;
} else if (line.startsWith("class ")) {
assert currentClass == null;
currentClass = line.split("\u0020")[1];
} else if (line.equals("}")) {
assert currentClass != null;
currentClass = null;
} else {
assert currentClass != null;
addSignature(currentClass, line);
for (String file : DEFINITION_FILES) {
int currentLine = -1;
try {
try (InputStream stream = Definition.class.getResourceAsStream(file);
LineNumberReader reader = new LineNumberReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
String line = null;
String currentClass = null;
while ((line = reader.readLine()) != null) {
currentLine = reader.getLineNumber();
line = line.trim();
if (line.length() == 0 || line.charAt(0) == '#') {
continue;
} else if (line.startsWith("class ")) {
assert currentClass == null;
currentClass = line.split("\u0020")[1];
} else if (line.equals("}")) {
assert currentClass != null;
currentClass = null;
} else {
assert currentClass != null;
addSignature(currentClass, line);
}
}
}
} catch (Exception e) {
throw new RuntimeException("syntax error in " + file + ", line: " + currentLine, e);
}
} catch (Exception e) {
throw new RuntimeException("syntax error in definition line: " + currentLine, e);
}
}
private final void addStruct(final String name, final Class<?> clazz) {
if (!name.matches("^[_a-zA-Z][<>,_a-zA-Z0-9]*$")) {
if (!name.matches("^[_a-zA-Z][\\.,_a-zA-Z0-9]*$")) {
throw new IllegalArgumentException("Invalid struct name [" + name + "].");
}
@ -591,7 +600,7 @@ public final class Definition {
}
final org.objectweb.asm.commons.Method asm = org.objectweb.asm.commons.Method.getMethod(reflect);
final Constructor constructor = new Constructor(name, owner, Arrays.asList(args), asm, reflect);
final Constructor constructor = new Constructor(name, owner, Arrays.asList(args), asm);
owner.constructors.put(methodKey, constructor);
}
@ -713,8 +722,8 @@ public final class Definition {
" with arguments " + Arrays.toString(classes) + ".");
}
final Method method = new Method(name, owner, rtn, Arrays.asList(args), asm, reflect, handle);
final int modifiers = reflect.getModifiers();
final Method method = new Method(name, owner, rtn, Arrays.asList(args), asm, modifiers, handle);
if (java.lang.reflect.Modifier.isStatic(modifiers)) {
owner.staticMethods.put(methodKey, method);
@ -767,7 +776,7 @@ public final class Definition {
" not found for class [" + owner.clazz.getName() + "].");
}
final Field field = new Field(name, owner, type, reflect, getter, setter);
final Field field = new Field(name, reflect.getName(), owner, type, modifiers, getter, setter);
if (isStatic) {
// require that all static fields are static final
@ -782,7 +791,7 @@ public final class Definition {
}
}
private final void copyStruct(final String struct, List<String> children) {
private void copyStruct(String struct, List<String> children) {
final Struct owner = structsMap.get(struct);
if (owner == null) {
@ -792,7 +801,7 @@ public final class Definition {
for (int count = 0; count < children.size(); ++count) {
final Struct child = structsMap.get(children.get(count));
if (struct == null) {
if (child == null) {
throw new IllegalArgumentException("Child struct [" + children.get(count) + "]" +
" not defined for copy to owner struct [" + owner.name + "].");
}
@ -802,62 +811,19 @@ public final class Definition {
" is not a super type of owner struct [" + owner.name + "] in copy.");
}
final boolean object = child.clazz.equals(Object.class) &&
java.lang.reflect.Modifier.isInterface(owner.clazz.getModifiers());
for (Map.Entry<MethodKey,Method> kvPair : child.methods.entrySet()) {
MethodKey methodKey = kvPair.getKey();
Method method = kvPair.getValue();
if (owner.methods.get(methodKey) == null) {
final Class<?> clazz = object ? Object.class : owner.clazz;
java.lang.reflect.Method reflect;
MethodHandle handle;
try {
reflect = clazz.getMethod(method.method.getName(), method.reflect.getParameterTypes());
} catch (final NoSuchMethodException exception) {
throw new IllegalArgumentException("Method [" + method.method.getName() + "] not found for" +
" class [" + owner.clazz.getName() + "] with arguments " +
Arrays.toString(method.reflect.getParameterTypes()) + ".");
}
try {
handle = MethodHandles.publicLookup().in(owner.clazz).unreflect(reflect);
} catch (final IllegalAccessException exception) {
throw new IllegalArgumentException("Method [" + method.method.getName() + "] not found for" +
" class [" + owner.clazz.getName() + "] with arguments " +
Arrays.toString(method.reflect.getParameterTypes()) + ".");
}
owner.methods.put(methodKey,
new Method(method.name, owner, method.rtn, method.arguments, method.method, reflect, handle));
new Method(method.name, owner, method.rtn, method.arguments, method.method, method.modifiers, method.handle));
}
}
for (final Field field : child.members.values()) {
for (Field field : child.members.values()) {
if (owner.members.get(field.name) == null) {
java.lang.reflect.Field reflect;
MethodHandle getter;
MethodHandle setter;
try {
reflect = owner.clazz.getField(field.reflect.getName());
} catch (final NoSuchFieldException exception) {
throw new IllegalArgumentException("Field [" + field.reflect.getName() + "]" +
" not found for class [" + owner.clazz.getName() + "].");
}
try {
getter = MethodHandles.publicLookup().unreflectGetter(reflect);
setter = MethodHandles.publicLookup().unreflectSetter(reflect);
} catch (final IllegalAccessException exception) {
throw new IllegalArgumentException("Getter/Setter [" + field.name + "]" +
" not found for class [" + owner.clazz.getName() + "].");
}
owner.members.put(field.name,
new Field(field.name, owner, field.type, reflect, getter, setter));
new Field(field.name, field.javaName, owner, field.type, field.modifiers, field.getter, field.setter));
}
}
}

View File

@ -95,7 +95,7 @@ public final class LCall extends ALink {
argument.write(writer);
}
if (java.lang.reflect.Modifier.isStatic(method.reflect.getModifiers())) {
if (java.lang.reflect.Modifier.isStatic(method.modifiers)) {
writer.invokeStatic(method.owner.type, method.method);
} else if (java.lang.reflect.Modifier.isInterface(method.owner.clazz.getModifiers())) {
writer.invokeInterface(method.owner.type, method.method);

View File

@ -62,7 +62,7 @@ public final class LField extends ALink {
field = statik ? struct.staticMembers.get(value) : struct.members.get(value);
if (field != null) {
if (store && java.lang.reflect.Modifier.isFinal(field.reflect.getModifiers())) {
if (store && java.lang.reflect.Modifier.isFinal(field.modifiers)) {
throw new IllegalArgumentException(error(
"Cannot write to read-only field [" + value + "] for type [" + struct.name + "]."));
}
@ -105,19 +105,19 @@ public final class LField extends ALink {
@Override
void load(MethodWriter writer) {
if (java.lang.reflect.Modifier.isStatic(field.reflect.getModifiers())) {
writer.getStatic(field.owner.type, field.reflect.getName(), field.type.type);
if (java.lang.reflect.Modifier.isStatic(field.modifiers)) {
writer.getStatic(field.owner.type, field.javaName, field.type.type);
} else {
writer.getField(field.owner.type, field.reflect.getName(), field.type.type);
writer.getField(field.owner.type, field.javaName, field.type.type);
}
}
@Override
void store(MethodWriter writer) {
if (java.lang.reflect.Modifier.isStatic(field.reflect.getModifiers())) {
writer.putStatic(field.owner.type, field.reflect.getName(), field.type.type);
if (java.lang.reflect.Modifier.isStatic(field.modifiers)) {
writer.putStatic(field.owner.type, field.javaName, field.type.type);
} else {
writer.putField(field.owner.type, field.reflect.getName(), field.type.type);
writer.putField(field.owner.type, field.javaName, field.type.type);
}
}
}

View File

@ -1,375 +0,0 @@
#
# Licensed to Elasticsearch under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
# Painless definition file. This defines the hierarchy of classes,
# what methods and fields they have, etc.
#
# primitive types
class void -> void {
}
class boolean -> boolean {
}
class byte -> byte {
}
class short -> short {
}
class char -> char {
}
class int -> int {
}
class long -> long {
}
class float -> float {
}
class double -> double {
}
# basic JDK classes
class Object -> java.lang.Object {
boolean equals(Object)
int hashCode()
String toString()
}
class def -> java.lang.Object {
boolean equals(Object)
int hashCode()
String toString()
}
class Void -> java.lang.Void extends Object {
}
class Boolean -> java.lang.Boolean extends Object {
Boolean TRUE
Boolean FALSE
int compare(boolean,boolean)
boolean parseBoolean(String)
Boolean valueOf(boolean)
boolean booleanValue()
int compareTo(Boolean)
}
class Byte -> java.lang.Byte extends Number,Object {
byte MIN_VALUE
byte MAX_VALUE
int compare(byte,byte)
int compareTo(Byte)
byte parseByte(String)
Byte valueOf(byte)
}
class Short -> java.lang.Short extends Number,Object {
short MIN_VALUE
short MAX_VALUE
int compare(short,short)
int compareTo(Short)
short parseShort(String)
Short valueOf(short)
}
class Character -> java.lang.Character extends Object {
char MIN_VALUE
char MAX_VALUE
int charCount(int)
char charValue()
int compare(char,char)
int compareTo(Character)
int digit(int,int)
char forDigit(int,int)
String getName(int)
int getNumericValue(int)
boolean isAlphabetic(int)
boolean isDefined(int)
boolean isDigit(int)
boolean isIdeographic(int)
boolean isLetter(int)
boolean isLetterOrDigit(int)
boolean isLowerCase(int)
boolean isMirrored(int)
boolean isSpaceChar(int)
boolean isTitleCase(int)
boolean isUpperCase(int)
boolean isWhitespace(int)
Character valueOf(char)
}
class Integer -> java.lang.Integer extends Number,Object {
int MIN_VALUE
int MAX_VALUE
int compare(int,int)
int compareTo(Integer)
int min(int,int)
int max(int,int)
int parseInt(String)
int signum(int)
String toHexString(int)
Integer valueOf(int)
}
class Long -> java.lang.Long extends Number,Object {
long MIN_VALUE
long MAX_VALUE
int compare(long,long)
int compareTo(Long)
long min(long,long)
long max(long,long)
long parseLong(String)
int signum(long)
String toHexString(long)
Long valueOf(long)
}
class Float -> java.lang.Float extends Number,Object {
float MIN_VALUE
float MAX_VALUE
int compare(float,float)
int compareTo(Float)
float min(float,float)
float max(float,float)
float parseFloat(String)
String toHexString(float)
Float valueOf(float)
}
class Double -> java.lang.Double extends Number,Object {
double MIN_VALUE
double MAX_VALUE
int compare(double,double)
int compareTo(Double)
double min(double,double)
double max(double,double)
double parseDouble(String)
String toHexString(double)
Double valueOf(double)
}
class Number -> java.lang.Number extends Object {
byte byteValue()
short shortValue()
int intValue()
long longValue()
float floatValue()
double doubleValue()
}
class CharSequence -> java.lang.CharSequence extends Object {
char charAt(int)
int length()
}
class String -> java.lang.String extends CharSequence,Object {
String <init>()
int codePointAt(int)
int compareTo(String)
String concat(String)
boolean endsWith(String)
int indexOf(String)
int indexOf(String,int)
boolean isEmpty()
String replace(CharSequence,CharSequence)
boolean startsWith(String)
String substring(int,int)
char[] toCharArray()
String trim()
}
class Math -> java.lang.Math {
double E
double PI
double abs(double)
double acos(double)
double asin(double)
double atan(double)
double atan2(double,double)
double cbrt(double)
double ceil(double)
double cos(double)
double cosh(double)
double exp(double)
double expm1(double)
double floor(double)
double hypot(double,double)
double log(double)
double log10(double)
double log1p(double)
double max(double,double)
double min(double,double)
double pow(double,double)
double random()
double rint(double)
long round(double)
double sin(double)
double sinh(double)
double sqrt(double)
double tan(double)
double tanh(double)
double toDegrees(double)
double toRadians(double)
}
class Iterator -> java.util.Iterator extends Object {
boolean hasNext()
def next()
void remove()
}
class Collection -> java.util.Collection extends Object {
boolean add(def)
void clear()
boolean contains(def)
boolean isEmpty()
Iterator iterator()
boolean remove(def)
int size()
}
class List -> java.util.List extends Collection,Object {
def set(int,def)
def get(int)
def remove(int)
int getLength/size()
}
class ArrayList -> java.util.ArrayList extends List,Collection,Object {
ArrayList <init>()
}
class Set -> java.util.Set extends Collection,Object {
}
class HashSet -> java.util.HashSet extends Set,Collection,Object {
HashSet <init>()
}
class Map -> java.util.Map extends Object {
def put(def,def)
def get(def)
def remove(def)
boolean isEmpty()
int size()
boolean containsKey(def)
Set keySet()
Collection values()
}
class HashMap -> java.util.HashMap extends Map,Object {
HashMap <init>()
}
class Exception -> java.lang.Exception extends Object {
String getMessage()
}
class ArithmeticException -> java.lang.ArithmeticException extends Exception,Object {
ArithmeticException <init>()
}
class IllegalArgumentException -> java.lang.IllegalArgumentException extends Exception,Object {
IllegalArgumentException <init>()
}
class IllegalStateException -> java.lang.IllegalStateException extends Exception,Object {
IllegalStateException <init>()
}
class NumberFormatException -> java.lang.NumberFormatException extends Exception,Object {
NumberFormatException <init>()
}
# ES Scripting API
class GeoPoint -> org.elasticsearch.common.geo.GeoPoint extends Object {
double getLat()
double getLon()
}
class Strings -> org.elasticsearch.index.fielddata.ScriptDocValues$Strings extends List,Collection,Object {
String getValue()
List getValues()
}
class Longs -> org.elasticsearch.index.fielddata.ScriptDocValues$Longs extends List,Collection,Object {
long getValue()
List getValues()
}
class Doubles -> org.elasticsearch.index.fielddata.ScriptDocValues$Doubles extends List,Collection,Object {
double getValue()
List getValues()
}
class GeoPoints -> org.elasticsearch.index.fielddata.ScriptDocValues$GeoPoints extends List,Collection,Object {
GeoPoint getValue()
List getValues()
double getLat()
double getLon()
double[] getLats()
double[] getLons()
# geo distance functions... so many...
double factorDistance(double,double)
double factorDistanceWithDefault(double,double,double)
double factorDistance02(double,double)
double factorDistance13(double,double)
double arcDistance(double,double)
double arcDistanceWithDefault(double,double,double)
double arcDistanceInKm(double,double)
double arcDistanceInKmWithDefault(double,double,double)
double arcDistanceInMiles(double,double)
double arcDistanceInMilesWithDefault(double,double,double)
double distance(double,double)
double distanceWithDefault(double,double,double)
double distanceInKm(double,double)
double distanceInKmWithDefault(double,double,double)
double distanceInMiles(double,double)
double distanceInMilesWithDefault(double,double,double)
double geohashDistance(String)
double geohashDistanceInKm(String)
double geohashDistanceInMiles(String)
}
# for testing.
# currently FeatureTest exposes overloaded constructor, field load store, and overloaded static methods
class FeatureTest -> org.elasticsearch.painless.FeatureTest extends Object {
FeatureTest <init>()
FeatureTest <init>(int,int)
int getX()
int getY()
void setX(int)
void setY(int)
boolean overloadedStatic()
boolean overloadedStatic(boolean)
}
# currently needed internally
class Executable -> org.elasticsearch.painless.Executable {
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,149 @@
#
# Licensed to Elasticsearch under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
# Painless definition file. This defines the hierarchy of classes,
# what methods and fields they have, etc.
#
#### Classes
class BigDecimal -> java.math.BigDecimal extends Number,Comparable,Object {
BigDecimal ONE
BigDecimal TEN
BigDecimal ZERO
BigDecimal <init>(String)
BigDecimal <init>(String,MathContext)
BigDecimal abs()
BigDecimal abs(MathContext)
BigDecimal add(BigDecimal)
BigDecimal add(BigDecimal,MathContext)
byte byteValueExact()
BigDecimal divide(BigDecimal)
BigDecimal divide(BigDecimal,MathContext)
BigDecimal[] divideAndRemainder(BigDecimal)
BigDecimal[] divideAndRemainder(BigDecimal,MathContext)
BigDecimal divideToIntegralValue(BigDecimal)
BigDecimal divideToIntegralValue(BigDecimal,MathContext)
int intValueExact()
long longValueExact()
BigDecimal max(BigDecimal)
BigDecimal min(BigDecimal)
BigDecimal movePointLeft(int)
BigDecimal movePointRight(int)
BigDecimal multiply(BigDecimal)
BigDecimal multiply(BigDecimal,MathContext)
BigDecimal negate()
BigDecimal negate(MathContext)
BigDecimal plus()
BigDecimal plus(MathContext)
BigDecimal pow(int)
BigDecimal pow(int,MathContext)
int precision()
BigDecimal remainder(BigDecimal)
BigDecimal remainder(BigDecimal,MathContext)
BigDecimal round(MathContext)
int scale()
BigDecimal scaleByPowerOfTen(int)
BigDecimal setScale(int)
BigDecimal setScale(int,RoundingMode)
short shortValueExact()
int signum()
BigDecimal stripTrailingZeros()
BigDecimal subtract(BigDecimal)
BigDecimal subtract(BigDecimal,MathContext)
BigInteger toBigInteger()
BigInteger toBigIntegerExact()
String toEngineeringString()
String toPlainString()
BigDecimal ulp()
BigDecimal valueOf(double)
}
class BigInteger -> java.math.BigInteger extends Number,Comparable,Object {
BigInteger ONE
BigInteger TEN
BigInteger ZERO
BigInteger <init>(String)
BigInteger <init>(String,int)
BigInteger abs()
BigInteger add(BigInteger)
BigInteger and(BigInteger)
BigInteger andNot(BigInteger)
int bitCount()
int bitLength()
byte byteValueExact()
BigInteger clearBit(int)
BigInteger divide(BigInteger)
BigInteger[] divideAndRemainder(BigInteger)
BigInteger flipBit(int)
BigInteger gcd(BigInteger)
int getLowestSetBit()
int intValueExact()
long longValueExact()
BigInteger max(BigInteger)
BigInteger min(BigInteger)
BigInteger mod(BigInteger)
BigInteger modInverse(BigInteger)
BigInteger modPow(BigInteger,BigInteger)
BigInteger multiply(BigInteger)
BigInteger negate()
BigInteger not()
BigInteger or(BigInteger)
BigInteger pow(int)
BigInteger remainder(BigInteger)
BigInteger setBit(int)
BigInteger shiftLeft(int)
BigInteger shiftRight(int)
short shortValueExact()
int signum()
BigInteger subtract(BigInteger)
boolean testBit(int)
byte[] toByteArray()
String toString(int)
BigInteger valueOf(long)
BigInteger xor(BigInteger)
}
class MathContext -> java.math.MathContext extends Object {
MathContext DECIMAL128
MathContext DECIMAL32
MathContext DECIMAL64
MathContext UNLIMITED
MathContext <init>(int)
MathContext <init>(int,RoundingMode)
int getPrecision()
RoundingMode getRoundingMode()
}
#### Enums
class RoundingMode -> java.math.RoundingMode extends Enum,Object {
RoundingMode CEILING
RoundingMode DOWN
RoundingMode FLOOR
RoundingMode HALF_DOWN
RoundingMode HALF_EVEN
RoundingMode HALF_UP
RoundingMode UNNECESSARY
RoundingMode UP
RoundingMode valueOf(String)
RoundingMode[] values()
}

View File

@ -0,0 +1,486 @@
#
# Licensed to Elasticsearch under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
# Painless definition file. This defines the hierarchy of classes,
# what methods and fields they have, etc.
#
#### Interfaces
class AttributedCharacterIterator -> java.text.AttributedCharacterIterator extends CharacterIterator {
Set getAllAttributeKeys()
def getAttribute(AttributedCharacterIterator.Attribute)
Map getAttributes()
int getRunLimit()
int getRunLimit(Set)
int getRunStart()
int getRunStart(Set)
}
class CharacterIterator -> java.text.CharacterIterator {
char DONE
def clone()
char current()
char first()
int getBeginIndex()
int getEndIndex()
int getIndex()
char last()
char next()
char previous()
char setIndex(int)
}
#### Classes
class Annotation -> java.text.Annotation extends Object {
Annotation <init>(Object)
def getValue()
}
class AttributedCharacterIterator.Attribute -> java.text.AttributedCharacterIterator$Attribute extends Object {
AttributedCharacterIterator.Attribute INPUT_METHOD_SEGMENT
AttributedCharacterIterator.Attribute LANGUAGE
AttributedCharacterIterator.Attribute READING
}
class AttributedString -> java.text.AttributedString extends Object {
AttributedString <init>(String)
AttributedString <init>(String,Map)
void addAttribute(AttributedCharacterIterator.Attribute,Object)
void addAttribute(AttributedCharacterIterator.Attribute,Object,int,int)
void addAttributes(Map,int,int)
AttributedCharacterIterator getIterator()
AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[])
AttributedCharacterIterator getIterator(AttributedCharacterIterator.Attribute[],int,int)
}
class Bidi -> java.text.Bidi extends Object {
int DIRECTION_DEFAULT_LEFT_TO_RIGHT
int DIRECTION_DEFAULT_RIGHT_TO_LEFT
int DIRECTION_LEFT_TO_RIGHT
int DIRECTION_RIGHT_TO_LEFT
Bidi <init>(AttributedCharacterIterator)
Bidi <init>(char[],int,byte[],int,int,int)
Bidi <init>(String,int)
boolean baseIsLeftToRight()
Bidi createLineBidi(int,int)
int getBaseLevel()
int getLength()
int getLevelAt(int)
int getRunCount()
int getRunLevel(int)
int getRunLimit(int)
int getRunStart(int)
boolean isLeftToRight()
boolean isMixed()
boolean isRightToLeft()
void reorderVisually(byte[],int,Object[],int,int)
boolean requiresBidi(char[],int,int)
}
class BreakIterator -> java.text.BreakIterator extend Object {
int DONE
def clone()
int current()
int first()
int following(int)
Locale[] getAvailableLocales()
BreakIterator getCharacterInstance()
BreakIterator getCharacterInstance(Locale)
BreakIterator getLineInstance()
BreakIterator getLineInstance(Locale)
BreakIterator getSentenceInstance()
BreakIterator getSentenceInstance(Locale)
CharacterIterator getText()
BreakIterator getWordInstance()
BreakIterator getWordInstance(Locale)
boolean isBoundary(int)
int last()
int next()
int next(int)
int preceding(int)
int previous()
void setText(String)
}
class ChoiceFormat -> java.text.ChoiceFormat extends NumberFormat,Format,Object {
ChoiceFormat <init>(double[],String[])
ChoiceFormat <init>(String)
void applyPattern(String)
def[] getFormats()
double[] getLimits()
double nextDouble(double)
double nextDouble(double,boolean)
double previousDouble(double)
void setChoices(double[],String[])
String toPattern()
}
class CollationElementIterator -> java.text.CollationElementIterator extends Object {
int NULLORDER
int getMaxExpansion(int)
int getOffset()
int next()
int previous()
int primaryOrder(int)
void reset()
short secondaryOrder(int)
void setOffset(int)
void setText(String)
short tertiaryOrder(int)
}
class CollationKey -> java.text.CollationKey extends Comparable,Object {
String getSourceString()
byte[] toByteArray()
}
class Collator -> java.text.Collator extends Comparator,Object {
int CANONICAL_DECOMPOSITION
int FULL_DECOMPOSITION
int IDENTICAL
int NO_DECOMPOSITION
int PRIMARY
int SECONDARY
int TERTIARY
def clone()
boolean equals(String,String)
Locale[] getAvailableLocales()
CollationKey getCollationKey(String)
int getDecomposition()
Collator getInstance()
Collator getInstance(Locale)
int getStrength()
void setDecomposition(int)
void setStrength(int)
}
class DateFormat -> java.text.DateFormat extends Format,Object {
int AM_PM_FIELD
int DATE_FIELD
int DAY_OF_WEEK_FIELD
int DAY_OF_WEEK_IN_MONTH_FIELD
int DAY_OF_YEAR_FIELD
int DEFAULT
int ERA_FIELD
int FULL
int HOUR_OF_DAY0_FIELD
int HOUR_OF_DAY1_FIELD
int HOUR0_FIELD
int HOUR1_FIELD
int LONG
int MEDIUM
int MILLISECOND_FIELD
int MINUTE_FIELD
int MONTH_FIELD
int SECOND_FIELD
int SHORT
int TIMEZONE_FIELD
int WEEK_OF_MONTH_FIELD
int WEEK_OF_YEAR_FIELD
int YEAR_FIELD
Locale[] getAvailableLocales()
Calendar getCalendar()
DateFormat getDateInstance()
DateFormat getDateInstance(int)
DateFormat getDateInstance(int,Locale)
DateFormat getDateTimeInstance()
DateFormat getDateTimeInstance(int,int)
DateFormat getDateTimeInstance(int,int,Locale)
DateFormat getInstance()
NumberFormat getNumberFormat()
DateFormat getTimeInstance()
DateFormat getTimeInstance(int)
DateFormat getTimeInstance(int,Locale)
TimeZone getTimeZone()
boolean isLenient()
Date parse(String)
Date parse(String,ParsePosition)
void setCalendar(Calendar)
void setLenient(boolean)
void setNumberFormat(NumberFormat)
void setTimeZone(TimeZone)
}
class DateFormat.Field -> java.text.DateFormat$Field extends Format.Field,AttributedCharacterIterator.Attribute,Object {
DateFormat.Field AM_PM
DateFormat.Field DAY_OF_MONTH
DateFormat.Field DAY_OF_WEEK
DateFormat.Field DAY_OF_WEEK_IN_MONTH
DateFormat.Field DAY_OF_YEAR
DateFormat.Field ERA
DateFormat.Field HOUR_OF_DAY0
DateFormat.Field HOUR_OF_DAY1
DateFormat.Field HOUR0
DateFormat.Field HOUR1
DateFormat.Field MILLISECOND
DateFormat.Field MINUTE
DateFormat.Field MONTH
DateFormat.Field SECOND
DateFormat.Field TIME_ZONE
DateFormat.Field WEEK_OF_MONTH
DateFormat.Field WEEK_OF_YEAR
DateFormat.Field YEAR
int getCalendarField()
DateFormat.Field ofCalendarField(int)
}
class DateFormatSymbols -> java.text.DateFormatSymbols extends Object {
DateFormatSymbols <init>()
DateFormatSymbols <init>(Locale)
def clone()
String[] getAmPmStrings()
Locale[] getAvailableLocales()
String[] getEras()
DateFormatSymbols getInstance()
DateFormatSymbols getInstance(Locale)
String getLocalPatternChars()
String[] getMonths()
String[] getShortMonths()
String[] getShortWeekdays()
String[] getWeekdays()
String[][] getZoneStrings()
int hashCode()
void setAmPmStrings(String[])
void setEras(String[])
void setLocalPatternChars(String)
void setMonths(String[])
void setShortMonths(String[])
void setShortWeekdays(String[])
void setWeekdays(String[])
void setZoneStrings(String[][])
}
class DecimalFormat -> java.text.DecimalFormat extends NumberFormat,Format,Object {
DecimalFormat <init>()
DecimalFormat <init>(String)
DecimalFormat <init>(String,DecimalFormatSymbols)
void applyLocalizedPattern(String)
void applyPattern(String)
DecimalFormatSymbols getDecimalFormatSymbols()
int getGroupingSize()
int getMultiplier()
String getNegativePrefix()
String getNegativeSuffix()
String getPositivePrefix()
String getPositiveSuffix()
boolean isDecimalSeparatorAlwaysShown()
boolean isParseBigDecimal()
void setDecimalFormatSymbols(DecimalFormatSymbols)
void setDecimalSeparatorAlwaysShown(boolean)
void setGroupingSize(int)
void setMultiplier(int)
void setNegativePrefix(String)
void setNegativeSuffix(String)
void setPositivePrefix(String)
void setPositiveSuffix(String)
void setParseBigDecimal(boolean)
String toLocalizedPattern()
String toPattern()
}
class DecimalFormatSymbols -> java.text.DecimalFormatSymbols extends Object {
DecimalFormatSymbols <init>()
DecimalFormatSymbols <init>(Locale)
def clone()
Locale[] getAvailableLocales()
Currency getCurrency()
String getCurrencySymbol()
char getDecimalSeparator()
char getDigit()
String getExponentSeparator()
char getGroupingSeparator()
String getInfinity()
DecimalFormatSymbols getInstance()
DecimalFormatSymbols getInstance(Locale)
String getInternationalCurrencySymbol()
char getMinusSign()
char getMonetaryDecimalSeparator()
String getNaN()
char getPatternSeparator()
char getPercent()
char getPerMill()
char getZeroDigit()
void setCurrency(Currency)
void setCurrencySymbol(String)
void setDecimalSeparator(char)
void setDigit(char)
void setExponentSeparator(String)
void setGroupingSeparator(char)
void setInfinity(String)
void setInternationalCurrencySymbol(String)
void setMinusSign(char)
void setMonetaryDecimalSeparator(char)
void setNaN(String)
void setPatternSeparator(char)
void setPercent(char)
void setPerMill(char)
void setZeroDigit(char)
}
class FieldPosition -> java.text.FieldPosition extends Object {
FieldPosition <init>(int)
FieldPosition <init>(Format.Field,int)
int getBeginIndex()
int getEndIndex()
int getField()
Format.Field getFieldAttribute()
void setBeginIndex(int)
void setEndIndex(int)
}
class Format -> java.text.Format extends Object {
def clone()
String format(Object)
StringBuffer format(Object,StringBuffer,FieldPosition)
AttributedCharacterIterator formatToCharacterIterator(Object)
Object parseObject(String)
Object parseObject(String,ParsePosition)
}
class Format.Field -> java.text.Format$Field extends AttributedCharacterIterator.Attribute,Object {
}
class MessageFormat -> java.text.MessageFormat extends Format,Object {
void applyPattern(String)
String format(String,Object[])
Format[] getFormats()
Format[] getFormatsByArgumentIndex()
Locale getLocale()
Object[] parse(String)
Object[] parse(String,ParsePosition)
void setFormat(int,Format)
void setFormatByArgumentIndex(int,Format)
void setFormats(Format[])
void setFormatsByArgumentIndex(Format[])
void setLocale(Locale)
String toPattern()
}
class MessageFormat.Field -> java.text.MessageFormat$Field extends Format.Field,AttributedCharacterIterator.Attribute,Object {
MessageFormat.Field ARGUMENT
}
class Normalizer -> java.text.Normalizer extends Object {
boolean isNormalized(CharSequence,Normalizer.Form)
String normalize(CharSequence,Normalizer.Form)
}
class NumberFormat -> java.text.NumberFormat extends Format,Object {
int FRACTION_FIELD
int INTEGER_FIELD
Locale[] getAvailableLocales()
Currency getCurrency()
NumberFormat getCurrencyInstance()
NumberFormat getCurrencyInstance(Locale)
NumberFormat getInstance()
NumberFormat getInstance(Locale)
NumberFormat getIntegerInstance()
NumberFormat getIntegerInstance(Locale)
int getMaximumFractionDigits()
int getMaximumIntegerDigits()
int getMinimumFractionDigits()
int getMinimumIntegerDigits()
NumberFormat getNumberInstance()
NumberFormat getNumberInstance(Locale)
NumberFormat getPercentInstance()
NumberFormat getPercentInstance(Locale)
RoundingMode getRoundingMode()
boolean isGroupingUsed()
boolean isParseIntegerOnly()
Number parse(String)
Number parse(String,ParsePosition)
void setCurrency(Currency)
void setGroupingUsed(boolean)
void setMaximumFractionDigits(int)
void setMaximumIntegerDigits(int)
void setMinimumFractionDigits(int)
void setMinimumIntegerDigits(int)
void setParseIntegerOnly(boolean)
void setRoundingMode(RoundingMode)
}
class NumberFormat.Field -> java.text.NumberFormat$Field extends Format.Field,AttributedCharacterIterator.Attribute,Object {
NumberFormat.Field CURRENCY
NumberFormat.Field DECIMAL_SEPARATOR
NumberFormat.Field EXPONENT
NumberFormat.Field EXPONENT_SIGN
NumberFormat.Field EXPONENT_SYMBOL
NumberFormat.Field FRACTION
NumberFormat.Field GROUPING_SEPARATOR
NumberFormat.Field INTEGER
NumberFormat.Field PERCENT
NumberFormat.Field PERMILLE
NumberFormat.Field SIGN
}
class ParsePosition -> java.text.ParsePosition extends Object {
ParsePosition <init>(int)
int getErrorIndex()
int getIndex()
void setErrorIndex(int)
void setIndex(int)
}
class RuleBasedCollator -> java.text.RuleBasedCollator extends Collator,Comparator,Object {
RuleBasedCollator <init>(String)
CollationElementIterator getCollationElementIterator(String)
String getRules()
}
class SimpleDateFormat -> java.text.SimpleDateFormat extends DateFormat,Format,Object {
SimpleDateFormat <init>()
SimpleDateFormat <init>(String)
SimpleDateFormat <init>(String,Locale)
void applyLocalizedPattern(String)
void applyPattern(String)
Date get2DigitYearStart()
DateFormatSymbols getDateFormatSymbols()
void setDateFormatSymbols(DateFormatSymbols)
void set2DigitYearStart(Date)
String toLocalizedPattern()
String toPattern()
}
class StringCharacterIterator -> java.text.StringCharacterIterator extends CharacterIterator,Object {
StringCharacterIterator <init>(String)
StringCharacterIterator <init>(String,int)
StringCharacterIterator <init>(String,int,int,int)
void setText(String)
}
#### Enums
class Normalizer.Form -> java.text.Normalizer$Form extends Enum,Object {
Normalizer.Form NFC
Normalizer.Form NFD
Normalizer.Form NFKC
Normalizer.Form NFKD
Normalizer.Form valueOf(String)
Normalizer.Form[] values()
}
#### Exceptions
class ParseException -> java.text.ParseException extends Exception,Object {
ParseException <init>(String,int)
int getErrorOffset()
}

View File

@ -0,0 +1,232 @@
#
# Licensed to Elasticsearch under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
# Painless definition file. This defines the hierarchy of classes,
# what methods and fields they have, etc.
#
#### Interfaces
class BiConsumer -> java.util.function.BiConsumer {
void accept(def,def)
BiConsumer andThen(BiConsumer)
}
class BiFunction -> java.util.function.BiFunction {
BiFunction andThen(Function)
def apply(def,def)
}
class BinaryOperator -> java.util.function.BinaryOperator extends BiFunction {
BinaryOperator maxBy(Comparator)
BinaryOperator minBy(Comparator)
}
class BiPredicate -> java.util.function.BiPredicate {
BiPredicate and(BiPredicate)
BiPredicate negate()
BiPredicate or(BiPredicate)
boolean test(def,def)
}
class BooleanSupplier -> java.util.function.BooleanSupplier {
boolean getAsBoolean()
}
class Consumer -> java.util.function.Consumer {
void accept(def)
Consumer andThen(Consumer)
}
class DoubleBinaryOperator -> java.util.function.DoubleBinaryOperator {
double applyAsDouble(double,double)
}
class DoubleConsumer -> java.util.function.DoubleConsumer {
void accept(double)
DoubleConsumer andThen(DoubleConsumer)
}
class DoubleFunction -> java.util.function.DoubleFunction {
def apply(double)
}
class DoublePredicate -> java.util.function.DoublePredicate {
DoublePredicate and(DoublePredicate)
DoublePredicate negate()
DoublePredicate or(DoublePredicate)
boolean test(double)
}
class DoubleSupplier -> java.util.function.DoubleSupplier {
double getAsDouble()
}
class DoubleToIntFunction -> java.util.function.DoubleToIntFunction {
int applyAsInt(double)
}
class DoubleToLongFunction -> java.util.function.DoubleToLongFunction {
long applyAsLong(double)
}
class DoubleUnaryOperator -> java.util.function.DoubleUnaryOperator {
DoubleUnaryOperator andThen(DoubleUnaryOperator)
double applyAsDouble(double)
DoubleUnaryOperator compose(DoubleUnaryOperator)
DoubleUnaryOperator identity()
}
class Function -> java.util.function.Function {
Function andThen(Function)
def apply(def)
Function compose(Function)
Function identity()
}
class IntBinaryOperator -> java.util.function.IntBinaryOperator {
int applyAsInt(int,int)
}
class IntConsumer -> java.util.function.IntConsumer {
void accept(int)
IntConsumer andThen(IntConsumer)
}
class IntFunction -> java.util.function.IntFunction {
def apply(int)
}
class IntPredicate -> java.util.function.IntPredicate {
IntPredicate and(IntPredicate)
IntPredicate negate()
IntPredicate or(IntPredicate)
boolean test(int)
}
class IntSupplier -> java.util.function.IntSupplier {
int getAsInt()
}
class IntToDoubleFunction -> java.util.function.IntToDoubleFunction {
double applyAsDouble(int)
}
class IntToLongFunction -> java.util.function.IntToLongFunction {
long applyAsLong(int)
}
class IntUnaryOperator -> java.util.function.IntUnaryOperator {
IntUnaryOperator andThen(IntUnaryOperator)
int applyAsInt(int)
IntUnaryOperator compose(IntUnaryOperator)
IntUnaryOperator identity()
}
class LongBinaryOperator -> java.util.function.LongBinaryOperator {
long applyAsLong(long,long)
}
class LongConsumer -> java.util.function.LongConsumer {
void accept(long)
LongConsumer andThen(LongConsumer)
}
class LongFunction -> java.util.function.LongFunction {
def apply(long)
}
class LongPredicate -> java.util.function.LongPredicate {
LongPredicate and(LongPredicate)
LongPredicate negate()
LongPredicate or(LongPredicate)
boolean test(long)
}
class LongSupplier -> java.util.function.LongSupplier {
long getAsLong()
}
class LongToDoubleFunction -> java.util.function.LongToDoubleFunction {
double applyAsDouble(long)
}
class LongToIntFunction -> java.util.function.LongToIntFunction {
int applyAsInt(long)
}
class LongUnaryOperator -> java.util.function.LongUnaryOperator {
LongUnaryOperator andThen(LongUnaryOperator)
long applyAsLong(long)
LongUnaryOperator compose(LongUnaryOperator)
LongUnaryOperator identity()
}
class ObjDoubleConsumer -> java.util.function.ObjDoubleConsumer {
void accept(def,double)
}
class ObjIntConsumer -> java.util.function.ObjIntConsumer {
void accept(def,int)
}
class ObjLongConsumer -> java.util.function.ObjLongConsumer {
void accept(def,long)
}
class Predicate -> java.util.function.Predicate {
Predicate and(Predicate)
Predicate isEqual(def)
Predicate negate()
Predicate or(Predicate)
boolean test(def)
}
class Supplier -> java.util.function.Supplier {
def get()
}
class ToDoubleBiFunction -> java.util.function.ToDoubleBiFunction {
double applyAsDouble(def,def)
}
class ToDoubleFunction -> java.util.function.ToDoubleFunction {
double applyAsDouble(def)
}
class ToIntBiFunction -> java.util.function.ToIntBiFunction {
int applyAsInt(def,def)
}
class ToIntFunction -> java.util.function.ToIntFunction {
int applyAsInt(def)
}
class ToLongBiFunction -> java.util.function.ToLongBiFunction {
long applyAsLong(def,def)
}
class ToLongFunction -> java.util.function.ToLongFunction {
long applyAsLong(def)
}
class UnaryOperator -> java.util.function.UnaryOperator extends Function {
UnaryOperator identity()
}

View File

@ -0,0 +1,273 @@
#
# Licensed to Elasticsearch under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
# Painless definition file. This defines the hierarchy of classes,
# what methods and fields they have, etc.
#
#### Interfaces
class BaseStream -> java.util.stream.BaseStream {
void close()
boolean isParallel()
Iterator iterator()
BaseStream sequential()
Spliterator spliterator()
BaseStream unordered()
}
class Collector -> java.util.stream.Collector {
BiConsumer accumulator()
Set characteristics()
BinaryOperator combiner()
Function finisher()
Collector of(Supplier,BiConsumer,BinaryOperator,Function,Collector.Characteristics[])
Collector of(Supplier,BiConsumer,BinaryOperator,Collector.Characteristics[])
Supplier supplier()
}
class DoubleStream -> java.util.stream.DoubleStream extends BaseStream {
boolean allMatch(DoublePredicate)
boolean anyMatch(DoublePredicate)
OptionalDouble average()
Stream boxed()
DoubleStream.Builder builder()
def collect(Supplier,ObjDoubleConsumer,BiConsumer)
DoubleStream concat(DoubleStream,DoubleStream)
long count()
DoubleStream distinct()
DoubleStream empty()
DoubleStream filter(DoublePredicate)
OptionalDouble findAny()
OptionalDouble findFirst()
DoubleStream flatMap(DoubleFunction)
void forEach(DoubleConsumer)
void forEachOrdered(DoubleConsumer)
PrimitiveIterator.OfDouble iterator()
DoubleStream limit(long)
DoubleStream map(DoubleUnaryOperator)
IntStream mapToInt(DoubleToIntFunction)
LongStream mapToLong(DoubleToLongFunction)
Stream mapToObj(DoubleFunction)
OptionalDouble max()
OptionalDouble min()
boolean noneMatch(DoublePredicate)
DoubleStream of(double[])
DoubleStream peek(DoubleConsumer)
OptionalDouble reduce(DoubleBinaryOperator)
double reduce(double,DoubleBinaryOperator)
DoubleStream sequential()
DoubleStream skip(long)
DoubleStream sorted()
Spliterator.OfDouble spliterator()
double sum()
DoubleSummaryStatistics summaryStatistics()
double[] toArray()
}
class DoubleStream.Builder -> java.util.stream.DoubleStream$Builder extends DoubleConsumer {
DoubleStream.Builder add(double)
DoubleStream build()
}
class IntStream -> java.util.stream.IntStream extends BaseStream {
boolean allMatch(IntPredicate)
boolean anyMatch(IntPredicate)
DoubleStream asDoubleStream()
LongStream asLongStream()
OptionalDouble average()
Stream boxed()
IntStream.Builder builder()
def collect(Supplier,ObjIntConsumer,BiConsumer)
IntStream concat(IntStream,IntStream)
long count()
IntStream distinct()
IntStream empty()
IntStream filter(IntPredicate)
OptionalInt findAny()
OptionalInt findFirst()
IntStream flatMap(IntFunction)
void forEach(IntConsumer)
void forEachOrdered(IntConsumer)
PrimitiveIterator.OfInt iterator()
IntStream limit(long)
IntStream map(IntUnaryOperator)
DoubleStream mapToDouble(IntToDoubleFunction)
LongStream mapToLong(IntToLongFunction)
Stream mapToObj(IntFunction)
OptionalInt max()
OptionalInt min()
boolean noneMatch(IntPredicate)
IntStream of(int[])
IntStream peek(IntConsumer)
IntStream range(int,int)
IntStream rangeClosed(int,int)
OptionalInt reduce(IntBinaryOperator)
int reduce(int,IntBinaryOperator)
IntStream sequential()
IntStream skip(long)
IntStream sorted()
Spliterator.OfInt spliterator()
int sum()
IntSummaryStatistics summaryStatistics()
int[] toArray()
}
class IntStream.Builder -> java.util.stream.IntStream$Builder extends IntConsumer {
IntStream.Builder add(int)
IntStream build()
}
class LongStream -> java.util.stream.LongStream extends BaseStream {
boolean allMatch(LongPredicate)
boolean anyMatch(LongPredicate)
DoubleStream asDoubleStream()
OptionalDouble average()
Stream boxed()
LongStream.Builder builder()
def collect(Supplier,ObjLongConsumer,BiConsumer)
LongStream concat(LongStream,LongStream)
long count()
LongStream distinct()
LongStream empty()
LongStream filter(LongPredicate)
OptionalLong findAny()
OptionalLong findFirst()
LongStream flatMap(LongFunction)
void forEach(LongConsumer)
void forEachOrdered(LongConsumer)
PrimitiveIterator.OfLong iterator()
LongStream limit(long)
LongStream map(LongUnaryOperator)
DoubleStream mapToDouble(LongToDoubleFunction)
IntStream mapToInt(LongToIntFunction)
Stream mapToObj(LongFunction)
OptionalLong max()
OptionalLong min()
boolean noneMatch(LongPredicate)
LongStream of(long[])
LongStream peek(LongConsumer)
LongStream range(long,long)
LongStream rangeClosed(long,long)
OptionalLong reduce(LongBinaryOperator)
long reduce(long,LongBinaryOperator)
LongStream sequential()
LongStream skip(long)
LongStream sorted()
Spliterator.OfLong spliterator()
long sum()
LongSummaryStatistics summaryStatistics()
long[] toArray()
}
class LongStream.Builder -> java.util.stream.LongStream$Builder extends LongConsumer {
LongStream.Builder add(long)
LongStream build()
}
class Stream -> java.util.stream.Stream extends BaseStream {
boolean allMatch(Predicate)
boolean anyMatch(Predicate)
Stream.Builder builder()
def collect(Collector)
def collect(Supplier,BiConsumer,BiConsumer)
Stream concat(Stream,Stream)
long count()
Stream distinct()
Stream empty()
Stream filter(Predicate)
Optional findAny()
Optional findFirst()
Stream flatMap(Function)
DoubleStream flatMapToDouble(Function)
IntStream flatMapToInt(Function)
LongStream flatMapToLong(Function)
void forEach(Consumer)
void forEachOrdered(Consumer)
Stream limit(long)
Stream map(Function)
DoubleStream mapToDouble(ToDoubleFunction)
IntStream mapToInt(ToIntFunction)
LongStream mapToLong(ToLongFunction)
Optional max(Comparator)
Optional min(Comparator)
boolean noneMatch(Predicate)
Stream of(def[])
Stream peek(Consumer)
Optional reduce(BinaryOperator)
def reduce(def,BinaryOperator)
def reduce(def,BiFunction,BinaryOperator)
Stream skip(long)
Stream sorted()
Stream sorted(Comparator)
def[] toArray()
def[] toArray(IntFunction)
}
class Stream.Builder -> java.util.stream.Stream$Builder extends Consumer {
Stream.Builder add(def)
Stream build()
}
#### Classes
class Collectors -> java.util.stream.Collectors extends Object {
Collector averagingDouble(ToDoubleFunction)
Collector averagingInt(ToIntFunction)
Collector averagingLong(ToLongFunction)
Collector collectingAndThen(Collector,Function)
Collector counting()
Collector groupingBy(Function)
Collector groupingBy(Function,Collector)
Collector groupingBy(Function,Supplier,Collector)
Collector joining()
Collector joining(CharSequence)
Collector joining(CharSequence,CharSequence,CharSequence)
Collector mapping(Function,Collector)
Collector maxBy(Comparator)
Collector minBy(Comparator)
Collector partitioningBy(Predicate)
Collector partitioningBy(Predicate,Collector)
Collector reducing(BinaryOperator)
Collector reducing(def,BinaryOperator)
Collector reducing(def,Function,BinaryOperator)
Collector summarizingDouble(ToDoubleFunction)
Collector summarizingInt(ToIntFunction)
Collector summarizingLong(ToLongFunction)
Collector summingDouble(ToDoubleFunction)
Collector summingInt(ToIntFunction)
Collector summingLong(ToLongFunction)
Collector toCollection(Supplier)
Collector toList()
Collector toMap(Function,Function)
Collector toMap(Function,Function,BinaryOperator)
Collector toMap(Function,Function,BinaryOperator,Supplier)
Collector toSet()
}
#### Enums
class Collector.Characteristics -> java.util.stream.Collector$Characteristics extends Enum,Object {
Collector.Characteristics CONCURRENT
Collector.Characteristics IDENTITY_FINISH
Collector.Characteristics UNORDERED
Collector.Characteristics valueOf(String)
Collector.Characteristics[] values()
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,127 @@
#
# Licensed to Elasticsearch under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
# Painless definition file. This defines the hierarchy of classes,
# what methods and fields they have, etc.
#
#### Primitive types
class void -> void {
}
class boolean -> boolean {
}
class byte -> byte {
}
class short -> short {
}
class char -> char {
}
class int -> int {
}
class long -> long {
}
class float -> float {
}
class double -> double {
}
class def -> java.lang.Object {
boolean equals(Object)
int hashCode()
String toString()
}
#### ES Scripting API
class GeoPoint -> org.elasticsearch.common.geo.GeoPoint extends Object {
double getLat()
double getLon()
}
class Strings -> org.elasticsearch.index.fielddata.ScriptDocValues$Strings extends List,Collection,Iterable,Object {
String getValue()
List getValues()
}
class Longs -> org.elasticsearch.index.fielddata.ScriptDocValues$Longs extends List,Collection,Iterable,Object {
long getValue()
List getValues()
}
class Doubles -> org.elasticsearch.index.fielddata.ScriptDocValues$Doubles extends List,Collection,Iterable,Object {
double getValue()
List getValues()
}
class GeoPoints -> org.elasticsearch.index.fielddata.ScriptDocValues$GeoPoints extends List,Collection,Iterable,Object {
GeoPoint getValue()
List getValues()
double getLat()
double getLon()
double[] getLats()
double[] getLons()
# geo distance functions... so many...
double factorDistance(double,double)
double factorDistanceWithDefault(double,double,double)
double factorDistance02(double,double)
double factorDistance13(double,double)
double arcDistance(double,double)
double arcDistanceWithDefault(double,double,double)
double arcDistanceInKm(double,double)
double arcDistanceInKmWithDefault(double,double,double)
double arcDistanceInMiles(double,double)
double arcDistanceInMilesWithDefault(double,double,double)
double distance(double,double)
double distanceWithDefault(double,double,double)
double distanceInKm(double,double)
double distanceInKmWithDefault(double,double,double)
double distanceInMiles(double,double)
double distanceInMilesWithDefault(double,double,double)
double geohashDistance(String)
double geohashDistanceInKm(String)
double geohashDistanceInMiles(String)
}
# for testing.
# currently FeatureTest exposes overloaded constructor, field load store, and overloaded static methods
class FeatureTest -> org.elasticsearch.painless.FeatureTest extends Object {
FeatureTest <init>()
FeatureTest <init>(int,int)
int getX()
int getY()
void setX(int)
void setY(int)
boolean overloadedStatic()
boolean overloadedStatic(boolean)
}
# currently needed internally
class Executable -> org.elasticsearch.painless.Executable {
}

View File

@ -19,6 +19,9 @@
package org.elasticsearch.painless;
import java.util.Arrays;
import java.util.Collections;
public class BasicAPITests extends ScriptTestCase {
public void testListIterator() {
@ -90,4 +93,8 @@ public class BasicAPITests extends ScriptTestCase {
assertBytecodeExists("def x = 1F", "INVOKESTATIC java/lang/Float.valueOf (F)Ljava/lang/Float;");
assertBytecodeExists("def x = 1D", "INVOKESTATIC java/lang/Double.valueOf (D)Ljava/lang/Double;");
}
void testStream() {
assertEquals(11, exec("params.list.stream().sum()", Collections.singletonMap("list", Arrays.asList(1,2,3,5))));
}
}