id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
14,200
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java
EvalHelper.getGenericAccessor
public static Method getGenericAccessor(Class<?> clazz, String field) { LOG.trace( "getGenericAccessor({}, {})", clazz, field ); String accessorQualifiedName = new StringBuilder(clazz.getCanonicalName()) .append(".").append(field).toString(); return accessorCache.computeIfAbsent(accessorQualifiedName, key -> Stream.of( clazz.getMethods() ) .filter( m -> Optional.ofNullable( m.getAnnotation( FEELProperty.class ) ) .map( ann -> ann.value().equals( field ) ) .orElse( false ) ) .findFirst() .orElse( getAccessor( clazz, field ) )); }
java
public static Method getGenericAccessor(Class<?> clazz, String field) { LOG.trace( "getGenericAccessor({}, {})", clazz, field ); String accessorQualifiedName = new StringBuilder(clazz.getCanonicalName()) .append(".").append(field).toString(); return accessorCache.computeIfAbsent(accessorQualifiedName, key -> Stream.of( clazz.getMethods() ) .filter( m -> Optional.ofNullable( m.getAnnotation( FEELProperty.class ) ) .map( ann -> ann.value().equals( field ) ) .orElse( false ) ) .findFirst() .orElse( getAccessor( clazz, field ) )); }
[ "public", "static", "Method", "getGenericAccessor", "(", "Class", "<", "?", ">", "clazz", ",", "String", "field", ")", "{", "LOG", ".", "trace", "(", "\"getGenericAccessor({}, {})\"", ",", "clazz", ",", "field", ")", ";", "String", "accessorQualifiedName", "=", "new", "StringBuilder", "(", "clazz", ".", "getCanonicalName", "(", ")", ")", ".", "append", "(", "\".\"", ")", ".", "append", "(", "field", ")", ".", "toString", "(", ")", ";", "return", "accessorCache", ".", "computeIfAbsent", "(", "accessorQualifiedName", ",", "key", "->", "Stream", ".", "of", "(", "clazz", ".", "getMethods", "(", ")", ")", ".", "filter", "(", "m", "->", "Optional", ".", "ofNullable", "(", "m", ".", "getAnnotation", "(", "FEELProperty", ".", "class", ")", ")", ".", "map", "(", "ann", "->", "ann", ".", "value", "(", ")", ".", "equals", "(", "field", ")", ")", ".", "orElse", "(", "false", ")", ")", ".", "findFirst", "(", ")", ".", "orElse", "(", "getAccessor", "(", "clazz", ",", "field", ")", ")", ")", ";", "}" ]
FEEL annotated or else Java accessor. @param clazz @param field @return
[ "FEEL", "annotated", "or", "else", "Java", "accessor", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java#L408-L422
14,201
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java
EvalHelper.getAccessor
public static Method getAccessor(Class<?> clazz, String field) { LOG.trace( "getAccessor({}, {})", clazz, field ); try { return clazz.getMethod( "get" + ucFirst( field ) ); } catch ( NoSuchMethodException e ) { try { return clazz.getMethod( field ); } catch ( NoSuchMethodException e1 ) { try { return clazz.getMethod( "is" + ucFirst( field ) ); } catch ( NoSuchMethodException e2 ) { return null; } } } }
java
public static Method getAccessor(Class<?> clazz, String field) { LOG.trace( "getAccessor({}, {})", clazz, field ); try { return clazz.getMethod( "get" + ucFirst( field ) ); } catch ( NoSuchMethodException e ) { try { return clazz.getMethod( field ); } catch ( NoSuchMethodException e1 ) { try { return clazz.getMethod( "is" + ucFirst( field ) ); } catch ( NoSuchMethodException e2 ) { return null; } } } }
[ "public", "static", "Method", "getAccessor", "(", "Class", "<", "?", ">", "clazz", ",", "String", "field", ")", "{", "LOG", ".", "trace", "(", "\"getAccessor({}, {})\"", ",", "clazz", ",", "field", ")", ";", "try", "{", "return", "clazz", ".", "getMethod", "(", "\"get\"", "+", "ucFirst", "(", "field", ")", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "try", "{", "return", "clazz", ".", "getMethod", "(", "field", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e1", ")", "{", "try", "{", "return", "clazz", ".", "getMethod", "(", "\"is\"", "+", "ucFirst", "(", "field", ")", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e2", ")", "{", "return", "null", ";", "}", "}", "}", "}" ]
JavaBean -spec compliant accessor. @param clazz @param field @return
[ "JavaBean", "-", "spec", "compliant", "accessor", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java#L434-L449
14,202
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java
EvalHelper.isEqual
public static Boolean isEqual(Object left, Object right, EvaluationContext ctx ) { if ( left == null || right == null ) { return left == right; } // spec defines that "a=[a]", i.e., singleton collections should be treated as the single element // and vice-versa if( left instanceof Collection && !(right instanceof Collection) && ((Collection)left).size() == 1 ) { left = ((Collection)left).toArray()[0]; } else if( right instanceof Collection && !(left instanceof Collection) && ((Collection)right).size()==1 ) { right = ((Collection) right).toArray()[0]; } if( left instanceof Range && right instanceof Range ) { return isEqual( (Range)left, (Range) right ); } else if( left instanceof Iterable && right instanceof Iterable ) { return isEqual( (Iterable)left, (Iterable) right ); } else if( left instanceof Map && right instanceof Map ) { return isEqual( (Map)left, (Map) right ); } else if (left instanceof TemporalAccessor && right instanceof TemporalAccessor) { // Handle specific cases when both date / datetime if (BuiltInType.determineTypeFromInstance(left) == BuiltInType.TIME && BuiltInType.determineTypeFromInstance(right) == BuiltInType.TIME) { return isEqualTime((TemporalAccessor) left, (TemporalAccessor) right); } else if (BuiltInType.determineTypeFromInstance(left) == BuiltInType.DATE_TIME && BuiltInType.determineTypeFromInstance(right) == BuiltInType.DATE_TIME) { return isEqualDateTime((TemporalAccessor) left, (TemporalAccessor) right); } // fallback; continue: } return compare( left, right, ctx, (l, r) -> l.compareTo( r ) == 0 ); }
java
public static Boolean isEqual(Object left, Object right, EvaluationContext ctx ) { if ( left == null || right == null ) { return left == right; } // spec defines that "a=[a]", i.e., singleton collections should be treated as the single element // and vice-versa if( left instanceof Collection && !(right instanceof Collection) && ((Collection)left).size() == 1 ) { left = ((Collection)left).toArray()[0]; } else if( right instanceof Collection && !(left instanceof Collection) && ((Collection)right).size()==1 ) { right = ((Collection) right).toArray()[0]; } if( left instanceof Range && right instanceof Range ) { return isEqual( (Range)left, (Range) right ); } else if( left instanceof Iterable && right instanceof Iterable ) { return isEqual( (Iterable)left, (Iterable) right ); } else if( left instanceof Map && right instanceof Map ) { return isEqual( (Map)left, (Map) right ); } else if (left instanceof TemporalAccessor && right instanceof TemporalAccessor) { // Handle specific cases when both date / datetime if (BuiltInType.determineTypeFromInstance(left) == BuiltInType.TIME && BuiltInType.determineTypeFromInstance(right) == BuiltInType.TIME) { return isEqualTime((TemporalAccessor) left, (TemporalAccessor) right); } else if (BuiltInType.determineTypeFromInstance(left) == BuiltInType.DATE_TIME && BuiltInType.determineTypeFromInstance(right) == BuiltInType.DATE_TIME) { return isEqualDateTime((TemporalAccessor) left, (TemporalAccessor) right); } // fallback; continue: } return compare( left, right, ctx, (l, r) -> l.compareTo( r ) == 0 ); }
[ "public", "static", "Boolean", "isEqual", "(", "Object", "left", ",", "Object", "right", ",", "EvaluationContext", "ctx", ")", "{", "if", "(", "left", "==", "null", "||", "right", "==", "null", ")", "{", "return", "left", "==", "right", ";", "}", "// spec defines that \"a=[a]\", i.e., singleton collections should be treated as the single element", "// and vice-versa", "if", "(", "left", "instanceof", "Collection", "&&", "!", "(", "right", "instanceof", "Collection", ")", "&&", "(", "(", "Collection", ")", "left", ")", ".", "size", "(", ")", "==", "1", ")", "{", "left", "=", "(", "(", "Collection", ")", "left", ")", ".", "toArray", "(", ")", "[", "0", "]", ";", "}", "else", "if", "(", "right", "instanceof", "Collection", "&&", "!", "(", "left", "instanceof", "Collection", ")", "&&", "(", "(", "Collection", ")", "right", ")", ".", "size", "(", ")", "==", "1", ")", "{", "right", "=", "(", "(", "Collection", ")", "right", ")", ".", "toArray", "(", ")", "[", "0", "]", ";", "}", "if", "(", "left", "instanceof", "Range", "&&", "right", "instanceof", "Range", ")", "{", "return", "isEqual", "(", "(", "Range", ")", "left", ",", "(", "Range", ")", "right", ")", ";", "}", "else", "if", "(", "left", "instanceof", "Iterable", "&&", "right", "instanceof", "Iterable", ")", "{", "return", "isEqual", "(", "(", "Iterable", ")", "left", ",", "(", "Iterable", ")", "right", ")", ";", "}", "else", "if", "(", "left", "instanceof", "Map", "&&", "right", "instanceof", "Map", ")", "{", "return", "isEqual", "(", "(", "Map", ")", "left", ",", "(", "Map", ")", "right", ")", ";", "}", "else", "if", "(", "left", "instanceof", "TemporalAccessor", "&&", "right", "instanceof", "TemporalAccessor", ")", "{", "// Handle specific cases when both date / datetime", "if", "(", "BuiltInType", ".", "determineTypeFromInstance", "(", "left", ")", "==", "BuiltInType", ".", "TIME", "&&", "BuiltInType", ".", "determineTypeFromInstance", "(", "right", ")", "==", "BuiltInType", ".", "TIME", ")", "{", "return", "isEqualTime", "(", "(", "TemporalAccessor", ")", "left", ",", "(", "TemporalAccessor", ")", "right", ")", ";", "}", "else", "if", "(", "BuiltInType", ".", "determineTypeFromInstance", "(", "left", ")", "==", "BuiltInType", ".", "DATE_TIME", "&&", "BuiltInType", ".", "determineTypeFromInstance", "(", "right", ")", "==", "BuiltInType", ".", "DATE_TIME", ")", "{", "return", "isEqualDateTime", "(", "(", "TemporalAccessor", ")", "left", ",", "(", "TemporalAccessor", ")", "right", ")", ";", "}", "// fallback; continue:", "}", "return", "compare", "(", "left", ",", "right", ",", "ctx", ",", "(", "l", ",", "r", ")", "->", "l", ".", "compareTo", "(", "r", ")", "==", "0", ")", ";", "}" ]
Compares left and right for equality applying FEEL semantics to specific data types @param left @param right @param ctx @return
[ "Compares", "left", "and", "right", "for", "equality", "applying", "FEEL", "semantics", "to", "specific", "data", "types" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java#L523-L551
14,203
kiegroup/drools
drools-core/src/main/java/org/drools/core/facttemplates/FactTemplateImpl.java
FactTemplateImpl.getFieldTemplate
public FieldTemplate getFieldTemplate(final String name) { for ( int idx = 0; idx < this.fields.length; idx++ ) { if ( this.fields[idx].getName().equals( name ) ) { return this.fields[idx]; } } return null; }
java
public FieldTemplate getFieldTemplate(final String name) { for ( int idx = 0; idx < this.fields.length; idx++ ) { if ( this.fields[idx].getName().equals( name ) ) { return this.fields[idx]; } } return null; }
[ "public", "FieldTemplate", "getFieldTemplate", "(", "final", "String", "name", ")", "{", "for", "(", "int", "idx", "=", "0", ";", "idx", "<", "this", ".", "fields", ".", "length", ";", "idx", "++", ")", "{", "if", "(", "this", ".", "fields", "[", "idx", "]", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "return", "this", ".", "fields", "[", "idx", "]", ";", "}", "}", "return", "null", ";", "}" ]
A convienance method for finding the slot matching the String name. @param name @return
[ "A", "convienance", "method", "for", "finding", "the", "slot", "matching", "the", "String", "name", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/facttemplates/FactTemplateImpl.java#L104-L111
14,204
kiegroup/drools
drools-core/src/main/java/org/drools/core/facttemplates/FactTemplateImpl.java
FactTemplateImpl.getFieldTemplateIndex
public int getFieldTemplateIndex(final String name) { for ( int index = 0; index < this.fields.length; index++ ) { if ( this.fields[index].getName().equals( name ) ) { return index; } } return -1; }
java
public int getFieldTemplateIndex(final String name) { for ( int index = 0; index < this.fields.length; index++ ) { if ( this.fields[index].getName().equals( name ) ) { return index; } } return -1; }
[ "public", "int", "getFieldTemplateIndex", "(", "final", "String", "name", ")", "{", "for", "(", "int", "index", "=", "0", ";", "index", "<", "this", ".", "fields", ".", "length", ";", "index", "++", ")", "{", "if", "(", "this", ".", "fields", "[", "index", "]", ".", "getName", "(", ")", ".", "equals", "(", "name", ")", ")", "{", "return", "index", ";", "}", "}", "return", "-", "1", ";", "}" ]
Look up the pattern index of the slot
[ "Look", "up", "the", "pattern", "index", "of", "the", "slot" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/facttemplates/FactTemplateImpl.java#L123-L130
14,205
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.get
public boolean get(int index) { int i = index >> 6; // div 64 // signed shift will keep a negative index and force an // array-index-out-of-bounds-exception, removing the need for an explicit check. if (i>=bits.length) return false; int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; return (bits[i] & bitmask) != 0; }
java
public boolean get(int index) { int i = index >> 6; // div 64 // signed shift will keep a negative index and force an // array-index-out-of-bounds-exception, removing the need for an explicit check. if (i>=bits.length) return false; int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; return (bits[i] & bitmask) != 0; }
[ "public", "boolean", "get", "(", "int", "index", ")", "{", "int", "i", "=", "index", ">>", "6", ";", "// div 64", "// signed shift will keep a negative index and force an", "// array-index-out-of-bounds-exception, removing the need for an explicit check.", "if", "(", "i", ">=", "bits", ".", "length", ")", "return", "false", ";", "int", "bit", "=", "index", "&", "0x3f", ";", "// mod 64", "long", "bitmask", "=", "1L", "<<", "bit", ";", "return", "(", "bits", "[", "i", "]", "&", "bitmask", ")", "!=", "0", ";", "}" ]
Returns true or false for the specified bit index.
[ "Returns", "true", "or", "false", "for", "the", "specified", "bit", "index", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L153-L162
14,206
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.fastGet
public boolean fastGet(int index) { assert index >= 0 && index < numBits; int i = index >> 6; // div 64 // signed shift will keep a negative index and force an // array-index-out-of-bounds-exception, removing the need for an explicit check. int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; return (bits[i] & bitmask) != 0; }
java
public boolean fastGet(int index) { assert index >= 0 && index < numBits; int i = index >> 6; // div 64 // signed shift will keep a negative index and force an // array-index-out-of-bounds-exception, removing the need for an explicit check. int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; return (bits[i] & bitmask) != 0; }
[ "public", "boolean", "fastGet", "(", "int", "index", ")", "{", "assert", "index", ">=", "0", "&&", "index", "<", "numBits", ";", "int", "i", "=", "index", ">>", "6", ";", "// div 64", "// signed shift will keep a negative index and force an", "// array-index-out-of-bounds-exception, removing the need for an explicit check.", "int", "bit", "=", "index", "&", "0x3f", ";", "// mod 64", "long", "bitmask", "=", "1L", "<<", "bit", ";", "return", "(", "bits", "[", "i", "]", "&", "bitmask", ")", "!=", "0", ";", "}" ]
Returns true or false for the specified bit index. The index should be less than the OpenBitSet size
[ "Returns", "true", "or", "false", "for", "the", "specified", "bit", "index", ".", "The", "index", "should", "be", "less", "than", "the", "OpenBitSet", "size" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L168-L176
14,207
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.getBit
public int getBit(int index) { assert index >= 0 && index < numBits; int i = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 return ((int)(bits[i]>>>bit)) & 0x01; }
java
public int getBit(int index) { assert index >= 0 && index < numBits; int i = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 return ((int)(bits[i]>>>bit)) & 0x01; }
[ "public", "int", "getBit", "(", "int", "index", ")", "{", "assert", "index", ">=", "0", "&&", "index", "<", "numBits", ";", "int", "i", "=", "index", ">>", "6", ";", "// div 64", "int", "bit", "=", "index", "&", "0x3f", ";", "// mod 64", "return", "(", "(", "int", ")", "(", "bits", "[", "i", "]", ">>>", "bit", ")", ")", "&", "0x01", ";", "}" ]
returns 1 if the bit is set, 0 if not. The index should be less than the OpenBitSet size
[ "returns", "1", "if", "the", "bit", "is", "set", "0", "if", "not", ".", "The", "index", "should", "be", "less", "than", "the", "OpenBitSet", "size" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L217-L222
14,208
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.set
public void set(long index) { int wordNum = expandingWordNum(index); int bit = (int)index & 0x3f; long bitmask = 1L << bit; bits[wordNum] |= bitmask; }
java
public void set(long index) { int wordNum = expandingWordNum(index); int bit = (int)index & 0x3f; long bitmask = 1L << bit; bits[wordNum] |= bitmask; }
[ "public", "void", "set", "(", "long", "index", ")", "{", "int", "wordNum", "=", "expandingWordNum", "(", "index", ")", ";", "int", "bit", "=", "(", "int", ")", "index", "&", "0x3f", ";", "long", "bitmask", "=", "1L", "<<", "bit", ";", "bits", "[", "wordNum", "]", "|=", "bitmask", ";", "}" ]
sets a bit, expanding the set size if necessary
[ "sets", "a", "bit", "expanding", "the", "set", "size", "if", "necessary" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L235-L240
14,209
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.fastSet
public void fastSet(int index) { assert index >= 0 && index < numBits; int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; bits[wordNum] |= bitmask; }
java
public void fastSet(int index) { assert index >= 0 && index < numBits; int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; bits[wordNum] |= bitmask; }
[ "public", "void", "fastSet", "(", "int", "index", ")", "{", "assert", "index", ">=", "0", "&&", "index", "<", "numBits", ";", "int", "wordNum", "=", "index", ">>", "6", ";", "// div 64", "int", "bit", "=", "index", "&", "0x3f", ";", "// mod 64", "long", "bitmask", "=", "1L", "<<", "bit", ";", "bits", "[", "wordNum", "]", "|=", "bitmask", ";", "}" ]
Sets the bit at the specified index. The index should be less than the OpenBitSet size.
[ "Sets", "the", "bit", "at", "the", "specified", "index", ".", "The", "index", "should", "be", "less", "than", "the", "OpenBitSet", "size", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L246-L252
14,210
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.fastClear
public void fastClear(int index) { assert index >= 0 && index < numBits; int wordNum = index >> 6; int bit = index & 0x03f; long bitmask = 1L << bit; bits[wordNum] &= ~bitmask; // hmmm, it takes one more instruction to clear than it does to set... any // way to work around this? If there were only 63 bits per word, we could // use a right shift of 10111111...111 in binary to position the 0 in the // correct place (using sign extension). // Could also use Long.rotateRight() or rotateLeft() *if* they were converted // by the JVM into a native instruction. // bits[word] &= Long.rotateLeft(0xfffffffe,bit); }
java
public void fastClear(int index) { assert index >= 0 && index < numBits; int wordNum = index >> 6; int bit = index & 0x03f; long bitmask = 1L << bit; bits[wordNum] &= ~bitmask; // hmmm, it takes one more instruction to clear than it does to set... any // way to work around this? If there were only 63 bits per word, we could // use a right shift of 10111111...111 in binary to position the 0 in the // correct place (using sign extension). // Could also use Long.rotateRight() or rotateLeft() *if* they were converted // by the JVM into a native instruction. // bits[word] &= Long.rotateLeft(0xfffffffe,bit); }
[ "public", "void", "fastClear", "(", "int", "index", ")", "{", "assert", "index", ">=", "0", "&&", "index", "<", "numBits", ";", "int", "wordNum", "=", "index", ">>", "6", ";", "int", "bit", "=", "index", "&", "0x03f", ";", "long", "bitmask", "=", "1L", "<<", "bit", ";", "bits", "[", "wordNum", "]", "&=", "~", "bitmask", ";", "// hmmm, it takes one more instruction to clear than it does to set... any", "// way to work around this? If there were only 63 bits per word, we could", "// use a right shift of 10111111...111 in binary to position the 0 in the", "// correct place (using sign extension).", "// Could also use Long.rotateRight() or rotateLeft() *if* they were converted", "// by the JVM into a native instruction.", "// bits[word] &= Long.rotateLeft(0xfffffffe,bit);", "}" ]
clears a bit. The index should be less than the OpenBitSet size.
[ "clears", "a", "bit", ".", "The", "index", "should", "be", "less", "than", "the", "OpenBitSet", "size", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L308-L321
14,211
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.clear
public void clear(long index) { int wordNum = (int)(index >> 6); // div 64 if (wordNum>=wlen) return; int bit = (int)index & 0x3f; // mod 64 long bitmask = 1L << bit; bits[wordNum] &= ~bitmask; }
java
public void clear(long index) { int wordNum = (int)(index >> 6); // div 64 if (wordNum>=wlen) return; int bit = (int)index & 0x3f; // mod 64 long bitmask = 1L << bit; bits[wordNum] &= ~bitmask; }
[ "public", "void", "clear", "(", "long", "index", ")", "{", "int", "wordNum", "=", "(", "int", ")", "(", "index", ">>", "6", ")", ";", "// div 64", "if", "(", "wordNum", ">=", "wlen", ")", "return", ";", "int", "bit", "=", "(", "int", ")", "index", "&", "0x3f", ";", "// mod 64", "long", "bitmask", "=", "1L", "<<", "bit", ";", "bits", "[", "wordNum", "]", "&=", "~", "bitmask", ";", "}" ]
clears a bit, allowing access beyond the current set size without changing the size.
[ "clears", "a", "bit", "allowing", "access", "beyond", "the", "current", "set", "size", "without", "changing", "the", "size", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L335-L341
14,212
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.fastFlip
public void fastFlip(int index) { assert index >= 0 && index < numBits; int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; bits[wordNum] ^= bitmask; }
java
public void fastFlip(int index) { assert index >= 0 && index < numBits; int wordNum = index >> 6; // div 64 int bit = index & 0x3f; // mod 64 long bitmask = 1L << bit; bits[wordNum] ^= bitmask; }
[ "public", "void", "fastFlip", "(", "int", "index", ")", "{", "assert", "index", ">=", "0", "&&", "index", "<", "numBits", ";", "int", "wordNum", "=", "index", ">>", "6", ";", "// div 64", "int", "bit", "=", "index", "&", "0x3f", ";", "// mod 64", "long", "bitmask", "=", "1L", "<<", "bit", ";", "bits", "[", "wordNum", "]", "^=", "bitmask", ";", "}" ]
flips a bit. The index should be less than the OpenBitSet size.
[ "flips", "a", "bit", ".", "The", "index", "should", "be", "less", "than", "the", "OpenBitSet", "size", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L447-L453
14,213
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.flip
public void flip(long index) { int wordNum = expandingWordNum(index); int bit = (int)index & 0x3f; // mod 64 long bitmask = 1L << bit; bits[wordNum] ^= bitmask; }
java
public void flip(long index) { int wordNum = expandingWordNum(index); int bit = (int)index & 0x3f; // mod 64 long bitmask = 1L << bit; bits[wordNum] ^= bitmask; }
[ "public", "void", "flip", "(", "long", "index", ")", "{", "int", "wordNum", "=", "expandingWordNum", "(", "index", ")", ";", "int", "bit", "=", "(", "int", ")", "index", "&", "0x3f", ";", "// mod 64", "long", "bitmask", "=", "1L", "<<", "bit", ";", "bits", "[", "wordNum", "]", "^=", "bitmask", ";", "}" ]
flips a bit, expanding the set size if necessary
[ "flips", "a", "bit", "expanding", "the", "set", "size", "if", "necessary" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L467-L472
14,214
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.intersectionCount
public static long intersectionCount(OpenBitSet a, OpenBitSet b) { return BitUtil.pop_intersect( a.bits, b.bits, 0, Math.min( a.wlen, b.wlen ) ); }
java
public static long intersectionCount(OpenBitSet a, OpenBitSet b) { return BitUtil.pop_intersect( a.bits, b.bits, 0, Math.min( a.wlen, b.wlen ) ); }
[ "public", "static", "long", "intersectionCount", "(", "OpenBitSet", "a", ",", "OpenBitSet", "b", ")", "{", "return", "BitUtil", ".", "pop_intersect", "(", "a", ".", "bits", ",", "b", ".", "bits", ",", "0", ",", "Math", ".", "min", "(", "a", ".", "wlen", ",", "b", ".", "wlen", ")", ")", ";", "}" ]
Returns the popcount or cardinality of the intersection of the two sets. Neither set is modified.
[ "Returns", "the", "popcount", "or", "cardinality", "of", "the", "intersection", "of", "the", "two", "sets", ".", "Neither", "set", "is", "modified", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L567-L569
14,215
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.unionCount
public static long unionCount(OpenBitSet a, OpenBitSet b) { long tot = BitUtil.pop_union( a.bits, b.bits, 0, Math.min( a.wlen, b.wlen ) ); if (a.wlen < b.wlen) { tot += BitUtil.pop_array( b.bits, a.wlen, b.wlen - a.wlen ); } else if (a.wlen > b.wlen) { tot += BitUtil.pop_array( a.bits, b.wlen, a.wlen - b.wlen ); } return tot; }
java
public static long unionCount(OpenBitSet a, OpenBitSet b) { long tot = BitUtil.pop_union( a.bits, b.bits, 0, Math.min( a.wlen, b.wlen ) ); if (a.wlen < b.wlen) { tot += BitUtil.pop_array( b.bits, a.wlen, b.wlen - a.wlen ); } else if (a.wlen > b.wlen) { tot += BitUtil.pop_array( a.bits, b.wlen, a.wlen - b.wlen ); } return tot; }
[ "public", "static", "long", "unionCount", "(", "OpenBitSet", "a", ",", "OpenBitSet", "b", ")", "{", "long", "tot", "=", "BitUtil", ".", "pop_union", "(", "a", ".", "bits", ",", "b", ".", "bits", ",", "0", ",", "Math", ".", "min", "(", "a", ".", "wlen", ",", "b", ".", "wlen", ")", ")", ";", "if", "(", "a", ".", "wlen", "<", "b", ".", "wlen", ")", "{", "tot", "+=", "BitUtil", ".", "pop_array", "(", "b", ".", "bits", ",", "a", ".", "wlen", ",", "b", ".", "wlen", "-", "a", ".", "wlen", ")", ";", "}", "else", "if", "(", "a", ".", "wlen", ">", "b", ".", "wlen", ")", "{", "tot", "+=", "BitUtil", ".", "pop_array", "(", "a", ".", "bits", ",", "b", ".", "wlen", ",", "a", ".", "wlen", "-", "b", ".", "wlen", ")", ";", "}", "return", "tot", ";", "}" ]
Returns the popcount or cardinality of the union of the two sets. Neither set is modified.
[ "Returns", "the", "popcount", "or", "cardinality", "of", "the", "union", "of", "the", "two", "sets", ".", "Neither", "set", "is", "modified", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L574-L582
14,216
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.xorCount
public static long xorCount(OpenBitSet a, OpenBitSet b) { long tot = BitUtil.pop_xor( a.bits, b.bits, 0, Math.min( a.wlen, b.wlen ) ); if (a.wlen < b.wlen) { tot += BitUtil.pop_array( b.bits, a.wlen, b.wlen - a.wlen ); } else if (a.wlen > b.wlen) { tot += BitUtil.pop_array( a.bits, b.wlen, a.wlen - b.wlen ); } return tot; }
java
public static long xorCount(OpenBitSet a, OpenBitSet b) { long tot = BitUtil.pop_xor( a.bits, b.bits, 0, Math.min( a.wlen, b.wlen ) ); if (a.wlen < b.wlen) { tot += BitUtil.pop_array( b.bits, a.wlen, b.wlen - a.wlen ); } else if (a.wlen > b.wlen) { tot += BitUtil.pop_array( a.bits, b.wlen, a.wlen - b.wlen ); } return tot; }
[ "public", "static", "long", "xorCount", "(", "OpenBitSet", "a", ",", "OpenBitSet", "b", ")", "{", "long", "tot", "=", "BitUtil", ".", "pop_xor", "(", "a", ".", "bits", ",", "b", ".", "bits", ",", "0", ",", "Math", ".", "min", "(", "a", ".", "wlen", ",", "b", ".", "wlen", ")", ")", ";", "if", "(", "a", ".", "wlen", "<", "b", ".", "wlen", ")", "{", "tot", "+=", "BitUtil", ".", "pop_array", "(", "b", ".", "bits", ",", "a", ".", "wlen", ",", "b", ".", "wlen", "-", "a", ".", "wlen", ")", ";", "}", "else", "if", "(", "a", ".", "wlen", ">", "b", ".", "wlen", ")", "{", "tot", "+=", "BitUtil", ".", "pop_array", "(", "a", ".", "bits", ",", "b", ".", "wlen", ",", "a", ".", "wlen", "-", "b", ".", "wlen", ")", ";", "}", "return", "tot", ";", "}" ]
Returns the popcount or cardinality of the exclusive-or of the two sets. Neither set is modified.
[ "Returns", "the", "popcount", "or", "cardinality", "of", "the", "exclusive", "-", "or", "of", "the", "two", "sets", ".", "Neither", "set", "is", "modified", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L599-L607
14,217
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.prevSetBit
public int prevSetBit(int index) { int i = index >> 6; final int subIndex; long word; if (i >= wlen) { i = wlen - 1; if (i < 0) return -1; subIndex = 63; // last possible bit word = bits[i]; } else { if (i < 0) return -1; subIndex = index & 0x3f; // index within the word word = (bits[i] << (63-subIndex)); // skip all the bits to the left of index } if (word != 0) { return (i << 6) + subIndex - Long.numberOfLeadingZeros(word); // See LUCENE-3197 } while (--i >= 0) { word = bits[i]; if (word !=0 ) { return (i << 6) + 63 - Long.numberOfLeadingZeros(word); } } return -1; }
java
public int prevSetBit(int index) { int i = index >> 6; final int subIndex; long word; if (i >= wlen) { i = wlen - 1; if (i < 0) return -1; subIndex = 63; // last possible bit word = bits[i]; } else { if (i < 0) return -1; subIndex = index & 0x3f; // index within the word word = (bits[i] << (63-subIndex)); // skip all the bits to the left of index } if (word != 0) { return (i << 6) + subIndex - Long.numberOfLeadingZeros(word); // See LUCENE-3197 } while (--i >= 0) { word = bits[i]; if (word !=0 ) { return (i << 6) + 63 - Long.numberOfLeadingZeros(word); } } return -1; }
[ "public", "int", "prevSetBit", "(", "int", "index", ")", "{", "int", "i", "=", "index", ">>", "6", ";", "final", "int", "subIndex", ";", "long", "word", ";", "if", "(", "i", ">=", "wlen", ")", "{", "i", "=", "wlen", "-", "1", ";", "if", "(", "i", "<", "0", ")", "return", "-", "1", ";", "subIndex", "=", "63", ";", "// last possible bit", "word", "=", "bits", "[", "i", "]", ";", "}", "else", "{", "if", "(", "i", "<", "0", ")", "return", "-", "1", ";", "subIndex", "=", "index", "&", "0x3f", ";", "// index within the word", "word", "=", "(", "bits", "[", "i", "]", "<<", "(", "63", "-", "subIndex", ")", ")", ";", "// skip all the bits to the left of index", "}", "if", "(", "word", "!=", "0", ")", "{", "return", "(", "i", "<<", "6", ")", "+", "subIndex", "-", "Long", ".", "numberOfLeadingZeros", "(", "word", ")", ";", "// See LUCENE-3197", "}", "while", "(", "--", "i", ">=", "0", ")", "{", "word", "=", "bits", "[", "i", "]", ";", "if", "(", "word", "!=", "0", ")", "{", "return", "(", "i", "<<", "6", ")", "+", "63", "-", "Long", ".", "numberOfLeadingZeros", "(", "word", ")", ";", "}", "}", "return", "-", "1", ";", "}" ]
Returns the index of the first set bit starting downwards at the index specified. -1 is returned if there are no more set bits.
[ "Returns", "the", "index", "of", "the", "first", "set", "bit", "starting", "downwards", "at", "the", "index", "specified", ".", "-", "1", "is", "returned", "if", "there", "are", "no", "more", "set", "bits", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L657-L684
14,218
kiegroup/drools
drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java
OpenBitSet.oversize
public static int oversize(int minTargetSize, int bytesPerElement) { if (minTargetSize < 0) { // catch usage that accidentally overflows int throw new IllegalArgumentException("invalid array size " + minTargetSize); } if (minTargetSize == 0) { // wait until at least one element is requested return 0; } // asymptotic exponential growth by 1/8th, favors // spending a bit more CPU to not tie up too much wasted // RAM: int extra = minTargetSize >> 3; if (extra < 3) { // for very small arrays, where constant overhead of // realloc is presumably relatively high, we grow // faster extra = 3; } int newSize = minTargetSize + extra; // add 7 to allow for worst case byte alignment addition below: if (newSize+7 < 0) { // int overflowed -- return max allowed array size return Integer.MAX_VALUE; } if (JRE_IS_64BIT) { // round up to 8 byte alignment in 64bit env switch(bytesPerElement) { case 4: // round up to project of 2 return (newSize + 1) & 0x7ffffffe; case 2: // round up to project of 4 return (newSize + 3) & 0x7ffffffc; case 1: // round up to project of 8 return (newSize + 7) & 0x7ffffff8; case 8: // no rounding default: // odd (invalid?) size return newSize; } } else { // round up to 4 byte alignment in 64bit env switch(bytesPerElement) { case 2: // round up to project of 2 return (newSize + 1) & 0x7ffffffe; case 1: // round up to project of 4 return (newSize + 3) & 0x7ffffffc; case 4: case 8: // no rounding default: // odd (invalid?) size return newSize; } } }
java
public static int oversize(int minTargetSize, int bytesPerElement) { if (minTargetSize < 0) { // catch usage that accidentally overflows int throw new IllegalArgumentException("invalid array size " + minTargetSize); } if (minTargetSize == 0) { // wait until at least one element is requested return 0; } // asymptotic exponential growth by 1/8th, favors // spending a bit more CPU to not tie up too much wasted // RAM: int extra = minTargetSize >> 3; if (extra < 3) { // for very small arrays, where constant overhead of // realloc is presumably relatively high, we grow // faster extra = 3; } int newSize = minTargetSize + extra; // add 7 to allow for worst case byte alignment addition below: if (newSize+7 < 0) { // int overflowed -- return max allowed array size return Integer.MAX_VALUE; } if (JRE_IS_64BIT) { // round up to 8 byte alignment in 64bit env switch(bytesPerElement) { case 4: // round up to project of 2 return (newSize + 1) & 0x7ffffffe; case 2: // round up to project of 4 return (newSize + 3) & 0x7ffffffc; case 1: // round up to project of 8 return (newSize + 7) & 0x7ffffff8; case 8: // no rounding default: // odd (invalid?) size return newSize; } } else { // round up to 4 byte alignment in 64bit env switch(bytesPerElement) { case 2: // round up to project of 2 return (newSize + 1) & 0x7ffffffe; case 1: // round up to project of 4 return (newSize + 3) & 0x7ffffffc; case 4: case 8: // no rounding default: // odd (invalid?) size return newSize; } } }
[ "public", "static", "int", "oversize", "(", "int", "minTargetSize", ",", "int", "bytesPerElement", ")", "{", "if", "(", "minTargetSize", "<", "0", ")", "{", "// catch usage that accidentally overflows int", "throw", "new", "IllegalArgumentException", "(", "\"invalid array size \"", "+", "minTargetSize", ")", ";", "}", "if", "(", "minTargetSize", "==", "0", ")", "{", "// wait until at least one element is requested", "return", "0", ";", "}", "// asymptotic exponential growth by 1/8th, favors", "// spending a bit more CPU to not tie up too much wasted", "// RAM:", "int", "extra", "=", "minTargetSize", ">>", "3", ";", "if", "(", "extra", "<", "3", ")", "{", "// for very small arrays, where constant overhead of", "// realloc is presumably relatively high, we grow", "// faster", "extra", "=", "3", ";", "}", "int", "newSize", "=", "minTargetSize", "+", "extra", ";", "// add 7 to allow for worst case byte alignment addition below:", "if", "(", "newSize", "+", "7", "<", "0", ")", "{", "// int overflowed -- return max allowed array size", "return", "Integer", ".", "MAX_VALUE", ";", "}", "if", "(", "JRE_IS_64BIT", ")", "{", "// round up to 8 byte alignment in 64bit env", "switch", "(", "bytesPerElement", ")", "{", "case", "4", ":", "// round up to project of 2", "return", "(", "newSize", "+", "1", ")", "&", "0x7ffffffe", ";", "case", "2", ":", "// round up to project of 4", "return", "(", "newSize", "+", "3", ")", "&", "0x7ffffffc", ";", "case", "1", ":", "// round up to project of 8", "return", "(", "newSize", "+", "7", ")", "&", "0x7ffffff8", ";", "case", "8", ":", "// no rounding", "default", ":", "// odd (invalid?) size", "return", "newSize", ";", "}", "}", "else", "{", "// round up to 4 byte alignment in 64bit env", "switch", "(", "bytesPerElement", ")", "{", "case", "2", ":", "// round up to project of 2", "return", "(", "newSize", "+", "1", ")", "&", "0x7ffffffe", ";", "case", "1", ":", "// round up to project of 4", "return", "(", "newSize", "+", "3", ")", "&", "0x7ffffffc", ";", "case", "4", ":", "case", "8", ":", "// no rounding", "default", ":", "// odd (invalid?) size", "return", "newSize", ";", "}", "}", "}" ]
Returns an array size >= minTargetSize, generally over-allocating exponentially to achieve amortized linear-time cost as the array grows. NOTE: this was originally borrowed from Python 2.4.2 listobject.c sources (attribution in LICENSE.txt), but has now been substantially changed based on discussions from java-dev thread with subject "Dynamic array reallocation algorithms", started on Jan 12 2010. @param minTargetSize Minimum required value to be returned. @param bytesPerElement Bytes used by each element of the array. @lucene.internal
[ "Returns", "an", "array", "size", ">", "=", "minTargetSize", "generally", "over", "-", "allocating", "exponentially", "to", "achieve", "amortized", "linear", "-", "time", "cost", "as", "the", "array", "grows", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-canonical-model/src/main/java/org/drools/model/bitmask/OpenBitSet.java#L919-L986
14,219
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/AttributeCol52.java
AttributeCol52.cloneColumn
public AttributeCol52 cloneColumn() { AttributeCol52 cloned = new AttributeCol52(); cloned.setAttribute( getAttribute() ); cloned.setReverseOrder( isReverseOrder() ); cloned.setUseRowNumber( isUseRowNumber() ); cloned.cloneCommonColumnConfigFrom( this ); return cloned; }
java
public AttributeCol52 cloneColumn() { AttributeCol52 cloned = new AttributeCol52(); cloned.setAttribute( getAttribute() ); cloned.setReverseOrder( isReverseOrder() ); cloned.setUseRowNumber( isUseRowNumber() ); cloned.cloneCommonColumnConfigFrom( this ); return cloned; }
[ "public", "AttributeCol52", "cloneColumn", "(", ")", "{", "AttributeCol52", "cloned", "=", "new", "AttributeCol52", "(", ")", ";", "cloned", ".", "setAttribute", "(", "getAttribute", "(", ")", ")", ";", "cloned", ".", "setReverseOrder", "(", "isReverseOrder", "(", ")", ")", ";", "cloned", ".", "setUseRowNumber", "(", "isUseRowNumber", "(", ")", ")", ";", "cloned", ".", "cloneCommonColumnConfigFrom", "(", "this", ")", ";", "return", "cloned", ";", "}" ]
Clones this attribute column instance. @return The cloned instance.
[ "Clones", "this", "attribute", "column", "instance", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/AttributeCol52.java#L81-L88
14,220
kiegroup/drools
drools-core/src/main/java/org/drools/core/common/EqualityAssertMapComparator.java
EqualityAssertMapComparator.equal
public boolean equal(final Object o1, Object o2) { if ( o1 == o2 ) { return true; } // o1 is a FactHandle, so just check their id's are the same if ( o1 instanceof FactHandle ) { return ((InternalFactHandle)o1).getId() == ((InternalFactHandle)o2).getId() ; } // o1 is an object, so unwrap o2 for comparison final InternalFactHandle handle = ((InternalFactHandle) o2); o2 = handle.getObject(); return o1 == o2 || o2.equals( o1 ); }
java
public boolean equal(final Object o1, Object o2) { if ( o1 == o2 ) { return true; } // o1 is a FactHandle, so just check their id's are the same if ( o1 instanceof FactHandle ) { return ((InternalFactHandle)o1).getId() == ((InternalFactHandle)o2).getId() ; } // o1 is an object, so unwrap o2 for comparison final InternalFactHandle handle = ((InternalFactHandle) o2); o2 = handle.getObject(); return o1 == o2 || o2.equals( o1 ); }
[ "public", "boolean", "equal", "(", "final", "Object", "o1", ",", "Object", "o2", ")", "{", "if", "(", "o1", "==", "o2", ")", "{", "return", "true", ";", "}", "// o1 is a FactHandle, so just check their id's are the same", "if", "(", "o1", "instanceof", "FactHandle", ")", "{", "return", "(", "(", "InternalFactHandle", ")", "o1", ")", ".", "getId", "(", ")", "==", "(", "(", "InternalFactHandle", ")", "o2", ")", ".", "getId", "(", ")", ";", "}", "// o1 is an object, so unwrap o2 for comparison", "final", "InternalFactHandle", "handle", "=", "(", "(", "InternalFactHandle", ")", "o2", ")", ";", "o2", "=", "handle", ".", "getObject", "(", ")", ";", "return", "o1", "==", "o2", "||", "o2", ".", "equals", "(", "o1", ")", ";", "}" ]
Special comparator that allows FactHandles to be keys, but always checks equals with the identity of the objects involved
[ "Special", "comparator", "that", "allows", "FactHandles", "to", "be", "keys", "but", "always", "checks", "equals", "with", "the", "identity", "of", "the", "objects", "involved" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/common/EqualityAssertMapComparator.java#L53-L68
14,221
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDiagram.java
DMNDiagram.setSize
public void setSize(org.kie.dmn.model.api.dmndi.Dimension value) { this.size = value; }
java
public void setSize(org.kie.dmn.model.api.dmndi.Dimension value) { this.size = value; }
[ "public", "void", "setSize", "(", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "Dimension", "value", ")", "{", "this", ".", "size", "=", "value", ";", "}" ]
Sets the value of the size property. @param value allowed object is {@link Dimension }
[ "Sets", "the", "value", "of", "the", "size", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDiagram.java#L49-L51
14,222
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDiagram.java
DMNDiagram.getDMNDiagramElement
public List<org.kie.dmn.model.api.dmndi.DiagramElement> getDMNDiagramElement() { if (dmnDiagramElement == null) { dmnDiagramElement = new ArrayList<>(); } return this.dmnDiagramElement; }
java
public List<org.kie.dmn.model.api.dmndi.DiagramElement> getDMNDiagramElement() { if (dmnDiagramElement == null) { dmnDiagramElement = new ArrayList<>(); } return this.dmnDiagramElement; }
[ "public", "List", "<", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "DiagramElement", ">", "getDMNDiagramElement", "(", ")", "{", "if", "(", "dmnDiagramElement", "==", "null", ")", "{", "dmnDiagramElement", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "return", "this", ".", "dmnDiagramElement", ";", "}" ]
Gets the value of the dmnDiagramElement property. <p> This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for the dmnDiagramElement property. <p> For example, to add a new item, do as follows: <pre> getDMNDiagramElement().add(newItem); </pre> <p> Objects of the following type(s) are allowed in the list {@link JAXBElement }{@code <}{@link DMNShape }{@code >} {@link JAXBElement }{@code <}{@link DiagramElement }{@code >} {@link JAXBElement }{@code <}{@link DMNEdge }{@code >}
[ "Gets", "the", "value", "of", "the", "dmnDiagramElement", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDiagram.java#L77-L82
14,223
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/marshaller/FEELStringMarshaller.java
FEELStringMarshaller.unmarshall
@Override public Object unmarshall(Type feelType, String value) { if ( "null".equals( value ) ) { return null; } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.NUMBER ) ) { return BuiltInFunctions.getFunction( NumberFunction.class ).invoke( value, null, null ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.STRING ) ) { return value; } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.DATE ) ) { return BuiltInFunctions.getFunction( DateFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.TIME ) ) { return BuiltInFunctions.getFunction( TimeFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.DATE_TIME ) ) { return BuiltInFunctions.getFunction( DateAndTimeFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.DURATION ) ) { return BuiltInFunctions.getFunction( DurationFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.BOOLEAN ) ) { return Boolean.parseBoolean( value ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.RANGE ) || feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.FUNCTION ) || feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.LIST ) || feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.CONTEXT ) || feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.UNARY_TEST ) ) { throw new UnsupportedOperationException( "FEELStringMarshaller is unable to unmarshall complex types like: "+feelType.getName() ); } return null; }
java
@Override public Object unmarshall(Type feelType, String value) { if ( "null".equals( value ) ) { return null; } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.NUMBER ) ) { return BuiltInFunctions.getFunction( NumberFunction.class ).invoke( value, null, null ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.STRING ) ) { return value; } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.DATE ) ) { return BuiltInFunctions.getFunction( DateFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.TIME ) ) { return BuiltInFunctions.getFunction( TimeFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.DATE_TIME ) ) { return BuiltInFunctions.getFunction( DateAndTimeFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.DURATION ) ) { return BuiltInFunctions.getFunction( DurationFunction.class ).invoke( value ).cata( justNull(), Function.identity() ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.BOOLEAN ) ) { return Boolean.parseBoolean( value ); } else if ( feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.RANGE ) || feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.FUNCTION ) || feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.LIST ) || feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.CONTEXT ) || feelType.equals( org.kie.dmn.feel.lang.types.BuiltInType.UNARY_TEST ) ) { throw new UnsupportedOperationException( "FEELStringMarshaller is unable to unmarshall complex types like: "+feelType.getName() ); } return null; }
[ "@", "Override", "public", "Object", "unmarshall", "(", "Type", "feelType", ",", "String", "value", ")", "{", "if", "(", "\"null\"", ".", "equals", "(", "value", ")", ")", "{", "return", "null", ";", "}", "else", "if", "(", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "NUMBER", ")", ")", "{", "return", "BuiltInFunctions", ".", "getFunction", "(", "NumberFunction", ".", "class", ")", ".", "invoke", "(", "value", ",", "null", ",", "null", ")", ".", "cata", "(", "justNull", "(", ")", ",", "Function", ".", "identity", "(", ")", ")", ";", "}", "else", "if", "(", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "STRING", ")", ")", "{", "return", "value", ";", "}", "else", "if", "(", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "DATE", ")", ")", "{", "return", "BuiltInFunctions", ".", "getFunction", "(", "DateFunction", ".", "class", ")", ".", "invoke", "(", "value", ")", ".", "cata", "(", "justNull", "(", ")", ",", "Function", ".", "identity", "(", ")", ")", ";", "}", "else", "if", "(", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "TIME", ")", ")", "{", "return", "BuiltInFunctions", ".", "getFunction", "(", "TimeFunction", ".", "class", ")", ".", "invoke", "(", "value", ")", ".", "cata", "(", "justNull", "(", ")", ",", "Function", ".", "identity", "(", ")", ")", ";", "}", "else", "if", "(", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "DATE_TIME", ")", ")", "{", "return", "BuiltInFunctions", ".", "getFunction", "(", "DateAndTimeFunction", ".", "class", ")", ".", "invoke", "(", "value", ")", ".", "cata", "(", "justNull", "(", ")", ",", "Function", ".", "identity", "(", ")", ")", ";", "}", "else", "if", "(", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "DURATION", ")", ")", "{", "return", "BuiltInFunctions", ".", "getFunction", "(", "DurationFunction", ".", "class", ")", ".", "invoke", "(", "value", ")", ".", "cata", "(", "justNull", "(", ")", ",", "Function", ".", "identity", "(", ")", ")", ";", "}", "else", "if", "(", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "BOOLEAN", ")", ")", "{", "return", "Boolean", ".", "parseBoolean", "(", "value", ")", ";", "}", "else", "if", "(", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "RANGE", ")", "||", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "FUNCTION", ")", "||", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "LIST", ")", "||", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "CONTEXT", ")", "||", "feelType", ".", "equals", "(", "org", ".", "kie", ".", "dmn", ".", "feel", ".", "lang", ".", "types", ".", "BuiltInType", ".", "UNARY_TEST", ")", ")", "{", "throw", "new", "UnsupportedOperationException", "(", "\"FEELStringMarshaller is unable to unmarshall complex types like: \"", "+", "feelType", ".", "getName", "(", ")", ")", ";", "}", "return", "null", ";", "}" ]
Unmarshalls the given string into a FEEL value. IMPORTANT: please note that it is only possible to unmarshall simple values, like strings and numbers. Complex values like lists and contexts don't have enough metadata marshalled in the string to enable them to be unmarshalled. @param feelType the expected type of the value to be unmarshalled @param value the marshalled value to unmarshall @return the value resulting from the unmarshalling of the string @throws UnsupportedOperationException in case the type is a complex type, i.e. RANGE, FUNCTION, CONTEXT, LIST or UNARY_TEST, the implementation raises the exception.
[ "Unmarshalls", "the", "given", "string", "into", "a", "FEEL", "value", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/marshaller/FEELStringMarshaller.java#L78-L101
14,224
kiegroup/drools
drools-core/src/main/java/org/drools/core/common/ObjectTypeConfigurationRegistry.java
ObjectTypeConfigurationRegistry.getObjectTypeConf
public ObjectTypeConf getObjectTypeConf(EntryPointId entrypoint, Object object) { // first see if it's a ClassObjectTypeConf Object key; if (object instanceof Activation) { key = ClassObjectType.Match_ObjectType.getClassType(); } else if (object instanceof Fact) { key = ((Fact) object).getFactTemplate().getName(); } else { key = object.getClass(); } ObjectTypeConf objectTypeConf = this.typeConfMap.get( key ); // it doesn't exist, so create it. if ( objectTypeConf == null ) { if ( object instanceof Fact ) { objectTypeConf = new FactTemplateTypeConf( entrypoint, ((Fact) object).getFactTemplate(), this.kBase ); } else { objectTypeConf = new ClassObjectTypeConf( entrypoint, (Class<?>) key, this.kBase ); } ObjectTypeConf existing = this.typeConfMap.putIfAbsent( key, objectTypeConf ); if ( existing != null ) { // Raced, take the (now) existing. objectTypeConf = existing; } } return objectTypeConf; }
java
public ObjectTypeConf getObjectTypeConf(EntryPointId entrypoint, Object object) { // first see if it's a ClassObjectTypeConf Object key; if (object instanceof Activation) { key = ClassObjectType.Match_ObjectType.getClassType(); } else if (object instanceof Fact) { key = ((Fact) object).getFactTemplate().getName(); } else { key = object.getClass(); } ObjectTypeConf objectTypeConf = this.typeConfMap.get( key ); // it doesn't exist, so create it. if ( objectTypeConf == null ) { if ( object instanceof Fact ) { objectTypeConf = new FactTemplateTypeConf( entrypoint, ((Fact) object).getFactTemplate(), this.kBase ); } else { objectTypeConf = new ClassObjectTypeConf( entrypoint, (Class<?>) key, this.kBase ); } ObjectTypeConf existing = this.typeConfMap.putIfAbsent( key, objectTypeConf ); if ( existing != null ) { // Raced, take the (now) existing. objectTypeConf = existing; } } return objectTypeConf; }
[ "public", "ObjectTypeConf", "getObjectTypeConf", "(", "EntryPointId", "entrypoint", ",", "Object", "object", ")", "{", "// first see if it's a ClassObjectTypeConf ", "Object", "key", ";", "if", "(", "object", "instanceof", "Activation", ")", "{", "key", "=", "ClassObjectType", ".", "Match_ObjectType", ".", "getClassType", "(", ")", ";", "}", "else", "if", "(", "object", "instanceof", "Fact", ")", "{", "key", "=", "(", "(", "Fact", ")", "object", ")", ".", "getFactTemplate", "(", ")", ".", "getName", "(", ")", ";", "}", "else", "{", "key", "=", "object", ".", "getClass", "(", ")", ";", "}", "ObjectTypeConf", "objectTypeConf", "=", "this", ".", "typeConfMap", ".", "get", "(", "key", ")", ";", "// it doesn't exist, so create it.", "if", "(", "objectTypeConf", "==", "null", ")", "{", "if", "(", "object", "instanceof", "Fact", ")", "{", "objectTypeConf", "=", "new", "FactTemplateTypeConf", "(", "entrypoint", ",", "(", "(", "Fact", ")", "object", ")", ".", "getFactTemplate", "(", ")", ",", "this", ".", "kBase", ")", ";", "}", "else", "{", "objectTypeConf", "=", "new", "ClassObjectTypeConf", "(", "entrypoint", ",", "(", "Class", "<", "?", ">", ")", "key", ",", "this", ".", "kBase", ")", ";", "}", "ObjectTypeConf", "existing", "=", "this", ".", "typeConfMap", ".", "putIfAbsent", "(", "key", ",", "objectTypeConf", ")", ";", "if", "(", "existing", "!=", "null", ")", "{", "// Raced, take the (now) existing.", "objectTypeConf", "=", "existing", ";", "}", "}", "return", "objectTypeConf", ";", "}" ]
Returns the ObjectTypeConfiguration object for the given object or creates a new one if none is found in the cache
[ "Returns", "the", "ObjectTypeConfiguration", "object", "for", "the", "given", "object", "or", "creates", "a", "new", "one", "if", "none", "is", "found", "in", "the", "cache" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/common/ObjectTypeConfigurationRegistry.java#L48-L80
14,225
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/dsl/DSLTokenizedMappingFile.java
DSLTokenizedMappingFile.readFile
private String readFile( Reader reader ) throws IOException { lineLengths = new ArrayList<Integer>(); lineLengths.add( null ); LineNumberReader lnr = new LineNumberReader( reader ); StringBuilder sb = new StringBuilder(); int nlCount = 0; boolean inEntry = false; String line; while( (line = lnr.readLine()) != null ){ lineLengths.add( line.length() ); Matcher commentMat = commentPat.matcher( line ); if( commentMat.matches() ){ if( inEntry ){ nlCount++; } else { sb.append( '\n' ); } if( "#/".equals( commentMat.group( 2 ) ) ){ String[] options = commentMat.group( 1 ).substring( 2 ).trim().split( "\\s+" ); for( String option: options ){ optionSet.add( option ); } } continue; } if( entryPat.matcher( line ).matches() ){ if( inEntry ){ for( int i = 0; i < nlCount; i++ ) sb.append( '\n' ); } sb.append( line ); nlCount = 1; inEntry = true; continue; } sb.append( ' ').append( line ); nlCount++; } if( inEntry ) sb.append( '\n' ); lnr.close(); // logger.info( "====== DSL definition:" ); // logger.info( sb.toString() ); return sb.toString(); }
java
private String readFile( Reader reader ) throws IOException { lineLengths = new ArrayList<Integer>(); lineLengths.add( null ); LineNumberReader lnr = new LineNumberReader( reader ); StringBuilder sb = new StringBuilder(); int nlCount = 0; boolean inEntry = false; String line; while( (line = lnr.readLine()) != null ){ lineLengths.add( line.length() ); Matcher commentMat = commentPat.matcher( line ); if( commentMat.matches() ){ if( inEntry ){ nlCount++; } else { sb.append( '\n' ); } if( "#/".equals( commentMat.group( 2 ) ) ){ String[] options = commentMat.group( 1 ).substring( 2 ).trim().split( "\\s+" ); for( String option: options ){ optionSet.add( option ); } } continue; } if( entryPat.matcher( line ).matches() ){ if( inEntry ){ for( int i = 0; i < nlCount; i++ ) sb.append( '\n' ); } sb.append( line ); nlCount = 1; inEntry = true; continue; } sb.append( ' ').append( line ); nlCount++; } if( inEntry ) sb.append( '\n' ); lnr.close(); // logger.info( "====== DSL definition:" ); // logger.info( sb.toString() ); return sb.toString(); }
[ "private", "String", "readFile", "(", "Reader", "reader", ")", "throws", "IOException", "{", "lineLengths", "=", "new", "ArrayList", "<", "Integer", ">", "(", ")", ";", "lineLengths", ".", "add", "(", "null", ")", ";", "LineNumberReader", "lnr", "=", "new", "LineNumberReader", "(", "reader", ")", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "int", "nlCount", "=", "0", ";", "boolean", "inEntry", "=", "false", ";", "String", "line", ";", "while", "(", "(", "line", "=", "lnr", ".", "readLine", "(", ")", ")", "!=", "null", ")", "{", "lineLengths", ".", "add", "(", "line", ".", "length", "(", ")", ")", ";", "Matcher", "commentMat", "=", "commentPat", ".", "matcher", "(", "line", ")", ";", "if", "(", "commentMat", ".", "matches", "(", ")", ")", "{", "if", "(", "inEntry", ")", "{", "nlCount", "++", ";", "}", "else", "{", "sb", ".", "append", "(", "'", "'", ")", ";", "}", "if", "(", "\"#/\"", ".", "equals", "(", "commentMat", ".", "group", "(", "2", ")", ")", ")", "{", "String", "[", "]", "options", "=", "commentMat", ".", "group", "(", "1", ")", ".", "substring", "(", "2", ")", ".", "trim", "(", ")", ".", "split", "(", "\"\\\\s+\"", ")", ";", "for", "(", "String", "option", ":", "options", ")", "{", "optionSet", ".", "add", "(", "option", ")", ";", "}", "}", "continue", ";", "}", "if", "(", "entryPat", ".", "matcher", "(", "line", ")", ".", "matches", "(", ")", ")", "{", "if", "(", "inEntry", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "nlCount", ";", "i", "++", ")", "sb", ".", "append", "(", "'", "'", ")", ";", "}", "sb", ".", "append", "(", "line", ")", ";", "nlCount", "=", "1", ";", "inEntry", "=", "true", ";", "continue", ";", "}", "sb", ".", "append", "(", "'", "'", ")", ".", "append", "(", "line", ")", ";", "nlCount", "++", ";", "}", "if", "(", "inEntry", ")", "sb", ".", "append", "(", "'", "'", ")", ";", "lnr", ".", "close", "(", ")", ";", "// logger.info( \"====== DSL definition:\" );", "// logger.info( sb.toString() );", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Read a DSL file and convert it to a String. Comment lines are removed. Split lines are joined, inserting a space for an EOL, but maintaining the original number of lines by inserting EOLs. Options are recognized. Keeps track of original line lengths for fixing parser error messages. @param reader for the DSL file data @return the transformed DSL file @throws IOException
[ "Read", "a", "DSL", "file", "and", "convert", "it", "to", "a", "String", ".", "Comment", "lines", "are", "removed", ".", "Split", "lines", "are", "joined", "inserting", "a", "space", "for", "an", "EOL", "but", "maintaining", "the", "original", "number", "of", "lines", "by", "inserting", "EOLs", ".", "Options", "are", "recognized", ".", "Keeps", "track", "of", "original", "line", "lengths", "for", "fixing", "parser", "error", "messages", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/dsl/DSLTokenizedMappingFile.java#L62-L107
14,226
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/Pattern52.java
Pattern52.clonePattern
public Pattern52 clonePattern() { Pattern52 cloned = new Pattern52(); cloned.setBoundName( getBoundName() ); cloned.setChildColumns( new ArrayList<ConditionCol52>( getChildColumns() ) ); cloned.setEntryPointName( getEntryPointName() ); cloned.setFactType( getFactType() ); cloned.setNegated( isNegated() ); cloned.setWindow( getWindow() ); return cloned; }
java
public Pattern52 clonePattern() { Pattern52 cloned = new Pattern52(); cloned.setBoundName( getBoundName() ); cloned.setChildColumns( new ArrayList<ConditionCol52>( getChildColumns() ) ); cloned.setEntryPointName( getEntryPointName() ); cloned.setFactType( getFactType() ); cloned.setNegated( isNegated() ); cloned.setWindow( getWindow() ); return cloned; }
[ "public", "Pattern52", "clonePattern", "(", ")", "{", "Pattern52", "cloned", "=", "new", "Pattern52", "(", ")", ";", "cloned", ".", "setBoundName", "(", "getBoundName", "(", ")", ")", ";", "cloned", ".", "setChildColumns", "(", "new", "ArrayList", "<", "ConditionCol52", ">", "(", "getChildColumns", "(", ")", ")", ")", ";", "cloned", ".", "setEntryPointName", "(", "getEntryPointName", "(", ")", ")", ";", "cloned", ".", "setFactType", "(", "getFactType", "(", ")", ")", ";", "cloned", ".", "setNegated", "(", "isNegated", "(", ")", ")", ";", "cloned", ".", "setWindow", "(", "getWindow", "(", ")", ")", ";", "return", "cloned", ";", "}" ]
Clones this pattern instance. @return The cloned instance.
[ "Clones", "this", "pattern", "instance", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/Pattern52.java#L123-L132
14,227
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/Pattern52.java
Pattern52.update
public void update( Pattern52 other ) { setBoundName( other.getBoundName() ); setChildColumns( other.getChildColumns() ); setEntryPointName( other.getEntryPointName() ); setFactType( other.getFactType() ); setNegated( other.isNegated() ); setWindow( other.getWindow() ); }
java
public void update( Pattern52 other ) { setBoundName( other.getBoundName() ); setChildColumns( other.getChildColumns() ); setEntryPointName( other.getEntryPointName() ); setFactType( other.getFactType() ); setNegated( other.isNegated() ); setWindow( other.getWindow() ); }
[ "public", "void", "update", "(", "Pattern52", "other", ")", "{", "setBoundName", "(", "other", ".", "getBoundName", "(", ")", ")", ";", "setChildColumns", "(", "other", ".", "getChildColumns", "(", ")", ")", ";", "setEntryPointName", "(", "other", ".", "getEntryPointName", "(", ")", ")", ";", "setFactType", "(", "other", ".", "getFactType", "(", ")", ")", ";", "setNegated", "(", "other", ".", "isNegated", "(", ")", ")", ";", "setWindow", "(", "other", ".", "getWindow", "(", ")", ")", ";", "}" ]
Update this pattern instance properties with the given ones from other pattern instance. @param other The pattern to obtain the properties to set.
[ "Update", "this", "pattern", "instance", "properties", "with", "the", "given", "ones", "from", "other", "pattern", "instance", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/Pattern52.java#L138-L145
14,228
kiegroup/drools
drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/context/GeneratorContextRuleModelVisitor.java
GeneratorContextRuleModelVisitor.visitActionFieldList
private void visitActionFieldList(final ActionInsertFact afl) { String factType = afl.getFactType(); for (ActionFieldValue afv : afl.getFieldValues()) { InterpolationVariable var = new InterpolationVariable(afv.getValue(), afv.getType(), factType, afv.getField()); if (afv.getNature() == FieldNatureType.TYPE_TEMPLATE && !vars.contains(var)) { vars.add(var); } else { hasNonTemplateOutput = true; } } }
java
private void visitActionFieldList(final ActionInsertFact afl) { String factType = afl.getFactType(); for (ActionFieldValue afv : afl.getFieldValues()) { InterpolationVariable var = new InterpolationVariable(afv.getValue(), afv.getType(), factType, afv.getField()); if (afv.getNature() == FieldNatureType.TYPE_TEMPLATE && !vars.contains(var)) { vars.add(var); } else { hasNonTemplateOutput = true; } } }
[ "private", "void", "visitActionFieldList", "(", "final", "ActionInsertFact", "afl", ")", "{", "String", "factType", "=", "afl", ".", "getFactType", "(", ")", ";", "for", "(", "ActionFieldValue", "afv", ":", "afl", ".", "getFieldValues", "(", ")", ")", "{", "InterpolationVariable", "var", "=", "new", "InterpolationVariable", "(", "afv", ".", "getValue", "(", ")", ",", "afv", ".", "getType", "(", ")", ",", "factType", ",", "afv", ".", "getField", "(", ")", ")", ";", "if", "(", "afv", ".", "getNature", "(", ")", "==", "FieldNatureType", ".", "TYPE_TEMPLATE", "&&", "!", "vars", ".", "contains", "(", "var", ")", ")", "{", "vars", ".", "add", "(", "var", ")", ";", "}", "else", "{", "hasNonTemplateOutput", "=", "true", ";", "}", "}", "}" ]
ActionInsertFact, ActionSetField, ActionpdateField
[ "ActionInsertFact", "ActionSetField", "ActionpdateField" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/context/GeneratorContextRuleModelVisitor.java#L133-L146
14,229
kiegroup/drools
kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/PMML4Compiler.java
PMML4Compiler.loadModel
public PMML loadModel(String model, InputStream source) { try { if (schema == null) { visitorBuildResults.add(new PMMLWarning(ResourceFactory.newInputStreamResource(source), "Could not validate PMML document, schema not available")); } final JAXBContext jc; final ClassLoader ccl = Thread.currentThread().getContextClassLoader(); XMLStreamReader reader = null; try { Thread.currentThread().setContextClassLoader(PMML4Compiler.class.getClassLoader()); Class c = PMML4Compiler.class.getClassLoader().loadClass("org.dmg.pmml.pmml_4_2.descr.PMML"); jc = JAXBContext.newInstance(c); XMLInputFactory xif = XMLInputFactory.newFactory(); xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); xif.setProperty(XMLInputFactory.SUPPORT_DTD, true); reader = xif.createXMLStreamReader(source); } finally { Thread.currentThread().setContextClassLoader(ccl); } Unmarshaller unmarshaller = jc.createUnmarshaller(); if (schema != null) { unmarshaller.setSchema(schema); } if (reader != null) { return (PMML) unmarshaller.unmarshal(reader); } else { this.results.add(new PMMLError("Unknown error in PMML")); return null; } } catch (ClassNotFoundException | XMLStreamException | JAXBException e) { this.results.add(new PMMLError(e.toString())); return null; } }
java
public PMML loadModel(String model, InputStream source) { try { if (schema == null) { visitorBuildResults.add(new PMMLWarning(ResourceFactory.newInputStreamResource(source), "Could not validate PMML document, schema not available")); } final JAXBContext jc; final ClassLoader ccl = Thread.currentThread().getContextClassLoader(); XMLStreamReader reader = null; try { Thread.currentThread().setContextClassLoader(PMML4Compiler.class.getClassLoader()); Class c = PMML4Compiler.class.getClassLoader().loadClass("org.dmg.pmml.pmml_4_2.descr.PMML"); jc = JAXBContext.newInstance(c); XMLInputFactory xif = XMLInputFactory.newFactory(); xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false); xif.setProperty(XMLInputFactory.SUPPORT_DTD, true); reader = xif.createXMLStreamReader(source); } finally { Thread.currentThread().setContextClassLoader(ccl); } Unmarshaller unmarshaller = jc.createUnmarshaller(); if (schema != null) { unmarshaller.setSchema(schema); } if (reader != null) { return (PMML) unmarshaller.unmarshal(reader); } else { this.results.add(new PMMLError("Unknown error in PMML")); return null; } } catch (ClassNotFoundException | XMLStreamException | JAXBException e) { this.results.add(new PMMLError(e.toString())); return null; } }
[ "public", "PMML", "loadModel", "(", "String", "model", ",", "InputStream", "source", ")", "{", "try", "{", "if", "(", "schema", "==", "null", ")", "{", "visitorBuildResults", ".", "add", "(", "new", "PMMLWarning", "(", "ResourceFactory", ".", "newInputStreamResource", "(", "source", ")", ",", "\"Could not validate PMML document, schema not available\"", ")", ")", ";", "}", "final", "JAXBContext", "jc", ";", "final", "ClassLoader", "ccl", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "XMLStreamReader", "reader", "=", "null", ";", "try", "{", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "PMML4Compiler", ".", "class", ".", "getClassLoader", "(", ")", ")", ";", "Class", "c", "=", "PMML4Compiler", ".", "class", ".", "getClassLoader", "(", ")", ".", "loadClass", "(", "\"org.dmg.pmml.pmml_4_2.descr.PMML\"", ")", ";", "jc", "=", "JAXBContext", ".", "newInstance", "(", "c", ")", ";", "XMLInputFactory", "xif", "=", "XMLInputFactory", ".", "newFactory", "(", ")", ";", "xif", ".", "setProperty", "(", "XMLInputFactory", ".", "IS_SUPPORTING_EXTERNAL_ENTITIES", ",", "false", ")", ";", "xif", ".", "setProperty", "(", "XMLInputFactory", ".", "SUPPORT_DTD", ",", "true", ")", ";", "reader", "=", "xif", ".", "createXMLStreamReader", "(", "source", ")", ";", "}", "finally", "{", "Thread", ".", "currentThread", "(", ")", ".", "setContextClassLoader", "(", "ccl", ")", ";", "}", "Unmarshaller", "unmarshaller", "=", "jc", ".", "createUnmarshaller", "(", ")", ";", "if", "(", "schema", "!=", "null", ")", "{", "unmarshaller", ".", "setSchema", "(", "schema", ")", ";", "}", "if", "(", "reader", "!=", "null", ")", "{", "return", "(", "PMML", ")", "unmarshaller", ".", "unmarshal", "(", "reader", ")", ";", "}", "else", "{", "this", ".", "results", ".", "add", "(", "new", "PMMLError", "(", "\"Unknown error in PMML\"", ")", ")", ";", "return", "null", ";", "}", "}", "catch", "(", "ClassNotFoundException", "|", "XMLStreamException", "|", "JAXBException", "e", ")", "{", "this", ".", "results", ".", "add", "(", "new", "PMMLError", "(", "e", ".", "toString", "(", ")", ")", ")", ";", "return", "null", ";", "}", "}" ]
Imports a PMML source file, returning a Java descriptor @param model the PMML package name (classes derived from a specific schema) @param source the name of the PMML resource storing the predictive model @return the Java Descriptor of the PMML resource
[ "Imports", "a", "PMML", "source", "file", "returning", "a", "Java", "descriptor" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/PMML4Compiler.java#L750-L784
14,230
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/AccumulateNode.java
AccumulateNode.createMemory
public Memory createMemory(final RuleBaseConfiguration config, InternalWorkingMemory wm) { BetaMemory betaMemory = this.constraints.createBetaMemory(config, NodeTypeEnums.AccumulateNode); AccumulateMemory memory = this.accumulate.isMultiFunction() ? new MultiAccumulateMemory(betaMemory, this.accumulate.getAccumulators()) : new SingleAccumulateMemory(betaMemory, this.accumulate.getAccumulators()[0]); memory.workingMemoryContext = this.accumulate.createWorkingMemoryContext(); memory.resultsContext = this.resultBinder.createContext(); return memory; }
java
public Memory createMemory(final RuleBaseConfiguration config, InternalWorkingMemory wm) { BetaMemory betaMemory = this.constraints.createBetaMemory(config, NodeTypeEnums.AccumulateNode); AccumulateMemory memory = this.accumulate.isMultiFunction() ? new MultiAccumulateMemory(betaMemory, this.accumulate.getAccumulators()) : new SingleAccumulateMemory(betaMemory, this.accumulate.getAccumulators()[0]); memory.workingMemoryContext = this.accumulate.createWorkingMemoryContext(); memory.resultsContext = this.resultBinder.createContext(); return memory; }
[ "public", "Memory", "createMemory", "(", "final", "RuleBaseConfiguration", "config", ",", "InternalWorkingMemory", "wm", ")", "{", "BetaMemory", "betaMemory", "=", "this", ".", "constraints", ".", "createBetaMemory", "(", "config", ",", "NodeTypeEnums", ".", "AccumulateNode", ")", ";", "AccumulateMemory", "memory", "=", "this", ".", "accumulate", ".", "isMultiFunction", "(", ")", "?", "new", "MultiAccumulateMemory", "(", "betaMemory", ",", "this", ".", "accumulate", ".", "getAccumulators", "(", ")", ")", ":", "new", "SingleAccumulateMemory", "(", "betaMemory", ",", "this", ".", "accumulate", ".", "getAccumulators", "(", ")", "[", "0", "]", ")", ";", "memory", ".", "workingMemoryContext", "=", "this", ".", "accumulate", ".", "createWorkingMemoryContext", "(", ")", ";", "memory", ".", "resultsContext", "=", "this", ".", "resultBinder", ".", "createContext", "(", ")", ";", "return", "memory", ";", "}" ]
Creates a BetaMemory for the BetaNode's memory.
[ "Creates", "a", "BetaMemory", "for", "the", "BetaNode", "s", "memory", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/AccumulateNode.java#L230-L240
14,231
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/dsl/DefaultDSLMapping.java
DefaultDSLMapping.getEntries
public List<DSLMappingEntry> getEntries(final DSLMappingEntry.Section section) { final List<DSLMappingEntry> list = new LinkedList<DSLMappingEntry>(); for ( final Iterator<DSLMappingEntry> it = this.entries.iterator(); it.hasNext(); ) { final DSLMappingEntry entry = it.next(); if ( entry.getSection().equals( section ) ) { list.add( entry ); } } return list; }
java
public List<DSLMappingEntry> getEntries(final DSLMappingEntry.Section section) { final List<DSLMappingEntry> list = new LinkedList<DSLMappingEntry>(); for ( final Iterator<DSLMappingEntry> it = this.entries.iterator(); it.hasNext(); ) { final DSLMappingEntry entry = it.next(); if ( entry.getSection().equals( section ) ) { list.add( entry ); } } return list; }
[ "public", "List", "<", "DSLMappingEntry", ">", "getEntries", "(", "final", "DSLMappingEntry", ".", "Section", "section", ")", "{", "final", "List", "<", "DSLMappingEntry", ">", "list", "=", "new", "LinkedList", "<", "DSLMappingEntry", ">", "(", ")", ";", "for", "(", "final", "Iterator", "<", "DSLMappingEntry", ">", "it", "=", "this", ".", "entries", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "final", "DSLMappingEntry", "entry", "=", "it", ".", "next", "(", ")", ";", "if", "(", "entry", ".", "getSection", "(", ")", ".", "equals", "(", "section", ")", ")", "{", "list", ".", "add", "(", "entry", ")", ";", "}", "}", "return", "list", ";", "}" ]
Returns the list of mappings for the given section @param section @return
[ "Returns", "the", "list", "of", "mappings", "for", "the", "given", "section" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/dsl/DefaultDSLMapping.java#L78-L87
14,232
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/builder/ReteooRuleBuilder.java
ReteooRuleBuilder.addInitialFactPattern
private void addInitialFactPattern( final GroupElement subrule ) { // creates a pattern for initial fact final Pattern pattern = new Pattern( 0, ClassObjectType.InitialFact_ObjectType ); // adds the pattern as the first child of the given AND group element subrule.addChild( 0, pattern ); }
java
private void addInitialFactPattern( final GroupElement subrule ) { // creates a pattern for initial fact final Pattern pattern = new Pattern( 0, ClassObjectType.InitialFact_ObjectType ); // adds the pattern as the first child of the given AND group element subrule.addChild( 0, pattern ); }
[ "private", "void", "addInitialFactPattern", "(", "final", "GroupElement", "subrule", ")", "{", "// creates a pattern for initial fact", "final", "Pattern", "pattern", "=", "new", "Pattern", "(", "0", ",", "ClassObjectType", ".", "InitialFact_ObjectType", ")", ";", "// adds the pattern as the first child of the given AND group element", "subrule", ".", "addChild", "(", "0", ",", "pattern", ")", ";", "}" ]
Adds a query pattern to the given subrule
[ "Adds", "a", "query", "pattern", "to", "the", "given", "subrule" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/builder/ReteooRuleBuilder.java#L226-L235
14,233
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/builder/BuildContext.java
BuildContext.push
public void push(final RuleConditionElement rce) { if (this.buildstack == null) { this.buildstack = new LinkedList<>(); } this.buildstack.addLast(rce); }
java
public void push(final RuleConditionElement rce) { if (this.buildstack == null) { this.buildstack = new LinkedList<>(); } this.buildstack.addLast(rce); }
[ "public", "void", "push", "(", "final", "RuleConditionElement", "rce", ")", "{", "if", "(", "this", ".", "buildstack", "==", "null", ")", "{", "this", ".", "buildstack", "=", "new", "LinkedList", "<>", "(", ")", ";", "}", "this", ".", "buildstack", ".", "addLast", "(", "rce", ")", ";", "}" ]
Adds the rce to the build stack
[ "Adds", "the", "rce", "to", "the", "build", "stack" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/builder/BuildContext.java#L264-L269
14,234
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/builder/BuildContext.java
BuildContext.stackIterator
ListIterator<RuleConditionElement> stackIterator() { if (this.buildstack == null) { this.buildstack = new LinkedList<>(); } return this.buildstack.listIterator(this.buildstack.size()); }
java
ListIterator<RuleConditionElement> stackIterator() { if (this.buildstack == null) { this.buildstack = new LinkedList<>(); } return this.buildstack.listIterator(this.buildstack.size()); }
[ "ListIterator", "<", "RuleConditionElement", ">", "stackIterator", "(", ")", "{", "if", "(", "this", ".", "buildstack", "==", "null", ")", "{", "this", ".", "buildstack", "=", "new", "LinkedList", "<>", "(", ")", ";", "}", "return", "this", ".", "buildstack", ".", "listIterator", "(", "this", ".", "buildstack", ".", "size", "(", ")", ")", ";", "}" ]
Returns a list iterator to iterate over the stacked elements
[ "Returns", "a", "list", "iterator", "to", "iterate", "over", "the", "stacked", "elements" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/builder/BuildContext.java#L294-L299
14,235
kiegroup/drools
drools-verifier/drools-verifier-drl/src/main/java/org/drools/verifier/visitor/RuleDescrVisitor.java
RuleDescrVisitor.visitConsequence
private Consequence visitConsequence(VerifierComponent parent, Object o) { TextConsequence consequence = new TextConsequence(rule); String text = o.toString(); /* * Strip all comments out of the code. */ StringBuffer buffer = new StringBuffer(text); int commentIndex = buffer.indexOf("//"); while (commentIndex != -1) { buffer = buffer.delete(commentIndex, buffer.indexOf("\n", commentIndex)); commentIndex = buffer.indexOf("//"); } text = buffer.toString(); /* * Strip all useless characters out of the code. */ text = text.replaceAll("\n", ""); text = text.replaceAll("\r", ""); text = text.replaceAll("\t", ""); text = text.replaceAll(" ", ""); consequence.setText(text); consequence.setParentPath(parent.getPath()); consequence.setParentType(parent.getVerifierComponentType()); data.add(consequence); return consequence; }
java
private Consequence visitConsequence(VerifierComponent parent, Object o) { TextConsequence consequence = new TextConsequence(rule); String text = o.toString(); /* * Strip all comments out of the code. */ StringBuffer buffer = new StringBuffer(text); int commentIndex = buffer.indexOf("//"); while (commentIndex != -1) { buffer = buffer.delete(commentIndex, buffer.indexOf("\n", commentIndex)); commentIndex = buffer.indexOf("//"); } text = buffer.toString(); /* * Strip all useless characters out of the code. */ text = text.replaceAll("\n", ""); text = text.replaceAll("\r", ""); text = text.replaceAll("\t", ""); text = text.replaceAll(" ", ""); consequence.setText(text); consequence.setParentPath(parent.getPath()); consequence.setParentType(parent.getVerifierComponentType()); data.add(consequence); return consequence; }
[ "private", "Consequence", "visitConsequence", "(", "VerifierComponent", "parent", ",", "Object", "o", ")", "{", "TextConsequence", "consequence", "=", "new", "TextConsequence", "(", "rule", ")", ";", "String", "text", "=", "o", ".", "toString", "(", ")", ";", "/*\n * Strip all comments out of the code.\n */", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", "text", ")", ";", "int", "commentIndex", "=", "buffer", ".", "indexOf", "(", "\"//\"", ")", ";", "while", "(", "commentIndex", "!=", "-", "1", ")", "{", "buffer", "=", "buffer", ".", "delete", "(", "commentIndex", ",", "buffer", ".", "indexOf", "(", "\"\\n\"", ",", "commentIndex", ")", ")", ";", "commentIndex", "=", "buffer", ".", "indexOf", "(", "\"//\"", ")", ";", "}", "text", "=", "buffer", ".", "toString", "(", ")", ";", "/*\n * Strip all useless characters out of the code.\n */", "text", "=", "text", ".", "replaceAll", "(", "\"\\n\"", ",", "\"\"", ")", ";", "text", "=", "text", ".", "replaceAll", "(", "\"\\r\"", ",", "\"\"", ")", ";", "text", "=", "text", ".", "replaceAll", "(", "\"\\t\"", ",", "\"\"", ")", ";", "text", "=", "text", ".", "replaceAll", "(", "\" \"", ",", "\"\"", ")", ";", "consequence", ".", "setText", "(", "text", ")", ";", "consequence", ".", "setParentPath", "(", "parent", ".", "getPath", "(", ")", ")", ";", "consequence", ".", "setParentType", "(", "parent", ".", "getVerifierComponentType", "(", ")", ")", ";", "data", ".", "add", "(", "consequence", ")", ";", "return", "consequence", ";", "}" ]
Creates verifier object from rule consequence. Currently only supports text based consequences. @param o Consequence object. @return Verifier object that implements the Consequence interface.
[ "Creates", "verifier", "object", "from", "rule", "consequence", ".", "Currently", "only", "supports", "text", "based", "consequences", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-verifier/drools-verifier-drl/src/main/java/org/drools/verifier/visitor/RuleDescrVisitor.java#L170-L211
14,236
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java
BinaryHeapQueue.enqueue
public void enqueue(final Activation element) { if ( isFull() ) { grow(); } percolateUpMaxHeap( element ); element.setQueued(true); if ( log.isTraceEnabled() ) { log.trace( "Queue Added {} {}", element.getQueueIndex(), element); } }
java
public void enqueue(final Activation element) { if ( isFull() ) { grow(); } percolateUpMaxHeap( element ); element.setQueued(true); if ( log.isTraceEnabled() ) { log.trace( "Queue Added {} {}", element.getQueueIndex(), element); } }
[ "public", "void", "enqueue", "(", "final", "Activation", "element", ")", "{", "if", "(", "isFull", "(", ")", ")", "{", "grow", "(", ")", ";", "}", "percolateUpMaxHeap", "(", "element", ")", ";", "element", ".", "setQueued", "(", "true", ")", ";", "if", "(", "log", ".", "isTraceEnabled", "(", ")", ")", "{", "log", ".", "trace", "(", "\"Queue Added {} {}\"", ",", "element", ".", "getQueueIndex", "(", ")", ",", "element", ")", ";", "}", "}" ]
Inserts an Queueable into queue. @param element the Queueable to be inserted
[ "Inserts", "an", "Queueable", "into", "queue", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java#L154-L165
14,237
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java
BinaryHeapQueue.dequeue
public Activation dequeue() throws NoSuchElementException { if ( isEmpty() ) { return null; } final Activation result = this.elements[1]; dequeue(result.getQueueIndex()); return result; }
java
public Activation dequeue() throws NoSuchElementException { if ( isEmpty() ) { return null; } final Activation result = this.elements[1]; dequeue(result.getQueueIndex()); return result; }
[ "public", "Activation", "dequeue", "(", ")", "throws", "NoSuchElementException", "{", "if", "(", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "final", "Activation", "result", "=", "this", ".", "elements", "[", "1", "]", ";", "dequeue", "(", "result", ".", "getQueueIndex", "(", ")", ")", ";", "return", "result", ";", "}" ]
Returns the Queueable on top of heap and remove it. @return the Queueable at top of heap @throws NoSuchElementException if <code>isEmpty() == true</code>
[ "Returns", "the", "Queueable", "on", "top", "of", "heap", "and", "remove", "it", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java#L173-L182
14,238
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java
BinaryHeapQueue.grow
private void grow() { final Activation[] elements = new Activation[this.elements.length * 2]; System.arraycopy( this.elements, 0, elements, 0, this.elements.length ); this.elements = elements; }
java
private void grow() { final Activation[] elements = new Activation[this.elements.length * 2]; System.arraycopy( this.elements, 0, elements, 0, this.elements.length ); this.elements = elements; }
[ "private", "void", "grow", "(", ")", "{", "final", "Activation", "[", "]", "elements", "=", "new", "Activation", "[", "this", ".", "elements", ".", "length", "*", "2", "]", ";", "System", ".", "arraycopy", "(", "this", ".", "elements", ",", "0", ",", "elements", ",", "0", ",", "this", ".", "elements", ".", "length", ")", ";", "this", ".", "elements", "=", "elements", ";", "}" ]
Increases the size of the heap to support additional elements
[ "Increases", "the", "size", "of", "the", "heap", "to", "support", "additional", "elements" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/BinaryHeapQueue.java#L308-L316
14,239
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/ReteooBuilder.java
ReteooBuilder.removePath
private void removePath( Collection<InternalWorkingMemory> wms, RuleRemovalContext context, Map<Integer, BaseNode> stillInUse, Collection<ObjectSource> alphas, PathEndNode endNode ) { LeftTupleNode[] nodes = endNode.getPathNodes(); for (int i = endNode.getPositionInPath(); i >= 0; i--) { BaseNode node = (BaseNode) nodes[i]; boolean removed = false; if ( NodeTypeEnums.isLeftTupleNode( node ) ) { removed = removeLeftTupleNode(wms, context, stillInUse, node); } if ( removed ) { // reteoo requires to call remove on the OTN for tuples cleanup if (NodeTypeEnums.isBetaNode(node) && !((BetaNode) node).isRightInputIsRiaNode()) { alphas.add(((BetaNode) node).getRightInput()); } else if (node.getType() == NodeTypeEnums.LeftInputAdapterNode) { alphas.add(((LeftInputAdapterNode) node).getObjectSource()); } } if (NodeTypeEnums.isBetaNode(node) && ((BetaNode) node).isRightInputIsRiaNode()) { endNode = (PathEndNode) ((BetaNode) node).getRightInput(); removePath(wms, context, stillInUse, alphas, endNode); return; } } }
java
private void removePath( Collection<InternalWorkingMemory> wms, RuleRemovalContext context, Map<Integer, BaseNode> stillInUse, Collection<ObjectSource> alphas, PathEndNode endNode ) { LeftTupleNode[] nodes = endNode.getPathNodes(); for (int i = endNode.getPositionInPath(); i >= 0; i--) { BaseNode node = (BaseNode) nodes[i]; boolean removed = false; if ( NodeTypeEnums.isLeftTupleNode( node ) ) { removed = removeLeftTupleNode(wms, context, stillInUse, node); } if ( removed ) { // reteoo requires to call remove on the OTN for tuples cleanup if (NodeTypeEnums.isBetaNode(node) && !((BetaNode) node).isRightInputIsRiaNode()) { alphas.add(((BetaNode) node).getRightInput()); } else if (node.getType() == NodeTypeEnums.LeftInputAdapterNode) { alphas.add(((LeftInputAdapterNode) node).getObjectSource()); } } if (NodeTypeEnums.isBetaNode(node) && ((BetaNode) node).isRightInputIsRiaNode()) { endNode = (PathEndNode) ((BetaNode) node).getRightInput(); removePath(wms, context, stillInUse, alphas, endNode); return; } } }
[ "private", "void", "removePath", "(", "Collection", "<", "InternalWorkingMemory", ">", "wms", ",", "RuleRemovalContext", "context", ",", "Map", "<", "Integer", ",", "BaseNode", ">", "stillInUse", ",", "Collection", "<", "ObjectSource", ">", "alphas", ",", "PathEndNode", "endNode", ")", "{", "LeftTupleNode", "[", "]", "nodes", "=", "endNode", ".", "getPathNodes", "(", ")", ";", "for", "(", "int", "i", "=", "endNode", ".", "getPositionInPath", "(", ")", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "BaseNode", "node", "=", "(", "BaseNode", ")", "nodes", "[", "i", "]", ";", "boolean", "removed", "=", "false", ";", "if", "(", "NodeTypeEnums", ".", "isLeftTupleNode", "(", "node", ")", ")", "{", "removed", "=", "removeLeftTupleNode", "(", "wms", ",", "context", ",", "stillInUse", ",", "node", ")", ";", "}", "if", "(", "removed", ")", "{", "// reteoo requires to call remove on the OTN for tuples cleanup", "if", "(", "NodeTypeEnums", ".", "isBetaNode", "(", "node", ")", "&&", "!", "(", "(", "BetaNode", ")", "node", ")", ".", "isRightInputIsRiaNode", "(", ")", ")", "{", "alphas", ".", "add", "(", "(", "(", "BetaNode", ")", "node", ")", ".", "getRightInput", "(", ")", ")", ";", "}", "else", "if", "(", "node", ".", "getType", "(", ")", "==", "NodeTypeEnums", ".", "LeftInputAdapterNode", ")", "{", "alphas", ".", "add", "(", "(", "(", "LeftInputAdapterNode", ")", "node", ")", ".", "getObjectSource", "(", ")", ")", ";", "}", "}", "if", "(", "NodeTypeEnums", ".", "isBetaNode", "(", "node", ")", "&&", "(", "(", "BetaNode", ")", "node", ")", ".", "isRightInputIsRiaNode", "(", ")", ")", "{", "endNode", "=", "(", "PathEndNode", ")", "(", "(", "BetaNode", ")", "node", ")", ".", "getRightInput", "(", ")", ";", "removePath", "(", "wms", ",", "context", ",", "stillInUse", ",", "alphas", ",", "endNode", ")", ";", "return", ";", "}", "}", "}" ]
Path's must be removed starting from the outer most path, iterating towards the inner most path. Each time it reaches a subnetwork beta node, the current path evaluation ends, and instead the subnetwork path continues.
[ "Path", "s", "must", "be", "removed", "starting", "from", "the", "outer", "most", "path", "iterating", "towards", "the", "inner", "most", "path", ".", "Each", "time", "it", "reaches", "a", "subnetwork", "beta", "node", "the", "current", "path", "evaluation", "ends", "and", "instead", "the", "subnetwork", "path", "continues", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/ReteooBuilder.java#L218-L243
14,240
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/builder/BuildUtils.java
BuildUtils.attachNode
public <T extends BaseNode> T attachNode(BuildContext context, T candidate) { BaseNode node = null; RuleBasePartitionId partition = null; if ( candidate.getType() == NodeTypeEnums.EntryPointNode ) { // entry point nodes are always shared node = context.getKnowledgeBase().getRete().getEntryPointNode( ((EntryPointNode) candidate).getEntryPoint() ); // all EntryPointNodes belong to the main partition partition = RuleBasePartitionId.MAIN_PARTITION; } else if ( candidate.getType() == NodeTypeEnums.ObjectTypeNode ) { // object type nodes are always shared Map<ObjectType, ObjectTypeNode> map = context.getKnowledgeBase().getRete().getObjectTypeNodes( context.getCurrentEntryPoint() ); if ( map != null ) { ObjectTypeNode otn = map.get( ((ObjectTypeNode) candidate).getObjectType() ); if ( otn != null ) { // adjusting expiration offset otn.mergeExpirationOffset( (ObjectTypeNode) candidate ); node = otn; } } // all ObjectTypeNodes belong to the main partition partition = RuleBasePartitionId.MAIN_PARTITION; } else if ( isSharingEnabledForNode( context, candidate ) ) { if ( (context.getTupleSource() != null) && NodeTypeEnums.isLeftTupleSink( candidate ) ) { node = context.getTupleSource().getSinkPropagator().getMatchingNode( candidate ); } else if ( (context.getObjectSource() != null) && NodeTypeEnums.isObjectSink( candidate ) ) { node = context.getObjectSource().getObjectSinkPropagator().getMatchingNode( candidate ); } else { throw new RuntimeException( "This is a bug on node sharing verification. Please report to development team." ); } } if ( node != null && !areNodesCompatibleForSharing(context, node, candidate) ) { node = null; } if ( node == null ) { // only attach() if it is a new node node = candidate; // new node, so it must be labeled if ( partition == null ) { // if it does not has a predefined label if ( context.getPartitionId() == null ) { // if no label in current context, create one context.setPartitionId( context.getKnowledgeBase().createNewPartitionId() ); } partition = context.getPartitionId(); } // set node whit the actual partition label node.setPartitionId( context, partition ); node.attach(context); // adds the node to the context list to track all added nodes context.getNodes().add( node ); } else { // shared node found mergeNodes(node, candidate); // undo previous id assignment context.releaseId( candidate ); if ( partition == null && context.getPartitionId() == null ) { partition = node.getPartitionId(); // if no label in current context, create one context.setPartitionId( partition ); } } node.addAssociation( context, context.getRule() ); return (T)node; }
java
public <T extends BaseNode> T attachNode(BuildContext context, T candidate) { BaseNode node = null; RuleBasePartitionId partition = null; if ( candidate.getType() == NodeTypeEnums.EntryPointNode ) { // entry point nodes are always shared node = context.getKnowledgeBase().getRete().getEntryPointNode( ((EntryPointNode) candidate).getEntryPoint() ); // all EntryPointNodes belong to the main partition partition = RuleBasePartitionId.MAIN_PARTITION; } else if ( candidate.getType() == NodeTypeEnums.ObjectTypeNode ) { // object type nodes are always shared Map<ObjectType, ObjectTypeNode> map = context.getKnowledgeBase().getRete().getObjectTypeNodes( context.getCurrentEntryPoint() ); if ( map != null ) { ObjectTypeNode otn = map.get( ((ObjectTypeNode) candidate).getObjectType() ); if ( otn != null ) { // adjusting expiration offset otn.mergeExpirationOffset( (ObjectTypeNode) candidate ); node = otn; } } // all ObjectTypeNodes belong to the main partition partition = RuleBasePartitionId.MAIN_PARTITION; } else if ( isSharingEnabledForNode( context, candidate ) ) { if ( (context.getTupleSource() != null) && NodeTypeEnums.isLeftTupleSink( candidate ) ) { node = context.getTupleSource().getSinkPropagator().getMatchingNode( candidate ); } else if ( (context.getObjectSource() != null) && NodeTypeEnums.isObjectSink( candidate ) ) { node = context.getObjectSource().getObjectSinkPropagator().getMatchingNode( candidate ); } else { throw new RuntimeException( "This is a bug on node sharing verification. Please report to development team." ); } } if ( node != null && !areNodesCompatibleForSharing(context, node, candidate) ) { node = null; } if ( node == null ) { // only attach() if it is a new node node = candidate; // new node, so it must be labeled if ( partition == null ) { // if it does not has a predefined label if ( context.getPartitionId() == null ) { // if no label in current context, create one context.setPartitionId( context.getKnowledgeBase().createNewPartitionId() ); } partition = context.getPartitionId(); } // set node whit the actual partition label node.setPartitionId( context, partition ); node.attach(context); // adds the node to the context list to track all added nodes context.getNodes().add( node ); } else { // shared node found mergeNodes(node, candidate); // undo previous id assignment context.releaseId( candidate ); if ( partition == null && context.getPartitionId() == null ) { partition = node.getPartitionId(); // if no label in current context, create one context.setPartitionId( partition ); } } node.addAssociation( context, context.getRule() ); return (T)node; }
[ "public", "<", "T", "extends", "BaseNode", ">", "T", "attachNode", "(", "BuildContext", "context", ",", "T", "candidate", ")", "{", "BaseNode", "node", "=", "null", ";", "RuleBasePartitionId", "partition", "=", "null", ";", "if", "(", "candidate", ".", "getType", "(", ")", "==", "NodeTypeEnums", ".", "EntryPointNode", ")", "{", "// entry point nodes are always shared", "node", "=", "context", ".", "getKnowledgeBase", "(", ")", ".", "getRete", "(", ")", ".", "getEntryPointNode", "(", "(", "(", "EntryPointNode", ")", "candidate", ")", ".", "getEntryPoint", "(", ")", ")", ";", "// all EntryPointNodes belong to the main partition", "partition", "=", "RuleBasePartitionId", ".", "MAIN_PARTITION", ";", "}", "else", "if", "(", "candidate", ".", "getType", "(", ")", "==", "NodeTypeEnums", ".", "ObjectTypeNode", ")", "{", "// object type nodes are always shared", "Map", "<", "ObjectType", ",", "ObjectTypeNode", ">", "map", "=", "context", ".", "getKnowledgeBase", "(", ")", ".", "getRete", "(", ")", ".", "getObjectTypeNodes", "(", "context", ".", "getCurrentEntryPoint", "(", ")", ")", ";", "if", "(", "map", "!=", "null", ")", "{", "ObjectTypeNode", "otn", "=", "map", ".", "get", "(", "(", "(", "ObjectTypeNode", ")", "candidate", ")", ".", "getObjectType", "(", ")", ")", ";", "if", "(", "otn", "!=", "null", ")", "{", "// adjusting expiration offset", "otn", ".", "mergeExpirationOffset", "(", "(", "ObjectTypeNode", ")", "candidate", ")", ";", "node", "=", "otn", ";", "}", "}", "// all ObjectTypeNodes belong to the main partition", "partition", "=", "RuleBasePartitionId", ".", "MAIN_PARTITION", ";", "}", "else", "if", "(", "isSharingEnabledForNode", "(", "context", ",", "candidate", ")", ")", "{", "if", "(", "(", "context", ".", "getTupleSource", "(", ")", "!=", "null", ")", "&&", "NodeTypeEnums", ".", "isLeftTupleSink", "(", "candidate", ")", ")", "{", "node", "=", "context", ".", "getTupleSource", "(", ")", ".", "getSinkPropagator", "(", ")", ".", "getMatchingNode", "(", "candidate", ")", ";", "}", "else", "if", "(", "(", "context", ".", "getObjectSource", "(", ")", "!=", "null", ")", "&&", "NodeTypeEnums", ".", "isObjectSink", "(", "candidate", ")", ")", "{", "node", "=", "context", ".", "getObjectSource", "(", ")", ".", "getObjectSinkPropagator", "(", ")", ".", "getMatchingNode", "(", "candidate", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"This is a bug on node sharing verification. Please report to development team.\"", ")", ";", "}", "}", "if", "(", "node", "!=", "null", "&&", "!", "areNodesCompatibleForSharing", "(", "context", ",", "node", ",", "candidate", ")", ")", "{", "node", "=", "null", ";", "}", "if", "(", "node", "==", "null", ")", "{", "// only attach() if it is a new node", "node", "=", "candidate", ";", "// new node, so it must be labeled", "if", "(", "partition", "==", "null", ")", "{", "// if it does not has a predefined label", "if", "(", "context", ".", "getPartitionId", "(", ")", "==", "null", ")", "{", "// if no label in current context, create one", "context", ".", "setPartitionId", "(", "context", ".", "getKnowledgeBase", "(", ")", ".", "createNewPartitionId", "(", ")", ")", ";", "}", "partition", "=", "context", ".", "getPartitionId", "(", ")", ";", "}", "// set node whit the actual partition label", "node", ".", "setPartitionId", "(", "context", ",", "partition", ")", ";", "node", ".", "attach", "(", "context", ")", ";", "// adds the node to the context list to track all added nodes", "context", ".", "getNodes", "(", ")", ".", "add", "(", "node", ")", ";", "}", "else", "{", "// shared node found", "mergeNodes", "(", "node", ",", "candidate", ")", ";", "// undo previous id assignment", "context", ".", "releaseId", "(", "candidate", ")", ";", "if", "(", "partition", "==", "null", "&&", "context", ".", "getPartitionId", "(", ")", "==", "null", ")", "{", "partition", "=", "node", ".", "getPartitionId", "(", ")", ";", "// if no label in current context, create one", "context", ".", "setPartitionId", "(", "partition", ")", ";", "}", "}", "node", ".", "addAssociation", "(", "context", ",", "context", ".", "getRule", "(", ")", ")", ";", "return", "(", "T", ")", "node", ";", "}" ]
Attaches a node into the network. If a node already exists that could substitute, it is used instead. @param context The current build context @param candidate The node to attach. @return the actual attached node that may be the one given as parameter or eventually one that was already in the cache if sharing is enabled
[ "Attaches", "a", "node", "into", "the", "network", ".", "If", "a", "node", "already", "exists", "that", "could", "substitute", "it", "is", "used", "instead", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/builder/BuildUtils.java#L96-L163
14,241
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/builder/BuildUtils.java
BuildUtils.isSharingEnabledForNode
private boolean isSharingEnabledForNode(BuildContext context, BaseNode node) { if ( NodeTypeEnums.isLeftTupleSource( node )) { return context.getKnowledgeBase().getConfiguration().isShareBetaNodes(); } else if ( NodeTypeEnums.isObjectSource( node ) ) { return context.getKnowledgeBase().getConfiguration().isShareAlphaNodes(); } return false; }
java
private boolean isSharingEnabledForNode(BuildContext context, BaseNode node) { if ( NodeTypeEnums.isLeftTupleSource( node )) { return context.getKnowledgeBase().getConfiguration().isShareBetaNodes(); } else if ( NodeTypeEnums.isObjectSource( node ) ) { return context.getKnowledgeBase().getConfiguration().isShareAlphaNodes(); } return false; }
[ "private", "boolean", "isSharingEnabledForNode", "(", "BuildContext", "context", ",", "BaseNode", "node", ")", "{", "if", "(", "NodeTypeEnums", ".", "isLeftTupleSource", "(", "node", ")", ")", "{", "return", "context", ".", "getKnowledgeBase", "(", ")", ".", "getConfiguration", "(", ")", ".", "isShareBetaNodes", "(", ")", ";", "}", "else", "if", "(", "NodeTypeEnums", ".", "isObjectSource", "(", "node", ")", ")", "{", "return", "context", ".", "getKnowledgeBase", "(", ")", ".", "getConfiguration", "(", ")", ".", "isShareAlphaNodes", "(", ")", ";", "}", "return", "false", ";", "}" ]
Utility function to check if sharing is enabled for nodes of the given class
[ "Utility", "function", "to", "check", "if", "sharing", "is", "enabled", "for", "nodes", "of", "the", "given", "class" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/builder/BuildUtils.java#L185-L192
14,242
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/builder/BuildUtils.java
BuildUtils.createBetaNodeConstraint
public BetaConstraints createBetaNodeConstraint(final BuildContext context, final List<BetaNodeFieldConstraint> list, final boolean disableIndexing) { BetaConstraints constraints; switch ( list.size() ) { case 0 : constraints = EmptyBetaConstraints.getInstance(); break; case 1 : constraints = new SingleBetaConstraints( list.get( 0 ), context.getKnowledgeBase().getConfiguration(), disableIndexing ); break; case 2 : constraints = new DoubleBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ), context.getKnowledgeBase().getConfiguration(), disableIndexing ); break; case 3 : constraints = new TripleBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ), context.getKnowledgeBase().getConfiguration(), disableIndexing ); break; case 4 : constraints = new QuadroupleBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ), context.getKnowledgeBase().getConfiguration(), disableIndexing ); break; default : constraints = new DefaultBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ), context.getKnowledgeBase().getConfiguration(), disableIndexing ); } return constraints; }
java
public BetaConstraints createBetaNodeConstraint(final BuildContext context, final List<BetaNodeFieldConstraint> list, final boolean disableIndexing) { BetaConstraints constraints; switch ( list.size() ) { case 0 : constraints = EmptyBetaConstraints.getInstance(); break; case 1 : constraints = new SingleBetaConstraints( list.get( 0 ), context.getKnowledgeBase().getConfiguration(), disableIndexing ); break; case 2 : constraints = new DoubleBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ), context.getKnowledgeBase().getConfiguration(), disableIndexing ); break; case 3 : constraints = new TripleBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ), context.getKnowledgeBase().getConfiguration(), disableIndexing ); break; case 4 : constraints = new QuadroupleBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ), context.getKnowledgeBase().getConfiguration(), disableIndexing ); break; default : constraints = new DefaultBetaConstraints( list.toArray( new BetaNodeFieldConstraint[list.size()] ), context.getKnowledgeBase().getConfiguration(), disableIndexing ); } return constraints; }
[ "public", "BetaConstraints", "createBetaNodeConstraint", "(", "final", "BuildContext", "context", ",", "final", "List", "<", "BetaNodeFieldConstraint", ">", "list", ",", "final", "boolean", "disableIndexing", ")", "{", "BetaConstraints", "constraints", ";", "switch", "(", "list", ".", "size", "(", ")", ")", "{", "case", "0", ":", "constraints", "=", "EmptyBetaConstraints", ".", "getInstance", "(", ")", ";", "break", ";", "case", "1", ":", "constraints", "=", "new", "SingleBetaConstraints", "(", "list", ".", "get", "(", "0", ")", ",", "context", ".", "getKnowledgeBase", "(", ")", ".", "getConfiguration", "(", ")", ",", "disableIndexing", ")", ";", "break", ";", "case", "2", ":", "constraints", "=", "new", "DoubleBetaConstraints", "(", "list", ".", "toArray", "(", "new", "BetaNodeFieldConstraint", "[", "list", ".", "size", "(", ")", "]", ")", ",", "context", ".", "getKnowledgeBase", "(", ")", ".", "getConfiguration", "(", ")", ",", "disableIndexing", ")", ";", "break", ";", "case", "3", ":", "constraints", "=", "new", "TripleBetaConstraints", "(", "list", ".", "toArray", "(", "new", "BetaNodeFieldConstraint", "[", "list", ".", "size", "(", ")", "]", ")", ",", "context", ".", "getKnowledgeBase", "(", ")", ".", "getConfiguration", "(", ")", ",", "disableIndexing", ")", ";", "break", ";", "case", "4", ":", "constraints", "=", "new", "QuadroupleBetaConstraints", "(", "list", ".", "toArray", "(", "new", "BetaNodeFieldConstraint", "[", "list", ".", "size", "(", ")", "]", ")", ",", "context", ".", "getKnowledgeBase", "(", ")", ".", "getConfiguration", "(", ")", ",", "disableIndexing", ")", ";", "break", ";", "default", ":", "constraints", "=", "new", "DefaultBetaConstraints", "(", "list", ".", "toArray", "(", "new", "BetaNodeFieldConstraint", "[", "list", ".", "size", "(", ")", "]", ")", ",", "context", ".", "getKnowledgeBase", "(", ")", ".", "getConfiguration", "(", ")", ",", "disableIndexing", ")", ";", "}", "return", "constraints", ";", "}" ]
Creates and returns a BetaConstraints object for the given list of constraints @param context the current build context @param list the list of constraints
[ "Creates", "and", "returns", "a", "BetaConstraints", "object", "for", "the", "given", "list", "of", "constraints" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/builder/BuildUtils.java#L213-L247
14,243
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/builder/BuildUtils.java
BuildUtils.calculateTemporalDistance
public TemporalDependencyMatrix calculateTemporalDistance(GroupElement groupElement) { // find the events List<Pattern> events = new ArrayList<Pattern>(); selectAllEventPatterns( events, groupElement ); final int size = events.size(); if ( size >= 1 ) { // create the matrix Interval[][] source = new Interval[size][]; for ( int row = 0; row < size; row++ ) { source[row] = new Interval[size]; for ( int col = 0; col < size; col++ ) { if ( row == col ) { source[row][col] = new Interval( 0, 0 ); } else { source[row][col] = new Interval( Interval.MIN, Interval.MAX ); } } } Interval[][] result; if ( size > 1 ) { List<Declaration> declarations = new ArrayList<Declaration>(); int eventIndex = 0; // populate the matrix for ( Pattern event : events ) { // references to other events are always backward references, so we can build the list as we go declarations.add( event.getDeclaration() ); Map<Declaration, Interval> temporal = new HashMap<Declaration, Interval>(); gatherTemporalRelationships( event.getConstraints(), temporal ); // intersects default values with the actual constrained intervals for ( Map.Entry<Declaration, Interval> entry : temporal.entrySet() ) { int targetIndex = declarations.indexOf( entry.getKey() ); Interval interval = entry.getValue(); source[targetIndex][eventIndex].intersect( interval ); Interval reverse = new Interval( interval.getUpperBound() == Long.MAX_VALUE ? Long.MIN_VALUE : -interval.getUpperBound(), interval.getLowerBound() == Long.MIN_VALUE ? Long.MAX_VALUE : -interval.getLowerBound() ); source[eventIndex][targetIndex].intersect( reverse ); } eventIndex++; } result = TimeUtils.calculateTemporalDistance( source ); } else { result = source; } return new TemporalDependencyMatrix( result, events ); } return null; }
java
public TemporalDependencyMatrix calculateTemporalDistance(GroupElement groupElement) { // find the events List<Pattern> events = new ArrayList<Pattern>(); selectAllEventPatterns( events, groupElement ); final int size = events.size(); if ( size >= 1 ) { // create the matrix Interval[][] source = new Interval[size][]; for ( int row = 0; row < size; row++ ) { source[row] = new Interval[size]; for ( int col = 0; col < size; col++ ) { if ( row == col ) { source[row][col] = new Interval( 0, 0 ); } else { source[row][col] = new Interval( Interval.MIN, Interval.MAX ); } } } Interval[][] result; if ( size > 1 ) { List<Declaration> declarations = new ArrayList<Declaration>(); int eventIndex = 0; // populate the matrix for ( Pattern event : events ) { // references to other events are always backward references, so we can build the list as we go declarations.add( event.getDeclaration() ); Map<Declaration, Interval> temporal = new HashMap<Declaration, Interval>(); gatherTemporalRelationships( event.getConstraints(), temporal ); // intersects default values with the actual constrained intervals for ( Map.Entry<Declaration, Interval> entry : temporal.entrySet() ) { int targetIndex = declarations.indexOf( entry.getKey() ); Interval interval = entry.getValue(); source[targetIndex][eventIndex].intersect( interval ); Interval reverse = new Interval( interval.getUpperBound() == Long.MAX_VALUE ? Long.MIN_VALUE : -interval.getUpperBound(), interval.getLowerBound() == Long.MIN_VALUE ? Long.MAX_VALUE : -interval.getLowerBound() ); source[eventIndex][targetIndex].intersect( reverse ); } eventIndex++; } result = TimeUtils.calculateTemporalDistance( source ); } else { result = source; } return new TemporalDependencyMatrix( result, events ); } return null; }
[ "public", "TemporalDependencyMatrix", "calculateTemporalDistance", "(", "GroupElement", "groupElement", ")", "{", "// find the events", "List", "<", "Pattern", ">", "events", "=", "new", "ArrayList", "<", "Pattern", ">", "(", ")", ";", "selectAllEventPatterns", "(", "events", ",", "groupElement", ")", ";", "final", "int", "size", "=", "events", ".", "size", "(", ")", ";", "if", "(", "size", ">=", "1", ")", "{", "// create the matrix", "Interval", "[", "]", "[", "]", "source", "=", "new", "Interval", "[", "size", "]", "[", "", "]", ";", "for", "(", "int", "row", "=", "0", ";", "row", "<", "size", ";", "row", "++", ")", "{", "source", "[", "row", "]", "=", "new", "Interval", "[", "size", "]", ";", "for", "(", "int", "col", "=", "0", ";", "col", "<", "size", ";", "col", "++", ")", "{", "if", "(", "row", "==", "col", ")", "{", "source", "[", "row", "]", "[", "col", "]", "=", "new", "Interval", "(", "0", ",", "0", ")", ";", "}", "else", "{", "source", "[", "row", "]", "[", "col", "]", "=", "new", "Interval", "(", "Interval", ".", "MIN", ",", "Interval", ".", "MAX", ")", ";", "}", "}", "}", "Interval", "[", "]", "[", "]", "result", ";", "if", "(", "size", ">", "1", ")", "{", "List", "<", "Declaration", ">", "declarations", "=", "new", "ArrayList", "<", "Declaration", ">", "(", ")", ";", "int", "eventIndex", "=", "0", ";", "// populate the matrix", "for", "(", "Pattern", "event", ":", "events", ")", "{", "// references to other events are always backward references, so we can build the list as we go", "declarations", ".", "add", "(", "event", ".", "getDeclaration", "(", ")", ")", ";", "Map", "<", "Declaration", ",", "Interval", ">", "temporal", "=", "new", "HashMap", "<", "Declaration", ",", "Interval", ">", "(", ")", ";", "gatherTemporalRelationships", "(", "event", ".", "getConstraints", "(", ")", ",", "temporal", ")", ";", "// intersects default values with the actual constrained intervals", "for", "(", "Map", ".", "Entry", "<", "Declaration", ",", "Interval", ">", "entry", ":", "temporal", ".", "entrySet", "(", ")", ")", "{", "int", "targetIndex", "=", "declarations", ".", "indexOf", "(", "entry", ".", "getKey", "(", ")", ")", ";", "Interval", "interval", "=", "entry", ".", "getValue", "(", ")", ";", "source", "[", "targetIndex", "]", "[", "eventIndex", "]", ".", "intersect", "(", "interval", ")", ";", "Interval", "reverse", "=", "new", "Interval", "(", "interval", ".", "getUpperBound", "(", ")", "==", "Long", ".", "MAX_VALUE", "?", "Long", ".", "MIN_VALUE", ":", "-", "interval", ".", "getUpperBound", "(", ")", ",", "interval", ".", "getLowerBound", "(", ")", "==", "Long", ".", "MIN_VALUE", "?", "Long", ".", "MAX_VALUE", ":", "-", "interval", ".", "getLowerBound", "(", ")", ")", ";", "source", "[", "eventIndex", "]", "[", "targetIndex", "]", ".", "intersect", "(", "reverse", ")", ";", "}", "eventIndex", "++", ";", "}", "result", "=", "TimeUtils", ".", "calculateTemporalDistance", "(", "source", ")", ";", "}", "else", "{", "result", "=", "source", ";", "}", "return", "new", "TemporalDependencyMatrix", "(", "result", ",", "events", ")", ";", "}", "return", "null", ";", "}" ]
Calculates the temporal distance between all event patterns in the given subrule. @param groupElement the root element of a subrule being added to the rulebase
[ "Calculates", "the", "temporal", "distance", "between", "all", "event", "patterns", "in", "the", "given", "subrule", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/builder/BuildUtils.java#L291-L343
14,244
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/asm/MethodComparator.java
MethodComparator.equivalent
public boolean equivalent(final String method1, final ClassReader class1, final String method2, final ClassReader class2) { return getMethodBytecode( method1, class1 ).equals( getMethodBytecode( method2, class2 ) ); }
java
public boolean equivalent(final String method1, final ClassReader class1, final String method2, final ClassReader class2) { return getMethodBytecode( method1, class1 ).equals( getMethodBytecode( method2, class2 ) ); }
[ "public", "boolean", "equivalent", "(", "final", "String", "method1", ",", "final", "ClassReader", "class1", ",", "final", "String", "method2", ",", "final", "ClassReader", "class2", ")", "{", "return", "getMethodBytecode", "(", "method1", ",", "class1", ")", ".", "equals", "(", "getMethodBytecode", "(", "method2", ",", "class2", ")", ")", ";", "}" ]
This actually does the comparing. Class1 and Class2 are class reader instances to the respective classes. method1 and method2 are looked up on the respective classes and their contents compared. This is a convenience method.
[ "This", "actually", "does", "the", "comparing", ".", "Class1", "and", "Class2", "are", "class", "reader", "instances", "to", "the", "respective", "classes", ".", "method1", "and", "method2", "are", "looked", "up", "on", "the", "respective", "classes", "and", "their", "contents", "compared", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/asm/MethodComparator.java#L40-L45
14,245
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/asm/MethodComparator.java
MethodComparator.getMethodBytecode
public String getMethodBytecode(final String methodName, final ClassReader classReader) { final Tracer visit = new Tracer( methodName ); classReader.accept( visit, ClassReader.SKIP_DEBUG ); return visit.getText(); }
java
public String getMethodBytecode(final String methodName, final ClassReader classReader) { final Tracer visit = new Tracer( methodName ); classReader.accept( visit, ClassReader.SKIP_DEBUG ); return visit.getText(); }
[ "public", "String", "getMethodBytecode", "(", "final", "String", "methodName", ",", "final", "ClassReader", "classReader", ")", "{", "final", "Tracer", "visit", "=", "new", "Tracer", "(", "methodName", ")", ";", "classReader", ".", "accept", "(", "visit", ",", "ClassReader", ".", "SKIP_DEBUG", ")", ";", "return", "visit", ".", "getText", "(", ")", ";", "}" ]
This will return a series of bytecode instructions which can be used to compare one method with another. debug info like local var declarations and line numbers are ignored, so the focus is on the content.
[ "This", "will", "return", "a", "series", "of", "bytecode", "instructions", "which", "can", "be", "used", "to", "compare", "one", "method", "with", "another", ".", "debug", "info", "like", "local", "var", "declarations", "and", "line", "numbers", "are", "ignored", "so", "the", "focus", "is", "on", "the", "content", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/asm/MethodComparator.java#L51-L56
14,246
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/Shape.java
Shape.setBounds
public void setBounds(org.kie.dmn.model.api.dmndi.Bounds value) { this.bounds = value; }
java
public void setBounds(org.kie.dmn.model.api.dmndi.Bounds value) { this.bounds = value; }
[ "public", "void", "setBounds", "(", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "Bounds", "value", ")", "{", "this", ".", "bounds", "=", "value", ";", "}" ]
Sets the value of the bounds property. @param value allowed object is {@link Bounds }
[ "Sets", "the", "value", "of", "the", "bounds", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/Shape.java#L43-L45
14,247
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/DroolsStreamUtils.java
DroolsStreamUtils.streamOut
public static byte[] streamOut(Object object, boolean compressed) throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); streamOut(bytes, object, compressed); bytes.flush(); bytes.close(); return bytes.toByteArray(); }
java
public static byte[] streamOut(Object object, boolean compressed) throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); streamOut(bytes, object, compressed); bytes.flush(); bytes.close(); return bytes.toByteArray(); }
[ "public", "static", "byte", "[", "]", "streamOut", "(", "Object", "object", ",", "boolean", "compressed", ")", "throws", "IOException", "{", "ByteArrayOutputStream", "bytes", "=", "new", "ByteArrayOutputStream", "(", ")", ";", "streamOut", "(", "bytes", ",", "object", ",", "compressed", ")", ";", "bytes", ".", "flush", "(", ")", ";", "bytes", ".", "close", "(", ")", ";", "return", "bytes", ".", "toByteArray", "(", ")", ";", "}" ]
This routine would stream out the give object, uncompressed or compressed depending on the given flag, and store the streamed contents in the return byte array. The output contents could only be read by the corresponding "streamIn" method of this class. @param object @param compressed @return @throws IOException
[ "This", "routine", "would", "stream", "out", "the", "give", "object", "uncompressed", "or", "compressed", "depending", "on", "the", "given", "flag", "and", "store", "the", "streamed", "contents", "in", "the", "return", "byte", "array", ".", "The", "output", "contents", "could", "only", "be", "read", "by", "the", "corresponding", "streamIn", "method", "of", "this", "class", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/DroolsStreamUtils.java#L60-L67
14,248
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/DroolsStreamUtils.java
DroolsStreamUtils.streamOut
public static void streamOut(OutputStream out, Object object) throws IOException { streamOut(out, object, false); }
java
public static void streamOut(OutputStream out, Object object) throws IOException { streamOut(out, object, false); }
[ "public", "static", "void", "streamOut", "(", "OutputStream", "out", ",", "Object", "object", ")", "throws", "IOException", "{", "streamOut", "(", "out", ",", "object", ",", "false", ")", ";", "}" ]
This method would stream out the given object to the given output stream uncompressed. The output contents could only be read by the corresponding "streamIn" method of this class. @param out @param object @throws IOException
[ "This", "method", "would", "stream", "out", "the", "given", "object", "to", "the", "given", "output", "stream", "uncompressed", ".", "The", "output", "contents", "could", "only", "be", "read", "by", "the", "corresponding", "streamIn", "method", "of", "this", "class", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/DroolsStreamUtils.java#L76-L78
14,249
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/DroolsStreamUtils.java
DroolsStreamUtils.streamOut
public static void streamOut(OutputStream out, Object object, boolean compressed) throws IOException { if (compressed) { out = new GZIPOutputStream(out); } DroolsObjectOutputStream doos = null; try { doos = new DroolsObjectOutputStream(out); doos.writeObject(object); } finally { if( doos != null ) { doos.close(); } if (compressed) { out.close(); } } }
java
public static void streamOut(OutputStream out, Object object, boolean compressed) throws IOException { if (compressed) { out = new GZIPOutputStream(out); } DroolsObjectOutputStream doos = null; try { doos = new DroolsObjectOutputStream(out); doos.writeObject(object); } finally { if( doos != null ) { doos.close(); } if (compressed) { out.close(); } } }
[ "public", "static", "void", "streamOut", "(", "OutputStream", "out", ",", "Object", "object", ",", "boolean", "compressed", ")", "throws", "IOException", "{", "if", "(", "compressed", ")", "{", "out", "=", "new", "GZIPOutputStream", "(", "out", ")", ";", "}", "DroolsObjectOutputStream", "doos", "=", "null", ";", "try", "{", "doos", "=", "new", "DroolsObjectOutputStream", "(", "out", ")", ";", "doos", ".", "writeObject", "(", "object", ")", ";", "}", "finally", "{", "if", "(", "doos", "!=", "null", ")", "{", "doos", ".", "close", "(", ")", ";", "}", "if", "(", "compressed", ")", "{", "out", ".", "close", "(", ")", ";", "}", "}", "}" ]
This method would stream out the given object to the given output stream uncompressed or compressed depending on the given flag. The output contents could only be read by the corresponding "streamIn" methods of this class. @param out @param object @throws IOException
[ "This", "method", "would", "stream", "out", "the", "given", "object", "to", "the", "given", "output", "stream", "uncompressed", "or", "compressed", "depending", "on", "the", "given", "flag", ".", "The", "output", "contents", "could", "only", "be", "read", "by", "the", "corresponding", "streamIn", "methods", "of", "this", "class", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/DroolsStreamUtils.java#L88-L104
14,250
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/DroolsStreamUtils.java
DroolsStreamUtils.streamIn
public static Object streamIn(byte[] bytes, ClassLoader classLoader) throws IOException, ClassNotFoundException { return streamIn(bytes, classLoader, false); }
java
public static Object streamIn(byte[] bytes, ClassLoader classLoader) throws IOException, ClassNotFoundException { return streamIn(bytes, classLoader, false); }
[ "public", "static", "Object", "streamIn", "(", "byte", "[", "]", "bytes", ",", "ClassLoader", "classLoader", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "return", "streamIn", "(", "bytes", ",", "classLoader", ",", "false", ")", ";", "}" ]
This method reads the contents from the given byte array and returns the object. It is expected that the contents in the given buffer was not compressed, and the content stream was written by the corresponding streamOut methods of this class. @param bytes @param classLoader @return @throws IOException @throws ClassNotFoundException
[ "This", "method", "reads", "the", "contents", "from", "the", "given", "byte", "array", "and", "returns", "the", "object", ".", "It", "is", "expected", "that", "the", "contents", "in", "the", "given", "buffer", "was", "not", "compressed", "and", "the", "content", "stream", "was", "written", "by", "the", "corresponding", "streamOut", "methods", "of", "this", "class", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/DroolsStreamUtils.java#L129-L132
14,251
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/DroolsStreamUtils.java
DroolsStreamUtils.streamIn
public static Object streamIn(InputStream in, ClassLoader classLoader, boolean compressed) throws IOException, ClassNotFoundException { if (compressed) in = new GZIPInputStream(in); return new DroolsObjectInputStream(in, classLoader).readObject(); }
java
public static Object streamIn(InputStream in, ClassLoader classLoader, boolean compressed) throws IOException, ClassNotFoundException { if (compressed) in = new GZIPInputStream(in); return new DroolsObjectInputStream(in, classLoader).readObject(); }
[ "public", "static", "Object", "streamIn", "(", "InputStream", "in", ",", "ClassLoader", "classLoader", ",", "boolean", "compressed", ")", "throws", "IOException", ",", "ClassNotFoundException", "{", "if", "(", "compressed", ")", "in", "=", "new", "GZIPInputStream", "(", "in", ")", ";", "return", "new", "DroolsObjectInputStream", "(", "in", ",", "classLoader", ")", ".", "readObject", "(", ")", ";", "}" ]
This method reads the contents from the given input stream and returns the object. The contents in the given stream could be compressed or uncompressed depending on the given flag. It is assumed that the content stream was written by the corresponding streamOut methods of this class. @param in @return @throws IOException @throws ClassNotFoundException
[ "This", "method", "reads", "the", "contents", "from", "the", "given", "input", "stream", "and", "returns", "the", "object", ".", "The", "contents", "in", "the", "given", "stream", "could", "be", "compressed", "or", "uncompressed", "depending", "on", "the", "given", "flag", ".", "It", "is", "assumed", "that", "the", "content", "stream", "was", "written", "by", "the", "corresponding", "streamOut", "methods", "of", "this", "class", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/DroolsStreamUtils.java#L201-L206
14,252
kiegroup/drools
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/impl/DMNModelImpl.java
DMNModelImpl.nameInCurrentModel
public String nameInCurrentModel(DMNNode node) { if (node.getModelNamespace().equals(this.getNamespace())) { return node.getName(); } else { Optional<String> lookupAlias = getImportAliasFor(node.getModelNamespace(), node.getModelName()); if (lookupAlias.isPresent()) { return lookupAlias.get() + "." + node.getName(); } else { return null; } } }
java
public String nameInCurrentModel(DMNNode node) { if (node.getModelNamespace().equals(this.getNamespace())) { return node.getName(); } else { Optional<String> lookupAlias = getImportAliasFor(node.getModelNamespace(), node.getModelName()); if (lookupAlias.isPresent()) { return lookupAlias.get() + "." + node.getName(); } else { return null; } } }
[ "public", "String", "nameInCurrentModel", "(", "DMNNode", "node", ")", "{", "if", "(", "node", ".", "getModelNamespace", "(", ")", ".", "equals", "(", "this", ".", "getNamespace", "(", ")", ")", ")", "{", "return", "node", ".", "getName", "(", ")", ";", "}", "else", "{", "Optional", "<", "String", ">", "lookupAlias", "=", "getImportAliasFor", "(", "node", ".", "getModelNamespace", "(", ")", ",", "node", ".", "getModelName", "(", ")", ")", ";", "if", "(", "lookupAlias", ".", "isPresent", "(", ")", ")", "{", "return", "lookupAlias", ".", "get", "(", ")", "+", "\".\"", "+", "node", ".", "getName", "(", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}", "}" ]
Given a DMNNode, compute the proper name of the node, considering DMN-Imports. For DMNNode in this current model, name is simply the name of the model. For imported DMNNodes, this is the name with the prefix of the direct-dependency of the import `name`. For transitively-imported DMNNodes, it is always null.
[ "Given", "a", "DMNNode", "compute", "the", "proper", "name", "of", "the", "node", "considering", "DMN", "-", "Imports", ".", "For", "DMNNode", "in", "this", "current", "model", "name", "is", "simply", "the", "name", "of", "the", "model", ".", "For", "imported", "DMNNodes", "this", "is", "the", "name", "with", "the", "prefix", "of", "the", "direct", "-", "dependency", "of", "the", "import", "name", ".", "For", "transitively", "-", "imported", "DMNNodes", "it", "is", "always", "null", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/impl/DMNModelImpl.java#L144-L155
14,253
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/compiler/DrlParser.java
DrlParser.parse
public PackageDescr parse(final Resource resource, final String text) throws DroolsParserException { this.resource = resource; return parse(false, text); }
java
public PackageDescr parse(final Resource resource, final String text) throws DroolsParserException { this.resource = resource; return parse(false, text); }
[ "public", "PackageDescr", "parse", "(", "final", "Resource", "resource", ",", "final", "String", "text", ")", "throws", "DroolsParserException", "{", "this", ".", "resource", "=", "resource", ";", "return", "parse", "(", "false", ",", "text", ")", ";", "}" ]
Parse a rule from text
[ "Parse", "a", "rule", "from", "text" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/compiler/DrlParser.java#L67-L70
14,254
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/compiler/DrlParser.java
DrlParser.getExpandedDRL
public String getExpandedDRL(final String source, final Reader dsl) throws DroolsParserException { DefaultExpanderResolver resolver = getDefaultResolver(dsl); return getExpandedDRL(source, resolver); }
java
public String getExpandedDRL(final String source, final Reader dsl) throws DroolsParserException { DefaultExpanderResolver resolver = getDefaultResolver(dsl); return getExpandedDRL(source, resolver); }
[ "public", "String", "getExpandedDRL", "(", "final", "String", "source", ",", "final", "Reader", "dsl", ")", "throws", "DroolsParserException", "{", "DefaultExpanderResolver", "resolver", "=", "getDefaultResolver", "(", "dsl", ")", ";", "return", "getExpandedDRL", "(", "source", ",", "resolver", ")", ";", "}" ]
This will expand the DRL. useful for debugging. @param source - the source which use a DSL @param dsl - the DSL itself. @throws DroolsParserException If unable to expand in any way.
[ "This", "will", "expand", "the", "DRL", ".", "useful", "for", "debugging", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/compiler/DrlParser.java#L178-L183
14,255
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/compiler/DrlParser.java
DrlParser.getExpandedDRL
public String getExpandedDRL(final String source, final DefaultExpanderResolver resolver) throws DroolsParserException { final Expander expander = resolver.get("*", null); final String expanded = expander.expand( source ); if ( expander.hasErrors() ) { String err = ""; for ( ExpanderException ex : expander.getErrors() ) { err = err + "\n Line:[" + ex.getLine() + "] " + ex.getMessage(); } throw new DroolsParserException( err ); } return expanded; }
java
public String getExpandedDRL(final String source, final DefaultExpanderResolver resolver) throws DroolsParserException { final Expander expander = resolver.get("*", null); final String expanded = expander.expand( source ); if ( expander.hasErrors() ) { String err = ""; for ( ExpanderException ex : expander.getErrors() ) { err = err + "\n Line:[" + ex.getLine() + "] " + ex.getMessage(); } throw new DroolsParserException( err ); } return expanded; }
[ "public", "String", "getExpandedDRL", "(", "final", "String", "source", ",", "final", "DefaultExpanderResolver", "resolver", ")", "throws", "DroolsParserException", "{", "final", "Expander", "expander", "=", "resolver", ".", "get", "(", "\"*\"", ",", "null", ")", ";", "final", "String", "expanded", "=", "expander", ".", "expand", "(", "source", ")", ";", "if", "(", "expander", ".", "hasErrors", "(", ")", ")", "{", "String", "err", "=", "\"\"", ";", "for", "(", "ExpanderException", "ex", ":", "expander", ".", "getErrors", "(", ")", ")", "{", "err", "=", "err", "+", "\"\\n Line:[\"", "+", "ex", ".", "getLine", "(", ")", "+", "\"] \"", "+", "ex", ".", "getMessage", "(", ")", ";", "}", "throw", "new", "DroolsParserException", "(", "err", ")", ";", "}", "return", "expanded", ";", "}" ]
This will expand the DRL using the given expander resolver. useful for debugging. @param source - the source which use a DSL @param resolver - the DSL expander resolver itself. @throws DroolsParserException If unable to expand in any way.
[ "This", "will", "expand", "the", "DRL", "using", "the", "given", "expander", "resolver", ".", "useful", "for", "debugging", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/compiler/DrlParser.java#L196-L211
14,256
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/compiler/DrlParser.java
DrlParser.makeErrorList
private void makeErrorList( final DRLParser parser ) { for ( final DroolsParserException recogErr : lexer.getErrors() ) { final ParserError err = new ParserError( resource, recogErr.getMessage(), recogErr.getLineNumber(), recogErr.getColumn() ); this.results.add( err ); } for ( final DroolsParserException recogErr : parser.getErrors() ) { final ParserError err = new ParserError( resource, recogErr.getMessage(), recogErr.getLineNumber(), recogErr.getColumn() ); this.results.add( err ); } }
java
private void makeErrorList( final DRLParser parser ) { for ( final DroolsParserException recogErr : lexer.getErrors() ) { final ParserError err = new ParserError( resource, recogErr.getMessage(), recogErr.getLineNumber(), recogErr.getColumn() ); this.results.add( err ); } for ( final DroolsParserException recogErr : parser.getErrors() ) { final ParserError err = new ParserError( resource, recogErr.getMessage(), recogErr.getLineNumber(), recogErr.getColumn() ); this.results.add( err ); } }
[ "private", "void", "makeErrorList", "(", "final", "DRLParser", "parser", ")", "{", "for", "(", "final", "DroolsParserException", "recogErr", ":", "lexer", ".", "getErrors", "(", ")", ")", "{", "final", "ParserError", "err", "=", "new", "ParserError", "(", "resource", ",", "recogErr", ".", "getMessage", "(", ")", ",", "recogErr", ".", "getLineNumber", "(", ")", ",", "recogErr", ".", "getColumn", "(", ")", ")", ";", "this", ".", "results", ".", "add", "(", "err", ")", ";", "}", "for", "(", "final", "DroolsParserException", "recogErr", ":", "parser", ".", "getErrors", "(", ")", ")", "{", "final", "ParserError", "err", "=", "new", "ParserError", "(", "resource", ",", "recogErr", ".", "getMessage", "(", ")", ",", "recogErr", ".", "getLineNumber", "(", ")", ",", "recogErr", ".", "getColumn", "(", ")", ")", ";", "this", ".", "results", ".", "add", "(", "err", ")", ";", "}", "}" ]
Convert the antlr exceptions to drools parser exceptions
[ "Convert", "the", "antlr", "exceptions", "to", "drools", "parser", "exceptions" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/compiler/DrlParser.java#L273-L288
14,257
kiegroup/drools
drools-examples/src/main/java/org/drools/examples/sudoku/Sudoku.java
Sudoku.dumpGrid
public void dumpGrid() { StringBuilder dumpGridSb = new StringBuilder(); Formatter fmt = new Formatter(dumpGridSb); fmt.format(" "); for (int iCol = 0; iCol < 9; iCol++) { fmt.format("Col: %d ", iCol); } fmt.format("\n"); for (int iRow = 0; iRow < 9; iRow++) { fmt.format("Row " + iRow + ": "); for (int iCol = 0; iCol < 9; iCol++) { if (cells[iRow][iCol].getValue() != null) { fmt.format(" --- %d --- ", cells[iRow][iCol].getValue()); } else { StringBuilder sb = new StringBuilder(); Set<Integer> perms = cells[iRow][iCol].getFree(); for (int i = 1; i <= 9; i++) { if (perms.contains(i)) { sb.append(i); } else { sb.append(' '); } } fmt.format(" %-10s", sb.toString()); } } fmt.format("\n"); } fmt.close(); System.out.println(dumpGridSb); }
java
public void dumpGrid() { StringBuilder dumpGridSb = new StringBuilder(); Formatter fmt = new Formatter(dumpGridSb); fmt.format(" "); for (int iCol = 0; iCol < 9; iCol++) { fmt.format("Col: %d ", iCol); } fmt.format("\n"); for (int iRow = 0; iRow < 9; iRow++) { fmt.format("Row " + iRow + ": "); for (int iCol = 0; iCol < 9; iCol++) { if (cells[iRow][iCol].getValue() != null) { fmt.format(" --- %d --- ", cells[iRow][iCol].getValue()); } else { StringBuilder sb = new StringBuilder(); Set<Integer> perms = cells[iRow][iCol].getFree(); for (int i = 1; i <= 9; i++) { if (perms.contains(i)) { sb.append(i); } else { sb.append(' '); } } fmt.format(" %-10s", sb.toString()); } } fmt.format("\n"); } fmt.close(); System.out.println(dumpGridSb); }
[ "public", "void", "dumpGrid", "(", ")", "{", "StringBuilder", "dumpGridSb", "=", "new", "StringBuilder", "(", ")", ";", "Formatter", "fmt", "=", "new", "Formatter", "(", "dumpGridSb", ")", ";", "fmt", ".", "format", "(", "\" \"", ")", ";", "for", "(", "int", "iCol", "=", "0", ";", "iCol", "<", "9", ";", "iCol", "++", ")", "{", "fmt", ".", "format", "(", "\"Col: %d \"", ",", "iCol", ")", ";", "}", "fmt", ".", "format", "(", "\"\\n\"", ")", ";", "for", "(", "int", "iRow", "=", "0", ";", "iRow", "<", "9", ";", "iRow", "++", ")", "{", "fmt", ".", "format", "(", "\"Row \"", "+", "iRow", "+", "\": \"", ")", ";", "for", "(", "int", "iCol", "=", "0", ";", "iCol", "<", "9", ";", "iCol", "++", ")", "{", "if", "(", "cells", "[", "iRow", "]", "[", "iCol", "]", ".", "getValue", "(", ")", "!=", "null", ")", "{", "fmt", ".", "format", "(", "\" --- %d --- \"", ",", "cells", "[", "iRow", "]", "[", "iCol", "]", ".", "getValue", "(", ")", ")", ";", "}", "else", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "Set", "<", "Integer", ">", "perms", "=", "cells", "[", "iRow", "]", "[", "iCol", "]", ".", "getFree", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "9", ";", "i", "++", ")", "{", "if", "(", "perms", ".", "contains", "(", "i", ")", ")", "{", "sb", ".", "append", "(", "i", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "'", "'", ")", ";", "}", "}", "fmt", ".", "format", "(", "\" %-10s\"", ",", "sb", ".", "toString", "(", ")", ")", ";", "}", "}", "fmt", ".", "format", "(", "\"\\n\"", ")", ";", "}", "fmt", ".", "close", "(", ")", ";", "System", ".", "out", ".", "println", "(", "dumpGridSb", ")", ";", "}" ]
Nice printout of the grid.
[ "Nice", "printout", "of", "the", "grid", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-examples/src/main/java/org/drools/examples/sudoku/Sudoku.java#L74-L104
14,258
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtree/src/main/java/org/drools/workbench/models/guided/dtree/backend/GuidedDecisionTreeModelMarshallingVisitor.java
GuidedDecisionTreeModelMarshallingVisitor.getDataType
private String getDataType(final Value value) { if (value instanceof BigDecimalValue) { return DataType.TYPE_NUMERIC_BIGDECIMAL; } else if (value instanceof BigIntegerValue) { return DataType.TYPE_NUMERIC_BIGINTEGER; } else if (value instanceof BooleanValue) { return DataType.TYPE_BOOLEAN; } else if (value instanceof ByteValue) { return DataType.TYPE_NUMERIC_BYTE; } else if (value instanceof DateValue) { return DataType.TYPE_DATE; } else if (value instanceof DoubleValue) { return DataType.TYPE_NUMERIC_DOUBLE; } else if (value instanceof FloatValue) { return DataType.TYPE_NUMERIC_FLOAT; } else if (value instanceof IntegerValue) { return DataType.TYPE_NUMERIC_INTEGER; } else if (value instanceof LongValue) { return DataType.TYPE_NUMERIC_LONG; } else if (value instanceof ShortValue) { return DataType.TYPE_NUMERIC_SHORT; } else if (value instanceof EnumValue) { return DataType.TYPE_COMPARABLE; } return DataType.TYPE_STRING; }
java
private String getDataType(final Value value) { if (value instanceof BigDecimalValue) { return DataType.TYPE_NUMERIC_BIGDECIMAL; } else if (value instanceof BigIntegerValue) { return DataType.TYPE_NUMERIC_BIGINTEGER; } else if (value instanceof BooleanValue) { return DataType.TYPE_BOOLEAN; } else if (value instanceof ByteValue) { return DataType.TYPE_NUMERIC_BYTE; } else if (value instanceof DateValue) { return DataType.TYPE_DATE; } else if (value instanceof DoubleValue) { return DataType.TYPE_NUMERIC_DOUBLE; } else if (value instanceof FloatValue) { return DataType.TYPE_NUMERIC_FLOAT; } else if (value instanceof IntegerValue) { return DataType.TYPE_NUMERIC_INTEGER; } else if (value instanceof LongValue) { return DataType.TYPE_NUMERIC_LONG; } else if (value instanceof ShortValue) { return DataType.TYPE_NUMERIC_SHORT; } else if (value instanceof EnumValue) { return DataType.TYPE_COMPARABLE; } return DataType.TYPE_STRING; }
[ "private", "String", "getDataType", "(", "final", "Value", "value", ")", "{", "if", "(", "value", "instanceof", "BigDecimalValue", ")", "{", "return", "DataType", ".", "TYPE_NUMERIC_BIGDECIMAL", ";", "}", "else", "if", "(", "value", "instanceof", "BigIntegerValue", ")", "{", "return", "DataType", ".", "TYPE_NUMERIC_BIGINTEGER", ";", "}", "else", "if", "(", "value", "instanceof", "BooleanValue", ")", "{", "return", "DataType", ".", "TYPE_BOOLEAN", ";", "}", "else", "if", "(", "value", "instanceof", "ByteValue", ")", "{", "return", "DataType", ".", "TYPE_NUMERIC_BYTE", ";", "}", "else", "if", "(", "value", "instanceof", "DateValue", ")", "{", "return", "DataType", ".", "TYPE_DATE", ";", "}", "else", "if", "(", "value", "instanceof", "DoubleValue", ")", "{", "return", "DataType", ".", "TYPE_NUMERIC_DOUBLE", ";", "}", "else", "if", "(", "value", "instanceof", "FloatValue", ")", "{", "return", "DataType", ".", "TYPE_NUMERIC_FLOAT", ";", "}", "else", "if", "(", "value", "instanceof", "IntegerValue", ")", "{", "return", "DataType", ".", "TYPE_NUMERIC_INTEGER", ";", "}", "else", "if", "(", "value", "instanceof", "LongValue", ")", "{", "return", "DataType", ".", "TYPE_NUMERIC_LONG", ";", "}", "else", "if", "(", "value", "instanceof", "ShortValue", ")", "{", "return", "DataType", ".", "TYPE_NUMERIC_SHORT", ";", "}", "else", "if", "(", "value", "instanceof", "EnumValue", ")", "{", "return", "DataType", ".", "TYPE_COMPARABLE", ";", "}", "return", "DataType", ".", "TYPE_STRING", ";", "}" ]
Convert a typed Value into legacy DataType
[ "Convert", "a", "typed", "Value", "into", "legacy", "DataType" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtree/src/main/java/org/drools/workbench/models/guided/dtree/backend/GuidedDecisionTreeModelMarshallingVisitor.java#L390-L416
14,259
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java
DRL5Parser.packageStatement
public String packageStatement( PackageDescrBuilder pkg ) throws RecognitionException { String pkgName = null; try { helper.start( pkg, PackageDescrBuilder.class, null ); match( input, DRL5Lexer.ID, DroolsSoftKeywords.PACKAGE, null, DroolsEditorType.KEYWORD ); if ( state.failed ) return pkgName; pkgName = qualifiedIdentifier(); if ( state.failed ) return pkgName; if ( state.backtracking == 0 ) { helper.setParaphrasesValue( DroolsParaphraseTypes.PACKAGE, pkgName ); } if ( input.LA( 1 ) == DRL5Lexer.SEMICOLON ) { match( input, DRL5Lexer.SEMICOLON, null, null, DroolsEditorType.SYMBOL ); if ( state.failed ) return pkgName; } } catch ( RecognitionException re ) { reportError( re ); } finally { helper.end( PackageDescrBuilder.class, pkg ); } return pkgName; }
java
public String packageStatement( PackageDescrBuilder pkg ) throws RecognitionException { String pkgName = null; try { helper.start( pkg, PackageDescrBuilder.class, null ); match( input, DRL5Lexer.ID, DroolsSoftKeywords.PACKAGE, null, DroolsEditorType.KEYWORD ); if ( state.failed ) return pkgName; pkgName = qualifiedIdentifier(); if ( state.failed ) return pkgName; if ( state.backtracking == 0 ) { helper.setParaphrasesValue( DroolsParaphraseTypes.PACKAGE, pkgName ); } if ( input.LA( 1 ) == DRL5Lexer.SEMICOLON ) { match( input, DRL5Lexer.SEMICOLON, null, null, DroolsEditorType.SYMBOL ); if ( state.failed ) return pkgName; } } catch ( RecognitionException re ) { reportError( re ); } finally { helper.end( PackageDescrBuilder.class, pkg ); } return pkgName; }
[ "public", "String", "packageStatement", "(", "PackageDescrBuilder", "pkg", ")", "throws", "RecognitionException", "{", "String", "pkgName", "=", "null", ";", "try", "{", "helper", ".", "start", "(", "pkg", ",", "PackageDescrBuilder", ".", "class", ",", "null", ")", ";", "match", "(", "input", ",", "DRL5Lexer", ".", "ID", ",", "DroolsSoftKeywords", ".", "PACKAGE", ",", "null", ",", "DroolsEditorType", ".", "KEYWORD", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "pkgName", ";", "pkgName", "=", "qualifiedIdentifier", "(", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "pkgName", ";", "if", "(", "state", ".", "backtracking", "==", "0", ")", "{", "helper", ".", "setParaphrasesValue", "(", "DroolsParaphraseTypes", ".", "PACKAGE", ",", "pkgName", ")", ";", "}", "if", "(", "input", ".", "LA", "(", "1", ")", "==", "DRL5Lexer", ".", "SEMICOLON", ")", "{", "match", "(", "input", ",", "DRL5Lexer", ".", "SEMICOLON", ",", "null", ",", "null", ",", "DroolsEditorType", ".", "SYMBOL", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "pkgName", ";", "}", "}", "catch", "(", "RecognitionException", "re", ")", "{", "reportError", "(", "re", ")", ";", "}", "finally", "{", "helper", ".", "end", "(", "PackageDescrBuilder", ".", "class", ",", "pkg", ")", ";", "}", "return", "pkgName", ";", "}" ]
Parses a package statement and returns the name of the package or null if none is defined. packageStatement := PACKAGE qualifiedIdentifier SEMICOLON? @return the name of the package or null if none is defined
[ "Parses", "a", "package", "statement", "and", "returns", "the", "name", "of", "the", "package", "or", "null", "if", "none", "is", "defined", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java#L154-L192
14,260
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java
DRL5Parser.speculateFullAnnotation
private boolean speculateFullAnnotation() { state.backtracking++; int start = input.mark(); try { exprParser.fullAnnotation( null ); } catch ( RecognitionException re ) { System.err.println( "impossible: " + re ); re.printStackTrace(); } boolean success = ! state.failed; input.rewind( start ); state.backtracking--; state.failed = false; return success; }
java
private boolean speculateFullAnnotation() { state.backtracking++; int start = input.mark(); try { exprParser.fullAnnotation( null ); } catch ( RecognitionException re ) { System.err.println( "impossible: " + re ); re.printStackTrace(); } boolean success = ! state.failed; input.rewind( start ); state.backtracking--; state.failed = false; return success; }
[ "private", "boolean", "speculateFullAnnotation", "(", ")", "{", "state", ".", "backtracking", "++", ";", "int", "start", "=", "input", ".", "mark", "(", ")", ";", "try", "{", "exprParser", ".", "fullAnnotation", "(", "null", ")", ";", "}", "catch", "(", "RecognitionException", "re", ")", "{", "System", ".", "err", ".", "println", "(", "\"impossible: \"", "+", "re", ")", ";", "re", ".", "printStackTrace", "(", ")", ";", "}", "boolean", "success", "=", "!", "state", ".", "failed", ";", "input", ".", "rewind", "(", "start", ")", ";", "state", ".", "backtracking", "--", ";", "state", ".", "failed", "=", "false", ";", "return", "success", ";", "}" ]
Invokes the expression parser, trying to parse the annotation as a full java-style annotation @return true if the sequence of tokens will match the elementValuePairs() syntax. false otherwise.
[ "Invokes", "the", "expression", "parser", "trying", "to", "parse", "the", "annotation", "as", "a", "full", "java", "-", "style", "annotation" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java#L4082-L4097
14,261
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java
DRL5Parser.type
public String type() throws RecognitionException { String type = ""; try { int first = input.index(), last = first; match( input, DRL5Lexer.ID, null, new int[]{DRL5Lexer.DOT, DRL5Lexer.LESS}, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return type; if ( input.LA( 1 ) == DRL5Lexer.LESS ) { typeArguments(); if ( state.failed ) return type; } while ( input.LA( 1 ) == DRL5Lexer.DOT && input.LA( 2 ) == DRL5Lexer.ID ) { match( input, DRL5Lexer.DOT, null, new int[]{DRL5Lexer.ID}, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return type; match( input, DRL5Lexer.ID, null, new int[]{DRL5Lexer.DOT}, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return type; if ( input.LA( 1 ) == DRL5Lexer.LESS ) { typeArguments(); if ( state.failed ) return type; } } while ( input.LA( 1 ) == DRL5Lexer.LEFT_SQUARE && input.LA( 2 ) == DRL5Lexer.RIGHT_SQUARE ) { match( input, DRL5Lexer.LEFT_SQUARE, null, new int[]{DRL5Lexer.RIGHT_SQUARE}, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return type; match( input, DRL5Lexer.RIGHT_SQUARE, null, null, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return type; } last = input.LT( -1 ).getTokenIndex(); type = input.toString( first, last ); type = type.replace( " ", "" ); } catch ( RecognitionException re ) { reportError( re ); } return type; }
java
public String type() throws RecognitionException { String type = ""; try { int first = input.index(), last = first; match( input, DRL5Lexer.ID, null, new int[]{DRL5Lexer.DOT, DRL5Lexer.LESS}, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return type; if ( input.LA( 1 ) == DRL5Lexer.LESS ) { typeArguments(); if ( state.failed ) return type; } while ( input.LA( 1 ) == DRL5Lexer.DOT && input.LA( 2 ) == DRL5Lexer.ID ) { match( input, DRL5Lexer.DOT, null, new int[]{DRL5Lexer.ID}, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return type; match( input, DRL5Lexer.ID, null, new int[]{DRL5Lexer.DOT}, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return type; if ( input.LA( 1 ) == DRL5Lexer.LESS ) { typeArguments(); if ( state.failed ) return type; } } while ( input.LA( 1 ) == DRL5Lexer.LEFT_SQUARE && input.LA( 2 ) == DRL5Lexer.RIGHT_SQUARE ) { match( input, DRL5Lexer.LEFT_SQUARE, null, new int[]{DRL5Lexer.RIGHT_SQUARE}, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return type; match( input, DRL5Lexer.RIGHT_SQUARE, null, null, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return type; } last = input.LT( -1 ).getTokenIndex(); type = input.toString( first, last ); type = type.replace( " ", "" ); } catch ( RecognitionException re ) { reportError( re ); } return type; }
[ "public", "String", "type", "(", ")", "throws", "RecognitionException", "{", "String", "type", "=", "\"\"", ";", "try", "{", "int", "first", "=", "input", ".", "index", "(", ")", ",", "last", "=", "first", ";", "match", "(", "input", ",", "DRL5Lexer", ".", "ID", ",", "null", ",", "new", "int", "[", "]", "{", "DRL5Lexer", ".", "DOT", ",", "DRL5Lexer", ".", "LESS", "}", ",", "DroolsEditorType", ".", "IDENTIFIER", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "type", ";", "if", "(", "input", ".", "LA", "(", "1", ")", "==", "DRL5Lexer", ".", "LESS", ")", "{", "typeArguments", "(", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "type", ";", "}", "while", "(", "input", ".", "LA", "(", "1", ")", "==", "DRL5Lexer", ".", "DOT", "&&", "input", ".", "LA", "(", "2", ")", "==", "DRL5Lexer", ".", "ID", ")", "{", "match", "(", "input", ",", "DRL5Lexer", ".", "DOT", ",", "null", ",", "new", "int", "[", "]", "{", "DRL5Lexer", ".", "ID", "}", ",", "DroolsEditorType", ".", "IDENTIFIER", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "type", ";", "match", "(", "input", ",", "DRL5Lexer", ".", "ID", ",", "null", ",", "new", "int", "[", "]", "{", "DRL5Lexer", ".", "DOT", "}", ",", "DroolsEditorType", ".", "IDENTIFIER", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "type", ";", "if", "(", "input", ".", "LA", "(", "1", ")", "==", "DRL5Lexer", ".", "LESS", ")", "{", "typeArguments", "(", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "type", ";", "}", "}", "while", "(", "input", ".", "LA", "(", "1", ")", "==", "DRL5Lexer", ".", "LEFT_SQUARE", "&&", "input", ".", "LA", "(", "2", ")", "==", "DRL5Lexer", ".", "RIGHT_SQUARE", ")", "{", "match", "(", "input", ",", "DRL5Lexer", ".", "LEFT_SQUARE", ",", "null", ",", "new", "int", "[", "]", "{", "DRL5Lexer", ".", "RIGHT_SQUARE", "}", ",", "DroolsEditorType", ".", "IDENTIFIER", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "type", ";", "match", "(", "input", ",", "DRL5Lexer", ".", "RIGHT_SQUARE", ",", "null", ",", "null", ",", "DroolsEditorType", ".", "IDENTIFIER", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "type", ";", "}", "last", "=", "input", ".", "LT", "(", "-", "1", ")", ".", "getTokenIndex", "(", ")", ";", "type", "=", "input", ".", "toString", "(", "first", ",", "last", ")", ";", "type", "=", "type", ".", "replace", "(", "\" \"", ",", "\"\"", ")", ";", "}", "catch", "(", "RecognitionException", "re", ")", "{", "reportError", "(", "re", ")", ";", "}", "return", "type", ";", "}" ]
Matches a type name type := ID typeArguments? ( DOT ID typeArguments? )* (LEFT_SQUARE RIGHT_SQUARE)* @return @throws RecognitionException
[ "Matches", "a", "type", "name" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java#L4112-L4171
14,262
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java
DRL5Parser.typeArguments
public String typeArguments() throws RecognitionException { String typeArguments = ""; try { int first = input.index(); Token token = match( input, DRL5Lexer.LESS, null, new int[]{DRL5Lexer.QUESTION, DRL5Lexer.ID}, DroolsEditorType.SYMBOL ); if ( state.failed ) return typeArguments; typeArgument(); if ( state.failed ) return typeArguments; while ( input.LA( 1 ) == DRL5Lexer.COMMA ) { token = match( input, DRL5Lexer.COMMA, null, new int[]{DRL5Lexer.QUESTION, DRL5Lexer.ID}, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return typeArguments; typeArgument(); if ( state.failed ) return typeArguments; } token = match( input, DRL5Lexer.GREATER, null, null, DroolsEditorType.SYMBOL ); if ( state.failed ) return typeArguments; typeArguments = input.toString( first, token.getTokenIndex() ); } catch ( RecognitionException re ) { reportError( re ); } return typeArguments; }
java
public String typeArguments() throws RecognitionException { String typeArguments = ""; try { int first = input.index(); Token token = match( input, DRL5Lexer.LESS, null, new int[]{DRL5Lexer.QUESTION, DRL5Lexer.ID}, DroolsEditorType.SYMBOL ); if ( state.failed ) return typeArguments; typeArgument(); if ( state.failed ) return typeArguments; while ( input.LA( 1 ) == DRL5Lexer.COMMA ) { token = match( input, DRL5Lexer.COMMA, null, new int[]{DRL5Lexer.QUESTION, DRL5Lexer.ID}, DroolsEditorType.IDENTIFIER ); if ( state.failed ) return typeArguments; typeArgument(); if ( state.failed ) return typeArguments; } token = match( input, DRL5Lexer.GREATER, null, null, DroolsEditorType.SYMBOL ); if ( state.failed ) return typeArguments; typeArguments = input.toString( first, token.getTokenIndex() ); } catch ( RecognitionException re ) { reportError( re ); } return typeArguments; }
[ "public", "String", "typeArguments", "(", ")", "throws", "RecognitionException", "{", "String", "typeArguments", "=", "\"\"", ";", "try", "{", "int", "first", "=", "input", ".", "index", "(", ")", ";", "Token", "token", "=", "match", "(", "input", ",", "DRL5Lexer", ".", "LESS", ",", "null", ",", "new", "int", "[", "]", "{", "DRL5Lexer", ".", "QUESTION", ",", "DRL5Lexer", ".", "ID", "}", ",", "DroolsEditorType", ".", "SYMBOL", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArguments", ";", "typeArgument", "(", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArguments", ";", "while", "(", "input", ".", "LA", "(", "1", ")", "==", "DRL5Lexer", ".", "COMMA", ")", "{", "token", "=", "match", "(", "input", ",", "DRL5Lexer", ".", "COMMA", ",", "null", ",", "new", "int", "[", "]", "{", "DRL5Lexer", ".", "QUESTION", ",", "DRL5Lexer", ".", "ID", "}", ",", "DroolsEditorType", ".", "IDENTIFIER", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArguments", ";", "typeArgument", "(", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArguments", ";", "}", "token", "=", "match", "(", "input", ",", "DRL5Lexer", ".", "GREATER", ",", "null", ",", "null", ",", "DroolsEditorType", ".", "SYMBOL", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArguments", ";", "typeArguments", "=", "input", ".", "toString", "(", "first", ",", "token", ".", "getTokenIndex", "(", ")", ")", ";", "}", "catch", "(", "RecognitionException", "re", ")", "{", "reportError", "(", "re", ")", ";", "}", "return", "typeArguments", ";", "}" ]
Matches type arguments typeArguments := LESS typeArgument (COMMA typeArgument)* GREATER @return @throws RecognitionException
[ "Matches", "type", "arguments" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java#L4181-L4220
14,263
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java
DRL5Parser.conditionalExpression
public String conditionalExpression() throws RecognitionException { int first = input.index(); exprParser.conditionalExpression(); if ( state.failed ) return null; if ( state.backtracking == 0 && input.index() > first ) { // expression consumed something String expr = input.toString( first, input.LT( -1 ).getTokenIndex() ); return expr; } return null; }
java
public String conditionalExpression() throws RecognitionException { int first = input.index(); exprParser.conditionalExpression(); if ( state.failed ) return null; if ( state.backtracking == 0 && input.index() > first ) { // expression consumed something String expr = input.toString( first, input.LT( -1 ).getTokenIndex() ); return expr; } return null; }
[ "public", "String", "conditionalExpression", "(", ")", "throws", "RecognitionException", "{", "int", "first", "=", "input", ".", "index", "(", ")", ";", "exprParser", ".", "conditionalExpression", "(", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "null", ";", "if", "(", "state", ".", "backtracking", "==", "0", "&&", "input", ".", "index", "(", ")", ">", "first", ")", "{", "// expression consumed something", "String", "expr", "=", "input", ".", "toString", "(", "first", ",", "input", ".", "LT", "(", "-", "1", ")", ".", "getTokenIndex", "(", ")", ")", ";", "return", "expr", ";", "}", "return", "null", ";", "}" ]
Matches a conditional expression @return @throws RecognitionException
[ "Matches", "a", "conditional", "expression" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java#L4332-L4344
14,264
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java
DRL5Parser.recoverFromMismatchedToken
protected Token recoverFromMismatchedToken( TokenStream input, int ttype, String text, int[] follow ) throws RecognitionException { RecognitionException e = null; // if next token is what we are looking for then "delete" this token if ( mismatchIsUnwantedToken( input, ttype, text ) ) { e = new UnwantedTokenException( ttype, input ); input.consume(); // simply delete extra token reportError( e ); // report after consuming so AW sees the token in the exception // we want to return the token we're actually matching Token matchedSymbol = input.LT( 1 ); input.consume(); // move past ttype token as if all were ok return matchedSymbol; } // can't recover with single token deletion, try insertion if ( mismatchIsMissingToken( input, follow ) ) { e = new MissingTokenException( ttype, input, null ); reportError( e ); // report after inserting so AW sees the token in the exception return null; } // even that didn't work; must throw the exception if ( text != null ) { e = new DroolsMismatchedTokenException( ttype, text, input ); } else { e = new MismatchedTokenException( ttype, input ); } throw e; }
java
protected Token recoverFromMismatchedToken( TokenStream input, int ttype, String text, int[] follow ) throws RecognitionException { RecognitionException e = null; // if next token is what we are looking for then "delete" this token if ( mismatchIsUnwantedToken( input, ttype, text ) ) { e = new UnwantedTokenException( ttype, input ); input.consume(); // simply delete extra token reportError( e ); // report after consuming so AW sees the token in the exception // we want to return the token we're actually matching Token matchedSymbol = input.LT( 1 ); input.consume(); // move past ttype token as if all were ok return matchedSymbol; } // can't recover with single token deletion, try insertion if ( mismatchIsMissingToken( input, follow ) ) { e = new MissingTokenException( ttype, input, null ); reportError( e ); // report after inserting so AW sees the token in the exception return null; } // even that didn't work; must throw the exception if ( text != null ) { e = new DroolsMismatchedTokenException( ttype, text, input ); } else { e = new MismatchedTokenException( ttype, input ); } throw e; }
[ "protected", "Token", "recoverFromMismatchedToken", "(", "TokenStream", "input", ",", "int", "ttype", ",", "String", "text", ",", "int", "[", "]", "follow", ")", "throws", "RecognitionException", "{", "RecognitionException", "e", "=", "null", ";", "// if next token is what we are looking for then \"delete\" this token", "if", "(", "mismatchIsUnwantedToken", "(", "input", ",", "ttype", ",", "text", ")", ")", "{", "e", "=", "new", "UnwantedTokenException", "(", "ttype", ",", "input", ")", ";", "input", ".", "consume", "(", ")", ";", "// simply delete extra token", "reportError", "(", "e", ")", ";", "// report after consuming so AW sees the token in the exception", "// we want to return the token we're actually matching", "Token", "matchedSymbol", "=", "input", ".", "LT", "(", "1", ")", ";", "input", ".", "consume", "(", ")", ";", "// move past ttype token as if all were ok", "return", "matchedSymbol", ";", "}", "// can't recover with single token deletion, try insertion", "if", "(", "mismatchIsMissingToken", "(", "input", ",", "follow", ")", ")", "{", "e", "=", "new", "MissingTokenException", "(", "ttype", ",", "input", ",", "null", ")", ";", "reportError", "(", "e", ")", ";", "// report after inserting so AW sees the token in the exception", "return", "null", ";", "}", "// even that didn't work; must throw the exception", "if", "(", "text", "!=", "null", ")", "{", "e", "=", "new", "DroolsMismatchedTokenException", "(", "ttype", ",", "text", ",", "input", ")", ";", "}", "else", "{", "e", "=", "new", "MismatchedTokenException", "(", "ttype", ",", "input", ")", ";", "}", "throw", "e", ";", "}" ]
Attempt to recover from a single missing or extra token. EXTRA TOKEN LA(1) is not what we are looking for. If LA(2) has the right token, however, then assume LA(1) is some extra spurious token. Delete it and LA(2) as if we were doing a normal match(), which advances the input. MISSING TOKEN If current token is consistent with what could come after ttype then it is ok to "insert" the missing token, else throw exception For example, Input "i=(3;" is clearly missing the ')'. When the parser returns from the nested call to expr, it will have call chain: stat -> expr -> atom and it will be trying to match the ')' at this point in the derivation: => ID '=' '(' INT ')' ('+' atom)* ';' ^ match() will see that ';' doesn't match ')' and report a mismatched token error. To recover, it sees that LA(1)==';' is in the set of tokens that can follow the ')' token reference in rule atom. It can assume that you forgot the ')'.
[ "Attempt", "to", "recover", "from", "a", "single", "missing", "or", "extra", "token", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL5Parser.java#L4490-L4528
14,265
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/commons/jci/compilers/JavaCompilerFactory.java
JavaCompilerFactory.createCompiler
public JavaCompiler createCompiler(final String pHint) { final String className; if (pHint.indexOf('.') < 0) { className = "org.drools.compiler.commons.jci.compilers." + ClassUtils.toJavaCasing(pHint) + "JavaCompiler"; } else { className = pHint; } Class clazz = (Class) classCache.get(className); if (clazz == null) { try { clazz = Class.forName(className); classCache.put(className, clazz); } catch (ClassNotFoundException e) { clazz = null; } } if (clazz == null) { return null; } try { return (JavaCompiler) clazz.newInstance(); } catch (Throwable t) { return null; } }
java
public JavaCompiler createCompiler(final String pHint) { final String className; if (pHint.indexOf('.') < 0) { className = "org.drools.compiler.commons.jci.compilers." + ClassUtils.toJavaCasing(pHint) + "JavaCompiler"; } else { className = pHint; } Class clazz = (Class) classCache.get(className); if (clazz == null) { try { clazz = Class.forName(className); classCache.put(className, clazz); } catch (ClassNotFoundException e) { clazz = null; } } if (clazz == null) { return null; } try { return (JavaCompiler) clazz.newInstance(); } catch (Throwable t) { return null; } }
[ "public", "JavaCompiler", "createCompiler", "(", "final", "String", "pHint", ")", "{", "final", "String", "className", ";", "if", "(", "pHint", ".", "indexOf", "(", "'", "'", ")", "<", "0", ")", "{", "className", "=", "\"org.drools.compiler.commons.jci.compilers.\"", "+", "ClassUtils", ".", "toJavaCasing", "(", "pHint", ")", "+", "\"JavaCompiler\"", ";", "}", "else", "{", "className", "=", "pHint", ";", "}", "Class", "clazz", "=", "(", "Class", ")", "classCache", ".", "get", "(", "className", ")", ";", "if", "(", "clazz", "==", "null", ")", "{", "try", "{", "clazz", "=", "Class", ".", "forName", "(", "className", ")", ";", "classCache", ".", "put", "(", "className", ",", "clazz", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "clazz", "=", "null", ";", "}", "}", "if", "(", "clazz", "==", "null", ")", "{", "return", "null", ";", "}", "try", "{", "return", "(", "JavaCompiler", ")", "clazz", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "return", "null", ";", "}", "}" ]
Tries to guess the class name by convention. So for compilers following the naming convention org.apache.commons.jci.compilers.SomeJavaCompiler you can use the short-hands "some"/"Some"/"SOME". Otherwise you have to provide the full class name. The compiler is getting instanciated via (cached) reflection. @param pHint @return JavaCompiler or null
[ "Tries", "to", "guess", "the", "class", "name", "by", "convention", ".", "So", "for", "compilers", "following", "the", "naming", "convention" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/commons/jci/compilers/JavaCompilerFactory.java#L62-L91
14,266
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/GuidedDTDRLOtherwiseHelper.java
GuidedDTDRLOtherwiseHelper.getBuilder
public static OtherwiseBuilder getBuilder( ConditionCol52 c ) { if ( c.getOperator().equals( "==" ) ) { return new EqualsOtherwiseBuilder(); } else if ( c.getOperator().equals( "!=" ) ) { return new NotEqualsOtherwiseBuilder(); } throw new IllegalArgumentException( "ConditionCol operator does not support Otherwise values" ); }
java
public static OtherwiseBuilder getBuilder( ConditionCol52 c ) { if ( c.getOperator().equals( "==" ) ) { return new EqualsOtherwiseBuilder(); } else if ( c.getOperator().equals( "!=" ) ) { return new NotEqualsOtherwiseBuilder(); } throw new IllegalArgumentException( "ConditionCol operator does not support Otherwise values" ); }
[ "public", "static", "OtherwiseBuilder", "getBuilder", "(", "ConditionCol52", "c", ")", "{", "if", "(", "c", ".", "getOperator", "(", ")", ".", "equals", "(", "\"==\"", ")", ")", "{", "return", "new", "EqualsOtherwiseBuilder", "(", ")", ";", "}", "else", "if", "(", "c", ".", "getOperator", "(", ")", ".", "equals", "(", "\"!=\"", ")", ")", "{", "return", "new", "NotEqualsOtherwiseBuilder", "(", ")", ";", "}", "throw", "new", "IllegalArgumentException", "(", "\"ConditionCol operator does not support Otherwise values\"", ")", ";", "}" ]
Retrieve the correct OtherwiseBuilder for the given column @param c @return
[ "Retrieve", "the", "correct", "OtherwiseBuilder", "for", "the", "given", "column" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/GuidedDTDRLOtherwiseHelper.java#L181-L189
14,267
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/GuidedDTDRLOtherwiseHelper.java
GuidedDTDRLOtherwiseHelper.extractColumnData
private static List<DTCellValue52> extractColumnData( List<List<DTCellValue52>> data, int columnIndex ) { List<DTCellValue52> columnData = new ArrayList<DTCellValue52>(); for ( List<DTCellValue52> row : data ) { columnData.add( row.get( columnIndex ) ); } return columnData; }
java
private static List<DTCellValue52> extractColumnData( List<List<DTCellValue52>> data, int columnIndex ) { List<DTCellValue52> columnData = new ArrayList<DTCellValue52>(); for ( List<DTCellValue52> row : data ) { columnData.add( row.get( columnIndex ) ); } return columnData; }
[ "private", "static", "List", "<", "DTCellValue52", ">", "extractColumnData", "(", "List", "<", "List", "<", "DTCellValue52", ">", ">", "data", ",", "int", "columnIndex", ")", "{", "List", "<", "DTCellValue52", ">", "columnData", "=", "new", "ArrayList", "<", "DTCellValue52", ">", "(", ")", ";", "for", "(", "List", "<", "DTCellValue52", ">", "row", ":", "data", ")", "{", "columnData", ".", "add", "(", "row", ".", "get", "(", "columnIndex", ")", ")", ";", "}", "return", "columnData", ";", "}" ]
Extract data relating to a single column
[ "Extract", "data", "relating", "to", "a", "single", "column" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/GuidedDTDRLOtherwiseHelper.java#L192-L199
14,268
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/asm/ClassFieldInspector.java
ClassFieldInspector.processClassWithByteCode
private void processClassWithByteCode( final Class< ? > clazz, final InputStream stream, final boolean includeFinalMethods ) throws IOException { final ClassReader reader = new ClassReader( stream ); final ClassFieldVisitor visitor = new ClassFieldVisitor( clazz, includeFinalMethods, this ); reader.accept( visitor, 0 ); if ( clazz.getSuperclass() != null ) { final String name = getResourcePath( clazz.getSuperclass() ); final InputStream parentStream = clazz.getResourceAsStream( name ); if ( parentStream != null ) { try { processClassWithByteCode( clazz.getSuperclass(), parentStream, includeFinalMethods ); } finally { parentStream.close(); } } else { processClassWithoutByteCode( clazz.getSuperclass(), includeFinalMethods ); } } if ( clazz.isInterface() ) { final Class< ? >[] interfaces = clazz.getInterfaces(); for ( Class<?> anInterface : interfaces ) { final String name = getResourcePath( anInterface ); final InputStream parentStream = clazz.getResourceAsStream( name ); if ( parentStream != null ) { try { processClassWithByteCode( anInterface, parentStream, includeFinalMethods ); } finally { parentStream.close(); } } else { processClassWithoutByteCode( anInterface, includeFinalMethods ); } } } }
java
private void processClassWithByteCode( final Class< ? > clazz, final InputStream stream, final boolean includeFinalMethods ) throws IOException { final ClassReader reader = new ClassReader( stream ); final ClassFieldVisitor visitor = new ClassFieldVisitor( clazz, includeFinalMethods, this ); reader.accept( visitor, 0 ); if ( clazz.getSuperclass() != null ) { final String name = getResourcePath( clazz.getSuperclass() ); final InputStream parentStream = clazz.getResourceAsStream( name ); if ( parentStream != null ) { try { processClassWithByteCode( clazz.getSuperclass(), parentStream, includeFinalMethods ); } finally { parentStream.close(); } } else { processClassWithoutByteCode( clazz.getSuperclass(), includeFinalMethods ); } } if ( clazz.isInterface() ) { final Class< ? >[] interfaces = clazz.getInterfaces(); for ( Class<?> anInterface : interfaces ) { final String name = getResourcePath( anInterface ); final InputStream parentStream = clazz.getResourceAsStream( name ); if ( parentStream != null ) { try { processClassWithByteCode( anInterface, parentStream, includeFinalMethods ); } finally { parentStream.close(); } } else { processClassWithoutByteCode( anInterface, includeFinalMethods ); } } } }
[ "private", "void", "processClassWithByteCode", "(", "final", "Class", "<", "?", ">", "clazz", ",", "final", "InputStream", "stream", ",", "final", "boolean", "includeFinalMethods", ")", "throws", "IOException", "{", "final", "ClassReader", "reader", "=", "new", "ClassReader", "(", "stream", ")", ";", "final", "ClassFieldVisitor", "visitor", "=", "new", "ClassFieldVisitor", "(", "clazz", ",", "includeFinalMethods", ",", "this", ")", ";", "reader", ".", "accept", "(", "visitor", ",", "0", ")", ";", "if", "(", "clazz", ".", "getSuperclass", "(", ")", "!=", "null", ")", "{", "final", "String", "name", "=", "getResourcePath", "(", "clazz", ".", "getSuperclass", "(", ")", ")", ";", "final", "InputStream", "parentStream", "=", "clazz", ".", "getResourceAsStream", "(", "name", ")", ";", "if", "(", "parentStream", "!=", "null", ")", "{", "try", "{", "processClassWithByteCode", "(", "clazz", ".", "getSuperclass", "(", ")", ",", "parentStream", ",", "includeFinalMethods", ")", ";", "}", "finally", "{", "parentStream", ".", "close", "(", ")", ";", "}", "}", "else", "{", "processClassWithoutByteCode", "(", "clazz", ".", "getSuperclass", "(", ")", ",", "includeFinalMethods", ")", ";", "}", "}", "if", "(", "clazz", ".", "isInterface", "(", ")", ")", "{", "final", "Class", "<", "?", ">", "[", "]", "interfaces", "=", "clazz", ".", "getInterfaces", "(", ")", ";", "for", "(", "Class", "<", "?", ">", "anInterface", ":", "interfaces", ")", "{", "final", "String", "name", "=", "getResourcePath", "(", "anInterface", ")", ";", "final", "InputStream", "parentStream", "=", "clazz", ".", "getResourceAsStream", "(", "name", ")", ";", "if", "(", "parentStream", "!=", "null", ")", "{", "try", "{", "processClassWithByteCode", "(", "anInterface", ",", "parentStream", ",", "includeFinalMethods", ")", ";", "}", "finally", "{", "parentStream", ".", "close", "(", ")", ";", "}", "}", "else", "{", "processClassWithoutByteCode", "(", "anInterface", ",", "includeFinalMethods", ")", ";", "}", "}", "}", "}" ]
Walk up the inheritance hierarchy recursively, reading in fields
[ "Walk", "up", "the", "inheritance", "hierarchy", "recursively", "reading", "in", "fields" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/asm/ClassFieldInspector.java#L99-L144
14,269
kiegroup/drools
drools-core/src/main/java/org/drools/core/factmodel/ClassDefinition.java
ClassDefinition.getField
public FieldDefinition getField(int index) { if (index >= fields.size() || index < 0) { return null; } Iterator<FieldDefinition> iter = fields.values().iterator(); for (int j = 0; j < index ; j++) { iter.next(); } return iter.next(); }
java
public FieldDefinition getField(int index) { if (index >= fields.size() || index < 0) { return null; } Iterator<FieldDefinition> iter = fields.values().iterator(); for (int j = 0; j < index ; j++) { iter.next(); } return iter.next(); }
[ "public", "FieldDefinition", "getField", "(", "int", "index", ")", "{", "if", "(", "index", ">=", "fields", ".", "size", "(", ")", "||", "index", "<", "0", ")", "{", "return", "null", ";", "}", "Iterator", "<", "FieldDefinition", ">", "iter", "=", "fields", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "index", ";", "j", "++", ")", "{", "iter", ".", "next", "(", ")", ";", "}", "return", "iter", ".", "next", "(", ")", ";", "}" ]
Returns the field at position index, as defined by the builder using the @position annotation @param index @return the index-th field
[ "Returns", "the", "field", "at", "position", "index", "as", "defined", "by", "the", "builder", "using", "the" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/factmodel/ClassDefinition.java#L189-L198
14,270
kiegroup/drools
kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/model/PMML4UnitImpl.java
PMML4UnitImpl.initDataDictionaryMap
private void initDataDictionaryMap() { DataDictionary dd = rawPmml.getDataDictionary(); if (dd != null) { dataDictionaryMap = new HashMap<>(); for (DataField dataField : dd.getDataFields()) { PMMLDataField df = new PMMLDataField(dataField); dataDictionaryMap.put(df.getName(), df); } } else { throw new IllegalStateException("BRMS-PMML requires a data dictionary section in the definition file"); } }
java
private void initDataDictionaryMap() { DataDictionary dd = rawPmml.getDataDictionary(); if (dd != null) { dataDictionaryMap = new HashMap<>(); for (DataField dataField : dd.getDataFields()) { PMMLDataField df = new PMMLDataField(dataField); dataDictionaryMap.put(df.getName(), df); } } else { throw new IllegalStateException("BRMS-PMML requires a data dictionary section in the definition file"); } }
[ "private", "void", "initDataDictionaryMap", "(", ")", "{", "DataDictionary", "dd", "=", "rawPmml", ".", "getDataDictionary", "(", ")", ";", "if", "(", "dd", "!=", "null", ")", "{", "dataDictionaryMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "DataField", "dataField", ":", "dd", ".", "getDataFields", "(", ")", ")", "{", "PMMLDataField", "df", "=", "new", "PMMLDataField", "(", "dataField", ")", ";", "dataDictionaryMap", ".", "put", "(", "df", ".", "getName", "(", ")", ",", "df", ")", ";", "}", "}", "else", "{", "throw", "new", "IllegalStateException", "(", "\"BRMS-PMML requires a data dictionary section in the definition file\"", ")", ";", "}", "}" ]
Initializes the internal structure that holds data dictionary information. This initializer should be called prior to any other initializers, since many other structures may have a dependency on the data dictionary.
[ "Initializes", "the", "internal", "structure", "that", "holds", "data", "dictionary", "information", ".", "This", "initializer", "should", "be", "called", "prior", "to", "any", "other", "initializers", "since", "many", "other", "structures", "may", "have", "a", "dependency", "on", "the", "data", "dictionary", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/model/PMML4UnitImpl.java#L84-L95
14,271
kiegroup/drools
kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/model/PMML4UnitImpl.java
PMML4UnitImpl.getMiningFieldsForModel
public List<MiningField> getMiningFieldsForModel(String modelId) { PMML4Model model = modelsMap.get(modelId); if (model != null) { return model.getRawMiningFields(); } return null; }
java
public List<MiningField> getMiningFieldsForModel(String modelId) { PMML4Model model = modelsMap.get(modelId); if (model != null) { return model.getRawMiningFields(); } return null; }
[ "public", "List", "<", "MiningField", ">", "getMiningFieldsForModel", "(", "String", "modelId", ")", "{", "PMML4Model", "model", "=", "modelsMap", ".", "get", "(", "modelId", ")", ";", "if", "(", "model", "!=", "null", ")", "{", "return", "model", ".", "getRawMiningFields", "(", ")", ";", "}", "return", "null", ";", "}" ]
Retrieves a List of the raw MiningField objects for a given model @param modelId The identifier of the model for which the list of MiningField objects is retrieved @return The list of MiningField objects belonging to the identified model
[ "Retrieves", "a", "List", "of", "the", "raw", "MiningField", "objects", "for", "a", "given", "model" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/model/PMML4UnitImpl.java#L140-L146
14,272
kiegroup/drools
kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/model/PMML4UnitImpl.java
PMML4UnitImpl.getMiningFields
public Map<String, List<MiningField>> getMiningFields() { Map<String, List<MiningField>> miningFieldsMap = new HashMap<>(); for (PMML4Model model : getModels()) { List<MiningField> miningFields = model.getRawMiningFields(); miningFieldsMap.put(model.getModelId(), miningFields); model.getChildModels(); } return miningFieldsMap; }
java
public Map<String, List<MiningField>> getMiningFields() { Map<String, List<MiningField>> miningFieldsMap = new HashMap<>(); for (PMML4Model model : getModels()) { List<MiningField> miningFields = model.getRawMiningFields(); miningFieldsMap.put(model.getModelId(), miningFields); model.getChildModels(); } return miningFieldsMap; }
[ "public", "Map", "<", "String", ",", "List", "<", "MiningField", ">", ">", "getMiningFields", "(", ")", "{", "Map", "<", "String", ",", "List", "<", "MiningField", ">", ">", "miningFieldsMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "PMML4Model", "model", ":", "getModels", "(", ")", ")", "{", "List", "<", "MiningField", ">", "miningFields", "=", "model", ".", "getRawMiningFields", "(", ")", ";", "miningFieldsMap", ".", "put", "(", "model", ".", "getModelId", "(", ")", ",", "miningFields", ")", ";", "model", ".", "getChildModels", "(", ")", ";", "}", "return", "miningFieldsMap", ";", "}" ]
Retrieves a Map with entries that consist of key -> a model identifier value -> the List of raw MiningField objects belonging to the model referenced by the key @return The Map of model identifiers and their corresponding list of raw MiningField objects
[ "Retrieves", "a", "Map", "with", "entries", "that", "consist", "of", "key", "-", ">", "a", "model", "identifier", "value", "-", ">", "the", "List", "of", "raw", "MiningField", "objects", "belonging", "to", "the", "model", "referenced", "by", "the", "key" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/model/PMML4UnitImpl.java#L154-L162
14,273
kiegroup/drools
kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/model/PMML4UnitImpl.java
PMML4UnitImpl.getChildModels
public Map<String, PMML4Model> getChildModels(String parentModelId) { PMML4Model parent = modelsMap.get(parentModelId); Map<String, PMML4Model> childMap = parent.getChildModels(); return (childMap != null && !childMap.isEmpty()) ? new HashMap<>(childMap) : new HashMap<>(); }
java
public Map<String, PMML4Model> getChildModels(String parentModelId) { PMML4Model parent = modelsMap.get(parentModelId); Map<String, PMML4Model> childMap = parent.getChildModels(); return (childMap != null && !childMap.isEmpty()) ? new HashMap<>(childMap) : new HashMap<>(); }
[ "public", "Map", "<", "String", ",", "PMML4Model", ">", "getChildModels", "(", "String", "parentModelId", ")", "{", "PMML4Model", "parent", "=", "modelsMap", ".", "get", "(", "parentModelId", ")", ";", "Map", "<", "String", ",", "PMML4Model", ">", "childMap", "=", "parent", ".", "getChildModels", "(", ")", ";", "return", "(", "childMap", "!=", "null", "&&", "!", "childMap", ".", "isEmpty", "(", ")", ")", "?", "new", "HashMap", "<>", "(", "childMap", ")", ":", "new", "HashMap", "<>", "(", ")", ";", "}" ]
Retrieves a Map whose entries consist of key -> a model identifier value -> the PMML4Model object that the key refers to where the PMML4Model indicates that it @param parentModelId @return
[ "Retrieves", "a", "Map", "whose", "entries", "consist", "of", "key", "-", ">", "a", "model", "identifier", "value", "-", ">", "the", "PMML4Model", "object", "that", "the", "key", "refers", "to", "where", "the", "PMML4Model", "indicates", "that", "it" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/model/PMML4UnitImpl.java#L205-L209
14,274
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/DataUtilities.java
DataUtilities.makeDataLists
public static List<List<DTCellValue52>> makeDataLists( Object[][] oldData ) { List<List<DTCellValue52>> newData = new ArrayList<List<DTCellValue52>>(); for ( int iRow = 0; iRow < oldData.length; iRow++ ) { Object[] oldRow = oldData[ iRow ]; List<DTCellValue52> newRow = makeDataRowList( oldRow ); newData.add( newRow ); } return newData; }
java
public static List<List<DTCellValue52>> makeDataLists( Object[][] oldData ) { List<List<DTCellValue52>> newData = new ArrayList<List<DTCellValue52>>(); for ( int iRow = 0; iRow < oldData.length; iRow++ ) { Object[] oldRow = oldData[ iRow ]; List<DTCellValue52> newRow = makeDataRowList( oldRow ); newData.add( newRow ); } return newData; }
[ "public", "static", "List", "<", "List", "<", "DTCellValue52", ">", ">", "makeDataLists", "(", "Object", "[", "]", "[", "]", "oldData", ")", "{", "List", "<", "List", "<", "DTCellValue52", ">>", "newData", "=", "new", "ArrayList", "<", "List", "<", "DTCellValue52", ">", ">", "(", ")", ";", "for", "(", "int", "iRow", "=", "0", ";", "iRow", "<", "oldData", ".", "length", ";", "iRow", "++", ")", "{", "Object", "[", "]", "oldRow", "=", "oldData", "[", "iRow", "]", ";", "List", "<", "DTCellValue52", ">", "newRow", "=", "makeDataRowList", "(", "oldRow", ")", ";", "newData", ".", "add", "(", "newRow", ")", ";", "}", "return", "newData", ";", "}" ]
Convert a two-dimensional array of Strings to a List of Lists, with type-safe individual entries @param oldData @return New data
[ "Convert", "a", "two", "-", "dimensional", "array", "of", "Strings", "to", "a", "List", "of", "Lists", "with", "type", "-", "safe", "individual", "entries" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/DataUtilities.java#L34-L42
14,275
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/DataUtilities.java
DataUtilities.makeDataRowList
public static List<DTCellValue52> makeDataRowList( Object[] oldRow ) { List<DTCellValue52> row = new ArrayList<DTCellValue52>(); //Row numbers are numerical if ( oldRow[ 0 ] instanceof String ) { DTCellValue52 rowDcv = new DTCellValue52( new Integer( (String) oldRow[ 0 ] ) ); row.add( rowDcv ); } else if ( oldRow[ 0 ] instanceof Number ) { DTCellValue52 rowDcv = new DTCellValue52( ( (Number) oldRow[ 0 ] ).intValue() ); row.add( rowDcv ); } else { DTCellValue52 rowDcv = new DTCellValue52( oldRow[ 0 ] ); row.add( rowDcv ); } for ( int iCol = 1; iCol < oldRow.length; iCol++ ) { //The original model was purely String based. Conversion to typed fields //occurs when the Model is re-saved in Guvnor. Ideally the conversion //should occur here but that requires reference to a SuggestionCompletionEngine //which requires RepositoryServices. I did not want to make a dependency between //common IDE classes and the Repository DTCellValue52 dcv = new DTCellValue52( oldRow[ iCol ] ); row.add( dcv ); } return row; }
java
public static List<DTCellValue52> makeDataRowList( Object[] oldRow ) { List<DTCellValue52> row = new ArrayList<DTCellValue52>(); //Row numbers are numerical if ( oldRow[ 0 ] instanceof String ) { DTCellValue52 rowDcv = new DTCellValue52( new Integer( (String) oldRow[ 0 ] ) ); row.add( rowDcv ); } else if ( oldRow[ 0 ] instanceof Number ) { DTCellValue52 rowDcv = new DTCellValue52( ( (Number) oldRow[ 0 ] ).intValue() ); row.add( rowDcv ); } else { DTCellValue52 rowDcv = new DTCellValue52( oldRow[ 0 ] ); row.add( rowDcv ); } for ( int iCol = 1; iCol < oldRow.length; iCol++ ) { //The original model was purely String based. Conversion to typed fields //occurs when the Model is re-saved in Guvnor. Ideally the conversion //should occur here but that requires reference to a SuggestionCompletionEngine //which requires RepositoryServices. I did not want to make a dependency between //common IDE classes and the Repository DTCellValue52 dcv = new DTCellValue52( oldRow[ iCol ] ); row.add( dcv ); } return row; }
[ "public", "static", "List", "<", "DTCellValue52", ">", "makeDataRowList", "(", "Object", "[", "]", "oldRow", ")", "{", "List", "<", "DTCellValue52", ">", "row", "=", "new", "ArrayList", "<", "DTCellValue52", ">", "(", ")", ";", "//Row numbers are numerical", "if", "(", "oldRow", "[", "0", "]", "instanceof", "String", ")", "{", "DTCellValue52", "rowDcv", "=", "new", "DTCellValue52", "(", "new", "Integer", "(", "(", "String", ")", "oldRow", "[", "0", "]", ")", ")", ";", "row", ".", "add", "(", "rowDcv", ")", ";", "}", "else", "if", "(", "oldRow", "[", "0", "]", "instanceof", "Number", ")", "{", "DTCellValue52", "rowDcv", "=", "new", "DTCellValue52", "(", "(", "(", "Number", ")", "oldRow", "[", "0", "]", ")", ".", "intValue", "(", ")", ")", ";", "row", ".", "add", "(", "rowDcv", ")", ";", "}", "else", "{", "DTCellValue52", "rowDcv", "=", "new", "DTCellValue52", "(", "oldRow", "[", "0", "]", ")", ";", "row", ".", "add", "(", "rowDcv", ")", ";", "}", "for", "(", "int", "iCol", "=", "1", ";", "iCol", "<", "oldRow", ".", "length", ";", "iCol", "++", ")", "{", "//The original model was purely String based. Conversion to typed fields", "//occurs when the Model is re-saved in Guvnor. Ideally the conversion ", "//should occur here but that requires reference to a SuggestionCompletionEngine", "//which requires RepositoryServices. I did not want to make a dependency between", "//common IDE classes and the Repository", "DTCellValue52", "dcv", "=", "new", "DTCellValue52", "(", "oldRow", "[", "iCol", "]", ")", ";", "row", ".", "add", "(", "dcv", ")", ";", "}", "return", "row", ";", "}" ]
Convert a single dimension array of Strings to a List with type-safe entries. The first entry is converted into a numerical row number @param oldRow @return New row
[ "Convert", "a", "single", "dimension", "array", "of", "Strings", "to", "a", "List", "with", "type", "-", "safe", "entries", ".", "The", "first", "entry", "is", "converted", "into", "a", "numerical", "row", "number" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/DataUtilities.java#L50-L76
14,276
kiegroup/drools
drools-core/src/main/java/org/drools/core/phreak/SegmentUtilities.java
SegmentUtilities.createSegmentMemory
public static void createSegmentMemory(LeftTupleSource tupleSource, InternalWorkingMemory wm) { Memory mem = wm.getNodeMemory((MemoryFactory) tupleSource); SegmentMemory smem = mem.getSegmentMemory(); if ( smem == null ) { createSegmentMemory(tupleSource, mem, wm); } }
java
public static void createSegmentMemory(LeftTupleSource tupleSource, InternalWorkingMemory wm) { Memory mem = wm.getNodeMemory((MemoryFactory) tupleSource); SegmentMemory smem = mem.getSegmentMemory(); if ( smem == null ) { createSegmentMemory(tupleSource, mem, wm); } }
[ "public", "static", "void", "createSegmentMemory", "(", "LeftTupleSource", "tupleSource", ",", "InternalWorkingMemory", "wm", ")", "{", "Memory", "mem", "=", "wm", ".", "getNodeMemory", "(", "(", "MemoryFactory", ")", "tupleSource", ")", ";", "SegmentMemory", "smem", "=", "mem", ".", "getSegmentMemory", "(", ")", ";", "if", "(", "smem", "==", "null", ")", "{", "createSegmentMemory", "(", "tupleSource", ",", "mem", ",", "wm", ")", ";", "}", "}" ]
Initialises the NodeSegment memory for all nodes in the segment.
[ "Initialises", "the", "NodeSegment", "memory", "for", "all", "nodes", "in", "the", "segment", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/phreak/SegmentUtilities.java#L64-L70
14,277
kiegroup/drools
drools-core/src/main/java/org/drools/core/phreak/SegmentUtilities.java
SegmentUtilities.inSubNetwork
public static boolean inSubNetwork(RightInputAdapterNode riaNode, LeftTupleSource leftTupleSource) { LeftTupleSource startTupleSource = riaNode.getStartTupleSource(); LeftTupleSource parent = riaNode.getLeftTupleSource(); while (parent != startTupleSource) { if (parent == leftTupleSource) { return true; } parent = parent.getLeftTupleSource(); } return false; }
java
public static boolean inSubNetwork(RightInputAdapterNode riaNode, LeftTupleSource leftTupleSource) { LeftTupleSource startTupleSource = riaNode.getStartTupleSource(); LeftTupleSource parent = riaNode.getLeftTupleSource(); while (parent != startTupleSource) { if (parent == leftTupleSource) { return true; } parent = parent.getLeftTupleSource(); } return false; }
[ "public", "static", "boolean", "inSubNetwork", "(", "RightInputAdapterNode", "riaNode", ",", "LeftTupleSource", "leftTupleSource", ")", "{", "LeftTupleSource", "startTupleSource", "=", "riaNode", ".", "getStartTupleSource", "(", ")", ";", "LeftTupleSource", "parent", "=", "riaNode", ".", "getLeftTupleSource", "(", ")", ";", "while", "(", "parent", "!=", "startTupleSource", ")", "{", "if", "(", "parent", "==", "leftTupleSource", ")", "{", "return", "true", ";", "}", "parent", "=", "parent", ".", "getLeftTupleSource", "(", ")", ";", "}", "return", "false", ";", "}" ]
Is the LeftTupleSource a node in the sub network for the RightInputAdapterNode To be in the same network, it must be a node is after the two output of the parent and before the rianode.
[ "Is", "the", "LeftTupleSource", "a", "node", "in", "the", "sub", "network", "for", "the", "RightInputAdapterNode", "To", "be", "in", "the", "same", "network", "it", "must", "be", "a", "node", "is", "after", "the", "two", "output", "of", "the", "parent", "and", "before", "the", "rianode", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/phreak/SegmentUtilities.java#L363-L375
14,278
kiegroup/drools
drools-core/src/main/java/org/drools/core/phreak/SegmentUtilities.java
SegmentUtilities.updateRiaAndTerminalMemory
private static int updateRiaAndTerminalMemory( LeftTupleSource lt, LeftTupleSource originalLt, SegmentMemory smem, InternalWorkingMemory wm, boolean fromPrototype, int nodeTypesInSegment ) { nodeTypesInSegment = checkSegmentBoundary(lt, wm, nodeTypesInSegment); for (LeftTupleSink sink : lt.getSinkPropagator().getSinks()) { if (NodeTypeEnums.isLeftTupleSource(sink)) { nodeTypesInSegment = updateRiaAndTerminalMemory((LeftTupleSource) sink, originalLt, smem, wm, fromPrototype, nodeTypesInSegment); } else if (sink.getType() == NodeTypeEnums.RightInputAdaterNode) { // Even though we don't add the pmem and smem together, all pmem's for all pathend nodes must be initialized RiaNodeMemory riaMem = (RiaNodeMemory) wm.getNodeMemory((MemoryFactory) sink); // Only add the RIANode, if the LeftTupleSource is part of the RIANode subnetwork if (inSubNetwork((RightInputAdapterNode) sink, originalLt)) { PathMemory pmem = riaMem.getRiaPathMemory(); smem.addPathMemory( pmem ); if (smem.getPos() < pmem.getSegmentMemories().length) { pmem.setSegmentMemory( smem.getPos(), smem ); } if (fromPrototype) { ObjectSink[] nodes = ((RightInputAdapterNode) sink).getObjectSinkPropagator().getSinks(); for ( ObjectSink node : nodes ) { // check if the SegmentMemory has been already created by the BetaNode and if so avoid to build it twice if ( NodeTypeEnums.isLeftTupleSource(node) && wm.getNodeMemory((MemoryFactory) node).getSegmentMemory() == null ) { restoreSegmentFromPrototype(wm, (LeftTupleSource) node, nodeTypesInSegment); } } } else if ( ( pmem.getAllLinkedMaskTest() & ( 1L << pmem.getSegmentMemories().length ) ) == 0 ) { // must eagerly initialize child segment memories ObjectSink[] nodes = ((RightInputAdapterNode) sink).getObjectSinkPropagator().getSinks(); for ( ObjectSink node : nodes ) { if ( NodeTypeEnums.isLeftTupleSource(node) ) { createSegmentMemory( (LeftTupleSource) node, wm ); } } } } } else if (NodeTypeEnums.isTerminalNode(sink)) { PathMemory pmem = (PathMemory) wm.getNodeMemory((MemoryFactory) sink); smem.addPathMemory(pmem); // this terminal segment could have been created during a rule removal with the only purpose to be merged // with the former one and in this case doesn't have to be added to the the path memory if (smem.getPos() < pmem.getSegmentMemories().length) { pmem.setSegmentMemory( smem.getPos(), smem ); if (smem.isSegmentLinked()) { // not's can cause segments to be linked, and the rules need to be notified for evaluation smem.notifyRuleLinkSegment(wm); } checkEagerSegmentCreation(sink.getLeftTupleSource(), wm, nodeTypesInSegment); } } } return nodeTypesInSegment; }
java
private static int updateRiaAndTerminalMemory( LeftTupleSource lt, LeftTupleSource originalLt, SegmentMemory smem, InternalWorkingMemory wm, boolean fromPrototype, int nodeTypesInSegment ) { nodeTypesInSegment = checkSegmentBoundary(lt, wm, nodeTypesInSegment); for (LeftTupleSink sink : lt.getSinkPropagator().getSinks()) { if (NodeTypeEnums.isLeftTupleSource(sink)) { nodeTypesInSegment = updateRiaAndTerminalMemory((LeftTupleSource) sink, originalLt, smem, wm, fromPrototype, nodeTypesInSegment); } else if (sink.getType() == NodeTypeEnums.RightInputAdaterNode) { // Even though we don't add the pmem and smem together, all pmem's for all pathend nodes must be initialized RiaNodeMemory riaMem = (RiaNodeMemory) wm.getNodeMemory((MemoryFactory) sink); // Only add the RIANode, if the LeftTupleSource is part of the RIANode subnetwork if (inSubNetwork((RightInputAdapterNode) sink, originalLt)) { PathMemory pmem = riaMem.getRiaPathMemory(); smem.addPathMemory( pmem ); if (smem.getPos() < pmem.getSegmentMemories().length) { pmem.setSegmentMemory( smem.getPos(), smem ); } if (fromPrototype) { ObjectSink[] nodes = ((RightInputAdapterNode) sink).getObjectSinkPropagator().getSinks(); for ( ObjectSink node : nodes ) { // check if the SegmentMemory has been already created by the BetaNode and if so avoid to build it twice if ( NodeTypeEnums.isLeftTupleSource(node) && wm.getNodeMemory((MemoryFactory) node).getSegmentMemory() == null ) { restoreSegmentFromPrototype(wm, (LeftTupleSource) node, nodeTypesInSegment); } } } else if ( ( pmem.getAllLinkedMaskTest() & ( 1L << pmem.getSegmentMemories().length ) ) == 0 ) { // must eagerly initialize child segment memories ObjectSink[] nodes = ((RightInputAdapterNode) sink).getObjectSinkPropagator().getSinks(); for ( ObjectSink node : nodes ) { if ( NodeTypeEnums.isLeftTupleSource(node) ) { createSegmentMemory( (LeftTupleSource) node, wm ); } } } } } else if (NodeTypeEnums.isTerminalNode(sink)) { PathMemory pmem = (PathMemory) wm.getNodeMemory((MemoryFactory) sink); smem.addPathMemory(pmem); // this terminal segment could have been created during a rule removal with the only purpose to be merged // with the former one and in this case doesn't have to be added to the the path memory if (smem.getPos() < pmem.getSegmentMemories().length) { pmem.setSegmentMemory( smem.getPos(), smem ); if (smem.isSegmentLinked()) { // not's can cause segments to be linked, and the rules need to be notified for evaluation smem.notifyRuleLinkSegment(wm); } checkEagerSegmentCreation(sink.getLeftTupleSource(), wm, nodeTypesInSegment); } } } return nodeTypesInSegment; }
[ "private", "static", "int", "updateRiaAndTerminalMemory", "(", "LeftTupleSource", "lt", ",", "LeftTupleSource", "originalLt", ",", "SegmentMemory", "smem", ",", "InternalWorkingMemory", "wm", ",", "boolean", "fromPrototype", ",", "int", "nodeTypesInSegment", ")", "{", "nodeTypesInSegment", "=", "checkSegmentBoundary", "(", "lt", ",", "wm", ",", "nodeTypesInSegment", ")", ";", "for", "(", "LeftTupleSink", "sink", ":", "lt", ".", "getSinkPropagator", "(", ")", ".", "getSinks", "(", ")", ")", "{", "if", "(", "NodeTypeEnums", ".", "isLeftTupleSource", "(", "sink", ")", ")", "{", "nodeTypesInSegment", "=", "updateRiaAndTerminalMemory", "(", "(", "LeftTupleSource", ")", "sink", ",", "originalLt", ",", "smem", ",", "wm", ",", "fromPrototype", ",", "nodeTypesInSegment", ")", ";", "}", "else", "if", "(", "sink", ".", "getType", "(", ")", "==", "NodeTypeEnums", ".", "RightInputAdaterNode", ")", "{", "// Even though we don't add the pmem and smem together, all pmem's for all pathend nodes must be initialized", "RiaNodeMemory", "riaMem", "=", "(", "RiaNodeMemory", ")", "wm", ".", "getNodeMemory", "(", "(", "MemoryFactory", ")", "sink", ")", ";", "// Only add the RIANode, if the LeftTupleSource is part of the RIANode subnetwork", "if", "(", "inSubNetwork", "(", "(", "RightInputAdapterNode", ")", "sink", ",", "originalLt", ")", ")", "{", "PathMemory", "pmem", "=", "riaMem", ".", "getRiaPathMemory", "(", ")", ";", "smem", ".", "addPathMemory", "(", "pmem", ")", ";", "if", "(", "smem", ".", "getPos", "(", ")", "<", "pmem", ".", "getSegmentMemories", "(", ")", ".", "length", ")", "{", "pmem", ".", "setSegmentMemory", "(", "smem", ".", "getPos", "(", ")", ",", "smem", ")", ";", "}", "if", "(", "fromPrototype", ")", "{", "ObjectSink", "[", "]", "nodes", "=", "(", "(", "RightInputAdapterNode", ")", "sink", ")", ".", "getObjectSinkPropagator", "(", ")", ".", "getSinks", "(", ")", ";", "for", "(", "ObjectSink", "node", ":", "nodes", ")", "{", "// check if the SegmentMemory has been already created by the BetaNode and if so avoid to build it twice", "if", "(", "NodeTypeEnums", ".", "isLeftTupleSource", "(", "node", ")", "&&", "wm", ".", "getNodeMemory", "(", "(", "MemoryFactory", ")", "node", ")", ".", "getSegmentMemory", "(", ")", "==", "null", ")", "{", "restoreSegmentFromPrototype", "(", "wm", ",", "(", "LeftTupleSource", ")", "node", ",", "nodeTypesInSegment", ")", ";", "}", "}", "}", "else", "if", "(", "(", "pmem", ".", "getAllLinkedMaskTest", "(", ")", "&", "(", "1L", "<<", "pmem", ".", "getSegmentMemories", "(", ")", ".", "length", ")", ")", "==", "0", ")", "{", "// must eagerly initialize child segment memories", "ObjectSink", "[", "]", "nodes", "=", "(", "(", "RightInputAdapterNode", ")", "sink", ")", ".", "getObjectSinkPropagator", "(", ")", ".", "getSinks", "(", ")", ";", "for", "(", "ObjectSink", "node", ":", "nodes", ")", "{", "if", "(", "NodeTypeEnums", ".", "isLeftTupleSource", "(", "node", ")", ")", "{", "createSegmentMemory", "(", "(", "LeftTupleSource", ")", "node", ",", "wm", ")", ";", "}", "}", "}", "}", "}", "else", "if", "(", "NodeTypeEnums", ".", "isTerminalNode", "(", "sink", ")", ")", "{", "PathMemory", "pmem", "=", "(", "PathMemory", ")", "wm", ".", "getNodeMemory", "(", "(", "MemoryFactory", ")", "sink", ")", ";", "smem", ".", "addPathMemory", "(", "pmem", ")", ";", "// this terminal segment could have been created during a rule removal with the only purpose to be merged", "// with the former one and in this case doesn't have to be added to the the path memory", "if", "(", "smem", ".", "getPos", "(", ")", "<", "pmem", ".", "getSegmentMemories", "(", ")", ".", "length", ")", "{", "pmem", ".", "setSegmentMemory", "(", "smem", ".", "getPos", "(", ")", ",", "smem", ")", ";", "if", "(", "smem", ".", "isSegmentLinked", "(", ")", ")", "{", "// not's can cause segments to be linked, and the rules need to be notified for evaluation", "smem", ".", "notifyRuleLinkSegment", "(", "wm", ")", ";", "}", "checkEagerSegmentCreation", "(", "sink", ".", "getLeftTupleSource", "(", ")", ",", "wm", ",", "nodeTypesInSegment", ")", ";", "}", "}", "}", "return", "nodeTypesInSegment", ";", "}" ]
This adds the segment memory to the terminal node or ria node's list of memories. In the case of the terminal node this allows it to know that all segments from the tip to root are linked. In the case of the ria node its all the segments up to the start of the subnetwork. This is because the rianode only cares if all of it's segments are linked, then it sets the bit of node it is the right input for.
[ "This", "adds", "the", "segment", "memory", "to", "the", "terminal", "node", "or", "ria", "node", "s", "list", "of", "memories", ".", "In", "the", "case", "of", "the", "terminal", "node", "this", "allows", "it", "to", "know", "that", "all", "segments", "from", "the", "tip", "to", "root", "are", "linked", ".", "In", "the", "case", "of", "the", "ria", "node", "its", "all", "the", "segments", "up", "to", "the", "start", "of", "the", "subnetwork", ".", "This", "is", "because", "the", "rianode", "only", "cares", "if", "all", "of", "it", "s", "segments", "are", "linked", "then", "it", "sets", "the", "bit", "of", "node", "it", "is", "the", "right", "input", "for", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/phreak/SegmentUtilities.java#L385-L442
14,279
kiegroup/drools
drools-core/src/main/java/org/drools/core/phreak/SegmentUtilities.java
SegmentUtilities.isRootNode
public static boolean isRootNode(LeftTupleNode node, TerminalNode removingTN) { return node.getType() == NodeTypeEnums.LeftInputAdapterNode || isNonTerminalTipNode( node.getLeftTupleSource(), removingTN ); }
java
public static boolean isRootNode(LeftTupleNode node, TerminalNode removingTN) { return node.getType() == NodeTypeEnums.LeftInputAdapterNode || isNonTerminalTipNode( node.getLeftTupleSource(), removingTN ); }
[ "public", "static", "boolean", "isRootNode", "(", "LeftTupleNode", "node", ",", "TerminalNode", "removingTN", ")", "{", "return", "node", ".", "getType", "(", ")", "==", "NodeTypeEnums", ".", "LeftInputAdapterNode", "||", "isNonTerminalTipNode", "(", "node", ".", "getLeftTupleSource", "(", ")", ",", "removingTN", ")", ";", "}" ]
Returns whether the node is the root of a segment. Lians are always the root of a segment. node cannot be null. The result should discount any removingRule. That means it gives you the result as if the rule had already been removed from the network.
[ "Returns", "whether", "the", "node", "is", "the", "root", "of", "a", "segment", ".", "Lians", "are", "always", "the", "root", "of", "a", "segment", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/phreak/SegmentUtilities.java#L471-L473
14,280
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/rule/builder/RuleBuilder.java
RuleBuilder.build
public static void build(final RuleBuildContext context) { RuleDescr ruleDescr = context.getRuleDescr(); final RuleConditionBuilder builder = (RuleConditionBuilder) context.getDialect().getBuilder( ruleDescr.getLhs().getClass() ); if ( builder != null ) { Pattern prefixPattern = context.getPrefixPattern(); // this is established during pre-processing, if it's query final GroupElement ce = (GroupElement) builder.build( context, getLhsForRuleUnit( context.getRule(), ruleDescr.getLhs() ), prefixPattern ); context.getRule().setLhs( ce ); } else { throw new RuntimeException( "BUG: builder not found for descriptor class " + ruleDescr.getLhs().getClass() ); } // build all the rule's attributes // must be after building LHS because some attributes require bindings from the LHS buildAttributes( context ); // Build the consequence and generate it's invoker/s // generate the main rule from the previously generated s. if ( !(ruleDescr instanceof QueryDescr) ) { // do not build the consequence if we have a query ConsequenceBuilder consequenceBuilder = context.getDialect().getConsequenceBuilder(); consequenceBuilder.build( context, RuleImpl.DEFAULT_CONSEQUENCE_NAME ); for ( String name : ruleDescr.getNamedConsequences().keySet() ) { consequenceBuilder.build( context, name ); } } }
java
public static void build(final RuleBuildContext context) { RuleDescr ruleDescr = context.getRuleDescr(); final RuleConditionBuilder builder = (RuleConditionBuilder) context.getDialect().getBuilder( ruleDescr.getLhs().getClass() ); if ( builder != null ) { Pattern prefixPattern = context.getPrefixPattern(); // this is established during pre-processing, if it's query final GroupElement ce = (GroupElement) builder.build( context, getLhsForRuleUnit( context.getRule(), ruleDescr.getLhs() ), prefixPattern ); context.getRule().setLhs( ce ); } else { throw new RuntimeException( "BUG: builder not found for descriptor class " + ruleDescr.getLhs().getClass() ); } // build all the rule's attributes // must be after building LHS because some attributes require bindings from the LHS buildAttributes( context ); // Build the consequence and generate it's invoker/s // generate the main rule from the previously generated s. if ( !(ruleDescr instanceof QueryDescr) ) { // do not build the consequence if we have a query ConsequenceBuilder consequenceBuilder = context.getDialect().getConsequenceBuilder(); consequenceBuilder.build( context, RuleImpl.DEFAULT_CONSEQUENCE_NAME ); for ( String name : ruleDescr.getNamedConsequences().keySet() ) { consequenceBuilder.build( context, name ); } } }
[ "public", "static", "void", "build", "(", "final", "RuleBuildContext", "context", ")", "{", "RuleDescr", "ruleDescr", "=", "context", ".", "getRuleDescr", "(", ")", ";", "final", "RuleConditionBuilder", "builder", "=", "(", "RuleConditionBuilder", ")", "context", ".", "getDialect", "(", ")", ".", "getBuilder", "(", "ruleDescr", ".", "getLhs", "(", ")", ".", "getClass", "(", ")", ")", ";", "if", "(", "builder", "!=", "null", ")", "{", "Pattern", "prefixPattern", "=", "context", ".", "getPrefixPattern", "(", ")", ";", "// this is established during pre-processing, if it's query", "final", "GroupElement", "ce", "=", "(", "GroupElement", ")", "builder", ".", "build", "(", "context", ",", "getLhsForRuleUnit", "(", "context", ".", "getRule", "(", ")", ",", "ruleDescr", ".", "getLhs", "(", ")", ")", ",", "prefixPattern", ")", ";", "context", ".", "getRule", "(", ")", ".", "setLhs", "(", "ce", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"BUG: builder not found for descriptor class \"", "+", "ruleDescr", ".", "getLhs", "(", ")", ".", "getClass", "(", ")", ")", ";", "}", "// build all the rule's attributes", "// must be after building LHS because some attributes require bindings from the LHS", "buildAttributes", "(", "context", ")", ";", "// Build the consequence and generate it's invoker/s", "// generate the main rule from the previously generated s.", "if", "(", "!", "(", "ruleDescr", "instanceof", "QueryDescr", ")", ")", "{", "// do not build the consequence if we have a query", "ConsequenceBuilder", "consequenceBuilder", "=", "context", ".", "getDialect", "(", ")", ".", "getConsequenceBuilder", "(", ")", ";", "consequenceBuilder", ".", "build", "(", "context", ",", "RuleImpl", ".", "DEFAULT_CONSEQUENCE_NAME", ")", ";", "for", "(", "String", "name", ":", "ruleDescr", ".", "getNamedConsequences", "(", ")", ".", "keySet", "(", ")", ")", "{", "consequenceBuilder", ".", "build", "(", "context", ",", "name", ")", ";", "}", "}", "}" ]
Build the give rule into the
[ "Build", "the", "give", "rule", "into", "the" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/rule/builder/RuleBuilder.java#L101-L132
14,281
kiegroup/drools
drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetParserUtil.java
RuleSheetParserUtil.getImportList
public static List<Import> getImportList(final List<String> importCells) { final List<Import> importList = new ArrayList<Import>(); if ( importCells == null ) return importList; for( String importCell: importCells ){ final StringTokenizer tokens = new StringTokenizer( importCell, "," ); while ( tokens.hasMoreTokens() ) { final Import imp = new Import(); imp.setClassName( tokens.nextToken().trim() ); importList.add( imp ); } } return importList; }
java
public static List<Import> getImportList(final List<String> importCells) { final List<Import> importList = new ArrayList<Import>(); if ( importCells == null ) return importList; for( String importCell: importCells ){ final StringTokenizer tokens = new StringTokenizer( importCell, "," ); while ( tokens.hasMoreTokens() ) { final Import imp = new Import(); imp.setClassName( tokens.nextToken().trim() ); importList.add( imp ); } } return importList; }
[ "public", "static", "List", "<", "Import", ">", "getImportList", "(", "final", "List", "<", "String", ">", "importCells", ")", "{", "final", "List", "<", "Import", ">", "importList", "=", "new", "ArrayList", "<", "Import", ">", "(", ")", ";", "if", "(", "importCells", "==", "null", ")", "return", "importList", ";", "for", "(", "String", "importCell", ":", "importCells", ")", "{", "final", "StringTokenizer", "tokens", "=", "new", "StringTokenizer", "(", "importCell", ",", "\",\"", ")", ";", "while", "(", "tokens", ".", "hasMoreTokens", "(", ")", ")", "{", "final", "Import", "imp", "=", "new", "Import", "(", ")", ";", "imp", ".", "setClassName", "(", "tokens", ".", "nextToken", "(", ")", ".", "trim", "(", ")", ")", ";", "importList", ".", "add", "(", "imp", ")", ";", "}", "}", "return", "importList", ";", "}" ]
Create a list of Import model objects from cell contents. @param importCells The cells containing text for all the classes to import. @return A list of Import classes, which can be added to the ruleset.
[ "Create", "a", "list", "of", "Import", "model", "objects", "from", "cell", "contents", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetParserUtil.java#L52-L65
14,282
kiegroup/drools
drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetParserUtil.java
RuleSheetParserUtil.getVariableList
public static List<Global> getVariableList( final List<String> variableCells ){ final List<Global> variableList = new ArrayList<Global>(); if ( variableCells == null ) return variableList; for( String variableCell: variableCells ){ final StringTokenizer tokens = new StringTokenizer( variableCell, "," ); while ( tokens.hasMoreTokens() ) { final String token = tokens.nextToken(); final Global vars = new Global(); final StringTokenizer paramTokens = new StringTokenizer( token, " " ); vars.setClassName( paramTokens.nextToken() ); if ( !paramTokens.hasMoreTokens() ) { throw new DecisionTableParseException( "The format for global variables is incorrect. " + "It should be: [Class name, Class otherName]. But it was: [" + variableCell + "]" ); } vars.setIdentifier( paramTokens.nextToken() ); variableList.add( vars ); } } return variableList; }
java
public static List<Global> getVariableList( final List<String> variableCells ){ final List<Global> variableList = new ArrayList<Global>(); if ( variableCells == null ) return variableList; for( String variableCell: variableCells ){ final StringTokenizer tokens = new StringTokenizer( variableCell, "," ); while ( tokens.hasMoreTokens() ) { final String token = tokens.nextToken(); final Global vars = new Global(); final StringTokenizer paramTokens = new StringTokenizer( token, " " ); vars.setClassName( paramTokens.nextToken() ); if ( !paramTokens.hasMoreTokens() ) { throw new DecisionTableParseException( "The format for global variables is incorrect. " + "It should be: [Class name, Class otherName]. But it was: [" + variableCell + "]" ); } vars.setIdentifier( paramTokens.nextToken() ); variableList.add( vars ); } } return variableList; }
[ "public", "static", "List", "<", "Global", ">", "getVariableList", "(", "final", "List", "<", "String", ">", "variableCells", ")", "{", "final", "List", "<", "Global", ">", "variableList", "=", "new", "ArrayList", "<", "Global", ">", "(", ")", ";", "if", "(", "variableCells", "==", "null", ")", "return", "variableList", ";", "for", "(", "String", "variableCell", ":", "variableCells", ")", "{", "final", "StringTokenizer", "tokens", "=", "new", "StringTokenizer", "(", "variableCell", ",", "\",\"", ")", ";", "while", "(", "tokens", ".", "hasMoreTokens", "(", ")", ")", "{", "final", "String", "token", "=", "tokens", ".", "nextToken", "(", ")", ";", "final", "Global", "vars", "=", "new", "Global", "(", ")", ";", "final", "StringTokenizer", "paramTokens", "=", "new", "StringTokenizer", "(", "token", ",", "\" \"", ")", ";", "vars", ".", "setClassName", "(", "paramTokens", ".", "nextToken", "(", ")", ")", ";", "if", "(", "!", "paramTokens", ".", "hasMoreTokens", "(", ")", ")", "{", "throw", "new", "DecisionTableParseException", "(", "\"The format for global variables is incorrect. \"", "+", "\"It should be: [Class name, Class otherName]. But it was: [\"", "+", "variableCell", "+", "\"]\"", ")", ";", "}", "vars", ".", "setIdentifier", "(", "paramTokens", ".", "nextToken", "(", ")", ")", ";", "variableList", ".", "add", "(", "vars", ")", ";", "}", "}", "return", "variableList", ";", "}" ]
Create a list of Global model objects from cell contents. @param variableCella The cells containing text for all the global variables to set. @return A list of Variable classes, which can be added to the ruleset.
[ "Create", "a", "list", "of", "Global", "model", "objects", "from", "cell", "contents", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetParserUtil.java#L72-L91
14,283
kiegroup/drools
drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetParserUtil.java
RuleSheetParserUtil.rc2name
public static String rc2name( int row, int col ){ StringBuilder sb = new StringBuilder(); int b = 26; int p = 1; if( col >= b ){ col -= b; p *= b; } if( col >= b*b ){ col -= b*b; p *= b; } while( p > 0 ){ sb.append( (char)(col/p + (int)'A') ); col %= p; p /= b; } sb.append( row + 1 ); return sb.toString(); }
java
public static String rc2name( int row, int col ){ StringBuilder sb = new StringBuilder(); int b = 26; int p = 1; if( col >= b ){ col -= b; p *= b; } if( col >= b*b ){ col -= b*b; p *= b; } while( p > 0 ){ sb.append( (char)(col/p + (int)'A') ); col %= p; p /= b; } sb.append( row + 1 ); return sb.toString(); }
[ "public", "static", "String", "rc2name", "(", "int", "row", ",", "int", "col", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "int", "b", "=", "26", ";", "int", "p", "=", "1", ";", "if", "(", "col", ">=", "b", ")", "{", "col", "-=", "b", ";", "p", "*=", "b", ";", "}", "if", "(", "col", ">=", "b", "*", "b", ")", "{", "col", "-=", "b", "*", "b", ";", "p", "*=", "b", ";", "}", "while", "(", "p", ">", "0", ")", "{", "sb", ".", "append", "(", "(", "char", ")", "(", "col", "/", "p", "+", "(", "int", ")", "'", "'", ")", ")", ";", "col", "%=", "p", ";", "p", "/=", "b", ";", "}", "sb", ".", "append", "(", "row", "+", "1", ")", ";", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
Convert spreadsheet row, column numbers to a cell name. @param row row number @param col the column number. Start with zero. @return The spreadsheet name for this cell, "A" to "ZZZ".
[ "Convert", "spreadsheet", "row", "column", "numbers", "to", "a", "cell", "name", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/RuleSheetParserUtil.java#L121-L140
14,284
kiegroup/drools
drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java
ActionType.addNewActionType
public static void addNewActionType( final Map<Integer, ActionType> actionTypeMap, final String value, final int column, final int row ) { final String ucValue = value.toUpperCase(); Code code = tag2code.get( ucValue ); if ( code == null ) { code = tag2code.get( ucValue.substring( 0, 1 ) ); } if ( code != null ) { int count = 0; for ( ActionType at : actionTypeMap.values() ) { if ( at.getCode() == code ) { count++; } } if ( count >= code.getMaxCount() ) { throw new DecisionTableParseException( "Maximum number of " + code.getColHeader() + "/" + code.getColShort() + " columns is " + code.getMaxCount() + ", in cell " + RuleSheetParserUtil.rc2name( row, column ) ); } actionTypeMap.put( new Integer( column ), new ActionType( code ) ); } else { throw new DecisionTableParseException( "Invalid column header: " + value + ", should be CONDITION, ACTION or attribute, " + "in cell " + RuleSheetParserUtil.rc2name( row, column ) ); } }
java
public static void addNewActionType( final Map<Integer, ActionType> actionTypeMap, final String value, final int column, final int row ) { final String ucValue = value.toUpperCase(); Code code = tag2code.get( ucValue ); if ( code == null ) { code = tag2code.get( ucValue.substring( 0, 1 ) ); } if ( code != null ) { int count = 0; for ( ActionType at : actionTypeMap.values() ) { if ( at.getCode() == code ) { count++; } } if ( count >= code.getMaxCount() ) { throw new DecisionTableParseException( "Maximum number of " + code.getColHeader() + "/" + code.getColShort() + " columns is " + code.getMaxCount() + ", in cell " + RuleSheetParserUtil.rc2name( row, column ) ); } actionTypeMap.put( new Integer( column ), new ActionType( code ) ); } else { throw new DecisionTableParseException( "Invalid column header: " + value + ", should be CONDITION, ACTION or attribute, " + "in cell " + RuleSheetParserUtil.rc2name( row, column ) ); } }
[ "public", "static", "void", "addNewActionType", "(", "final", "Map", "<", "Integer", ",", "ActionType", ">", "actionTypeMap", ",", "final", "String", "value", ",", "final", "int", "column", ",", "final", "int", "row", ")", "{", "final", "String", "ucValue", "=", "value", ".", "toUpperCase", "(", ")", ";", "Code", "code", "=", "tag2code", ".", "get", "(", "ucValue", ")", ";", "if", "(", "code", "==", "null", ")", "{", "code", "=", "tag2code", ".", "get", "(", "ucValue", ".", "substring", "(", "0", ",", "1", ")", ")", ";", "}", "if", "(", "code", "!=", "null", ")", "{", "int", "count", "=", "0", ";", "for", "(", "ActionType", "at", ":", "actionTypeMap", ".", "values", "(", ")", ")", "{", "if", "(", "at", ".", "getCode", "(", ")", "==", "code", ")", "{", "count", "++", ";", "}", "}", "if", "(", "count", ">=", "code", ".", "getMaxCount", "(", ")", ")", "{", "throw", "new", "DecisionTableParseException", "(", "\"Maximum number of \"", "+", "code", ".", "getColHeader", "(", ")", "+", "\"/\"", "+", "code", ".", "getColShort", "(", ")", "+", "\" columns is \"", "+", "code", ".", "getMaxCount", "(", ")", "+", "\", in cell \"", "+", "RuleSheetParserUtil", ".", "rc2name", "(", "row", ",", "column", ")", ")", ";", "}", "actionTypeMap", ".", "put", "(", "new", "Integer", "(", "column", ")", ",", "new", "ActionType", "(", "code", ")", ")", ";", "}", "else", "{", "throw", "new", "DecisionTableParseException", "(", "\"Invalid column header: \"", "+", "value", "+", "\", should be CONDITION, ACTION or attribute, \"", "+", "\"in cell \"", "+", "RuleSheetParserUtil", ".", "rc2name", "(", "row", ",", "column", ")", ")", ";", "}", "}" ]
Create a new action type that matches this cell, and add it to the map, keyed on that column.
[ "Create", "a", "new", "action", "type", "that", "matches", "this", "cell", "and", "add", "it", "to", "the", "map", "keyed", "on", "that", "column", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java#L143-L172
14,285
kiegroup/drools
drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java
ActionType.addTemplate
public void addTemplate( int row, int column, String content ) { if ( this.sourceBuilder == null ) { throw new DecisionTableParseException( "Unexpected content \"" + content + "\" in cell " + RuleSheetParserUtil.rc2name( row, column ) + ", leave this cell blank" ); } this.sourceBuilder.addTemplate( row, column, content ); }
java
public void addTemplate( int row, int column, String content ) { if ( this.sourceBuilder == null ) { throw new DecisionTableParseException( "Unexpected content \"" + content + "\" in cell " + RuleSheetParserUtil.rc2name( row, column ) + ", leave this cell blank" ); } this.sourceBuilder.addTemplate( row, column, content ); }
[ "public", "void", "addTemplate", "(", "int", "row", ",", "int", "column", ",", "String", "content", ")", "{", "if", "(", "this", ".", "sourceBuilder", "==", "null", ")", "{", "throw", "new", "DecisionTableParseException", "(", "\"Unexpected content \\\"\"", "+", "content", "+", "\"\\\" in cell \"", "+", "RuleSheetParserUtil", ".", "rc2name", "(", "row", ",", "column", ")", "+", "\", leave this cell blank\"", ")", ";", "}", "this", ".", "sourceBuilder", ".", "addTemplate", "(", "row", ",", "column", ",", "content", ")", ";", "}" ]
This is where a code snippet template is added.
[ "This", "is", "where", "a", "code", "snippet", "template", "is", "added", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java#L177-L186
14,286
kiegroup/drools
drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java
ActionType.addCellValue
public void addCellValue( int row, int column, String content, boolean _escapeQuotesFlag, boolean trimCell ) { if ( _escapeQuotesFlag ) { //Michael Neale: // For single standard quotes we escape them - eg they may mean "inches" // as in "I want a Stonehenge replica 19" tall" int idx = content.indexOf( "\"" ); if ( idx > 0 && content.indexOf( "\"", idx ) > -1 ) { content = content.replace( "\"", "\\\"" ); } } this.sourceBuilder.addCellValue( row, column, content, trimCell ); }
java
public void addCellValue( int row, int column, String content, boolean _escapeQuotesFlag, boolean trimCell ) { if ( _escapeQuotesFlag ) { //Michael Neale: // For single standard quotes we escape them - eg they may mean "inches" // as in "I want a Stonehenge replica 19" tall" int idx = content.indexOf( "\"" ); if ( idx > 0 && content.indexOf( "\"", idx ) > -1 ) { content = content.replace( "\"", "\\\"" ); } } this.sourceBuilder.addCellValue( row, column, content, trimCell ); }
[ "public", "void", "addCellValue", "(", "int", "row", ",", "int", "column", ",", "String", "content", ",", "boolean", "_escapeQuotesFlag", ",", "boolean", "trimCell", ")", "{", "if", "(", "_escapeQuotesFlag", ")", "{", "//Michael Neale:", "// For single standard quotes we escape them - eg they may mean \"inches\" ", "// as in \"I want a Stonehenge replica 19\" tall\"", "int", "idx", "=", "content", ".", "indexOf", "(", "\"\\\"\"", ")", ";", "if", "(", "idx", ">", "0", "&&", "content", ".", "indexOf", "(", "\"\\\"\"", ",", "idx", ")", ">", "-", "1", ")", "{", "content", "=", "content", ".", "replace", "(", "\"\\\"\"", ",", "\"\\\\\\\"\"", ")", ";", "}", "}", "this", ".", "sourceBuilder", ".", "addCellValue", "(", "row", ",", "column", ",", "content", ",", "trimCell", ")", ";", "}" ]
Values are added to populate the template. The source builder contained needs to be "cleared" when the resultant snippet is extracted.
[ "Values", "are", "added", "to", "populate", "the", "template", ".", "The", "source", "builder", "contained", "needs", "to", "be", "cleared", "when", "the", "resultant", "snippet", "is", "extracted", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/ActionType.java#L199-L214
14,287
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DRL6StrictParser.java
DRL6StrictParser.typeArgument
public String typeArgument() throws RecognitionException { String typeArgument = ""; try { int first = input.index(), last = first; int next = input.LA(1); switch (next) { case DRL6Lexer.QUESTION: match(input, DRL6Lexer.QUESTION, null, null, DroolsEditorType.SYMBOL); if (state.failed) return typeArgument; if (helper.validateIdentifierKey(DroolsSoftKeywords.EXTENDS)) { match(input, DRL6Lexer.ID, DroolsSoftKeywords.EXTENDS, null, DroolsEditorType.SYMBOL); if (state.failed) return typeArgument; type(); if (state.failed) return typeArgument; } else if (helper.validateIdentifierKey(DroolsSoftKeywords.SUPER)) { match(input, DRL6Lexer.ID, DroolsSoftKeywords.SUPER, null, DroolsEditorType.SYMBOL); if (state.failed) return typeArgument; type(); if (state.failed) return typeArgument; } break; case DRL6Lexer.ID: type(); if (state.failed) return typeArgument; break; default: // TODO: raise error } last = input.LT(-1).getTokenIndex(); typeArgument = input.toString(first, last); } catch (RecognitionException re) { reportError(re); } return typeArgument; }
java
public String typeArgument() throws RecognitionException { String typeArgument = ""; try { int first = input.index(), last = first; int next = input.LA(1); switch (next) { case DRL6Lexer.QUESTION: match(input, DRL6Lexer.QUESTION, null, null, DroolsEditorType.SYMBOL); if (state.failed) return typeArgument; if (helper.validateIdentifierKey(DroolsSoftKeywords.EXTENDS)) { match(input, DRL6Lexer.ID, DroolsSoftKeywords.EXTENDS, null, DroolsEditorType.SYMBOL); if (state.failed) return typeArgument; type(); if (state.failed) return typeArgument; } else if (helper.validateIdentifierKey(DroolsSoftKeywords.SUPER)) { match(input, DRL6Lexer.ID, DroolsSoftKeywords.SUPER, null, DroolsEditorType.SYMBOL); if (state.failed) return typeArgument; type(); if (state.failed) return typeArgument; } break; case DRL6Lexer.ID: type(); if (state.failed) return typeArgument; break; default: // TODO: raise error } last = input.LT(-1).getTokenIndex(); typeArgument = input.toString(first, last); } catch (RecognitionException re) { reportError(re); } return typeArgument; }
[ "public", "String", "typeArgument", "(", ")", "throws", "RecognitionException", "{", "String", "typeArgument", "=", "\"\"", ";", "try", "{", "int", "first", "=", "input", ".", "index", "(", ")", ",", "last", "=", "first", ";", "int", "next", "=", "input", ".", "LA", "(", "1", ")", ";", "switch", "(", "next", ")", "{", "case", "DRL6Lexer", ".", "QUESTION", ":", "match", "(", "input", ",", "DRL6Lexer", ".", "QUESTION", ",", "null", ",", "null", ",", "DroolsEditorType", ".", "SYMBOL", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArgument", ";", "if", "(", "helper", ".", "validateIdentifierKey", "(", "DroolsSoftKeywords", ".", "EXTENDS", ")", ")", "{", "match", "(", "input", ",", "DRL6Lexer", ".", "ID", ",", "DroolsSoftKeywords", ".", "EXTENDS", ",", "null", ",", "DroolsEditorType", ".", "SYMBOL", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArgument", ";", "type", "(", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArgument", ";", "}", "else", "if", "(", "helper", ".", "validateIdentifierKey", "(", "DroolsSoftKeywords", ".", "SUPER", ")", ")", "{", "match", "(", "input", ",", "DRL6Lexer", ".", "ID", ",", "DroolsSoftKeywords", ".", "SUPER", ",", "null", ",", "DroolsEditorType", ".", "SYMBOL", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArgument", ";", "type", "(", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArgument", ";", "}", "break", ";", "case", "DRL6Lexer", ".", "ID", ":", "type", "(", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "typeArgument", ";", "break", ";", "default", ":", "// TODO: raise error", "}", "last", "=", "input", ".", "LT", "(", "-", "1", ")", ".", "getTokenIndex", "(", ")", ";", "typeArgument", "=", "input", ".", "toString", "(", "first", ",", "last", ")", ";", "}", "catch", "(", "RecognitionException", "re", ")", "{", "reportError", "(", "re", ")", ";", "}", "return", "typeArgument", ";", "}" ]
Matches a type argument typeArguments := QUESTION (( EXTENDS | SUPER ) type )? | type ; @return @throws org.antlr.runtime.RecognitionException
[ "Matches", "a", "type", "argument" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL6StrictParser.java#L4681-L4736
14,288
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DRL6StrictParser.java
DRL6StrictParser.qualifiedIdentifier
public String qualifiedIdentifier() throws RecognitionException { String qi = ""; try { Token first = match(input, DRL6Lexer.ID, null, new int[]{DRL6Lexer.DOT}, DroolsEditorType.IDENTIFIER); if (state.failed) return qi; Token last = first; while (input.LA(1) == DRL6Lexer.DOT && input.LA(2) == DRL6Lexer.ID) { last = match(input, DRL6Lexer.DOT, null, new int[]{DRL6Lexer.ID}, DroolsEditorType.IDENTIFIER); if (state.failed) return qi; last = match(input, DRL6Lexer.ID, null, new int[]{DRL6Lexer.DOT}, DroolsEditorType.IDENTIFIER); if (state.failed) return qi; } qi = input.toString(first, last); qi = qi.replace(" ", ""); } catch (RecognitionException re) { reportError(re); } return qi; }
java
public String qualifiedIdentifier() throws RecognitionException { String qi = ""; try { Token first = match(input, DRL6Lexer.ID, null, new int[]{DRL6Lexer.DOT}, DroolsEditorType.IDENTIFIER); if (state.failed) return qi; Token last = first; while (input.LA(1) == DRL6Lexer.DOT && input.LA(2) == DRL6Lexer.ID) { last = match(input, DRL6Lexer.DOT, null, new int[]{DRL6Lexer.ID}, DroolsEditorType.IDENTIFIER); if (state.failed) return qi; last = match(input, DRL6Lexer.ID, null, new int[]{DRL6Lexer.DOT}, DroolsEditorType.IDENTIFIER); if (state.failed) return qi; } qi = input.toString(first, last); qi = qi.replace(" ", ""); } catch (RecognitionException re) { reportError(re); } return qi; }
[ "public", "String", "qualifiedIdentifier", "(", ")", "throws", "RecognitionException", "{", "String", "qi", "=", "\"\"", ";", "try", "{", "Token", "first", "=", "match", "(", "input", ",", "DRL6Lexer", ".", "ID", ",", "null", ",", "new", "int", "[", "]", "{", "DRL6Lexer", ".", "DOT", "}", ",", "DroolsEditorType", ".", "IDENTIFIER", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "qi", ";", "Token", "last", "=", "first", ";", "while", "(", "input", ".", "LA", "(", "1", ")", "==", "DRL6Lexer", ".", "DOT", "&&", "input", ".", "LA", "(", "2", ")", "==", "DRL6Lexer", ".", "ID", ")", "{", "last", "=", "match", "(", "input", ",", "DRL6Lexer", ".", "DOT", ",", "null", ",", "new", "int", "[", "]", "{", "DRL6Lexer", ".", "ID", "}", ",", "DroolsEditorType", ".", "IDENTIFIER", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "qi", ";", "last", "=", "match", "(", "input", ",", "DRL6Lexer", ".", "ID", ",", "null", ",", "new", "int", "[", "]", "{", "DRL6Lexer", ".", "DOT", "}", ",", "DroolsEditorType", ".", "IDENTIFIER", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "qi", ";", "}", "qi", "=", "input", ".", "toString", "(", "first", ",", "last", ")", ";", "qi", "=", "qi", ".", "replace", "(", "\" \"", ",", "\"\"", ")", ";", "}", "catch", "(", "RecognitionException", "re", ")", "{", "reportError", "(", "re", ")", ";", "}", "return", "qi", ";", "}" ]
Matches a qualified identifier qualifiedIdentifier := ID ( DOT ID )* @return @throws org.antlr.runtime.RecognitionException
[ "Matches", "a", "qualified", "identifier" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL6StrictParser.java#L4746-L4782
14,289
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DRL6StrictParser.java
DRL6StrictParser.chunk
public String chunk(final int leftDelimiter, final int rightDelimiter, final int location) { String chunk = ""; int first = -1, last = first; try { match(input, leftDelimiter, null, null, DroolsEditorType.SYMBOL); if (state.failed) return chunk; if (state.backtracking == 0 && location >= 0) { helper.emit(location); } int nests = 0; first = input.index(); while (input.LA(1) != DRL6Lexer.EOF && (input.LA(1) != rightDelimiter || nests > 0)) { if (input.LA(1) == rightDelimiter) { nests--; } else if (input.LA(1) == leftDelimiter) { nests++; } input.consume(); } last = input.LT(-1).getTokenIndex(); for (int i = first; i < last + 1; i++) { helper.emit(input.get(i), DroolsEditorType.CODE_CHUNK); } match(input, rightDelimiter, null, null, DroolsEditorType.SYMBOL); if (state.failed) return chunk; } catch (RecognitionException re) { reportError(re); } finally { if (last >= first) { chunk = input.toString(first, last); } } return chunk; }
java
public String chunk(final int leftDelimiter, final int rightDelimiter, final int location) { String chunk = ""; int first = -1, last = first; try { match(input, leftDelimiter, null, null, DroolsEditorType.SYMBOL); if (state.failed) return chunk; if (state.backtracking == 0 && location >= 0) { helper.emit(location); } int nests = 0; first = input.index(); while (input.LA(1) != DRL6Lexer.EOF && (input.LA(1) != rightDelimiter || nests > 0)) { if (input.LA(1) == rightDelimiter) { nests--; } else if (input.LA(1) == leftDelimiter) { nests++; } input.consume(); } last = input.LT(-1).getTokenIndex(); for (int i = first; i < last + 1; i++) { helper.emit(input.get(i), DroolsEditorType.CODE_CHUNK); } match(input, rightDelimiter, null, null, DroolsEditorType.SYMBOL); if (state.failed) return chunk; } catch (RecognitionException re) { reportError(re); } finally { if (last >= first) { chunk = input.toString(first, last); } } return chunk; }
[ "public", "String", "chunk", "(", "final", "int", "leftDelimiter", ",", "final", "int", "rightDelimiter", ",", "final", "int", "location", ")", "{", "String", "chunk", "=", "\"\"", ";", "int", "first", "=", "-", "1", ",", "last", "=", "first", ";", "try", "{", "match", "(", "input", ",", "leftDelimiter", ",", "null", ",", "null", ",", "DroolsEditorType", ".", "SYMBOL", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "chunk", ";", "if", "(", "state", ".", "backtracking", "==", "0", "&&", "location", ">=", "0", ")", "{", "helper", ".", "emit", "(", "location", ")", ";", "}", "int", "nests", "=", "0", ";", "first", "=", "input", ".", "index", "(", ")", ";", "while", "(", "input", ".", "LA", "(", "1", ")", "!=", "DRL6Lexer", ".", "EOF", "&&", "(", "input", ".", "LA", "(", "1", ")", "!=", "rightDelimiter", "||", "nests", ">", "0", ")", ")", "{", "if", "(", "input", ".", "LA", "(", "1", ")", "==", "rightDelimiter", ")", "{", "nests", "--", ";", "}", "else", "if", "(", "input", ".", "LA", "(", "1", ")", "==", "leftDelimiter", ")", "{", "nests", "++", ";", "}", "input", ".", "consume", "(", ")", ";", "}", "last", "=", "input", ".", "LT", "(", "-", "1", ")", ".", "getTokenIndex", "(", ")", ";", "for", "(", "int", "i", "=", "first", ";", "i", "<", "last", "+", "1", ";", "i", "++", ")", "{", "helper", ".", "emit", "(", "input", ".", "get", "(", "i", ")", ",", "DroolsEditorType", ".", "CODE_CHUNK", ")", ";", "}", "match", "(", "input", ",", "rightDelimiter", ",", "null", ",", "null", ",", "DroolsEditorType", ".", "SYMBOL", ")", ";", "if", "(", "state", ".", "failed", ")", "return", "chunk", ";", "}", "catch", "(", "RecognitionException", "re", ")", "{", "reportError", "(", "re", ")", ";", "}", "finally", "{", "if", "(", "last", ">=", "first", ")", "{", "chunk", "=", "input", ".", "toString", "(", "first", ",", "last", ")", ";", "}", "}", "return", "chunk", ";", "}" ]
Matches a chunk started by the leftDelimiter and ended by the rightDelimiter. @param leftDelimiter @param rightDelimiter @param location @return the matched chunk without the delimiters
[ "Matches", "a", "chunk", "started", "by", "the", "leftDelimiter", "and", "ended", "by", "the", "rightDelimiter", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL6StrictParser.java#L4834-L4884
14,290
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DRL6StrictParser.java
DRL6StrictParser.match
Token match( TokenStream input, int ttype, String text, int[] follow, DroolsEditorType etype ) throws RecognitionException { Token matchedSymbol = null; matchedSymbol = input.LT(1); if (input.LA(1) == ttype && (text == null || text.equals(matchedSymbol.getText()))) { input.consume(); state.errorRecovery = false; state.failed = false; helper.emit(matchedSymbol, etype); return matchedSymbol; } if (state.backtracking > 0) { state.failed = true; return matchedSymbol; } matchedSymbol = recoverFromMismatchedToken(input, ttype, text, follow); helper.emit(matchedSymbol, etype); return matchedSymbol; }
java
Token match( TokenStream input, int ttype, String text, int[] follow, DroolsEditorType etype ) throws RecognitionException { Token matchedSymbol = null; matchedSymbol = input.LT(1); if (input.LA(1) == ttype && (text == null || text.equals(matchedSymbol.getText()))) { input.consume(); state.errorRecovery = false; state.failed = false; helper.emit(matchedSymbol, etype); return matchedSymbol; } if (state.backtracking > 0) { state.failed = true; return matchedSymbol; } matchedSymbol = recoverFromMismatchedToken(input, ttype, text, follow); helper.emit(matchedSymbol, etype); return matchedSymbol; }
[ "Token", "match", "(", "TokenStream", "input", ",", "int", "ttype", ",", "String", "text", ",", "int", "[", "]", "follow", ",", "DroolsEditorType", "etype", ")", "throws", "RecognitionException", "{", "Token", "matchedSymbol", "=", "null", ";", "matchedSymbol", "=", "input", ".", "LT", "(", "1", ")", ";", "if", "(", "input", ".", "LA", "(", "1", ")", "==", "ttype", "&&", "(", "text", "==", "null", "||", "text", ".", "equals", "(", "matchedSymbol", ".", "getText", "(", ")", ")", ")", ")", "{", "input", ".", "consume", "(", ")", ";", "state", ".", "errorRecovery", "=", "false", ";", "state", ".", "failed", "=", "false", ";", "helper", ".", "emit", "(", "matchedSymbol", ",", "etype", ")", ";", "return", "matchedSymbol", ";", "}", "if", "(", "state", ".", "backtracking", ">", "0", ")", "{", "state", ".", "failed", "=", "true", ";", "return", "matchedSymbol", ";", "}", "matchedSymbol", "=", "recoverFromMismatchedToken", "(", "input", ",", "ttype", ",", "text", ",", "follow", ")", ";", "helper", ".", "emit", "(", "matchedSymbol", ",", "etype", ")", ";", "return", "matchedSymbol", ";", "}" ]
Match current input symbol against ttype and optionally check the text of the token against text. Attempt single token insertion or deletion error recovery. If that fails, throw MismatchedTokenException.
[ "Match", "current", "input", "symbol", "against", "ttype", "and", "optionally", "check", "the", "text", "of", "the", "token", "against", "text", ".", "Attempt", "single", "token", "insertion", "or", "deletion", "error", "recovery", ".", "If", "that", "fails", "throw", "MismatchedTokenException", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DRL6StrictParser.java#L4895-L4921
14,291
kiegroup/drools
drools-templates/src/main/java/org/drools/template/jdbc/ResultSetGenerator.java
ResultSetGenerator.processData
private void processData(final ResultSet rs, List<DataListener> listeners) { try { ResultSetMetaData rsmd = rs.getMetaData(); int colCount = rsmd.getColumnCount(); int i = 0; while (rs.next()) { newRow(listeners, i, colCount); for (int cellNum = 1; cellNum < colCount + 1; cellNum++) { String cell; int sqlType = rsmd.getColumnType(cellNum); switch (sqlType) { case java.sql.Types.DATE: cell = rs.getDate(cellNum).toString(); break; case java.sql.Types.INTEGER: case java.sql.Types.DOUBLE: cell = String.valueOf(rs.getInt(cellNum)); break; default: cell = rs.getString(cellNum); } newCell(listeners, i, cellNum - 1, cell, DataListener.NON_MERGED); } i++; } } catch (SQLException e) { //TODO: you need to throw or handle } finishData(listeners); }
java
private void processData(final ResultSet rs, List<DataListener> listeners) { try { ResultSetMetaData rsmd = rs.getMetaData(); int colCount = rsmd.getColumnCount(); int i = 0; while (rs.next()) { newRow(listeners, i, colCount); for (int cellNum = 1; cellNum < colCount + 1; cellNum++) { String cell; int sqlType = rsmd.getColumnType(cellNum); switch (sqlType) { case java.sql.Types.DATE: cell = rs.getDate(cellNum).toString(); break; case java.sql.Types.INTEGER: case java.sql.Types.DOUBLE: cell = String.valueOf(rs.getInt(cellNum)); break; default: cell = rs.getString(cellNum); } newCell(listeners, i, cellNum - 1, cell, DataListener.NON_MERGED); } i++; } } catch (SQLException e) { //TODO: you need to throw or handle } finishData(listeners); }
[ "private", "void", "processData", "(", "final", "ResultSet", "rs", ",", "List", "<", "DataListener", ">", "listeners", ")", "{", "try", "{", "ResultSetMetaData", "rsmd", "=", "rs", ".", "getMetaData", "(", ")", ";", "int", "colCount", "=", "rsmd", ".", "getColumnCount", "(", ")", ";", "int", "i", "=", "0", ";", "while", "(", "rs", ".", "next", "(", ")", ")", "{", "newRow", "(", "listeners", ",", "i", ",", "colCount", ")", ";", "for", "(", "int", "cellNum", "=", "1", ";", "cellNum", "<", "colCount", "+", "1", ";", "cellNum", "++", ")", "{", "String", "cell", ";", "int", "sqlType", "=", "rsmd", ".", "getColumnType", "(", "cellNum", ")", ";", "switch", "(", "sqlType", ")", "{", "case", "java", ".", "sql", ".", "Types", ".", "DATE", ":", "cell", "=", "rs", ".", "getDate", "(", "cellNum", ")", ".", "toString", "(", ")", ";", "break", ";", "case", "java", ".", "sql", ".", "Types", ".", "INTEGER", ":", "case", "java", ".", "sql", ".", "Types", ".", "DOUBLE", ":", "cell", "=", "String", ".", "valueOf", "(", "rs", ".", "getInt", "(", "cellNum", ")", ")", ";", "break", ";", "default", ":", "cell", "=", "rs", ".", "getString", "(", "cellNum", ")", ";", "}", "newCell", "(", "listeners", ",", "i", ",", "cellNum", "-", "1", ",", "cell", ",", "DataListener", ".", "NON_MERGED", ")", ";", "}", "i", "++", ";", "}", "}", "catch", "(", "SQLException", "e", ")", "{", "//TODO: you need to throw or handle", "}", "finishData", "(", "listeners", ")", ";", "}" ]
Iterate through the resultset. @param rs the resultset for the table data @param listeners list of template data listener
[ "Iterate", "through", "the", "resultset", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-templates/src/main/java/org/drools/template/jdbc/ResultSetGenerator.java#L89-L130
14,292
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/builder/impl/TypeDeclarationUtils.java
TypeDeclarationUtils.toBuildableType
public static String toBuildableType(String className, ClassLoader loader) { int arrayDim = BuildUtils.externalArrayDimSize(className); String prefix = ""; String coreType = arrayDim == 0 ? className : className.substring(0, className.indexOf("[")); coreType = typeName2ClassName(coreType, loader); if (arrayDim > 0) { coreType = BuildUtils.getTypeDescriptor(coreType); for (int j = 0; j < arrayDim; j++) { prefix = "[" + prefix; } } else { return coreType; } return prefix + coreType; }
java
public static String toBuildableType(String className, ClassLoader loader) { int arrayDim = BuildUtils.externalArrayDimSize(className); String prefix = ""; String coreType = arrayDim == 0 ? className : className.substring(0, className.indexOf("[")); coreType = typeName2ClassName(coreType, loader); if (arrayDim > 0) { coreType = BuildUtils.getTypeDescriptor(coreType); for (int j = 0; j < arrayDim; j++) { prefix = "[" + prefix; } } else { return coreType; } return prefix + coreType; }
[ "public", "static", "String", "toBuildableType", "(", "String", "className", ",", "ClassLoader", "loader", ")", "{", "int", "arrayDim", "=", "BuildUtils", ".", "externalArrayDimSize", "(", "className", ")", ";", "String", "prefix", "=", "\"\"", ";", "String", "coreType", "=", "arrayDim", "==", "0", "?", "className", ":", "className", ".", "substring", "(", "0", ",", "className", ".", "indexOf", "(", "\"[\"", ")", ")", ";", "coreType", "=", "typeName2ClassName", "(", "coreType", ",", "loader", ")", ";", "if", "(", "arrayDim", ">", "0", ")", "{", "coreType", "=", "BuildUtils", ".", "getTypeDescriptor", "(", "coreType", ")", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "arrayDim", ";", "j", "++", ")", "{", "prefix", "=", "\"[\"", "+", "prefix", ";", "}", "}", "else", "{", "return", "coreType", ";", "}", "return", "prefix", "+", "coreType", ";", "}" ]
not the cleanest logic, but this is what the builders expect downstream
[ "not", "the", "cleanest", "logic", "but", "this", "is", "what", "the", "builders", "expect", "downstream" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/builder/impl/TypeDeclarationUtils.java#L273-L290
14,293
kiegroup/drools
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNEvaluatorCompiler.java
DMNEvaluatorCompiler.recurseUpToInferTypeRef
private static QName recurseUpToInferTypeRef(DMNModelImpl model, OutputClause originalElement, DMNElement recursionIdx) { if ( recursionIdx.getParent() instanceof Decision ) { InformationItem parentVariable = ((Decision) recursionIdx.getParent()).getVariable(); if ( parentVariable != null ) { return variableTypeRefOrErrIfNull(model, parentVariable); } else { return null; // simply to avoid NPE, the proper error is already managed in compilation } } else if ( recursionIdx.getParent() instanceof BusinessKnowledgeModel ) { InformationItem parentVariable = ((BusinessKnowledgeModel) recursionIdx.getParent()).getVariable(); if ( parentVariable != null ) { return variableTypeRefOrErrIfNull(model, parentVariable); } else { return null; // simply to avoid NPE, the proper error is already managed in compilation } } else if ( recursionIdx.getParent() instanceof ContextEntry ) { ContextEntry parentCtxEntry = (ContextEntry) recursionIdx.getParent(); if ( parentCtxEntry.getVariable() != null ) { return variableTypeRefOrErrIfNull(model, parentCtxEntry.getVariable()); } else { Context parentCtx = (Context) parentCtxEntry.getParent(); if ( parentCtx.getContextEntry().get(parentCtx.getContextEntry().size()-1).equals(parentCtxEntry) ) { // the ContextEntry is the last one in the Context, so I can recurse up-ward in the DMN model tree // please notice the recursion would be considering the parentCtxEntry's parent, which is the `parentCtx` so is effectively a 2x jump upward in the model tree return recurseUpToInferTypeRef(model, originalElement, parentCtx); } else { // error not last ContextEntry in context MsgUtil.reportMessage( logger, DMNMessage.Severity.ERROR, parentCtxEntry, model, null, null, Msg.MISSING_VARIABLE_ON_CONTEXT, parentCtxEntry ); return null; } } } else { // this is only for safety in case the recursion is escaping the allowed path for a broken model. MsgUtil.reportMessage( logger, DMNMessage.Severity.ERROR, originalElement, model, null, null, Msg.UNKNOWN_OUTPUT_TYPE_FOR_DT_ON_NODE, originalElement.getParentDRDElement().getIdentifierString() ); return null; } }
java
private static QName recurseUpToInferTypeRef(DMNModelImpl model, OutputClause originalElement, DMNElement recursionIdx) { if ( recursionIdx.getParent() instanceof Decision ) { InformationItem parentVariable = ((Decision) recursionIdx.getParent()).getVariable(); if ( parentVariable != null ) { return variableTypeRefOrErrIfNull(model, parentVariable); } else { return null; // simply to avoid NPE, the proper error is already managed in compilation } } else if ( recursionIdx.getParent() instanceof BusinessKnowledgeModel ) { InformationItem parentVariable = ((BusinessKnowledgeModel) recursionIdx.getParent()).getVariable(); if ( parentVariable != null ) { return variableTypeRefOrErrIfNull(model, parentVariable); } else { return null; // simply to avoid NPE, the proper error is already managed in compilation } } else if ( recursionIdx.getParent() instanceof ContextEntry ) { ContextEntry parentCtxEntry = (ContextEntry) recursionIdx.getParent(); if ( parentCtxEntry.getVariable() != null ) { return variableTypeRefOrErrIfNull(model, parentCtxEntry.getVariable()); } else { Context parentCtx = (Context) parentCtxEntry.getParent(); if ( parentCtx.getContextEntry().get(parentCtx.getContextEntry().size()-1).equals(parentCtxEntry) ) { // the ContextEntry is the last one in the Context, so I can recurse up-ward in the DMN model tree // please notice the recursion would be considering the parentCtxEntry's parent, which is the `parentCtx` so is effectively a 2x jump upward in the model tree return recurseUpToInferTypeRef(model, originalElement, parentCtx); } else { // error not last ContextEntry in context MsgUtil.reportMessage( logger, DMNMessage.Severity.ERROR, parentCtxEntry, model, null, null, Msg.MISSING_VARIABLE_ON_CONTEXT, parentCtxEntry ); return null; } } } else { // this is only for safety in case the recursion is escaping the allowed path for a broken model. MsgUtil.reportMessage( logger, DMNMessage.Severity.ERROR, originalElement, model, null, null, Msg.UNKNOWN_OUTPUT_TYPE_FOR_DT_ON_NODE, originalElement.getParentDRDElement().getIdentifierString() ); return null; } }
[ "private", "static", "QName", "recurseUpToInferTypeRef", "(", "DMNModelImpl", "model", ",", "OutputClause", "originalElement", ",", "DMNElement", "recursionIdx", ")", "{", "if", "(", "recursionIdx", ".", "getParent", "(", ")", "instanceof", "Decision", ")", "{", "InformationItem", "parentVariable", "=", "(", "(", "Decision", ")", "recursionIdx", ".", "getParent", "(", ")", ")", ".", "getVariable", "(", ")", ";", "if", "(", "parentVariable", "!=", "null", ")", "{", "return", "variableTypeRefOrErrIfNull", "(", "model", ",", "parentVariable", ")", ";", "}", "else", "{", "return", "null", ";", "// simply to avoid NPE, the proper error is already managed in compilation", "}", "}", "else", "if", "(", "recursionIdx", ".", "getParent", "(", ")", "instanceof", "BusinessKnowledgeModel", ")", "{", "InformationItem", "parentVariable", "=", "(", "(", "BusinessKnowledgeModel", ")", "recursionIdx", ".", "getParent", "(", ")", ")", ".", "getVariable", "(", ")", ";", "if", "(", "parentVariable", "!=", "null", ")", "{", "return", "variableTypeRefOrErrIfNull", "(", "model", ",", "parentVariable", ")", ";", "}", "else", "{", "return", "null", ";", "// simply to avoid NPE, the proper error is already managed in compilation", "}", "}", "else", "if", "(", "recursionIdx", ".", "getParent", "(", ")", "instanceof", "ContextEntry", ")", "{", "ContextEntry", "parentCtxEntry", "=", "(", "ContextEntry", ")", "recursionIdx", ".", "getParent", "(", ")", ";", "if", "(", "parentCtxEntry", ".", "getVariable", "(", ")", "!=", "null", ")", "{", "return", "variableTypeRefOrErrIfNull", "(", "model", ",", "parentCtxEntry", ".", "getVariable", "(", ")", ")", ";", "}", "else", "{", "Context", "parentCtx", "=", "(", "Context", ")", "parentCtxEntry", ".", "getParent", "(", ")", ";", "if", "(", "parentCtx", ".", "getContextEntry", "(", ")", ".", "get", "(", "parentCtx", ".", "getContextEntry", "(", ")", ".", "size", "(", ")", "-", "1", ")", ".", "equals", "(", "parentCtxEntry", ")", ")", "{", "// the ContextEntry is the last one in the Context, so I can recurse up-ward in the DMN model tree", "// please notice the recursion would be considering the parentCtxEntry's parent, which is the `parentCtx` so is effectively a 2x jump upward in the model tree", "return", "recurseUpToInferTypeRef", "(", "model", ",", "originalElement", ",", "parentCtx", ")", ";", "}", "else", "{", "// error not last ContextEntry in context", "MsgUtil", ".", "reportMessage", "(", "logger", ",", "DMNMessage", ".", "Severity", ".", "ERROR", ",", "parentCtxEntry", ",", "model", ",", "null", ",", "null", ",", "Msg", ".", "MISSING_VARIABLE_ON_CONTEXT", ",", "parentCtxEntry", ")", ";", "return", "null", ";", "}", "}", "}", "else", "{", "// this is only for safety in case the recursion is escaping the allowed path for a broken model.", "MsgUtil", ".", "reportMessage", "(", "logger", ",", "DMNMessage", ".", "Severity", ".", "ERROR", ",", "originalElement", ",", "model", ",", "null", ",", "null", ",", "Msg", ".", "UNKNOWN_OUTPUT_TYPE_FOR_DT_ON_NODE", ",", "originalElement", ".", "getParentDRDElement", "(", ")", ".", "getIdentifierString", "(", ")", ")", ";", "return", "null", ";", "}", "}" ]
Utility method for DecisionTable with only 1 output, to infer typeRef from parent @param model used for reporting errors @param originalElement the original OutputClause[0] single output for which the DecisionTable parameter recursionIdx is being processed for inferring the typeRef @param recursionIdx start of the recursion is the DecisionTable model node itself @return the inferred `typeRef` or null in case of errors. Errors are reported with standard notification mechanism via MsgUtil.reportMessage
[ "Utility", "method", "for", "DecisionTable", "with", "only", "1", "output", "to", "infer", "typeRef", "from", "parent" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNEvaluatorCompiler.java#L682-L732
14,294
kiegroup/drools
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNEvaluatorCompiler.java
DMNEvaluatorCompiler.variableTypeRefOrErrIfNull
private static QName variableTypeRefOrErrIfNull(DMNModelImpl model, InformationItem variable) { if ( variable.getTypeRef() != null ) { return variable.getTypeRef(); } else { MsgUtil.reportMessage( logger, DMNMessage.Severity.ERROR, variable, model, null, null, Msg.MISSING_TYPEREF_FOR_VARIABLE, variable.getName(), variable.getParentDRDElement().getIdentifierString() ); return null; } }
java
private static QName variableTypeRefOrErrIfNull(DMNModelImpl model, InformationItem variable) { if ( variable.getTypeRef() != null ) { return variable.getTypeRef(); } else { MsgUtil.reportMessage( logger, DMNMessage.Severity.ERROR, variable, model, null, null, Msg.MISSING_TYPEREF_FOR_VARIABLE, variable.getName(), variable.getParentDRDElement().getIdentifierString() ); return null; } }
[ "private", "static", "QName", "variableTypeRefOrErrIfNull", "(", "DMNModelImpl", "model", ",", "InformationItem", "variable", ")", "{", "if", "(", "variable", ".", "getTypeRef", "(", ")", "!=", "null", ")", "{", "return", "variable", ".", "getTypeRef", "(", ")", ";", "}", "else", "{", "MsgUtil", ".", "reportMessage", "(", "logger", ",", "DMNMessage", ".", "Severity", ".", "ERROR", ",", "variable", ",", "model", ",", "null", ",", "null", ",", "Msg", ".", "MISSING_TYPEREF_FOR_VARIABLE", ",", "variable", ".", "getName", "(", ")", ",", "variable", ".", "getParentDRDElement", "(", ")", ".", "getIdentifierString", "(", ")", ")", ";", "return", "null", ";", "}", "}" ]
Utility method to have a error message is reported if a DMN Variable is missing typeRef. @param model used for reporting errors @param variable the variable to extract typeRef @return the `variable.typeRef` or null in case of errors. Errors are reported with standard notification mechanism via MsgUtil.reportMessage
[ "Utility", "method", "to", "have", "a", "error", "message", "is", "reported", "if", "a", "DMN", "Variable", "is", "missing", "typeRef", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DMNEvaluatorCompiler.java#L740-L755
14,295
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/DateUtils.java
DateUtils.parseDate
public static Date parseDate(final String input) { try { return df.get().parse(input); } catch (final ParseException e) { try { // FIXME: Workaround to make the tests run with non-English locales return new SimpleDateFormat(DATE_FORMAT_MASK, Locale.UK).parse(input); } catch (ParseException e1) { throw new IllegalArgumentException("Invalid date input format: [" + input + "] it should follow: [" + DATE_FORMAT_MASK + "]"); } } }
java
public static Date parseDate(final String input) { try { return df.get().parse(input); } catch (final ParseException e) { try { // FIXME: Workaround to make the tests run with non-English locales return new SimpleDateFormat(DATE_FORMAT_MASK, Locale.UK).parse(input); } catch (ParseException e1) { throw new IllegalArgumentException("Invalid date input format: [" + input + "] it should follow: [" + DATE_FORMAT_MASK + "]"); } } }
[ "public", "static", "Date", "parseDate", "(", "final", "String", "input", ")", "{", "try", "{", "return", "df", ".", "get", "(", ")", ".", "parse", "(", "input", ")", ";", "}", "catch", "(", "final", "ParseException", "e", ")", "{", "try", "{", "// FIXME: Workaround to make the tests run with non-English locales", "return", "new", "SimpleDateFormat", "(", "DATE_FORMAT_MASK", ",", "Locale", ".", "UK", ")", ".", "parse", "(", "input", ")", ";", "}", "catch", "(", "ParseException", "e1", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Invalid date input format: [\"", "+", "input", "+", "\"] it should follow: [\"", "+", "DATE_FORMAT_MASK", "+", "\"]\"", ")", ";", "}", "}", "}" ]
Use the simple date formatter to read the date from a string
[ "Use", "the", "simple", "date", "formatter", "to", "read", "the", "date", "from", "a", "string" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/DateUtils.java#L62-L74
14,296
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/DateUtils.java
DateUtils.getRightDate
public static Date getRightDate(final Object object2) { if (object2 == null) { return null; } if (object2 instanceof String) { return parseDate((String) object2); } else if (object2 instanceof Date) { return (Date) object2; } else { throw new IllegalArgumentException("Unable to convert " + object2.getClass() + " to a Date."); } }
java
public static Date getRightDate(final Object object2) { if (object2 == null) { return null; } if (object2 instanceof String) { return parseDate((String) object2); } else if (object2 instanceof Date) { return (Date) object2; } else { throw new IllegalArgumentException("Unable to convert " + object2.getClass() + " to a Date."); } }
[ "public", "static", "Date", "getRightDate", "(", "final", "Object", "object2", ")", "{", "if", "(", "object2", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "object2", "instanceof", "String", ")", "{", "return", "parseDate", "(", "(", "String", ")", "object2", ")", ";", "}", "else", "if", "(", "object2", "instanceof", "Date", ")", "{", "return", "(", "Date", ")", "object2", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Unable to convert \"", "+", "object2", ".", "getClass", "(", ")", "+", "\" to a Date.\"", ")", ";", "}", "}" ]
Converts the right hand side date as appropriate
[ "Converts", "the", "right", "hand", "side", "date", "as", "appropriate" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/DateUtils.java#L82-L94
14,297
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/DateUtils.java
DateUtils.getDateFormatMask
public static String getDateFormatMask() { String fmt = System.getProperty("drools.dateformat"); if (fmt == null) { fmt = DEFAULT_FORMAT_MASK; } return fmt; }
java
public static String getDateFormatMask() { String fmt = System.getProperty("drools.dateformat"); if (fmt == null) { fmt = DEFAULT_FORMAT_MASK; } return fmt; }
[ "public", "static", "String", "getDateFormatMask", "(", ")", "{", "String", "fmt", "=", "System", ".", "getProperty", "(", "\"drools.dateformat\"", ")", ";", "if", "(", "fmt", "==", "null", ")", "{", "fmt", "=", "DEFAULT_FORMAT_MASK", ";", "}", "return", "fmt", ";", "}" ]
Check for the system property override, if it exists
[ "Check", "for", "the", "system", "property", "override", "if", "it", "exists" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/DateUtils.java#L97-L103
14,298
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/GuidedDecisionTableProviderImpl.java
GuidedDecisionTableProviderImpl.hasDSLSentences
public static boolean hasDSLSentences(final GuidedDecisionTable52 model) { for (CompositeColumn<? extends BaseColumn> column : model.getConditions()) { if (column instanceof BRLConditionColumn) { final BRLConditionColumn brlColumn = (BRLConditionColumn) column; for (IPattern pattern : brlColumn.getDefinition()) { if (pattern instanceof DSLSentence) { return true; } } } } for (ActionCol52 column : model.getActionCols()) { if (column instanceof BRLActionColumn) { final BRLActionColumn brlColumn = (BRLActionColumn) column; for (IAction action : brlColumn.getDefinition()) { if (action instanceof DSLSentence) { return true; } } } } return false; }
java
public static boolean hasDSLSentences(final GuidedDecisionTable52 model) { for (CompositeColumn<? extends BaseColumn> column : model.getConditions()) { if (column instanceof BRLConditionColumn) { final BRLConditionColumn brlColumn = (BRLConditionColumn) column; for (IPattern pattern : brlColumn.getDefinition()) { if (pattern instanceof DSLSentence) { return true; } } } } for (ActionCol52 column : model.getActionCols()) { if (column instanceof BRLActionColumn) { final BRLActionColumn brlColumn = (BRLActionColumn) column; for (IAction action : brlColumn.getDefinition()) { if (action instanceof DSLSentence) { return true; } } } } return false; }
[ "public", "static", "boolean", "hasDSLSentences", "(", "final", "GuidedDecisionTable52", "model", ")", "{", "for", "(", "CompositeColumn", "<", "?", "extends", "BaseColumn", ">", "column", ":", "model", ".", "getConditions", "(", ")", ")", "{", "if", "(", "column", "instanceof", "BRLConditionColumn", ")", "{", "final", "BRLConditionColumn", "brlColumn", "=", "(", "BRLConditionColumn", ")", "column", ";", "for", "(", "IPattern", "pattern", ":", "brlColumn", ".", "getDefinition", "(", ")", ")", "{", "if", "(", "pattern", "instanceof", "DSLSentence", ")", "{", "return", "true", ";", "}", "}", "}", "}", "for", "(", "ActionCol52", "column", ":", "model", ".", "getActionCols", "(", ")", ")", "{", "if", "(", "column", "instanceof", "BRLActionColumn", ")", "{", "final", "BRLActionColumn", "brlColumn", "=", "(", "BRLActionColumn", ")", "column", ";", "for", "(", "IAction", "action", ":", "brlColumn", ".", "getDefinition", "(", ")", ")", "{", "if", "(", "action", "instanceof", "DSLSentence", ")", "{", "return", "true", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
a DataModelOracle just to determine whether the model has DSLs is an expensive operation and not needed here.
[ "a", "DataModelOracle", "just", "to", "determine", "whether", "the", "model", "has", "DSLs", "is", "an", "expensive", "operation", "and", "not", "needed", "here", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/GuidedDecisionTableProviderImpl.java#L52-L74
14,299
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNStyle.java
DMNStyle.setFillColor
public void setFillColor(org.kie.dmn.model.api.dmndi.Color value) { this.fillColor = value; }
java
public void setFillColor(org.kie.dmn.model.api.dmndi.Color value) { this.fillColor = value; }
[ "public", "void", "setFillColor", "(", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "Color", "value", ")", "{", "this", ".", "fillColor", "=", "value", ";", "}" ]
Sets the value of the fillColor property. @param value allowed object is {@link Color }
[ "Sets", "the", "value", "of", "the", "fillColor", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNStyle.java#L56-L58