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,100
kiegroup/drools
drools-core/src/main/java/org/drools/core/base/evaluators/Operator.java
Operator.addOperatorToRegistry
public static Operator addOperatorToRegistry(final String operatorId, final boolean isNegated) { Operator op = new Operator( operatorId, isNegated ); CACHE.put( getKey( operatorId, isNegated ), op ); return op; }
java
public static Operator addOperatorToRegistry(final String operatorId, final boolean isNegated) { Operator op = new Operator( operatorId, isNegated ); CACHE.put( getKey( operatorId, isNegated ), op ); return op; }
[ "public", "static", "Operator", "addOperatorToRegistry", "(", "final", "String", "operatorId", ",", "final", "boolean", "isNegated", ")", "{", "Operator", "op", "=", "new", "Operator", "(", "operatorId", ",", "isNegated", ")", ";", "CACHE", ".", "put", "(", "getKey", "(", "operatorId", ",", "isNegated", ")", ",", "op", ")", ";", "return", "op", ";", "}" ]
Creates a new Operator instance for the given parameters, adds it to the registry and return it @param operatorId the identification symbol of the operator @param isNegated true if it is negated @return the newly created operator
[ "Creates", "a", "new", "Operator", "instance", "for", "the", "given", "parameters", "adds", "it", "to", "the", "registry", "and", "return", "it" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/base/evaluators/Operator.java#L86-L94
14,101
kiegroup/drools
drools-core/src/main/java/org/drools/core/base/evaluators/Operator.java
Operator.determineOperator
public static Operator determineOperator(final String operatorId, final boolean isNegated) { Operator op = CACHE.get( getKey( operatorId, isNegated ) ); return op; }
java
public static Operator determineOperator(final String operatorId, final boolean isNegated) { Operator op = CACHE.get( getKey( operatorId, isNegated ) ); return op; }
[ "public", "static", "Operator", "determineOperator", "(", "final", "String", "operatorId", ",", "final", "boolean", "isNegated", ")", "{", "Operator", "op", "=", "CACHE", ".", "get", "(", "getKey", "(", "operatorId", ",", "isNegated", ")", ")", ";", "return", "op", ";", "}" ]
Returns the operator instance for the given parameters @param operatorId the identification symbol of the operator @param isNegated true if it is negated @return the operator in case it exists
[ "Returns", "the", "operator", "instance", "for", "the", "given", "parameters" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/base/evaluators/Operator.java#L108-L113
14,102
kiegroup/drools
drools-core/src/main/java/org/drools/core/audit/WorkingMemoryLogger.java
WorkingMemoryLogger.filterLogEvent
private void filterLogEvent(final LogEvent logEvent) { for ( ILogEventFilter filter: this.filters) { // do nothing if one of the filters doesn't accept the event if ( !filter.acceptEvent( logEvent ) ) { return; } } // if all the filters accepted the event, signal the creation // of the event logEventCreated( logEvent ); }
java
private void filterLogEvent(final LogEvent logEvent) { for ( ILogEventFilter filter: this.filters) { // do nothing if one of the filters doesn't accept the event if ( !filter.acceptEvent( logEvent ) ) { return; } } // if all the filters accepted the event, signal the creation // of the event logEventCreated( logEvent ); }
[ "private", "void", "filterLogEvent", "(", "final", "LogEvent", "logEvent", ")", "{", "for", "(", "ILogEventFilter", "filter", ":", "this", ".", "filters", ")", "{", "// do nothing if one of the filters doesn't accept the event", "if", "(", "!", "filter", ".", "acceptEvent", "(", "logEvent", ")", ")", "{", "return", ";", "}", "}", "// if all the filters accepted the event, signal the creation", "// of the event", "logEventCreated", "(", "logEvent", ")", ";", "}" ]
This method is invoked every time a new log event is created. It filters out unwanted events. @param logEvent
[ "This", "method", "is", "invoked", "every", "time", "a", "new", "log", "event", "is", "created", ".", "It", "filters", "out", "unwanted", "events", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/audit/WorkingMemoryLogger.java#L196-L206
14,103
kiegroup/drools
drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java
DefaultRuleSheetListener.objectTypeRow
private void objectTypeRow(final int row, final int column, final String value, final int mergedColStart) { if ( value.contains( "$param" ) || value.contains( "$1" ) ) { throw new DecisionTableParseException( "It looks like you have snippets in the row that is " + "meant for object declarations." + " Please insert an additional row before the snippets, " + "at cell " + RuleSheetParserUtil.rc2name( row, column ) ); } ActionType action = getActionForColumn( row, column ); if ( mergedColStart == RuleSheetListener.NON_MERGED ) { if ( action.getCode() == Code.CONDITION ) { SourceBuilder src = new LhsBuilder( row-1, column, value ); action.setSourceBuilder( src ); this.sourceBuilders.add( src ); } else if ( action.getCode() == Code.ACTION ) { SourceBuilder src = new RhsBuilder( Code.ACTION, row-1, column, value ); action.setSourceBuilder( src ); this.sourceBuilders.add( src ); } } else { if ( column == mergedColStart ) { if ( action.getCode() == Code.CONDITION ) { action.setSourceBuilder( new LhsBuilder( row-1, column, value ) ); this.sourceBuilders.add( action.getSourceBuilder() ); } else if ( action.getCode() == Code.ACTION ) { action.setSourceBuilder( new RhsBuilder( Code.ACTION, row-1, column, value ) ); this.sourceBuilders.add( action.getSourceBuilder() ); } } else { ActionType startOfMergeAction = getActionForColumn( row, mergedColStart ); action.setSourceBuilder( startOfMergeAction.getSourceBuilder() ); } } }
java
private void objectTypeRow(final int row, final int column, final String value, final int mergedColStart) { if ( value.contains( "$param" ) || value.contains( "$1" ) ) { throw new DecisionTableParseException( "It looks like you have snippets in the row that is " + "meant for object declarations." + " Please insert an additional row before the snippets, " + "at cell " + RuleSheetParserUtil.rc2name( row, column ) ); } ActionType action = getActionForColumn( row, column ); if ( mergedColStart == RuleSheetListener.NON_MERGED ) { if ( action.getCode() == Code.CONDITION ) { SourceBuilder src = new LhsBuilder( row-1, column, value ); action.setSourceBuilder( src ); this.sourceBuilders.add( src ); } else if ( action.getCode() == Code.ACTION ) { SourceBuilder src = new RhsBuilder( Code.ACTION, row-1, column, value ); action.setSourceBuilder( src ); this.sourceBuilders.add( src ); } } else { if ( column == mergedColStart ) { if ( action.getCode() == Code.CONDITION ) { action.setSourceBuilder( new LhsBuilder( row-1, column, value ) ); this.sourceBuilders.add( action.getSourceBuilder() ); } else if ( action.getCode() == Code.ACTION ) { action.setSourceBuilder( new RhsBuilder( Code.ACTION, row-1, column, value ) ); this.sourceBuilders.add( action.getSourceBuilder() ); } } else { ActionType startOfMergeAction = getActionForColumn( row, mergedColStart ); action.setSourceBuilder( startOfMergeAction.getSourceBuilder() ); } } }
[ "private", "void", "objectTypeRow", "(", "final", "int", "row", ",", "final", "int", "column", ",", "final", "String", "value", ",", "final", "int", "mergedColStart", ")", "{", "if", "(", "value", ".", "contains", "(", "\"$param\"", ")", "||", "value", ".", "contains", "(", "\"$1\"", ")", ")", "{", "throw", "new", "DecisionTableParseException", "(", "\"It looks like you have snippets in the row that is \"", "+", "\"meant for object declarations.\"", "+", "\" Please insert an additional row before the snippets, \"", "+", "\"at cell \"", "+", "RuleSheetParserUtil", ".", "rc2name", "(", "row", ",", "column", ")", ")", ";", "}", "ActionType", "action", "=", "getActionForColumn", "(", "row", ",", "column", ")", ";", "if", "(", "mergedColStart", "==", "RuleSheetListener", ".", "NON_MERGED", ")", "{", "if", "(", "action", ".", "getCode", "(", ")", "==", "Code", ".", "CONDITION", ")", "{", "SourceBuilder", "src", "=", "new", "LhsBuilder", "(", "row", "-", "1", ",", "column", ",", "value", ")", ";", "action", ".", "setSourceBuilder", "(", "src", ")", ";", "this", ".", "sourceBuilders", ".", "add", "(", "src", ")", ";", "}", "else", "if", "(", "action", ".", "getCode", "(", ")", "==", "Code", ".", "ACTION", ")", "{", "SourceBuilder", "src", "=", "new", "RhsBuilder", "(", "Code", ".", "ACTION", ",", "row", "-", "1", ",", "column", ",", "value", ")", ";", "action", ".", "setSourceBuilder", "(", "src", ")", ";", "this", ".", "sourceBuilders", ".", "add", "(", "src", ")", ";", "}", "}", "else", "{", "if", "(", "column", "==", "mergedColStart", ")", "{", "if", "(", "action", ".", "getCode", "(", ")", "==", "Code", ".", "CONDITION", ")", "{", "action", ".", "setSourceBuilder", "(", "new", "LhsBuilder", "(", "row", "-", "1", ",", "column", ",", "value", ")", ")", ";", "this", ".", "sourceBuilders", ".", "add", "(", "action", ".", "getSourceBuilder", "(", ")", ")", ";", "}", "else", "if", "(", "action", ".", "getCode", "(", ")", "==", "Code", ".", "ACTION", ")", "{", "action", ".", "setSourceBuilder", "(", "new", "RhsBuilder", "(", "Code", ".", "ACTION", ",", "row", "-", "1", ",", "column", ",", "value", ")", ")", ";", "this", ".", "sourceBuilders", ".", "add", "(", "action", ".", "getSourceBuilder", "(", ")", ")", ";", "}", "}", "else", "{", "ActionType", "startOfMergeAction", "=", "getActionForColumn", "(", "row", ",", "mergedColStart", ")", ";", "action", ".", "setSourceBuilder", "(", "startOfMergeAction", ".", "getSourceBuilder", "(", ")", ")", ";", "}", "}", "}" ]
This is for handling a row where an object declaration may appear, this is the row immediately above the snippets. It may be blank, but there has to be a row here. Merged cells have "special meaning" which is why this is so freaking hard. A future refactor may be to move away from an "event" based listener.
[ "This", "is", "for", "handling", "a", "row", "where", "an", "object", "declaration", "may", "appear", "this", "is", "the", "row", "immediately", "above", "the", "snippets", ".", "It", "may", "be", "blank", "but", "there", "has", "to", "be", "a", "row", "here", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-decisiontables/src/main/java/org/drools/decisiontable/parser/DefaultRuleSheetListener.java#L494-L529
14,104
kiegroup/drools
drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserTokenManagerBase.java
GeneratedDrlConstraintParserTokenManagerBase.tokenRange
private static TokenRange tokenRange(Token token) { JavaToken javaToken = token.javaToken; return new TokenRange(javaToken, javaToken); }
java
private static TokenRange tokenRange(Token token) { JavaToken javaToken = token.javaToken; return new TokenRange(javaToken, javaToken); }
[ "private", "static", "TokenRange", "tokenRange", "(", "Token", "token", ")", "{", "JavaToken", "javaToken", "=", "token", ".", "javaToken", ";", "return", "new", "TokenRange", "(", "javaToken", ",", "javaToken", ")", ";", "}" ]
Create a TokenRange that spans exactly one token
[ "Create", "a", "TokenRange", "that", "spans", "exactly", "one", "token" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserTokenManagerBase.java#L49-L52
14,105
kiegroup/drools
drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserTokenManagerBase.java
GeneratedDrlConstraintParserTokenManagerBase.createCommentFromToken
static Comment createCommentFromToken(Token token) { String commentText = token.image; if (token.kind == JAVADOC_COMMENT) { return new JavadocComment(tokenRange(token), commentText.substring(3, commentText.length() - 2)); } else if (token.kind == MULTI_LINE_COMMENT) { return new BlockComment(tokenRange(token), commentText.substring(2, commentText.length() - 2)); } else if (token.kind == SINGLE_LINE_COMMENT) { // line comments have their end of line character(s) included, and we don't want that. Range range = new Range(pos(token.beginLine, token.beginColumn), pos(token.endLine, token.endColumn)); while (commentText.endsWith("\r") || commentText.endsWith("\n")) { commentText = commentText.substring(0, commentText.length() - 1); } range = range.withEnd(pos(range.begin.line, range.begin.column + commentText.length())); LineComment comment = new LineComment(tokenRange(token), commentText.substring(2)); comment.setRange(range); return comment; } throw new AssertionError("Unexpectedly got passed a non-comment token."); }
java
static Comment createCommentFromToken(Token token) { String commentText = token.image; if (token.kind == JAVADOC_COMMENT) { return new JavadocComment(tokenRange(token), commentText.substring(3, commentText.length() - 2)); } else if (token.kind == MULTI_LINE_COMMENT) { return new BlockComment(tokenRange(token), commentText.substring(2, commentText.length() - 2)); } else if (token.kind == SINGLE_LINE_COMMENT) { // line comments have their end of line character(s) included, and we don't want that. Range range = new Range(pos(token.beginLine, token.beginColumn), pos(token.endLine, token.endColumn)); while (commentText.endsWith("\r") || commentText.endsWith("\n")) { commentText = commentText.substring(0, commentText.length() - 1); } range = range.withEnd(pos(range.begin.line, range.begin.column + commentText.length())); LineComment comment = new LineComment(tokenRange(token), commentText.substring(2)); comment.setRange(range); return comment; } throw new AssertionError("Unexpectedly got passed a non-comment token."); }
[ "static", "Comment", "createCommentFromToken", "(", "Token", "token", ")", "{", "String", "commentText", "=", "token", ".", "image", ";", "if", "(", "token", ".", "kind", "==", "JAVADOC_COMMENT", ")", "{", "return", "new", "JavadocComment", "(", "tokenRange", "(", "token", ")", ",", "commentText", ".", "substring", "(", "3", ",", "commentText", ".", "length", "(", ")", "-", "2", ")", ")", ";", "}", "else", "if", "(", "token", ".", "kind", "==", "MULTI_LINE_COMMENT", ")", "{", "return", "new", "BlockComment", "(", "tokenRange", "(", "token", ")", ",", "commentText", ".", "substring", "(", "2", ",", "commentText", ".", "length", "(", ")", "-", "2", ")", ")", ";", "}", "else", "if", "(", "token", ".", "kind", "==", "SINGLE_LINE_COMMENT", ")", "{", "// line comments have their end of line character(s) included, and we don't want that.", "Range", "range", "=", "new", "Range", "(", "pos", "(", "token", ".", "beginLine", ",", "token", ".", "beginColumn", ")", ",", "pos", "(", "token", ".", "endLine", ",", "token", ".", "endColumn", ")", ")", ";", "while", "(", "commentText", ".", "endsWith", "(", "\"\\r\"", ")", "||", "commentText", ".", "endsWith", "(", "\"\\n\"", ")", ")", "{", "commentText", "=", "commentText", ".", "substring", "(", "0", ",", "commentText", ".", "length", "(", ")", "-", "1", ")", ";", "}", "range", "=", "range", ".", "withEnd", "(", "pos", "(", "range", ".", "begin", ".", "line", ",", "range", ".", "begin", ".", "column", "+", "commentText", ".", "length", "(", ")", ")", ")", ";", "LineComment", "comment", "=", "new", "LineComment", "(", "tokenRange", "(", "token", ")", ",", "commentText", ".", "substring", "(", "2", ")", ")", ";", "comment", ".", "setRange", "(", "range", ")", ";", "return", "comment", ";", "}", "throw", "new", "AssertionError", "(", "\"Unexpectedly got passed a non-comment token.\"", ")", ";", "}" ]
Since comments are completely captured in a single token, including their delimiters, deconstruct them here so we can turn them into nodes later on.
[ "Since", "comments", "are", "completely", "captured", "in", "a", "single", "token", "including", "their", "delimiters", "deconstruct", "them", "here", "so", "we", "can", "turn", "them", "into", "nodes", "later", "on", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserTokenManagerBase.java#L58-L76
14,106
kiegroup/drools
drools-core/src/main/java/org/drools/core/event/AbstractEventSupport.java
AbstractEventSupport.removeEventListener
public final synchronized void removeEventListener(final Class cls) { for (int listenerIndex = 0; listenerIndex < this.listeners.size();) { E listener = this.listeners.get(listenerIndex); if (cls.isAssignableFrom(listener.getClass())) { this.listeners.remove(listenerIndex); } else { listenerIndex++; } } }
java
public final synchronized void removeEventListener(final Class cls) { for (int listenerIndex = 0; listenerIndex < this.listeners.size();) { E listener = this.listeners.get(listenerIndex); if (cls.isAssignableFrom(listener.getClass())) { this.listeners.remove(listenerIndex); } else { listenerIndex++; } } }
[ "public", "final", "synchronized", "void", "removeEventListener", "(", "final", "Class", "cls", ")", "{", "for", "(", "int", "listenerIndex", "=", "0", ";", "listenerIndex", "<", "this", ".", "listeners", ".", "size", "(", ")", ";", ")", "{", "E", "listener", "=", "this", ".", "listeners", ".", "get", "(", "listenerIndex", ")", ";", "if", "(", "cls", ".", "isAssignableFrom", "(", "listener", ".", "getClass", "(", ")", ")", ")", "{", "this", ".", "listeners", ".", "remove", "(", "listenerIndex", ")", ";", "}", "else", "{", "listenerIndex", "++", ";", "}", "}", "}" ]
Removes all event listeners of the specified class. Note that this method needs to be synchonized because it performs two independent operations on the underlying list @param cls class of listener to remove
[ "Removes", "all", "event", "listeners", "of", "the", "specified", "class", ".", "Note", "that", "this", "method", "needs", "to", "be", "synchonized", "because", "it", "performs", "two", "independent", "operations", "on", "the", "underlying", "list" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/event/AbstractEventSupport.java#L85-L95
14,107
kiegroup/drools
drools-examples/src/main/java/org/drools/examples/sudoku/Cell.java
Cell.makeReferences
public void makeReferences(CellRow row, CellCol col, CellSqr sqr) { this.cellRow = row; this.cellCol = col; this.cellSqr = sqr; this.exCells = new HashSet<Cell>(); this.exCells.addAll(this.cellRow.getCells()); this.exCells.addAll(this.cellCol.getCells()); this.exCells.addAll(this.cellSqr.getCells()); this.exCells.remove(this); }
java
public void makeReferences(CellRow row, CellCol col, CellSqr sqr) { this.cellRow = row; this.cellCol = col; this.cellSqr = sqr; this.exCells = new HashSet<Cell>(); this.exCells.addAll(this.cellRow.getCells()); this.exCells.addAll(this.cellCol.getCells()); this.exCells.addAll(this.cellSqr.getCells()); this.exCells.remove(this); }
[ "public", "void", "makeReferences", "(", "CellRow", "row", ",", "CellCol", "col", ",", "CellSqr", "sqr", ")", "{", "this", ".", "cellRow", "=", "row", ";", "this", ".", "cellCol", "=", "col", ";", "this", ".", "cellSqr", "=", "sqr", ";", "this", ".", "exCells", "=", "new", "HashSet", "<", "Cell", ">", "(", ")", ";", "this", ".", "exCells", ".", "addAll", "(", "this", ".", "cellRow", ".", "getCells", "(", ")", ")", ";", "this", ".", "exCells", ".", "addAll", "(", "this", ".", "cellCol", ".", "getCells", "(", ")", ")", ";", "this", ".", "exCells", ".", "addAll", "(", "this", ".", "cellSqr", ".", "getCells", "(", ")", ")", ";", "this", ".", "exCells", ".", "remove", "(", "this", ")", ";", "}" ]
Set references to all cell groups containing this cell. @param row the cell group for the row @param col the cell group for the column @param sqr the cell group for the square 3x3 area
[ "Set", "references", "to", "all", "cell", "groups", "containing", "this", "cell", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-examples/src/main/java/org/drools/examples/sudoku/Cell.java#L46-L55
14,108
kiegroup/drools
drools-verifier/drools-verifier-drl/src/main/java/org/drools/verifier/report/html/UrlFactory.java
UrlFactory.getUrl
public static String getUrl(Object o) { if ( o instanceof VerifierRule ) { VerifierRule rule = (VerifierRule) o; return getRuleUrl( UrlFactory.RULE_FOLDER, rule.getPath(), rule.getName() ); } return o.toString(); }
java
public static String getUrl(Object o) { if ( o instanceof VerifierRule ) { VerifierRule rule = (VerifierRule) o; return getRuleUrl( UrlFactory.RULE_FOLDER, rule.getPath(), rule.getName() ); } return o.toString(); }
[ "public", "static", "String", "getUrl", "(", "Object", "o", ")", "{", "if", "(", "o", "instanceof", "VerifierRule", ")", "{", "VerifierRule", "rule", "=", "(", "VerifierRule", ")", "o", ";", "return", "getRuleUrl", "(", "UrlFactory", ".", "RULE_FOLDER", ",", "rule", ".", "getPath", "(", ")", ",", "rule", ".", "getName", "(", ")", ")", ";", "}", "return", "o", ".", "toString", "(", ")", ";", "}" ]
Finds a link to object if one exists. @param o Object that might have a page that can be linked. @return Link to objects page or the toString() text if no link could not be created.
[ "Finds", "a", "link", "to", "object", "if", "one", "exists", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-verifier/drools-verifier-drl/src/main/java/org/drools/verifier/report/html/UrlFactory.java#L49-L58
14,109
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/ClassUtils.java
ClassUtils.loadClass
public static Class<?> loadClass(String className, ClassLoader classLoader) { Class cls = (Class) classes.get( className ); if ( cls == null ) { try { cls = Class.forName( className ); } catch ( Exception e ) { //swallow } //ConfFileFinder if ( cls == null && classLoader != null ) { try { cls = classLoader.loadClass( className ); } catch ( Exception e ) { //swallow } } if ( cls == null ) { try { cls = ClassUtils.class.getClassLoader().loadClass( className ); } catch ( Exception e ) { //swallow } } if ( cls == null ) { try { cls = Thread.currentThread().getContextClassLoader().loadClass( className ); } catch ( Exception e ) { //swallow } } if ( cls == null ) { try { cls = ClassLoader.getSystemClassLoader().loadClass( className ); } catch ( Exception e ) { //swallow } } if ( cls != null ) { classes.put( className, cls ); } else { throw new RuntimeException( "Unable to load class '" + className + "'" ); } } return cls; }
java
public static Class<?> loadClass(String className, ClassLoader classLoader) { Class cls = (Class) classes.get( className ); if ( cls == null ) { try { cls = Class.forName( className ); } catch ( Exception e ) { //swallow } //ConfFileFinder if ( cls == null && classLoader != null ) { try { cls = classLoader.loadClass( className ); } catch ( Exception e ) { //swallow } } if ( cls == null ) { try { cls = ClassUtils.class.getClassLoader().loadClass( className ); } catch ( Exception e ) { //swallow } } if ( cls == null ) { try { cls = Thread.currentThread().getContextClassLoader().loadClass( className ); } catch ( Exception e ) { //swallow } } if ( cls == null ) { try { cls = ClassLoader.getSystemClassLoader().loadClass( className ); } catch ( Exception e ) { //swallow } } if ( cls != null ) { classes.put( className, cls ); } else { throw new RuntimeException( "Unable to load class '" + className + "'" ); } } return cls; }
[ "public", "static", "Class", "<", "?", ">", "loadClass", "(", "String", "className", ",", "ClassLoader", "classLoader", ")", "{", "Class", "cls", "=", "(", "Class", ")", "classes", ".", "get", "(", "className", ")", ";", "if", "(", "cls", "==", "null", ")", "{", "try", "{", "cls", "=", "Class", ".", "forName", "(", "className", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "//swallow", "}", "//ConfFileFinder", "if", "(", "cls", "==", "null", "&&", "classLoader", "!=", "null", ")", "{", "try", "{", "cls", "=", "classLoader", ".", "loadClass", "(", "className", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "//swallow", "}", "}", "if", "(", "cls", "==", "null", ")", "{", "try", "{", "cls", "=", "ClassUtils", ".", "class", ".", "getClassLoader", "(", ")", ".", "loadClass", "(", "className", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "//swallow", "}", "}", "if", "(", "cls", "==", "null", ")", "{", "try", "{", "cls", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ".", "loadClass", "(", "className", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "//swallow", "}", "}", "if", "(", "cls", "==", "null", ")", "{", "try", "{", "cls", "=", "ClassLoader", ".", "getSystemClassLoader", "(", ")", ".", "loadClass", "(", "className", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "//swallow", "}", "}", "if", "(", "cls", "!=", "null", ")", "{", "classes", ".", "put", "(", "className", ",", "cls", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Unable to load class '\"", "+", "className", "+", "\"'\"", ")", ";", "}", "}", "return", "cls", ";", "}" ]
This method will attempt to load the specified Class. It uses a syncrhonized HashMap to cache the reflection Class lookup.
[ "This", "method", "will", "attempt", "to", "load", "the", "specified", "Class", ".", "It", "uses", "a", "syncrhonized", "HashMap", "to", "cache", "the", "reflection", "Class", "lookup", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/ClassUtils.java#L196-L246
14,110
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/ClassUtils.java
ClassUtils.instantiateObject
public static Object instantiateObject(String className, ClassLoader classLoader) { Object object; try { object = loadClass(className, classLoader).newInstance(); } catch ( Throwable e ) { throw new RuntimeException( "Unable to instantiate object for class '" + className + "'", e ); } return object; }
java
public static Object instantiateObject(String className, ClassLoader classLoader) { Object object; try { object = loadClass(className, classLoader).newInstance(); } catch ( Throwable e ) { throw new RuntimeException( "Unable to instantiate object for class '" + className + "'", e ); } return object; }
[ "public", "static", "Object", "instantiateObject", "(", "String", "className", ",", "ClassLoader", "classLoader", ")", "{", "Object", "object", ";", "try", "{", "object", "=", "loadClass", "(", "className", ",", "classLoader", ")", ".", "newInstance", "(", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Unable to instantiate object for class '\"", "+", "className", "+", "\"'\"", ",", "e", ")", ";", "}", "return", "object", ";", "}" ]
This method will attempt to create an instance of the specified Class. It uses a syncrhonized HashMap to cache the reflection Class lookup.
[ "This", "method", "will", "attempt", "to", "create", "an", "instance", "of", "the", "specified", "Class", ".", "It", "uses", "a", "syncrhonized", "HashMap", "to", "cache", "the", "reflection", "Class", "lookup", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/ClassUtils.java#L257-L267
14,111
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/ClassUtils.java
ClassUtils.addImportStylePatterns
public static void addImportStylePatterns(Map<String, Object> patterns, String str) { if ( str == null || "".equals( str.trim() ) ) { return; } String[] items = str.split( " " ); for (String item : items) { String qualifiedNamespace = item.substring(0, item.lastIndexOf('.')).trim(); String name = item.substring(item.lastIndexOf('.') + 1).trim(); Object object = patterns.get(qualifiedNamespace); if (object == null) { if (STAR.equals(name)) { patterns.put(qualifiedNamespace, STAR); } else { // create a new list and add it List<String> list = new ArrayList<String>(); list.add(name); patterns.put(qualifiedNamespace, list); } } else if (name.equals(STAR)) { // if its a STAR now add it anyway, we don't care if it was a STAR or a List before patterns.put(qualifiedNamespace, STAR); } else { // its a list so add it if it doesn't already exist List list = (List) object; if (!list.contains(name)) { list.add(name); } } } }
java
public static void addImportStylePatterns(Map<String, Object> patterns, String str) { if ( str == null || "".equals( str.trim() ) ) { return; } String[] items = str.split( " " ); for (String item : items) { String qualifiedNamespace = item.substring(0, item.lastIndexOf('.')).trim(); String name = item.substring(item.lastIndexOf('.') + 1).trim(); Object object = patterns.get(qualifiedNamespace); if (object == null) { if (STAR.equals(name)) { patterns.put(qualifiedNamespace, STAR); } else { // create a new list and add it List<String> list = new ArrayList<String>(); list.add(name); patterns.put(qualifiedNamespace, list); } } else if (name.equals(STAR)) { // if its a STAR now add it anyway, we don't care if it was a STAR or a List before patterns.put(qualifiedNamespace, STAR); } else { // its a list so add it if it doesn't already exist List list = (List) object; if (!list.contains(name)) { list.add(name); } } } }
[ "public", "static", "void", "addImportStylePatterns", "(", "Map", "<", "String", ",", "Object", ">", "patterns", ",", "String", "str", ")", "{", "if", "(", "str", "==", "null", "||", "\"\"", ".", "equals", "(", "str", ".", "trim", "(", ")", ")", ")", "{", "return", ";", "}", "String", "[", "]", "items", "=", "str", ".", "split", "(", "\" \"", ")", ";", "for", "(", "String", "item", ":", "items", ")", "{", "String", "qualifiedNamespace", "=", "item", ".", "substring", "(", "0", ",", "item", ".", "lastIndexOf", "(", "'", "'", ")", ")", ".", "trim", "(", ")", ";", "String", "name", "=", "item", ".", "substring", "(", "item", ".", "lastIndexOf", "(", "'", "'", ")", "+", "1", ")", ".", "trim", "(", ")", ";", "Object", "object", "=", "patterns", ".", "get", "(", "qualifiedNamespace", ")", ";", "if", "(", "object", "==", "null", ")", "{", "if", "(", "STAR", ".", "equals", "(", "name", ")", ")", "{", "patterns", ".", "put", "(", "qualifiedNamespace", ",", "STAR", ")", ";", "}", "else", "{", "// create a new list and add it", "List", "<", "String", ">", "list", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "list", ".", "add", "(", "name", ")", ";", "patterns", ".", "put", "(", "qualifiedNamespace", ",", "list", ")", ";", "}", "}", "else", "if", "(", "name", ".", "equals", "(", "STAR", ")", ")", "{", "// if its a STAR now add it anyway, we don't care if it was a STAR or a List before", "patterns", ".", "put", "(", "qualifiedNamespace", ",", "STAR", ")", ";", "}", "else", "{", "// its a list so add it if it doesn't already exist", "List", "list", "=", "(", "List", ")", "object", ";", "if", "(", "!", "list", ".", "contains", "(", "name", ")", ")", "{", "list", ".", "add", "(", "name", ")", ";", "}", "}", "}", "}" ]
Populates the import style pattern map from give comma delimited string
[ "Populates", "the", "import", "style", "pattern", "map", "from", "give", "comma", "delimited", "string" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/ClassUtils.java#L308-L341
14,112
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/ClassUtils.java
ClassUtils.isMatched
public static boolean isMatched(Map<String, Object> patterns, String className) { // Array [] object class names are "[x", where x is the first letter of the array type // -> NO '.' in class name, thus! // see http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29 String qualifiedNamespace = className; String name = className; if( className.indexOf('.') > 0 ) { qualifiedNamespace = className.substring( 0, className.lastIndexOf( '.' ) ).trim(); name = className.substring( className.lastIndexOf( '.' ) + 1 ).trim(); } else if( className.indexOf('[') == 0 ) { qualifiedNamespace = className.substring(0, className.lastIndexOf('[') ); } Object object = patterns.get( qualifiedNamespace ); if ( object == null ) { return true; } else if ( STAR.equals( object ) ) { return false; } else if ( patterns.containsKey( "*" ) ) { // for now we assume if the name space is * then we have a catchall *.* pattern return true; } else { List list = (List) object; return !list.contains( name ); } }
java
public static boolean isMatched(Map<String, Object> patterns, String className) { // Array [] object class names are "[x", where x is the first letter of the array type // -> NO '.' in class name, thus! // see http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29 String qualifiedNamespace = className; String name = className; if( className.indexOf('.') > 0 ) { qualifiedNamespace = className.substring( 0, className.lastIndexOf( '.' ) ).trim(); name = className.substring( className.lastIndexOf( '.' ) + 1 ).trim(); } else if( className.indexOf('[') == 0 ) { qualifiedNamespace = className.substring(0, className.lastIndexOf('[') ); } Object object = patterns.get( qualifiedNamespace ); if ( object == null ) { return true; } else if ( STAR.equals( object ) ) { return false; } else if ( patterns.containsKey( "*" ) ) { // for now we assume if the name space is * then we have a catchall *.* pattern return true; } else { List list = (List) object; return !list.contains( name ); } }
[ "public", "static", "boolean", "isMatched", "(", "Map", "<", "String", ",", "Object", ">", "patterns", ",", "String", "className", ")", "{", "// Array [] object class names are \"[x\", where x is the first letter of the array type", "// -> NO '.' in class name, thus!", "// see http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getName%28%29", "String", "qualifiedNamespace", "=", "className", ";", "String", "name", "=", "className", ";", "if", "(", "className", ".", "indexOf", "(", "'", "'", ")", ">", "0", ")", "{", "qualifiedNamespace", "=", "className", ".", "substring", "(", "0", ",", "className", ".", "lastIndexOf", "(", "'", "'", ")", ")", ".", "trim", "(", ")", ";", "name", "=", "className", ".", "substring", "(", "className", ".", "lastIndexOf", "(", "'", "'", ")", "+", "1", ")", ".", "trim", "(", ")", ";", "}", "else", "if", "(", "className", ".", "indexOf", "(", "'", "'", ")", "==", "0", ")", "{", "qualifiedNamespace", "=", "className", ".", "substring", "(", "0", ",", "className", ".", "lastIndexOf", "(", "'", "'", ")", ")", ";", "}", "Object", "object", "=", "patterns", ".", "get", "(", "qualifiedNamespace", ")", ";", "if", "(", "object", "==", "null", ")", "{", "return", "true", ";", "}", "else", "if", "(", "STAR", ".", "equals", "(", "object", ")", ")", "{", "return", "false", ";", "}", "else", "if", "(", "patterns", ".", "containsKey", "(", "\"*\"", ")", ")", "{", "// for now we assume if the name space is * then we have a catchall *.* pattern", "return", "true", ";", "}", "else", "{", "List", "list", "=", "(", "List", ")", "object", ";", "return", "!", "list", ".", "contains", "(", "name", ")", ";", "}", "}" ]
Determines if a given full qualified class name matches any import style patterns.
[ "Determines", "if", "a", "given", "full", "qualified", "class", "name", "matches", "any", "import", "style", "patterns", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/ClassUtils.java#L346-L372
14,113
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/ClassUtils.java
ClassUtils.getPackage
public static String getPackage(Class<?> cls) { // cls.getPackage() sometimes returns null, in which case fall back to string massaging. java.lang.Package pkg = cls.isArray() ? cls.getComponentType().getPackage() : cls.getPackage(); if ( pkg == null ) { int dotPos; int dolPos = cls.getName().indexOf( '$' ); if ( dolPos > 0 ) { // we have nested classes, so adjust dotpos to before first $ dotPos = cls.getName().substring( 0, dolPos ).lastIndexOf( '.' ); } else { dotPos = cls.getName().lastIndexOf( '.' ); } if ( dotPos > 0 ) { return cls.getName().substring( 0, dotPos ); } else { // must be default package. return ""; } } else { return pkg.getName(); } }
java
public static String getPackage(Class<?> cls) { // cls.getPackage() sometimes returns null, in which case fall back to string massaging. java.lang.Package pkg = cls.isArray() ? cls.getComponentType().getPackage() : cls.getPackage(); if ( pkg == null ) { int dotPos; int dolPos = cls.getName().indexOf( '$' ); if ( dolPos > 0 ) { // we have nested classes, so adjust dotpos to before first $ dotPos = cls.getName().substring( 0, dolPos ).lastIndexOf( '.' ); } else { dotPos = cls.getName().lastIndexOf( '.' ); } if ( dotPos > 0 ) { return cls.getName().substring( 0, dotPos ); } else { // must be default package. return ""; } } else { return pkg.getName(); } }
[ "public", "static", "String", "getPackage", "(", "Class", "<", "?", ">", "cls", ")", "{", "// cls.getPackage() sometimes returns null, in which case fall back to string massaging.", "java", ".", "lang", ".", "Package", "pkg", "=", "cls", ".", "isArray", "(", ")", "?", "cls", ".", "getComponentType", "(", ")", ".", "getPackage", "(", ")", ":", "cls", ".", "getPackage", "(", ")", ";", "if", "(", "pkg", "==", "null", ")", "{", "int", "dotPos", ";", "int", "dolPos", "=", "cls", ".", "getName", "(", ")", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "dolPos", ">", "0", ")", "{", "// we have nested classes, so adjust dotpos to before first $", "dotPos", "=", "cls", ".", "getName", "(", ")", ".", "substring", "(", "0", ",", "dolPos", ")", ".", "lastIndexOf", "(", "'", "'", ")", ";", "}", "else", "{", "dotPos", "=", "cls", ".", "getName", "(", ")", ".", "lastIndexOf", "(", "'", "'", ")", ";", "}", "if", "(", "dotPos", ">", "0", ")", "{", "return", "cls", ".", "getName", "(", ")", ".", "substring", "(", "0", ",", "dotPos", ")", ";", "}", "else", "{", "// must be default package.", "return", "\"\"", ";", "}", "}", "else", "{", "return", "pkg", ".", "getName", "(", ")", ";", "}", "}" ]
Extracts the package name from the given class object
[ "Extracts", "the", "package", "name", "from", "the", "given", "class", "object" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/ClassUtils.java#L377-L400
14,114
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/auditlog/AuditLog.java
AuditLog.add
public boolean add( AuditLogEntry e ) { if ( filter == null ) { throw new IllegalStateException( "AuditLogFilter has not been set. Please set before inserting entries." ); } if ( filter.accept( e ) ) { entries.addFirst( e ); return true; } return false; }
java
public boolean add( AuditLogEntry e ) { if ( filter == null ) { throw new IllegalStateException( "AuditLogFilter has not been set. Please set before inserting entries." ); } if ( filter.accept( e ) ) { entries.addFirst( e ); return true; } return false; }
[ "public", "boolean", "add", "(", "AuditLogEntry", "e", ")", "{", "if", "(", "filter", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"AuditLogFilter has not been set. Please set before inserting entries.\"", ")", ";", "}", "if", "(", "filter", ".", "accept", "(", "e", ")", ")", "{", "entries", ".", "addFirst", "(", "e", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Add a new AuditLogEntry at the beginning of the list. This is different behaviour to a regular List but it prevents the need to sort entries in descending order.
[ "Add", "a", "new", "AuditLogEntry", "at", "the", "beginning", "of", "the", "list", ".", "This", "is", "different", "behaviour", "to", "a", "regular", "List", "but", "it", "prevents", "the", "need", "to", "sort", "entries", "in", "descending", "order", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/auditlog/AuditLog.java#L80-L89
14,115
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/ParseException.java
ParseException.getMessage
public String getMessage() { if ( this.cause == null ) { return super.getMessage() + " Line number: " + this.lineNumber; } else { return super.getMessage() + " Line number: " + this.lineNumber + ". Caused by: " + this.cause.getMessage(); } }
java
public String getMessage() { if ( this.cause == null ) { return super.getMessage() + " Line number: " + this.lineNumber; } else { return super.getMessage() + " Line number: " + this.lineNumber + ". Caused by: " + this.cause.getMessage(); } }
[ "public", "String", "getMessage", "(", ")", "{", "if", "(", "this", ".", "cause", "==", "null", ")", "{", "return", "super", ".", "getMessage", "(", ")", "+", "\" Line number: \"", "+", "this", ".", "lineNumber", ";", "}", "else", "{", "return", "super", ".", "getMessage", "(", ")", "+", "\" Line number: \"", "+", "this", ".", "lineNumber", "+", "\". Caused by: \"", "+", "this", ".", "cause", ".", "getMessage", "(", ")", ";", "}", "}" ]
This will print out a summary, including the line number. It will also print out the cause message if applicable.
[ "This", "will", "print", "out", "a", "summary", "including", "the", "line", "number", ".", "It", "will", "also", "print", "out", "the", "cause", "message", "if", "applicable", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/ParseException.java#L60-L66
14,116
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/ConfFileUtils.java
ConfFileUtils.getURL
public static URL getURL(String confName, ClassLoader classLoader, Class cls) { URL url = null; // User home String userHome = System.getProperty( "user.home" ); if ( userHome.endsWith( "\\" ) || userHome.endsWith( "/" ) ) { url = getURLForFile( userHome + confName ); } else { url = getURLForFile( userHome + "/" + confName ); } // Working directory if ( url == null ) { url = getURLForFile( confName ); } // check Class folder if ( cls != null ) { URL urlResource = cls.getResource( confName ); if (urlResource != null) { url = urlResource; } } // check META-INF directories for all known ClassLoaders if ( url == null && classLoader != null ) { ClassLoader confClassLoader = classLoader; if ( confClassLoader != null ) { url = confClassLoader.getResource( "META-INF/" + confName ); } } if ( url == null ) { ClassLoader confClassLoader = ConfFileUtils.class.getClassLoader(); if ( confClassLoader != null && confClassLoader != classLoader ) { url = confClassLoader.getResource( "META-INF/" + confName ); } } if ( url == null && cls != null ) { ClassLoader confClassLoader = cls.getClassLoader(); if ( confClassLoader != null && confClassLoader != classLoader ) { url = confClassLoader.getResource( "META-INF/" + confName ); } } if ( url == null ) { ClassLoader confClassLoader = Thread.currentThread().getContextClassLoader(); if ( confClassLoader != null && confClassLoader != classLoader ) { url = confClassLoader.getResource( "META-INF/" + confName ); } } if ( url == null ) { ClassLoader confClassLoader = ClassLoader.getSystemClassLoader(); if ( confClassLoader != null && confClassLoader != classLoader ) { url = confClassLoader.getResource( "META-INF/" + confName ); } } return url; }
java
public static URL getURL(String confName, ClassLoader classLoader, Class cls) { URL url = null; // User home String userHome = System.getProperty( "user.home" ); if ( userHome.endsWith( "\\" ) || userHome.endsWith( "/" ) ) { url = getURLForFile( userHome + confName ); } else { url = getURLForFile( userHome + "/" + confName ); } // Working directory if ( url == null ) { url = getURLForFile( confName ); } // check Class folder if ( cls != null ) { URL urlResource = cls.getResource( confName ); if (urlResource != null) { url = urlResource; } } // check META-INF directories for all known ClassLoaders if ( url == null && classLoader != null ) { ClassLoader confClassLoader = classLoader; if ( confClassLoader != null ) { url = confClassLoader.getResource( "META-INF/" + confName ); } } if ( url == null ) { ClassLoader confClassLoader = ConfFileUtils.class.getClassLoader(); if ( confClassLoader != null && confClassLoader != classLoader ) { url = confClassLoader.getResource( "META-INF/" + confName ); } } if ( url == null && cls != null ) { ClassLoader confClassLoader = cls.getClassLoader(); if ( confClassLoader != null && confClassLoader != classLoader ) { url = confClassLoader.getResource( "META-INF/" + confName ); } } if ( url == null ) { ClassLoader confClassLoader = Thread.currentThread().getContextClassLoader(); if ( confClassLoader != null && confClassLoader != classLoader ) { url = confClassLoader.getResource( "META-INF/" + confName ); } } if ( url == null ) { ClassLoader confClassLoader = ClassLoader.getSystemClassLoader(); if ( confClassLoader != null && confClassLoader != classLoader ) { url = confClassLoader.getResource( "META-INF/" + confName ); } } return url; }
[ "public", "static", "URL", "getURL", "(", "String", "confName", ",", "ClassLoader", "classLoader", ",", "Class", "cls", ")", "{", "URL", "url", "=", "null", ";", "// User home ", "String", "userHome", "=", "System", ".", "getProperty", "(", "\"user.home\"", ")", ";", "if", "(", "userHome", ".", "endsWith", "(", "\"\\\\\"", ")", "||", "userHome", ".", "endsWith", "(", "\"/\"", ")", ")", "{", "url", "=", "getURLForFile", "(", "userHome", "+", "confName", ")", ";", "}", "else", "{", "url", "=", "getURLForFile", "(", "userHome", "+", "\"/\"", "+", "confName", ")", ";", "}", "// Working directory ", "if", "(", "url", "==", "null", ")", "{", "url", "=", "getURLForFile", "(", "confName", ")", ";", "}", "// check Class folder", "if", "(", "cls", "!=", "null", ")", "{", "URL", "urlResource", "=", "cls", ".", "getResource", "(", "confName", ")", ";", "if", "(", "urlResource", "!=", "null", ")", "{", "url", "=", "urlResource", ";", "}", "}", "// check META-INF directories for all known ClassLoaders", "if", "(", "url", "==", "null", "&&", "classLoader", "!=", "null", ")", "{", "ClassLoader", "confClassLoader", "=", "classLoader", ";", "if", "(", "confClassLoader", "!=", "null", ")", "{", "url", "=", "confClassLoader", ".", "getResource", "(", "\"META-INF/\"", "+", "confName", ")", ";", "}", "}", "if", "(", "url", "==", "null", ")", "{", "ClassLoader", "confClassLoader", "=", "ConfFileUtils", ".", "class", ".", "getClassLoader", "(", ")", ";", "if", "(", "confClassLoader", "!=", "null", "&&", "confClassLoader", "!=", "classLoader", ")", "{", "url", "=", "confClassLoader", ".", "getResource", "(", "\"META-INF/\"", "+", "confName", ")", ";", "}", "}", "if", "(", "url", "==", "null", "&&", "cls", "!=", "null", ")", "{", "ClassLoader", "confClassLoader", "=", "cls", ".", "getClassLoader", "(", ")", ";", "if", "(", "confClassLoader", "!=", "null", "&&", "confClassLoader", "!=", "classLoader", ")", "{", "url", "=", "confClassLoader", ".", "getResource", "(", "\"META-INF/\"", "+", "confName", ")", ";", "}", "}", "if", "(", "url", "==", "null", ")", "{", "ClassLoader", "confClassLoader", "=", "Thread", ".", "currentThread", "(", ")", ".", "getContextClassLoader", "(", ")", ";", "if", "(", "confClassLoader", "!=", "null", "&&", "confClassLoader", "!=", "classLoader", ")", "{", "url", "=", "confClassLoader", ".", "getResource", "(", "\"META-INF/\"", "+", "confName", ")", ";", "}", "}", "if", "(", "url", "==", "null", ")", "{", "ClassLoader", "confClassLoader", "=", "ClassLoader", ".", "getSystemClassLoader", "(", ")", ";", "if", "(", "confClassLoader", "!=", "null", "&&", "confClassLoader", "!=", "classLoader", ")", "{", "url", "=", "confClassLoader", ".", "getResource", "(", "\"META-INF/\"", "+", "confName", ")", ";", "}", "}", "return", "url", ";", "}" ]
Return the URL for a given conf file @param confName @param classLoader @return
[ "Return", "the", "URL", "for", "a", "given", "conf", "file" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/ConfFileUtils.java#L35-L96
14,117
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/ConfFileUtils.java
ConfFileUtils.getURLForFile
public static URL getURLForFile(String fileName) { URL url = null; if ( fileName != null ) { File file = new File( fileName ); if ( file != null && file.exists() ) { try { url = file.toURL(); } catch ( MalformedURLException e ) { throw new IllegalArgumentException( "file.toURL() failed for '" + file + "'" ); } } } return url; }
java
public static URL getURLForFile(String fileName) { URL url = null; if ( fileName != null ) { File file = new File( fileName ); if ( file != null && file.exists() ) { try { url = file.toURL(); } catch ( MalformedURLException e ) { throw new IllegalArgumentException( "file.toURL() failed for '" + file + "'" ); } } } return url; }
[ "public", "static", "URL", "getURLForFile", "(", "String", "fileName", ")", "{", "URL", "url", "=", "null", ";", "if", "(", "fileName", "!=", "null", ")", "{", "File", "file", "=", "new", "File", "(", "fileName", ")", ";", "if", "(", "file", "!=", "null", "&&", "file", ".", "exists", "(", ")", ")", "{", "try", "{", "url", "=", "file", ".", "toURL", "(", ")", ";", "}", "catch", "(", "MalformedURLException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"file.toURL() failed for '\"", "+", "file", "+", "\"'\"", ")", ";", "}", "}", "}", "return", "url", ";", "}" ]
Return URL for given filename @param fileName @return URL
[ "Return", "URL", "for", "given", "filename" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/ConfFileUtils.java#L105-L118
14,118
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/descr/AnnotatedBaseDescr.java
AnnotatedBaseDescr.addAnnotation
public AnnotationDescr addAnnotation( String name, String value ) { if ( this.annotations == null ) { this.annotations = new HashMap<String, AnnotationDescr>(); } else { AnnotationDescr existingAnnotation = annotations.get( name ); if (existingAnnotation != null) { existingAnnotation.setDuplicated(); return existingAnnotation; } } AnnotationDescr annotation = new AnnotationDescr( name, value ); annotation.setResource(getResource()); return this.annotations.put( annotation.getName(), annotation ); }
java
public AnnotationDescr addAnnotation( String name, String value ) { if ( this.annotations == null ) { this.annotations = new HashMap<String, AnnotationDescr>(); } else { AnnotationDescr existingAnnotation = annotations.get( name ); if (existingAnnotation != null) { existingAnnotation.setDuplicated(); return existingAnnotation; } } AnnotationDescr annotation = new AnnotationDescr( name, value ); annotation.setResource(getResource()); return this.annotations.put( annotation.getName(), annotation ); }
[ "public", "AnnotationDescr", "addAnnotation", "(", "String", "name", ",", "String", "value", ")", "{", "if", "(", "this", ".", "annotations", "==", "null", ")", "{", "this", ".", "annotations", "=", "new", "HashMap", "<", "String", ",", "AnnotationDescr", ">", "(", ")", ";", "}", "else", "{", "AnnotationDescr", "existingAnnotation", "=", "annotations", ".", "get", "(", "name", ")", ";", "if", "(", "existingAnnotation", "!=", "null", ")", "{", "existingAnnotation", ".", "setDuplicated", "(", ")", ";", "return", "existingAnnotation", ";", "}", "}", "AnnotationDescr", "annotation", "=", "new", "AnnotationDescr", "(", "name", ",", "value", ")", ";", "annotation", ".", "setResource", "(", "getResource", "(", ")", ")", ";", "return", "this", ".", "annotations", ".", "put", "(", "annotation", ".", "getName", "(", ")", ",", "annotation", ")", ";", "}" ]
Assigns a new annotation to this type with the respective name and value @param name @param value @return returns the previous value of this annotation
[ "Assigns", "a", "new", "annotation", "to", "this", "type", "with", "the", "respective", "name", "and", "value" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/descr/AnnotatedBaseDescr.java#L92-L108
14,119
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/descr/AnnotatedBaseDescr.java
AnnotatedBaseDescr.getAnnotation
public AnnotationDescr getAnnotation( String name ) { return annotations == null ? null : annotations.get( name ); }
java
public AnnotationDescr getAnnotation( String name ) { return annotations == null ? null : annotations.get( name ); }
[ "public", "AnnotationDescr", "getAnnotation", "(", "String", "name", ")", "{", "return", "annotations", "==", "null", "?", "null", ":", "annotations", ".", "get", "(", "name", ")", ";", "}" ]
Returns the annotation with the given name @param name
[ "Returns", "the", "annotation", "with", "the", "given", "name" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/descr/AnnotatedBaseDescr.java#L114-L116
14,120
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/LogicTransformer.java
LogicTransformer.initialize
private void initialize() { // these pairs will be transformed addTransformationPair( GroupElement.NOT, new NotOrTransformation() ); addTransformationPair( GroupElement.EXISTS, new ExistOrTransformation() ); addTransformationPair( GroupElement.AND, new AndOrTransformation() ); }
java
private void initialize() { // these pairs will be transformed addTransformationPair( GroupElement.NOT, new NotOrTransformation() ); addTransformationPair( GroupElement.EXISTS, new ExistOrTransformation() ); addTransformationPair( GroupElement.AND, new AndOrTransformation() ); }
[ "private", "void", "initialize", "(", ")", "{", "// these pairs will be transformed", "addTransformationPair", "(", "GroupElement", ".", "NOT", ",", "new", "NotOrTransformation", "(", ")", ")", ";", "addTransformationPair", "(", "GroupElement", ".", "EXISTS", ",", "new", "ExistOrTransformation", "(", ")", ")", ";", "addTransformationPair", "(", "GroupElement", ".", "AND", ",", "new", "AndOrTransformation", "(", ")", ")", ";", "}" ]
sets up the parent->child transformations map
[ "sets", "up", "the", "parent", "-", ">", "child", "transformations", "map" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/LogicTransformer.java#L56-L64
14,121
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/LogicTransformer.java
LogicTransformer.fixClonedDeclarations
protected void fixClonedDeclarations( GroupElement and, Map<String, Class<?>> globals ) { Stack<RuleConditionElement> contextStack = new Stack<RuleConditionElement>(); DeclarationScopeResolver resolver = new DeclarationScopeResolver( globals, contextStack ); contextStack.push( and ); processElement( resolver, contextStack, and ); contextStack.pop(); }
java
protected void fixClonedDeclarations( GroupElement and, Map<String, Class<?>> globals ) { Stack<RuleConditionElement> contextStack = new Stack<RuleConditionElement>(); DeclarationScopeResolver resolver = new DeclarationScopeResolver( globals, contextStack ); contextStack.push( and ); processElement( resolver, contextStack, and ); contextStack.pop(); }
[ "protected", "void", "fixClonedDeclarations", "(", "GroupElement", "and", ",", "Map", "<", "String", ",", "Class", "<", "?", ">", ">", "globals", ")", "{", "Stack", "<", "RuleConditionElement", ">", "contextStack", "=", "new", "Stack", "<", "RuleConditionElement", ">", "(", ")", ";", "DeclarationScopeResolver", "resolver", "=", "new", "DeclarationScopeResolver", "(", "globals", ",", "contextStack", ")", ";", "contextStack", ".", "push", "(", "and", ")", ";", "processElement", "(", "resolver", ",", "contextStack", ",", "and", ")", ";", "contextStack", ".", "pop", "(", ")", ";", "}" ]
During the logic transformation, we eventually clone CEs, specially patterns and corresponding declarations. So now we need to fix any references to cloned declarations.
[ "During", "the", "logic", "transformation", "we", "eventually", "clone", "CEs", "specially", "patterns", "and", "corresponding", "declarations", ".", "So", "now", "we", "need", "to", "fix", "any", "references", "to", "cloned", "declarations", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/LogicTransformer.java#L147-L157
14,122
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/LogicTransformer.java
LogicTransformer.processTree
private void processTree(final GroupElement ce, boolean[] result) throws InvalidPatternException { boolean hasChildOr = false; // first we elimininate any redundancy ce.pack(); for (Object child : ce.getChildren().toArray()) { if (child instanceof GroupElement) { final GroupElement group = (GroupElement) child; processTree(group, result); if ((group.isOr() || group.isAnd()) && group.getType() == ce.getType()) { group.pack(ce); } else if (group.isOr()) { hasChildOr = true; } } else if (child instanceof NamedConsequence) { result[0] = true; } else if (child instanceof Pattern && ((Pattern) child).getObjectType().isEvent()) { result[1] = true; } } if ( hasChildOr ) { applyOrTransformation( ce ); } }
java
private void processTree(final GroupElement ce, boolean[] result) throws InvalidPatternException { boolean hasChildOr = false; // first we elimininate any redundancy ce.pack(); for (Object child : ce.getChildren().toArray()) { if (child instanceof GroupElement) { final GroupElement group = (GroupElement) child; processTree(group, result); if ((group.isOr() || group.isAnd()) && group.getType() == ce.getType()) { group.pack(ce); } else if (group.isOr()) { hasChildOr = true; } } else if (child instanceof NamedConsequence) { result[0] = true; } else if (child instanceof Pattern && ((Pattern) child).getObjectType().isEvent()) { result[1] = true; } } if ( hasChildOr ) { applyOrTransformation( ce ); } }
[ "private", "void", "processTree", "(", "final", "GroupElement", "ce", ",", "boolean", "[", "]", "result", ")", "throws", "InvalidPatternException", "{", "boolean", "hasChildOr", "=", "false", ";", "// first we elimininate any redundancy", "ce", ".", "pack", "(", ")", ";", "for", "(", "Object", "child", ":", "ce", ".", "getChildren", "(", ")", ".", "toArray", "(", ")", ")", "{", "if", "(", "child", "instanceof", "GroupElement", ")", "{", "final", "GroupElement", "group", "=", "(", "GroupElement", ")", "child", ";", "processTree", "(", "group", ",", "result", ")", ";", "if", "(", "(", "group", ".", "isOr", "(", ")", "||", "group", ".", "isAnd", "(", ")", ")", "&&", "group", ".", "getType", "(", ")", "==", "ce", ".", "getType", "(", ")", ")", "{", "group", ".", "pack", "(", "ce", ")", ";", "}", "else", "if", "(", "group", ".", "isOr", "(", ")", ")", "{", "hasChildOr", "=", "true", ";", "}", "}", "else", "if", "(", "child", "instanceof", "NamedConsequence", ")", "{", "result", "[", "0", "]", "=", "true", ";", "}", "else", "if", "(", "child", "instanceof", "Pattern", "&&", "(", "(", "Pattern", ")", "child", ")", ".", "getObjectType", "(", ")", ".", "isEvent", "(", ")", ")", "{", "result", "[", "1", "]", "=", "true", ";", "}", "}", "if", "(", "hasChildOr", ")", "{", "applyOrTransformation", "(", "ce", ")", ";", "}", "}" ]
Traverses a Tree, during the process it transforms Or nodes moving the upwards and it removes duplicate logic statement, this does not include Not nodes. Traversal involves three levels the graph for each iteration. The first level is the current node, this node will not be transformed, instead what we are interested in are the children of the current node (called the parent nodes) and the children of those parents (call the child nodes).
[ "Traverses", "a", "Tree", "during", "the", "process", "it", "transforms", "Or", "nodes", "moving", "the", "upwards", "and", "it", "removes", "duplicate", "logic", "statement", "this", "does", "not", "include", "Not", "nodes", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/LogicTransformer.java#L360-L386
14,123
kiegroup/drools
drools-verifier/drools-verifier-core/src/main/java/org/drools/verifier/core/checks/base/CheckRunManager.java
CheckRunManager.run
public void run(final StatusUpdate onStatus, final Command onCompletion) { //Ensure active analysis is cancelled cancelExistingAnalysis(); //If there are no checks to run simply return if (rechecks.isEmpty()) { if (onCompletion != null) { onCompletion.execute(); return; } } checkRunner.run(rechecks, onStatus, onCompletion); rechecks.clear(); }
java
public void run(final StatusUpdate onStatus, final Command onCompletion) { //Ensure active analysis is cancelled cancelExistingAnalysis(); //If there are no checks to run simply return if (rechecks.isEmpty()) { if (onCompletion != null) { onCompletion.execute(); return; } } checkRunner.run(rechecks, onStatus, onCompletion); rechecks.clear(); }
[ "public", "void", "run", "(", "final", "StatusUpdate", "onStatus", ",", "final", "Command", "onCompletion", ")", "{", "//Ensure active analysis is cancelled", "cancelExistingAnalysis", "(", ")", ";", "//If there are no checks to run simply return", "if", "(", "rechecks", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "onCompletion", "!=", "null", ")", "{", "onCompletion", ".", "execute", "(", ")", ";", "return", ";", "}", "}", "checkRunner", ".", "run", "(", "rechecks", ",", "onStatus", ",", "onCompletion", ")", ";", "rechecks", ".", "clear", "(", ")", ";", "}" ]
Run analysis with feedback @param onStatus Command executed repeatedly receiving status update @param onCompletion Command executed on completion
[ "Run", "analysis", "with", "feedback" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-verifier/drools-verifier-core/src/main/java/org/drools/verifier/core/checks/base/CheckRunManager.java#L41-L58
14,124
kiegroup/drools
drools-core/src/main/java/org/drools/core/impl/KnowledgeBaseFactory.java
KnowledgeBaseFactory.newKnowledgeBase
public static InternalKnowledgeBase newKnowledgeBase(KieBaseConfiguration conf) { return newKnowledgeBase( UUID.randomUUID().toString(), (RuleBaseConfiguration) conf ); }
java
public static InternalKnowledgeBase newKnowledgeBase(KieBaseConfiguration conf) { return newKnowledgeBase( UUID.randomUUID().toString(), (RuleBaseConfiguration) conf ); }
[ "public", "static", "InternalKnowledgeBase", "newKnowledgeBase", "(", "KieBaseConfiguration", "conf", ")", "{", "return", "newKnowledgeBase", "(", "UUID", ".", "randomUUID", "(", ")", ".", "toString", "(", ")", ",", "(", "RuleBaseConfiguration", ")", "conf", ")", ";", "}" ]
Create a new KnowledgeBase using the given KnowledgeBaseConfiguration @return The KnowledgeBase
[ "Create", "a", "new", "KnowledgeBase", "using", "the", "given", "KnowledgeBaseConfiguration" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/impl/KnowledgeBaseFactory.java#L88-L90
14,125
kiegroup/drools
drools-core/src/main/java/org/drools/core/impl/KnowledgeBaseFactory.java
KnowledgeBaseFactory.newKnowledgeBase
public static InternalKnowledgeBase newKnowledgeBase(String kbaseId, KieBaseConfiguration conf) { return new KnowledgeBaseImpl( kbaseId, (RuleBaseConfiguration) conf); }
java
public static InternalKnowledgeBase newKnowledgeBase(String kbaseId, KieBaseConfiguration conf) { return new KnowledgeBaseImpl( kbaseId, (RuleBaseConfiguration) conf); }
[ "public", "static", "InternalKnowledgeBase", "newKnowledgeBase", "(", "String", "kbaseId", ",", "KieBaseConfiguration", "conf", ")", "{", "return", "new", "KnowledgeBaseImpl", "(", "kbaseId", ",", "(", "RuleBaseConfiguration", ")", "conf", ")", ";", "}" ]
Create a new KnowledgeBase using the given KnowledgeBaseConfiguration and the given KnowledgeBase ID. @param kbaseId A string Identifier for the knowledge base. Specially useful when enabling JMX monitoring and management, as that ID will be used to compose the JMX ObjectName for all related MBeans. The application must ensure all kbase IDs are unique. @return The KnowledgeBase
[ "Create", "a", "new", "KnowledgeBase", "using", "the", "given", "KnowledgeBaseConfiguration", "and", "the", "given", "KnowledgeBase", "ID", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/impl/KnowledgeBaseFactory.java#L104-L107
14,126
kiegroup/drools
drools-core/src/main/java/org/drools/core/common/TruthMaintenanceSystem.java
TruthMaintenanceSystem.readLogicalDependency
public void readLogicalDependency(final InternalFactHandle handle, final Object object, final Object value, final Activation activation, final PropagationContext context, final RuleImpl rule, final ObjectTypeConf typeConf) { addLogicalDependency( handle, object, value, activation, context, rule, typeConf, true ); }
java
public void readLogicalDependency(final InternalFactHandle handle, final Object object, final Object value, final Activation activation, final PropagationContext context, final RuleImpl rule, final ObjectTypeConf typeConf) { addLogicalDependency( handle, object, value, activation, context, rule, typeConf, true ); }
[ "public", "void", "readLogicalDependency", "(", "final", "InternalFactHandle", "handle", ",", "final", "Object", "object", ",", "final", "Object", "value", ",", "final", "Activation", "activation", ",", "final", "PropagationContext", "context", ",", "final", "RuleImpl", "rule", ",", "final", "ObjectTypeConf", "typeConf", ")", "{", "addLogicalDependency", "(", "handle", ",", "object", ",", "value", ",", "activation", ",", "context", ",", "rule", ",", "typeConf", ",", "true", ")", ";", "}" ]
Adds a justification for the FactHandle to the justifiedMap. @param handle @param activation @param context @param rule @param typeConf
[ "Adds", "a", "justification", "for", "the", "FactHandle", "to", "the", "justifiedMap", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/common/TruthMaintenanceSystem.java#L187-L195
14,127
kiegroup/drools
drools-core/src/main/java/org/drools/core/common/TruthMaintenanceSystem.java
TruthMaintenanceSystem.enableTMS
private void enableTMS(Object object, ObjectTypeConf conf) { Iterator<InternalFactHandle> it = ((ClassAwareObjectStore) ep.getObjectStore()).iterateFactHandles(getActualClass(object)); while (it.hasNext()) { InternalFactHandle handle = it.next(); if (handle != null && handle.getEqualityKey() == null) { EqualityKey key = new EqualityKey(handle); handle.setEqualityKey(key); key.setStatus(EqualityKey.STATED); put(key); } } // Enable TMS for this type. conf.enableTMS(); }
java
private void enableTMS(Object object, ObjectTypeConf conf) { Iterator<InternalFactHandle> it = ((ClassAwareObjectStore) ep.getObjectStore()).iterateFactHandles(getActualClass(object)); while (it.hasNext()) { InternalFactHandle handle = it.next(); if (handle != null && handle.getEqualityKey() == null) { EqualityKey key = new EqualityKey(handle); handle.setEqualityKey(key); key.setStatus(EqualityKey.STATED); put(key); } } // Enable TMS for this type. conf.enableTMS(); }
[ "private", "void", "enableTMS", "(", "Object", "object", ",", "ObjectTypeConf", "conf", ")", "{", "Iterator", "<", "InternalFactHandle", ">", "it", "=", "(", "(", "ClassAwareObjectStore", ")", "ep", ".", "getObjectStore", "(", ")", ")", ".", "iterateFactHandles", "(", "getActualClass", "(", "object", ")", ")", ";", "while", "(", "it", ".", "hasNext", "(", ")", ")", "{", "InternalFactHandle", "handle", "=", "it", ".", "next", "(", ")", ";", "if", "(", "handle", "!=", "null", "&&", "handle", ".", "getEqualityKey", "(", ")", "==", "null", ")", "{", "EqualityKey", "key", "=", "new", "EqualityKey", "(", "handle", ")", ";", "handle", ".", "setEqualityKey", "(", "key", ")", ";", "key", ".", "setStatus", "(", "EqualityKey", ".", "STATED", ")", ";", "put", "(", "key", ")", ";", "}", "}", "// Enable TMS for this type.", "conf", ".", "enableTMS", "(", ")", ";", "}" ]
TMS will be automatically enabled when the first logical insert happens. We will take all the already asserted objects of the same type and initialize the equality map. @param object the logically inserted object. @param conf the type's configuration.
[ "TMS", "will", "be", "automatically", "enabled", "when", "the", "first", "logical", "insert", "happens", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/common/TruthMaintenanceSystem.java#L262-L277
14,128
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/java/JavaDialectConfiguration.java
JavaDialectConfiguration.setJavaLanguageLevel
public void setJavaLanguageLevel(final String languageLevel) { if ( Arrays.binarySearch( LANGUAGE_LEVELS, languageLevel ) < 0 ) { throw new RuntimeException( "value '" + languageLevel + "' is not a valid language level" ); } this.languageLevel = languageLevel; }
java
public void setJavaLanguageLevel(final String languageLevel) { if ( Arrays.binarySearch( LANGUAGE_LEVELS, languageLevel ) < 0 ) { throw new RuntimeException( "value '" + languageLevel + "' is not a valid language level" ); } this.languageLevel = languageLevel; }
[ "public", "void", "setJavaLanguageLevel", "(", "final", "String", "languageLevel", ")", "{", "if", "(", "Arrays", ".", "binarySearch", "(", "LANGUAGE_LEVELS", ",", "languageLevel", ")", "<", "0", ")", "{", "throw", "new", "RuntimeException", "(", "\"value '\"", "+", "languageLevel", "+", "\"' is not a valid language level\"", ")", ";", "}", "this", ".", "languageLevel", "=", "languageLevel", ";", "}" ]
You cannot set language level below 1.5, as we need static imports, 1.5 is now the default. @param languageLevel
[ "You", "cannot", "set", "language", "level", "below", "1", ".", "5", "as", "we", "need", "static", "imports", "1", ".", "5", "is", "now", "the", "default", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/java/JavaDialectConfiguration.java#L99-L105
14,129
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/java/JavaDialectConfiguration.java
JavaDialectConfiguration.setCompiler
public void setCompiler(final CompilerType compiler) { // check that the jar for the specified compiler are present if ( compiler == CompilerType.ECLIPSE ) { try { Class.forName( "org.eclipse.jdt.internal.compiler.Compiler", true, this.conf.getClassLoader() ); } catch ( ClassNotFoundException e ) { throw new RuntimeException( "The Eclipse JDT Core jar is not in the classpath" ); } } else if ( compiler == CompilerType.JANINO ){ try { Class.forName( "org.codehaus.janino.Parser", true, this.conf.getClassLoader() ); } catch ( ClassNotFoundException e ) { throw new RuntimeException( "The Janino jar is not in the classpath" ); } } switch ( compiler ) { case ECLIPSE : this.compiler = CompilerType.ECLIPSE; break; case JANINO : this.compiler = CompilerType.JANINO; break; case NATIVE : this.compiler = CompilerType.NATIVE; break; default : throw new RuntimeException( "value '" + compiler + "' is not a valid compiler" ); } }
java
public void setCompiler(final CompilerType compiler) { // check that the jar for the specified compiler are present if ( compiler == CompilerType.ECLIPSE ) { try { Class.forName( "org.eclipse.jdt.internal.compiler.Compiler", true, this.conf.getClassLoader() ); } catch ( ClassNotFoundException e ) { throw new RuntimeException( "The Eclipse JDT Core jar is not in the classpath" ); } } else if ( compiler == CompilerType.JANINO ){ try { Class.forName( "org.codehaus.janino.Parser", true, this.conf.getClassLoader() ); } catch ( ClassNotFoundException e ) { throw new RuntimeException( "The Janino jar is not in the classpath" ); } } switch ( compiler ) { case ECLIPSE : this.compiler = CompilerType.ECLIPSE; break; case JANINO : this.compiler = CompilerType.JANINO; break; case NATIVE : this.compiler = CompilerType.NATIVE; break; default : throw new RuntimeException( "value '" + compiler + "' is not a valid compiler" ); } }
[ "public", "void", "setCompiler", "(", "final", "CompilerType", "compiler", ")", "{", "// check that the jar for the specified compiler are present", "if", "(", "compiler", "==", "CompilerType", ".", "ECLIPSE", ")", "{", "try", "{", "Class", ".", "forName", "(", "\"org.eclipse.jdt.internal.compiler.Compiler\"", ",", "true", ",", "this", ".", "conf", ".", "getClassLoader", "(", ")", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"The Eclipse JDT Core jar is not in the classpath\"", ")", ";", "}", "}", "else", "if", "(", "compiler", "==", "CompilerType", ".", "JANINO", ")", "{", "try", "{", "Class", ".", "forName", "(", "\"org.codehaus.janino.Parser\"", ",", "true", ",", "this", ".", "conf", ".", "getClassLoader", "(", ")", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"The Janino jar is not in the classpath\"", ")", ";", "}", "}", "switch", "(", "compiler", ")", "{", "case", "ECLIPSE", ":", "this", ".", "compiler", "=", "CompilerType", ".", "ECLIPSE", ";", "break", ";", "case", "JANINO", ":", "this", ".", "compiler", "=", "CompilerType", ".", "JANINO", ";", "break", ";", "case", "NATIVE", ":", "this", ".", "compiler", "=", "CompilerType", ".", "NATIVE", ";", "break", ";", "default", ":", "throw", "new", "RuntimeException", "(", "\"value '\"", "+", "compiler", "+", "\"' is not a valid compiler\"", ")", ";", "}", "}" ]
Set the compiler to be used when building the rules semantic code blocks. This overrides the default, and even what was set as a system property.
[ "Set", "the", "compiler", "to", "be", "used", "when", "building", "the", "rules", "semantic", "code", "blocks", ".", "This", "overrides", "the", "default", "and", "even", "what", "was", "set", "as", "a", "system", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/java/JavaDialectConfiguration.java#L111-L140
14,130
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/java/JavaDialectConfiguration.java
JavaDialectConfiguration.getDefaultCompiler
private CompilerType getDefaultCompiler() { try { final String prop = this.conf.getChainedProperties().getProperty( JAVA_COMPILER_PROPERTY, "ECLIPSE" ); if ( prop.equals( "NATIVE" ) ) { return CompilerType.NATIVE; } else if ( prop.equals( "ECLIPSE" ) ) { return CompilerType.ECLIPSE; } else if ( prop.equals( "JANINO" ) ) { return CompilerType.JANINO; } else { logger.error( "Drools config: unable to use the drools.compiler property. Using default. It was set to:" + prop ); return CompilerType.ECLIPSE; } } catch ( final SecurityException e ) { logger.error( "Drools config: unable to read the drools.compiler property. Using default.", e); return CompilerType.ECLIPSE; } }
java
private CompilerType getDefaultCompiler() { try { final String prop = this.conf.getChainedProperties().getProperty( JAVA_COMPILER_PROPERTY, "ECLIPSE" ); if ( prop.equals( "NATIVE" ) ) { return CompilerType.NATIVE; } else if ( prop.equals( "ECLIPSE" ) ) { return CompilerType.ECLIPSE; } else if ( prop.equals( "JANINO" ) ) { return CompilerType.JANINO; } else { logger.error( "Drools config: unable to use the drools.compiler property. Using default. It was set to:" + prop ); return CompilerType.ECLIPSE; } } catch ( final SecurityException e ) { logger.error( "Drools config: unable to read the drools.compiler property. Using default.", e); return CompilerType.ECLIPSE; } }
[ "private", "CompilerType", "getDefaultCompiler", "(", ")", "{", "try", "{", "final", "String", "prop", "=", "this", ".", "conf", ".", "getChainedProperties", "(", ")", ".", "getProperty", "(", "JAVA_COMPILER_PROPERTY", ",", "\"ECLIPSE\"", ")", ";", "if", "(", "prop", ".", "equals", "(", "\"NATIVE\"", ")", ")", "{", "return", "CompilerType", ".", "NATIVE", ";", "}", "else", "if", "(", "prop", ".", "equals", "(", "\"ECLIPSE\"", ")", ")", "{", "return", "CompilerType", ".", "ECLIPSE", ";", "}", "else", "if", "(", "prop", ".", "equals", "(", "\"JANINO\"", ")", ")", "{", "return", "CompilerType", ".", "JANINO", ";", "}", "else", "{", "logger", ".", "error", "(", "\"Drools config: unable to use the drools.compiler property. Using default. It was set to:\"", "+", "prop", ")", ";", "return", "CompilerType", ".", "ECLIPSE", ";", "}", "}", "catch", "(", "final", "SecurityException", "e", ")", "{", "logger", ".", "error", "(", "\"Drools config: unable to read the drools.compiler property. Using default.\"", ",", "e", ")", ";", "return", "CompilerType", ".", "ECLIPSE", ";", "}", "}" ]
This will attempt to read the System property to work out what default to set. This should only be done once when the class is loaded. After that point, you will have to programmatically override it.
[ "This", "will", "attempt", "to", "read", "the", "System", "property", "to", "work", "out", "what", "default", "to", "set", ".", "This", "should", "only", "be", "done", "once", "when", "the", "class", "is", "loaded", ".", "After", "that", "point", "you", "will", "have", "to", "programmatically", "override", "it", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/java/JavaDialectConfiguration.java#L151-L169
14,131
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/CompositeObjectSinkAdapter.java
CompositeObjectSinkAdapter.registerFieldIndex
private FieldIndex registerFieldIndex(final int index, final InternalReadAccessor fieldExtractor) { FieldIndex fieldIndex = null; // is linkedlist null, if so create and add if ( this.hashedFieldIndexes == null ) { this.hashedFieldIndexes = new LinkedList<FieldIndex>(); fieldIndex = new FieldIndex( index, fieldExtractor ); this.hashedFieldIndexes.add( fieldIndex ); } // still null, so see if it already exists if ( fieldIndex == null ) { fieldIndex = findFieldIndex( index ); } // doesn't exist so create it if ( fieldIndex == null ) { fieldIndex = new FieldIndex( index, fieldExtractor ); this.hashedFieldIndexes.add( fieldIndex ); } fieldIndex.increaseCounter(); return fieldIndex; }
java
private FieldIndex registerFieldIndex(final int index, final InternalReadAccessor fieldExtractor) { FieldIndex fieldIndex = null; // is linkedlist null, if so create and add if ( this.hashedFieldIndexes == null ) { this.hashedFieldIndexes = new LinkedList<FieldIndex>(); fieldIndex = new FieldIndex( index, fieldExtractor ); this.hashedFieldIndexes.add( fieldIndex ); } // still null, so see if it already exists if ( fieldIndex == null ) { fieldIndex = findFieldIndex( index ); } // doesn't exist so create it if ( fieldIndex == null ) { fieldIndex = new FieldIndex( index, fieldExtractor ); this.hashedFieldIndexes.add( fieldIndex ); } fieldIndex.increaseCounter(); return fieldIndex; }
[ "private", "FieldIndex", "registerFieldIndex", "(", "final", "int", "index", ",", "final", "InternalReadAccessor", "fieldExtractor", ")", "{", "FieldIndex", "fieldIndex", "=", "null", ";", "// is linkedlist null, if so create and add", "if", "(", "this", ".", "hashedFieldIndexes", "==", "null", ")", "{", "this", ".", "hashedFieldIndexes", "=", "new", "LinkedList", "<", "FieldIndex", ">", "(", ")", ";", "fieldIndex", "=", "new", "FieldIndex", "(", "index", ",", "fieldExtractor", ")", ";", "this", ".", "hashedFieldIndexes", ".", "add", "(", "fieldIndex", ")", ";", "}", "// still null, so see if it already exists", "if", "(", "fieldIndex", "==", "null", ")", "{", "fieldIndex", "=", "findFieldIndex", "(", "index", ")", ";", "}", "// doesn't exist so create it", "if", "(", "fieldIndex", "==", "null", ")", "{", "fieldIndex", "=", "new", "FieldIndex", "(", "index", ",", "fieldExtractor", ")", ";", "this", ".", "hashedFieldIndexes", ".", "add", "(", "fieldIndex", ")", ";", "}", "fieldIndex", ".", "increaseCounter", "(", ")", ";", "return", "fieldIndex", ";", "}" ]
Returns a FieldIndex which Keeps a count on how many times a particular field is used with an equality check in the sinks.
[ "Returns", "a", "FieldIndex", "which", "Keeps", "a", "count", "on", "how", "many", "times", "a", "particular", "field", "is", "used", "with", "an", "equality", "check", "in", "the", "sinks", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/CompositeObjectSinkAdapter.java#L304-L331
14,132
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/CompositeObjectSinkAdapter.java
CompositeObjectSinkAdapter.doPropagateAssertObject
protected void doPropagateAssertObject(InternalFactHandle factHandle, PropagationContext context, InternalWorkingMemory workingMemory, ObjectSink sink) { sink.assertObject( factHandle, context, workingMemory ); }
java
protected void doPropagateAssertObject(InternalFactHandle factHandle, PropagationContext context, InternalWorkingMemory workingMemory, ObjectSink sink) { sink.assertObject( factHandle, context, workingMemory ); }
[ "protected", "void", "doPropagateAssertObject", "(", "InternalFactHandle", "factHandle", ",", "PropagationContext", "context", ",", "InternalWorkingMemory", "workingMemory", ",", "ObjectSink", "sink", ")", "{", "sink", ".", "assertObject", "(", "factHandle", ",", "context", ",", "workingMemory", ")", ";", "}" ]
This is a Hook method for subclasses to override. Please keep it protected unless you know what you are doing.
[ "This", "is", "a", "Hook", "method", "for", "subclasses", "to", "override", ".", "Please", "keep", "it", "protected", "unless", "you", "know", "what", "you", "are", "doing", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/CompositeObjectSinkAdapter.java#L494-L501
14,133
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java
DecisionTableImpl.evaluate
public FEELFnResult<Object> evaluate(EvaluationContext ctx, Object[] params) { if ( decisionRules.isEmpty() ) { return FEELFnResult.ofError(new FEELEventBase(Severity.WARN, "Decision table is empty", null)); } Object[] actualInputs = resolveActualInputs( ctx, feel ); Either<FEELEvent, Object> actualInputMatch = actualInputsMatchInputValues( ctx, actualInputs ); if ( actualInputMatch.isLeft() ) { return actualInputMatch.cata( e -> FEELFnResult.ofError(e), e -> FEELFnResult.ofError(null) ); } List<DTDecisionRule> matches = findMatches( ctx, actualInputs ); if( !matches.isEmpty() ) { List<Object> results = evaluateResults( ctx, feel, actualInputs, matches ); Map<Integer, String> msgs = checkResults( ctx, matches, results ); if( msgs.isEmpty() ) { Object result = hitPolicy.getDti().dti( ctx, this, matches, results ); return FEELFnResult.ofResult( result ); } else { List<Integer> offending = msgs.keySet().stream().collect( Collectors.toList()); return FEELFnResult.ofError( new HitPolicyViolationEvent( Severity.ERROR, "Errors found evaluating decision table '"+getName()+"': \n"+(msgs.values().stream().collect( Collectors.joining( "\n" ) )), name, offending ) ); } } else { // check if there is a default value set for the outputs if( hasDefaultValues ) { Object result = defaultToOutput( ctx, feel ); return FEELFnResult.ofResult( result ); } else { if( hitPolicy.getDefaultValue() != null ) { return FEELFnResult.ofResult( hitPolicy.getDefaultValue() ); } return FEELFnResult.ofError( new HitPolicyViolationEvent( Severity.WARN, "No rule matched for decision table '" + name + "' and no default values were defined. Setting result to null.", name, Collections.EMPTY_LIST ) ); } } }
java
public FEELFnResult<Object> evaluate(EvaluationContext ctx, Object[] params) { if ( decisionRules.isEmpty() ) { return FEELFnResult.ofError(new FEELEventBase(Severity.WARN, "Decision table is empty", null)); } Object[] actualInputs = resolveActualInputs( ctx, feel ); Either<FEELEvent, Object> actualInputMatch = actualInputsMatchInputValues( ctx, actualInputs ); if ( actualInputMatch.isLeft() ) { return actualInputMatch.cata( e -> FEELFnResult.ofError(e), e -> FEELFnResult.ofError(null) ); } List<DTDecisionRule> matches = findMatches( ctx, actualInputs ); if( !matches.isEmpty() ) { List<Object> results = evaluateResults( ctx, feel, actualInputs, matches ); Map<Integer, String> msgs = checkResults( ctx, matches, results ); if( msgs.isEmpty() ) { Object result = hitPolicy.getDti().dti( ctx, this, matches, results ); return FEELFnResult.ofResult( result ); } else { List<Integer> offending = msgs.keySet().stream().collect( Collectors.toList()); return FEELFnResult.ofError( new HitPolicyViolationEvent( Severity.ERROR, "Errors found evaluating decision table '"+getName()+"': \n"+(msgs.values().stream().collect( Collectors.joining( "\n" ) )), name, offending ) ); } } else { // check if there is a default value set for the outputs if( hasDefaultValues ) { Object result = defaultToOutput( ctx, feel ); return FEELFnResult.ofResult( result ); } else { if( hitPolicy.getDefaultValue() != null ) { return FEELFnResult.ofResult( hitPolicy.getDefaultValue() ); } return FEELFnResult.ofError( new HitPolicyViolationEvent( Severity.WARN, "No rule matched for decision table '" + name + "' and no default values were defined. Setting result to null.", name, Collections.EMPTY_LIST ) ); } } }
[ "public", "FEELFnResult", "<", "Object", ">", "evaluate", "(", "EvaluationContext", "ctx", ",", "Object", "[", "]", "params", ")", "{", "if", "(", "decisionRules", ".", "isEmpty", "(", ")", ")", "{", "return", "FEELFnResult", ".", "ofError", "(", "new", "FEELEventBase", "(", "Severity", ".", "WARN", ",", "\"Decision table is empty\"", ",", "null", ")", ")", ";", "}", "Object", "[", "]", "actualInputs", "=", "resolveActualInputs", "(", "ctx", ",", "feel", ")", ";", "Either", "<", "FEELEvent", ",", "Object", ">", "actualInputMatch", "=", "actualInputsMatchInputValues", "(", "ctx", ",", "actualInputs", ")", ";", "if", "(", "actualInputMatch", ".", "isLeft", "(", ")", ")", "{", "return", "actualInputMatch", ".", "cata", "(", "e", "->", "FEELFnResult", ".", "ofError", "(", "e", ")", ",", "e", "->", "FEELFnResult", ".", "ofError", "(", "null", ")", ")", ";", "}", "List", "<", "DTDecisionRule", ">", "matches", "=", "findMatches", "(", "ctx", ",", "actualInputs", ")", ";", "if", "(", "!", "matches", ".", "isEmpty", "(", ")", ")", "{", "List", "<", "Object", ">", "results", "=", "evaluateResults", "(", "ctx", ",", "feel", ",", "actualInputs", ",", "matches", ")", ";", "Map", "<", "Integer", ",", "String", ">", "msgs", "=", "checkResults", "(", "ctx", ",", "matches", ",", "results", ")", ";", "if", "(", "msgs", ".", "isEmpty", "(", ")", ")", "{", "Object", "result", "=", "hitPolicy", ".", "getDti", "(", ")", ".", "dti", "(", "ctx", ",", "this", ",", "matches", ",", "results", ")", ";", "return", "FEELFnResult", ".", "ofResult", "(", "result", ")", ";", "}", "else", "{", "List", "<", "Integer", ">", "offending", "=", "msgs", ".", "keySet", "(", ")", ".", "stream", "(", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "return", "FEELFnResult", ".", "ofError", "(", "new", "HitPolicyViolationEvent", "(", "Severity", ".", "ERROR", ",", "\"Errors found evaluating decision table '\"", "+", "getName", "(", ")", "+", "\"': \\n\"", "+", "(", "msgs", ".", "values", "(", ")", ".", "stream", "(", ")", ".", "collect", "(", "Collectors", ".", "joining", "(", "\"\\n\"", ")", ")", ")", ",", "name", ",", "offending", ")", ")", ";", "}", "}", "else", "{", "// check if there is a default value set for the outputs", "if", "(", "hasDefaultValues", ")", "{", "Object", "result", "=", "defaultToOutput", "(", "ctx", ",", "feel", ")", ";", "return", "FEELFnResult", ".", "ofResult", "(", "result", ")", ";", "}", "else", "{", "if", "(", "hitPolicy", ".", "getDefaultValue", "(", ")", "!=", "null", ")", "{", "return", "FEELFnResult", ".", "ofResult", "(", "hitPolicy", ".", "getDefaultValue", "(", ")", ")", ";", "}", "return", "FEELFnResult", ".", "ofError", "(", "new", "HitPolicyViolationEvent", "(", "Severity", ".", "WARN", ",", "\"No rule matched for decision table '\"", "+", "name", "+", "\"' and no default values were defined. Setting result to null.\"", ",", "name", ",", "Collections", ".", "EMPTY_LIST", ")", ")", ";", "}", "}", "}" ]
Evaluates this decision table returning the result @param ctx @param params these are the required information items, not to confuse with the columns of the decision table that are expressions derived from these parameters @return
[ "Evaluates", "this", "decision", "table", "returning", "the", "result" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java#L86-L129
14,134
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java
DecisionTableImpl.actualInputsMatchInputValues
private Either<FEELEvent, Object> actualInputsMatchInputValues(EvaluationContext ctx, Object[] params) { // check that all the parameters match the input list values if they are defined for( int i = 0; i < params.length; i++ ) { final DTInputClause input = inputs.get( i ); // if a list of values is defined, check the the parameter matches the value if ( input.getInputValues() != null && ! input.getInputValues().isEmpty() ) { final Object parameter = params[i]; boolean satisfies = input.getInputValues().stream().map( ut -> ut.apply( ctx, parameter ) ).filter( Boolean::booleanValue ).findAny().orElse( false ); if ( !satisfies ) { String values = input.getInputValuesText(); return Either.ofLeft(new InvalidInputEvent( FEELEvent.Severity.ERROR, input.getInputExpression()+"='" + parameter + "' does not match any of the valid values " + values + " for decision table '" + getName() + "'.", getName(), null, values ) ); } } } return Either.ofRight(true); }
java
private Either<FEELEvent, Object> actualInputsMatchInputValues(EvaluationContext ctx, Object[] params) { // check that all the parameters match the input list values if they are defined for( int i = 0; i < params.length; i++ ) { final DTInputClause input = inputs.get( i ); // if a list of values is defined, check the the parameter matches the value if ( input.getInputValues() != null && ! input.getInputValues().isEmpty() ) { final Object parameter = params[i]; boolean satisfies = input.getInputValues().stream().map( ut -> ut.apply( ctx, parameter ) ).filter( Boolean::booleanValue ).findAny().orElse( false ); if ( !satisfies ) { String values = input.getInputValuesText(); return Either.ofLeft(new InvalidInputEvent( FEELEvent.Severity.ERROR, input.getInputExpression()+"='" + parameter + "' does not match any of the valid values " + values + " for decision table '" + getName() + "'.", getName(), null, values ) ); } } } return Either.ofRight(true); }
[ "private", "Either", "<", "FEELEvent", ",", "Object", ">", "actualInputsMatchInputValues", "(", "EvaluationContext", "ctx", ",", "Object", "[", "]", "params", ")", "{", "// check that all the parameters match the input list values if they are defined", "for", "(", "int", "i", "=", "0", ";", "i", "<", "params", ".", "length", ";", "i", "++", ")", "{", "final", "DTInputClause", "input", "=", "inputs", ".", "get", "(", "i", ")", ";", "// if a list of values is defined, check the the parameter matches the value", "if", "(", "input", ".", "getInputValues", "(", ")", "!=", "null", "&&", "!", "input", ".", "getInputValues", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "final", "Object", "parameter", "=", "params", "[", "i", "]", ";", "boolean", "satisfies", "=", "input", ".", "getInputValues", "(", ")", ".", "stream", "(", ")", ".", "map", "(", "ut", "->", "ut", ".", "apply", "(", "ctx", ",", "parameter", ")", ")", ".", "filter", "(", "Boolean", "::", "booleanValue", ")", ".", "findAny", "(", ")", ".", "orElse", "(", "false", ")", ";", "if", "(", "!", "satisfies", ")", "{", "String", "values", "=", "input", ".", "getInputValuesText", "(", ")", ";", "return", "Either", ".", "ofLeft", "(", "new", "InvalidInputEvent", "(", "FEELEvent", ".", "Severity", ".", "ERROR", ",", "input", ".", "getInputExpression", "(", ")", "+", "\"='\"", "+", "parameter", "+", "\"' does not match any of the valid values \"", "+", "values", "+", "\" for decision table '\"", "+", "getName", "(", ")", "+", "\"'.\"", ",", "getName", "(", ")", ",", "null", ",", "values", ")", ")", ";", "}", "}", "}", "return", "Either", ".", "ofRight", "(", "true", ")", ";", "}" ]
If valid input values are defined, check that all parameters match the respective valid inputs @param ctx @param params @return
[ "If", "valid", "input", "values", "are", "defined", "check", "that", "all", "parameters", "match", "the", "respective", "valid", "inputs" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java#L213-L234
14,135
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java
DecisionTableImpl.findMatches
private List<DTDecisionRule> findMatches(EvaluationContext ctx, Object[] params) { List<DTDecisionRule> matchingDecisionRules = new ArrayList<>(); for ( DTDecisionRule decisionRule : decisionRules ) { if ( matches( ctx, params, decisionRule ) ) { matchingDecisionRules.add( decisionRule ); } } ctx.notifyEvt( () -> { List<Integer> matches = matchingDecisionRules.stream().map( dr -> dr.getIndex() + 1 ).collect( Collectors.toList() ); return new DecisionTableRulesMatchedEvent(FEELEvent.Severity.INFO, "Rules matched for decision table '" + getName() + "': " + matches.toString(), getName(), getName(), matches ); } ); return matchingDecisionRules; }
java
private List<DTDecisionRule> findMatches(EvaluationContext ctx, Object[] params) { List<DTDecisionRule> matchingDecisionRules = new ArrayList<>(); for ( DTDecisionRule decisionRule : decisionRules ) { if ( matches( ctx, params, decisionRule ) ) { matchingDecisionRules.add( decisionRule ); } } ctx.notifyEvt( () -> { List<Integer> matches = matchingDecisionRules.stream().map( dr -> dr.getIndex() + 1 ).collect( Collectors.toList() ); return new DecisionTableRulesMatchedEvent(FEELEvent.Severity.INFO, "Rules matched for decision table '" + getName() + "': " + matches.toString(), getName(), getName(), matches ); } ); return matchingDecisionRules; }
[ "private", "List", "<", "DTDecisionRule", ">", "findMatches", "(", "EvaluationContext", "ctx", ",", "Object", "[", "]", "params", ")", "{", "List", "<", "DTDecisionRule", ">", "matchingDecisionRules", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "DTDecisionRule", "decisionRule", ":", "decisionRules", ")", "{", "if", "(", "matches", "(", "ctx", ",", "params", ",", "decisionRule", ")", ")", "{", "matchingDecisionRules", ".", "add", "(", "decisionRule", ")", ";", "}", "}", "ctx", ".", "notifyEvt", "(", "(", ")", "->", "{", "List", "<", "Integer", ">", "matches", "=", "matchingDecisionRules", ".", "stream", "(", ")", ".", "map", "(", "dr", "->", "dr", ".", "getIndex", "(", ")", "+", "1", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "return", "new", "DecisionTableRulesMatchedEvent", "(", "FEELEvent", ".", "Severity", ".", "INFO", ",", "\"Rules matched for decision table '\"", "+", "getName", "(", ")", "+", "\"': \"", "+", "matches", ".", "toString", "(", ")", ",", "getName", "(", ")", ",", "getName", "(", ")", ",", "matches", ")", ";", "}", ")", ";", "return", "matchingDecisionRules", ";", "}" ]
Finds all rules that match a given set of parameters @param ctx @param params @return
[ "Finds", "all", "rules", "that", "match", "a", "given", "set", "of", "parameters" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java#L243-L260
14,136
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java
DecisionTableImpl.matches
private boolean matches(EvaluationContext ctx, Object[] params, DTDecisionRule rule) { for( int i = 0; i < params.length; i++ ) { CompiledExpression compiledInput = inputs.get(i).getCompiledInput(); if ( compiledInput instanceof CompiledFEELExpression) { ctx.setValue("?", ((CompiledFEELExpression) compiledInput).apply(ctx)); } if( ! satisfies( ctx, params[i], rule.getInputEntry().get( i ) ) ) { return false; } } return true; }
java
private boolean matches(EvaluationContext ctx, Object[] params, DTDecisionRule rule) { for( int i = 0; i < params.length; i++ ) { CompiledExpression compiledInput = inputs.get(i).getCompiledInput(); if ( compiledInput instanceof CompiledFEELExpression) { ctx.setValue("?", ((CompiledFEELExpression) compiledInput).apply(ctx)); } if( ! satisfies( ctx, params[i], rule.getInputEntry().get( i ) ) ) { return false; } } return true; }
[ "private", "boolean", "matches", "(", "EvaluationContext", "ctx", ",", "Object", "[", "]", "params", ",", "DTDecisionRule", "rule", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "params", ".", "length", ";", "i", "++", ")", "{", "CompiledExpression", "compiledInput", "=", "inputs", ".", "get", "(", "i", ")", ".", "getCompiledInput", "(", ")", ";", "if", "(", "compiledInput", "instanceof", "CompiledFEELExpression", ")", "{", "ctx", ".", "setValue", "(", "\"?\"", ",", "(", "(", "CompiledFEELExpression", ")", "compiledInput", ")", ".", "apply", "(", "ctx", ")", ")", ";", "}", "if", "(", "!", "satisfies", "(", "ctx", ",", "params", "[", "i", "]", ",", "rule", ".", "getInputEntry", "(", ")", ".", "get", "(", "i", ")", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks if the parameters match a single rule @param ctx @param params @param rule @return
[ "Checks", "if", "the", "parameters", "match", "a", "single", "rule" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java#L269-L280
14,137
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java
DecisionTableImpl.satisfies
private boolean satisfies(EvaluationContext ctx, Object param, UnaryTest test ) { return test.apply( ctx, param ); }
java
private boolean satisfies(EvaluationContext ctx, Object param, UnaryTest test ) { return test.apply( ctx, param ); }
[ "private", "boolean", "satisfies", "(", "EvaluationContext", "ctx", ",", "Object", "param", ",", "UnaryTest", "test", ")", "{", "return", "test", ".", "apply", "(", "ctx", ",", "param", ")", ";", "}" ]
Checks that a given parameter matches a single cell test @param ctx @param param @param test @return
[ "Checks", "that", "a", "given", "parameter", "matches", "a", "single", "cell", "test" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java#L289-L291
14,138
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java
DecisionTableImpl.defaultToOutput
private Object defaultToOutput(EvaluationContext ctx, FEEL feel) { Map<String, Object> values = ctx.getAllValues(); if ( outputs.size() == 1 ) { Object value = feel.evaluate( outputs.get( 0 ).getDefaultValue(), values ); return value; } else { // zip outputEntries with its name: return IntStream.range( 0, outputs.size() ).boxed() .collect( toMap( i -> outputs.get( i ).getName(), i -> feel.evaluate( outputs.get( i ).getDefaultValue(), values ) ) ); } }
java
private Object defaultToOutput(EvaluationContext ctx, FEEL feel) { Map<String, Object> values = ctx.getAllValues(); if ( outputs.size() == 1 ) { Object value = feel.evaluate( outputs.get( 0 ).getDefaultValue(), values ); return value; } else { // zip outputEntries with its name: return IntStream.range( 0, outputs.size() ).boxed() .collect( toMap( i -> outputs.get( i ).getName(), i -> feel.evaluate( outputs.get( i ).getDefaultValue(), values ) ) ); } }
[ "private", "Object", "defaultToOutput", "(", "EvaluationContext", "ctx", ",", "FEEL", "feel", ")", "{", "Map", "<", "String", ",", "Object", ">", "values", "=", "ctx", ".", "getAllValues", "(", ")", ";", "if", "(", "outputs", ".", "size", "(", ")", "==", "1", ")", "{", "Object", "value", "=", "feel", ".", "evaluate", "(", "outputs", ".", "get", "(", "0", ")", ".", "getDefaultValue", "(", ")", ",", "values", ")", ";", "return", "value", ";", "}", "else", "{", "// zip outputEntries with its name:", "return", "IntStream", ".", "range", "(", "0", ",", "outputs", ".", "size", "(", ")", ")", ".", "boxed", "(", ")", ".", "collect", "(", "toMap", "(", "i", "->", "outputs", ".", "get", "(", "i", ")", ".", "getName", "(", ")", ",", "i", "->", "feel", ".", "evaluate", "(", "outputs", ".", "get", "(", "i", ")", ".", "getDefaultValue", "(", ")", ",", "values", ")", ")", ")", ";", "}", "}" ]
No hits matched for the DT, so calculate result based on default outputs
[ "No", "hits", "matched", "for", "the", "DT", "so", "calculate", "result", "based", "on", "default", "outputs" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/decisiontables/DecisionTableImpl.java#L319-L329
14,139
kiegroup/drools
kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_1/xstream/XStreamMarshaller.java
XStreamMarshaller.marshalMarshall
@Deprecated public void marshalMarshall(Object o, OutputStream out) { try { XStream xStream = newXStream(); out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes()); OutputStreamWriter ows = new OutputStreamWriter(out, "UTF-8"); xStream.toXML(o, ows); } catch ( Exception e ) { e.printStackTrace(); } }
java
@Deprecated public void marshalMarshall(Object o, OutputStream out) { try { XStream xStream = newXStream(); out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes()); OutputStreamWriter ows = new OutputStreamWriter(out, "UTF-8"); xStream.toXML(o, ows); } catch ( Exception e ) { e.printStackTrace(); } }
[ "@", "Deprecated", "public", "void", "marshalMarshall", "(", "Object", "o", ",", "OutputStream", "out", ")", "{", "try", "{", "XStream", "xStream", "=", "newXStream", "(", ")", ";", "out", ".", "write", "(", "\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\"", ".", "getBytes", "(", ")", ")", ";", "OutputStreamWriter", "ows", "=", "new", "OutputStreamWriter", "(", "out", ",", "\"UTF-8\"", ")", ";", "xStream", ".", "toXML", "(", "o", ",", "ows", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Unnecessary as was a tentative UTF-8 preamble output but still not working.
[ "Unnecessary", "as", "was", "a", "tentative", "UTF", "-", "8", "preamble", "output", "but", "still", "not", "working", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_1/xstream/XStreamMarshaller.java#L197-L207
14,140
kiegroup/drools
kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_1/xstream/XStreamMarshaller.java
XStreamMarshaller.formatXml
@Deprecated public static String formatXml(String xml){ try{ Transformer serializer= SAXTransformerFactory.newInstance().newTransformer(); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); Source xmlSource=new SAXSource(new InputSource(new ByteArrayInputStream(xml.getBytes()))); StreamResult res = new StreamResult(new ByteArrayOutputStream()); serializer.transform(xmlSource, res); return new String(((ByteArrayOutputStream)res.getOutputStream()).toByteArray()); }catch(Exception e){ return xml; } }
java
@Deprecated public static String formatXml(String xml){ try{ Transformer serializer= SAXTransformerFactory.newInstance().newTransformer(); serializer.setOutputProperty(OutputKeys.INDENT, "yes"); serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2"); Source xmlSource=new SAXSource(new InputSource(new ByteArrayInputStream(xml.getBytes()))); StreamResult res = new StreamResult(new ByteArrayOutputStream()); serializer.transform(xmlSource, res); return new String(((ByteArrayOutputStream)res.getOutputStream()).toByteArray()); }catch(Exception e){ return xml; } }
[ "@", "Deprecated", "public", "static", "String", "formatXml", "(", "String", "xml", ")", "{", "try", "{", "Transformer", "serializer", "=", "SAXTransformerFactory", ".", "newInstance", "(", ")", ".", "newTransformer", "(", ")", ";", "serializer", ".", "setOutputProperty", "(", "OutputKeys", ".", "INDENT", ",", "\"yes\"", ")", ";", "serializer", ".", "setOutputProperty", "(", "\"{http://xml.apache.org/xslt}indent-amount\"", ",", "\"2\"", ")", ";", "Source", "xmlSource", "=", "new", "SAXSource", "(", "new", "InputSource", "(", "new", "ByteArrayInputStream", "(", "xml", ".", "getBytes", "(", ")", ")", ")", ")", ";", "StreamResult", "res", "=", "new", "StreamResult", "(", "new", "ByteArrayOutputStream", "(", ")", ")", ";", "serializer", ".", "transform", "(", "xmlSource", ",", "res", ")", ";", "return", "new", "String", "(", "(", "(", "ByteArrayOutputStream", ")", "res", ".", "getOutputStream", "(", ")", ")", ".", "toByteArray", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "return", "xml", ";", "}", "}" ]
Unnecessary as the stax driver custom anon as static definition is embedding the indentation.
[ "Unnecessary", "as", "the", "stax", "driver", "custom", "anon", "as", "static", "definition", "is", "embedding", "the", "indentation", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-backend/src/main/java/org/kie/dmn/backend/marshalling/v1_1/xstream/XStreamMarshaller.java#L212-L225
14,141
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNEdge.java
DMNEdge.setDMNLabel
public void setDMNLabel(org.kie.dmn.model.api.dmndi.DMNLabel value) { this.dmnLabel = value; }
java
public void setDMNLabel(org.kie.dmn.model.api.dmndi.DMNLabel value) { this.dmnLabel = value; }
[ "public", "void", "setDMNLabel", "(", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "DMNLabel", "value", ")", "{", "this", ".", "dmnLabel", "=", "value", ";", "}" ]
Sets the value of the dmnLabel property. @param value allowed object is {@link DMNLabel }
[ "Sets", "the", "value", "of", "the", "dmnLabel", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNEdge.java#L46-L48
14,142
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/builder/impl/ClassDefinitionFactory.java
ClassDefinitionFactory.generateDeclaredBean
public ClassDefinition generateDeclaredBean(AbstractClassTypeDeclarationDescr typeDescr, TypeDeclaration type, PackageRegistry pkgRegistry, List<TypeDefinition> unresolvedTypeDefinitions, Map<String, AbstractClassTypeDeclarationDescr> unprocesseableDescrs) { ClassDefinition def = createClassDefinition(typeDescr, type); boolean success = true; success &= wireAnnotationDefs(typeDescr, type, def, pkgRegistry.getTypeResolver()); success &= wireEnumLiteralDefs(typeDescr, type, def); success &= wireFields(typeDescr, type, def, pkgRegistry, unresolvedTypeDefinitions); if (!success) { unprocesseableDescrs.put(typeDescr.getType().getFullName(), typeDescr); } // attach the class definition, it will be completed later type.setTypeClassDef(def); return def; }
java
public ClassDefinition generateDeclaredBean(AbstractClassTypeDeclarationDescr typeDescr, TypeDeclaration type, PackageRegistry pkgRegistry, List<TypeDefinition> unresolvedTypeDefinitions, Map<String, AbstractClassTypeDeclarationDescr> unprocesseableDescrs) { ClassDefinition def = createClassDefinition(typeDescr, type); boolean success = true; success &= wireAnnotationDefs(typeDescr, type, def, pkgRegistry.getTypeResolver()); success &= wireEnumLiteralDefs(typeDescr, type, def); success &= wireFields(typeDescr, type, def, pkgRegistry, unresolvedTypeDefinitions); if (!success) { unprocesseableDescrs.put(typeDescr.getType().getFullName(), typeDescr); } // attach the class definition, it will be completed later type.setTypeClassDef(def); return def; }
[ "public", "ClassDefinition", "generateDeclaredBean", "(", "AbstractClassTypeDeclarationDescr", "typeDescr", ",", "TypeDeclaration", "type", ",", "PackageRegistry", "pkgRegistry", ",", "List", "<", "TypeDefinition", ">", "unresolvedTypeDefinitions", ",", "Map", "<", "String", ",", "AbstractClassTypeDeclarationDescr", ">", "unprocesseableDescrs", ")", "{", "ClassDefinition", "def", "=", "createClassDefinition", "(", "typeDescr", ",", "type", ")", ";", "boolean", "success", "=", "true", ";", "success", "&=", "wireAnnotationDefs", "(", "typeDescr", ",", "type", ",", "def", ",", "pkgRegistry", ".", "getTypeResolver", "(", ")", ")", ";", "success", "&=", "wireEnumLiteralDefs", "(", "typeDescr", ",", "type", ",", "def", ")", ";", "success", "&=", "wireFields", "(", "typeDescr", ",", "type", ",", "def", ",", "pkgRegistry", ",", "unresolvedTypeDefinitions", ")", ";", "if", "(", "!", "success", ")", "{", "unprocesseableDescrs", ".", "put", "(", "typeDescr", ".", "getType", "(", ")", ".", "getFullName", "(", ")", ",", "typeDescr", ")", ";", "}", "// attach the class definition, it will be completed later", "type", ".", "setTypeClassDef", "(", "def", ")", ";", "return", "def", ";", "}" ]
Generates a bean, and adds it to the composite class loader that everything is using.
[ "Generates", "a", "bean", "and", "adds", "it", "to", "the", "composite", "class", "loader", "that", "everything", "is", "using", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/builder/impl/ClassDefinitionFactory.java#L72-L92
14,143
kiegroup/drools
drools-core/src/main/java/org/drools/core/audit/WorkingMemoryFileLogger.java
WorkingMemoryFileLogger.writeToDisk
public void writeToDisk() { if ( !initialized ) { initializeLog(); } Writer writer = null; try { FileOutputStream fileOut = new FileOutputStream( this.fileName + (this.nbOfFile == 0 ? ".log" : this.nbOfFile + ".log" ), true ); writer = new OutputStreamWriter( fileOut, IoUtils.UTF8_CHARSET ); final XStream xstream = createTrustingXStream(); WorkingMemoryLog log = null; synchronized ( this.events ) { log = new WorkingMemoryLog(new ArrayList<LogEvent>( this.events )); clear(); } writer.write( xstream.toXML( log ) + "\n" ); } catch ( final FileNotFoundException exc ) { throw new RuntimeException( "Could not create the log file. Please make sure that directory that the log file should be placed in does exist." ); } catch ( final Throwable t ) { logger.error("error", t); } finally { if ( writer != null ) { try { writer.close(); } catch ( Exception e ) { } } } if ( terminate ) { closeLog(); terminate = true; } else if ( split ) { closeLog(); this.nbOfFile++; initialized = false; } }
java
public void writeToDisk() { if ( !initialized ) { initializeLog(); } Writer writer = null; try { FileOutputStream fileOut = new FileOutputStream( this.fileName + (this.nbOfFile == 0 ? ".log" : this.nbOfFile + ".log" ), true ); writer = new OutputStreamWriter( fileOut, IoUtils.UTF8_CHARSET ); final XStream xstream = createTrustingXStream(); WorkingMemoryLog log = null; synchronized ( this.events ) { log = new WorkingMemoryLog(new ArrayList<LogEvent>( this.events )); clear(); } writer.write( xstream.toXML( log ) + "\n" ); } catch ( final FileNotFoundException exc ) { throw new RuntimeException( "Could not create the log file. Please make sure that directory that the log file should be placed in does exist." ); } catch ( final Throwable t ) { logger.error("error", t); } finally { if ( writer != null ) { try { writer.close(); } catch ( Exception e ) { } } } if ( terminate ) { closeLog(); terminate = true; } else if ( split ) { closeLog(); this.nbOfFile++; initialized = false; } }
[ "public", "void", "writeToDisk", "(", ")", "{", "if", "(", "!", "initialized", ")", "{", "initializeLog", "(", ")", ";", "}", "Writer", "writer", "=", "null", ";", "try", "{", "FileOutputStream", "fileOut", "=", "new", "FileOutputStream", "(", "this", ".", "fileName", "+", "(", "this", ".", "nbOfFile", "==", "0", "?", "\".log\"", ":", "this", ".", "nbOfFile", "+", "\".log\"", ")", ",", "true", ")", ";", "writer", "=", "new", "OutputStreamWriter", "(", "fileOut", ",", "IoUtils", ".", "UTF8_CHARSET", ")", ";", "final", "XStream", "xstream", "=", "createTrustingXStream", "(", ")", ";", "WorkingMemoryLog", "log", "=", "null", ";", "synchronized", "(", "this", ".", "events", ")", "{", "log", "=", "new", "WorkingMemoryLog", "(", "new", "ArrayList", "<", "LogEvent", ">", "(", "this", ".", "events", ")", ")", ";", "clear", "(", ")", ";", "}", "writer", ".", "write", "(", "xstream", ".", "toXML", "(", "log", ")", "+", "\"\\n\"", ")", ";", "}", "catch", "(", "final", "FileNotFoundException", "exc", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not create the log file. Please make sure that directory that the log file should be placed in does exist.\"", ")", ";", "}", "catch", "(", "final", "Throwable", "t", ")", "{", "logger", ".", "error", "(", "\"error\"", ",", "t", ")", ";", "}", "finally", "{", "if", "(", "writer", "!=", "null", ")", "{", "try", "{", "writer", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "}", "}", "if", "(", "terminate", ")", "{", "closeLog", "(", ")", ";", "terminate", "=", "true", ";", "}", "else", "if", "(", "split", ")", "{", "closeLog", "(", ")", ";", "this", ".", "nbOfFile", "++", ";", "initialized", "=", "false", ";", "}", "}" ]
All events in the log are written to file. The log is automatically cleared afterwards.
[ "All", "events", "in", "the", "log", "are", "written", "to", "file", ".", "The", "log", "is", "automatically", "cleared", "afterwards", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/audit/WorkingMemoryFileLogger.java#L121-L159
14,144
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/InfixOpNode.java
InfixOpNode.and
public static Object and(Object left, Object right, EvaluationContext ctx) { Boolean l = EvalHelper.getBooleanOrNull( left ); Boolean r = EvalHelper.getBooleanOrNull( right ); // have to check for all nulls first to avoid NPE if ( (l == null && r == null) || (l == null && r == true) || (r == null && l == true) ) { return null; } else if ( l == null || r == null ) { return false; } return l && r; }
java
public static Object and(Object left, Object right, EvaluationContext ctx) { Boolean l = EvalHelper.getBooleanOrNull( left ); Boolean r = EvalHelper.getBooleanOrNull( right ); // have to check for all nulls first to avoid NPE if ( (l == null && r == null) || (l == null && r == true) || (r == null && l == true) ) { return null; } else if ( l == null || r == null ) { return false; } return l && r; }
[ "public", "static", "Object", "and", "(", "Object", "left", ",", "Object", "right", ",", "EvaluationContext", "ctx", ")", "{", "Boolean", "l", "=", "EvalHelper", ".", "getBooleanOrNull", "(", "left", ")", ";", "Boolean", "r", "=", "EvalHelper", ".", "getBooleanOrNull", "(", "right", ")", ";", "// have to check for all nulls first to avoid NPE", "if", "(", "(", "l", "==", "null", "&&", "r", "==", "null", ")", "||", "(", "l", "==", "null", "&&", "r", "==", "true", ")", "||", "(", "r", "==", "null", "&&", "l", "==", "true", ")", ")", "{", "return", "null", ";", "}", "else", "if", "(", "l", "==", "null", "||", "r", "==", "null", ")", "{", "return", "false", ";", "}", "return", "l", "&&", "r", ";", "}" ]
Implements the ternary logic AND operation
[ "Implements", "the", "ternary", "logic", "AND", "operation" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/ast/InfixOpNode.java#L362-L372
14,145
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/compiler/DialectCompiletimeRegistry.java
DialectCompiletimeRegistry.addResults
public List<KnowledgeBuilderResult> addResults(List<KnowledgeBuilderResult> list) { if ( list == null ) { list = new ArrayList<KnowledgeBuilderResult>(); } for (Dialect dialect : map.values()) { List<KnowledgeBuilderResult> results = dialect.getResults(); if ( results != null ) { for (KnowledgeBuilderResult result : results) { if (!list.contains(result)) { list.add(result); } } dialect.clearResults(); } } return list; }
java
public List<KnowledgeBuilderResult> addResults(List<KnowledgeBuilderResult> list) { if ( list == null ) { list = new ArrayList<KnowledgeBuilderResult>(); } for (Dialect dialect : map.values()) { List<KnowledgeBuilderResult> results = dialect.getResults(); if ( results != null ) { for (KnowledgeBuilderResult result : results) { if (!list.contains(result)) { list.add(result); } } dialect.clearResults(); } } return list; }
[ "public", "List", "<", "KnowledgeBuilderResult", ">", "addResults", "(", "List", "<", "KnowledgeBuilderResult", ">", "list", ")", "{", "if", "(", "list", "==", "null", ")", "{", "list", "=", "new", "ArrayList", "<", "KnowledgeBuilderResult", ">", "(", ")", ";", "}", "for", "(", "Dialect", "dialect", ":", "map", ".", "values", "(", ")", ")", "{", "List", "<", "KnowledgeBuilderResult", ">", "results", "=", "dialect", ".", "getResults", "(", ")", ";", "if", "(", "results", "!=", "null", ")", "{", "for", "(", "KnowledgeBuilderResult", "result", ":", "results", ")", "{", "if", "(", "!", "list", ".", "contains", "(", "result", ")", ")", "{", "list", ".", "add", "(", "result", ")", ";", "}", "}", "dialect", ".", "clearResults", "(", ")", ";", "}", "}", "return", "list", ";", "}" ]
Add all registered Dialect results to the provided List. @param list @return
[ "Add", "all", "registered", "Dialect", "results", "to", "the", "provided", "List", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/compiler/DialectCompiletimeRegistry.java#L78-L94
14,146
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/compiler/DialectCompiletimeRegistry.java
DialectCompiletimeRegistry.addImport
public void addImport(ImportDescr importDescr) { for (Dialect dialect : this.map.values()) { dialect.addImport(importDescr); } }
java
public void addImport(ImportDescr importDescr) { for (Dialect dialect : this.map.values()) { dialect.addImport(importDescr); } }
[ "public", "void", "addImport", "(", "ImportDescr", "importDescr", ")", "{", "for", "(", "Dialect", "dialect", ":", "this", ".", "map", ".", "values", "(", ")", ")", "{", "dialect", ".", "addImport", "(", "importDescr", ")", ";", "}", "}" ]
Iterates all registered dialects, informing them of an import added to the PackageBuilder @param importEntry
[ "Iterates", "all", "registered", "dialects", "informing", "them", "of", "an", "import", "added", "to", "the", "PackageBuilder" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/compiler/DialectCompiletimeRegistry.java#L100-L104
14,147
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/compiler/DialectCompiletimeRegistry.java
DialectCompiletimeRegistry.addStaticImport
public void addStaticImport(ImportDescr importDescr) { for (Dialect dialect : this.map.values()) { dialect.addStaticImport(importDescr); } }
java
public void addStaticImport(ImportDescr importDescr) { for (Dialect dialect : this.map.values()) { dialect.addStaticImport(importDescr); } }
[ "public", "void", "addStaticImport", "(", "ImportDescr", "importDescr", ")", "{", "for", "(", "Dialect", "dialect", ":", "this", ".", "map", ".", "values", "(", ")", ")", "{", "dialect", ".", "addStaticImport", "(", "importDescr", ")", ";", "}", "}" ]
Iterates all registered dialects, informing them of a static imports added to the PackageBuilder @param staticImportEntry
[ "Iterates", "all", "registered", "dialects", "informing", "them", "of", "a", "static", "imports", "added", "to", "the", "PackageBuilder" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/compiler/DialectCompiletimeRegistry.java#L110-L114
14,148
kiegroup/drools
kie-ci/src/main/java/org/kie/scanner/KieMavenRepository.java
KieMavenRepository.deployArtifact
public void deployArtifact( AFReleaseId releaseId, InternalKieModule kieModule, File pomfile ) { RemoteRepository repository = getRemoteRepositoryFromDistributionManagement( pomfile ); if (repository == null) { log.warn( "No Distribution Management configured: unknown repository" ); return; } deployArtifact( repository, releaseId, kieModule, pomfile ); }
java
public void deployArtifact( AFReleaseId releaseId, InternalKieModule kieModule, File pomfile ) { RemoteRepository repository = getRemoteRepositoryFromDistributionManagement( pomfile ); if (repository == null) { log.warn( "No Distribution Management configured: unknown repository" ); return; } deployArtifact( repository, releaseId, kieModule, pomfile ); }
[ "public", "void", "deployArtifact", "(", "AFReleaseId", "releaseId", ",", "InternalKieModule", "kieModule", ",", "File", "pomfile", ")", "{", "RemoteRepository", "repository", "=", "getRemoteRepositoryFromDistributionManagement", "(", "pomfile", ")", ";", "if", "(", "repository", "==", "null", ")", "{", "log", ".", "warn", "(", "\"No Distribution Management configured: unknown repository\"", ")", ";", "return", ";", "}", "deployArtifact", "(", "repository", ",", "releaseId", ",", "kieModule", ",", "pomfile", ")", ";", "}" ]
Deploys the kjar in the given kieModule on the remote repository defined in the distributionManagement tag of the provided pom file. If the pom file doesn't define a distributionManagement no deployment will be performed and a warning message will be logged. @param releaseId The releaseId with which the deployment will be made @param kieModule The kieModule containing the kjar to be deployed @param pomfile The pom file to be deployed together with the kjar
[ "Deploys", "the", "kjar", "in", "the", "given", "kieModule", "on", "the", "remote", "repository", "defined", "in", "the", "distributionManagement", "tag", "of", "the", "provided", "pom", "file", ".", "If", "the", "pom", "file", "doesn", "t", "define", "a", "distributionManagement", "no", "deployment", "will", "be", "performed", "and", "a", "warning", "message", "will", "be", "logged", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-ci/src/main/java/org/kie/scanner/KieMavenRepository.java#L61-L70
14,149
kiegroup/drools
kie-ci/src/main/java/org/kie/scanner/KieMavenRepository.java
KieMavenRepository.deployArtifact
public void deployArtifact( RemoteRepository repository, AFReleaseId releaseId, InternalKieModule kieModule, File pomfile ) { File jarFile = bytesToFile( releaseId, kieModule.getBytes(), ".jar" ); deployArtifact( repository, releaseId, jarFile, pomfile ); }
java
public void deployArtifact( RemoteRepository repository, AFReleaseId releaseId, InternalKieModule kieModule, File pomfile ) { File jarFile = bytesToFile( releaseId, kieModule.getBytes(), ".jar" ); deployArtifact( repository, releaseId, jarFile, pomfile ); }
[ "public", "void", "deployArtifact", "(", "RemoteRepository", "repository", ",", "AFReleaseId", "releaseId", ",", "InternalKieModule", "kieModule", ",", "File", "pomfile", ")", "{", "File", "jarFile", "=", "bytesToFile", "(", "releaseId", ",", "kieModule", ".", "getBytes", "(", ")", ",", "\".jar\"", ")", ";", "deployArtifact", "(", "repository", ",", "releaseId", ",", "jarFile", ",", "pomfile", ")", ";", "}" ]
Deploys the kjar in the given kieModule on a remote repository. @param repository The remote repository where the kjar will be deployed @param releaseId The releaseId with which the deployment will be made @param kieModule The kieModule containing the kjar to be deployed @param pomfile The pom file to be deployed together with the kjar
[ "Deploys", "the", "kjar", "in", "the", "given", "kieModule", "on", "a", "remote", "repository", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-ci/src/main/java/org/kie/scanner/KieMavenRepository.java#L80-L86
14,150
kiegroup/drools
kie-ci/src/main/java/org/kie/scanner/KieMavenRepository.java
KieMavenRepository.installArtifact
public void installArtifact( AFReleaseId releaseId, InternalKieModule kieModule, File pomfile ) { File jarFile = bytesToFile( releaseId, kieModule.getBytes(), ".jar" ); installArtifact( releaseId, jarFile, pomfile ); }
java
public void installArtifact( AFReleaseId releaseId, InternalKieModule kieModule, File pomfile ) { File jarFile = bytesToFile( releaseId, kieModule.getBytes(), ".jar" ); installArtifact( releaseId, jarFile, pomfile ); }
[ "public", "void", "installArtifact", "(", "AFReleaseId", "releaseId", ",", "InternalKieModule", "kieModule", ",", "File", "pomfile", ")", "{", "File", "jarFile", "=", "bytesToFile", "(", "releaseId", ",", "kieModule", ".", "getBytes", "(", ")", ",", "\".jar\"", ")", ";", "installArtifact", "(", "releaseId", ",", "jarFile", ",", "pomfile", ")", ";", "}" ]
Installs the kjar in the given kieModule into the local repository. @param releaseId The releaseId with which the kjar will be installed @param kieModule The kieModule containing the kjar to be installed @param pomfile The pom file to be installed together with the kjar
[ "Installs", "the", "kjar", "in", "the", "given", "kieModule", "into", "the", "local", "repository", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-ci/src/main/java/org/kie/scanner/KieMavenRepository.java#L96-L101
14,151
kiegroup/drools
drools-model/drools-constraint-parser/src/main/java/org/drools/constraint/parser/ast/expr/NullSafeFieldAccessExpr.java
NullSafeFieldAccessExpr.setScope
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public NullSafeFieldAccessExpr setScope(final Expression scope) { assertNotNull(scope); if (scope == this.scope) { return (NullSafeFieldAccessExpr) this; } notifyPropertyChange(ObservableProperty.SCOPE, this.scope, scope); if (this.scope != null) { this.scope.setParentNode(null); } this.scope = scope; setAsParentNodeOf(scope); return this; }
java
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public NullSafeFieldAccessExpr setScope(final Expression scope) { assertNotNull(scope); if (scope == this.scope) { return (NullSafeFieldAccessExpr) this; } notifyPropertyChange(ObservableProperty.SCOPE, this.scope, scope); if (this.scope != null) { this.scope.setParentNode(null); } this.scope = scope; setAsParentNodeOf(scope); return this; }
[ "@", "Generated", "(", "\"com.github.javaparser.generator.core.node.PropertyGenerator\"", ")", "public", "NullSafeFieldAccessExpr", "setScope", "(", "final", "Expression", "scope", ")", "{", "assertNotNull", "(", "scope", ")", ";", "if", "(", "scope", "==", "this", ".", "scope", ")", "{", "return", "(", "NullSafeFieldAccessExpr", ")", "this", ";", "}", "notifyPropertyChange", "(", "ObservableProperty", ".", "SCOPE", ",", "this", ".", "scope", ",", "scope", ")", ";", "if", "(", "this", ".", "scope", "!=", "null", ")", "{", "this", ".", "scope", ".", "setParentNode", "(", "null", ")", ";", "}", "this", ".", "scope", "=", "scope", ";", "setAsParentNodeOf", "(", "scope", ")", ";", "return", "this", ";", "}" ]
Sets the scope @param scope the scope, can not be null @return this, the NullSafeFieldAccessExpr
[ "Sets", "the", "scope" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-constraint-parser/src/main/java/org/drools/constraint/parser/ast/expr/NullSafeFieldAccessExpr.java#L159-L172
14,152
kiegroup/drools
drools-model/drools-constraint-parser/src/main/java/org/drools/constraint/parser/ast/expr/NullSafeFieldAccessExpr.java
NullSafeFieldAccessExpr.setTypeArguments
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public NullSafeFieldAccessExpr setTypeArguments(final NodeList<Type> typeArguments) { if (typeArguments == this.typeArguments) { return (NullSafeFieldAccessExpr) this; } notifyPropertyChange(ObservableProperty.TYPE_ARGUMENTS, this.typeArguments, typeArguments); if (this.typeArguments != null) { this.typeArguments.setParentNode(null); } this.typeArguments = typeArguments; setAsParentNodeOf(typeArguments); return this; }
java
@Generated("com.github.javaparser.generator.core.node.PropertyGenerator") public NullSafeFieldAccessExpr setTypeArguments(final NodeList<Type> typeArguments) { if (typeArguments == this.typeArguments) { return (NullSafeFieldAccessExpr) this; } notifyPropertyChange(ObservableProperty.TYPE_ARGUMENTS, this.typeArguments, typeArguments); if (this.typeArguments != null) { this.typeArguments.setParentNode(null); } this.typeArguments = typeArguments; setAsParentNodeOf(typeArguments); return this; }
[ "@", "Generated", "(", "\"com.github.javaparser.generator.core.node.PropertyGenerator\"", ")", "public", "NullSafeFieldAccessExpr", "setTypeArguments", "(", "final", "NodeList", "<", "Type", ">", "typeArguments", ")", "{", "if", "(", "typeArguments", "==", "this", ".", "typeArguments", ")", "{", "return", "(", "NullSafeFieldAccessExpr", ")", "this", ";", "}", "notifyPropertyChange", "(", "ObservableProperty", ".", "TYPE_ARGUMENTS", ",", "this", ".", "typeArguments", ",", "typeArguments", ")", ";", "if", "(", "this", ".", "typeArguments", "!=", "null", ")", "{", "this", ".", "typeArguments", ".", "setParentNode", "(", "null", ")", ";", "}", "this", ".", "typeArguments", "=", "typeArguments", ";", "setAsParentNodeOf", "(", "typeArguments", ")", ";", "return", "this", ";", "}" ]
Sets the type arguments @param typeArguments the type arguments, can be null @return this, the NullSafeFieldAccessExpr
[ "Sets", "the", "type", "arguments" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-constraint-parser/src/main/java/org/drools/constraint/parser/ast/expr/NullSafeFieldAccessExpr.java#L185-L197
14,153
kiegroup/drools
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DecisionServiceCompiler.java
DecisionServiceCompiler.compileNode
public void compileNode(DecisionService ds, DMNCompilerImpl compiler, DMNModelImpl model) { DMNType type = null; if (ds.getVariable() == null) { // even for the v1.1 backport, variable creation is taken care in DMNCompiler. DMNCompilerHelper.reportMissingVariable(model, ds, ds, Msg.MISSING_VARIABLE_FOR_DS); return; } DMNCompilerHelper.checkVariableName(model, ds, ds.getName()); if (ds.getVariable() != null && ds.getVariable().getTypeRef() != null) { type = compiler.resolveTypeRef(model, ds, ds.getVariable(), ds.getVariable().getTypeRef()); } else { // for now the call bellow will return type UNKNOWN type = compiler.resolveTypeRef(model, ds, ds, null); } DecisionServiceNodeImpl bkmn = new DecisionServiceNodeImpl(ds, type); model.addDecisionService(bkmn); }
java
public void compileNode(DecisionService ds, DMNCompilerImpl compiler, DMNModelImpl model) { DMNType type = null; if (ds.getVariable() == null) { // even for the v1.1 backport, variable creation is taken care in DMNCompiler. DMNCompilerHelper.reportMissingVariable(model, ds, ds, Msg.MISSING_VARIABLE_FOR_DS); return; } DMNCompilerHelper.checkVariableName(model, ds, ds.getName()); if (ds.getVariable() != null && ds.getVariable().getTypeRef() != null) { type = compiler.resolveTypeRef(model, ds, ds.getVariable(), ds.getVariable().getTypeRef()); } else { // for now the call bellow will return type UNKNOWN type = compiler.resolveTypeRef(model, ds, ds, null); } DecisionServiceNodeImpl bkmn = new DecisionServiceNodeImpl(ds, type); model.addDecisionService(bkmn); }
[ "public", "void", "compileNode", "(", "DecisionService", "ds", ",", "DMNCompilerImpl", "compiler", ",", "DMNModelImpl", "model", ")", "{", "DMNType", "type", "=", "null", ";", "if", "(", "ds", ".", "getVariable", "(", ")", "==", "null", ")", "{", "// even for the v1.1 backport, variable creation is taken care in DMNCompiler.", "DMNCompilerHelper", ".", "reportMissingVariable", "(", "model", ",", "ds", ",", "ds", ",", "Msg", ".", "MISSING_VARIABLE_FOR_DS", ")", ";", "return", ";", "}", "DMNCompilerHelper", ".", "checkVariableName", "(", "model", ",", "ds", ",", "ds", ".", "getName", "(", ")", ")", ";", "if", "(", "ds", ".", "getVariable", "(", ")", "!=", "null", "&&", "ds", ".", "getVariable", "(", ")", ".", "getTypeRef", "(", ")", "!=", "null", ")", "{", "type", "=", "compiler", ".", "resolveTypeRef", "(", "model", ",", "ds", ",", "ds", ".", "getVariable", "(", ")", ",", "ds", ".", "getVariable", "(", ")", ".", "getTypeRef", "(", ")", ")", ";", "}", "else", "{", "// for now the call bellow will return type UNKNOWN", "type", "=", "compiler", ".", "resolveTypeRef", "(", "model", ",", "ds", ",", "ds", ",", "null", ")", ";", "}", "DecisionServiceNodeImpl", "bkmn", "=", "new", "DecisionServiceNodeImpl", "(", "ds", ",", "type", ")", ";", "model", ".", "addDecisionService", "(", "bkmn", ")", ";", "}" ]
backport of DMN v1.1
[ "backport", "of", "DMN", "v1", ".", "1" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DecisionServiceCompiler.java#L55-L70
14,154
kiegroup/drools
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DecisionServiceCompiler.java
DecisionServiceCompiler.inputQualifiedNamePrefix
private static String inputQualifiedNamePrefix(DMNNode input, DMNModelImpl model) { if (input.getModelNamespace().equals(model.getNamespace())) { return null; } else { Optional<String> importAlias = model.getImportAliasFor(input.getModelNamespace(), input.getModelName()); if (!importAlias.isPresent()) { MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, ((DMNBaseNode)input).getSource(), model, null, null, Msg.IMPORT_NOT_FOUND_FOR_NODE_MISSING_ALIAS, new QName(input.getModelNamespace(), input.getModelName()), ((DMNBaseNode)input).getSource()); return null; } return importAlias.get(); } }
java
private static String inputQualifiedNamePrefix(DMNNode input, DMNModelImpl model) { if (input.getModelNamespace().equals(model.getNamespace())) { return null; } else { Optional<String> importAlias = model.getImportAliasFor(input.getModelNamespace(), input.getModelName()); if (!importAlias.isPresent()) { MsgUtil.reportMessage(LOG, DMNMessage.Severity.ERROR, ((DMNBaseNode)input).getSource(), model, null, null, Msg.IMPORT_NOT_FOUND_FOR_NODE_MISSING_ALIAS, new QName(input.getModelNamespace(), input.getModelName()), ((DMNBaseNode)input).getSource()); return null; } return importAlias.get(); } }
[ "private", "static", "String", "inputQualifiedNamePrefix", "(", "DMNNode", "input", ",", "DMNModelImpl", "model", ")", "{", "if", "(", "input", ".", "getModelNamespace", "(", ")", ".", "equals", "(", "model", ".", "getNamespace", "(", ")", ")", ")", "{", "return", "null", ";", "}", "else", "{", "Optional", "<", "String", ">", "importAlias", "=", "model", ".", "getImportAliasFor", "(", "input", ".", "getModelNamespace", "(", ")", ",", "input", ".", "getModelName", "(", ")", ")", ";", "if", "(", "!", "importAlias", ".", "isPresent", "(", ")", ")", "{", "MsgUtil", ".", "reportMessage", "(", "LOG", ",", "DMNMessage", ".", "Severity", ".", "ERROR", ",", "(", "(", "DMNBaseNode", ")", "input", ")", ".", "getSource", "(", ")", ",", "model", ",", "null", ",", "null", ",", "Msg", ".", "IMPORT_NOT_FOUND_FOR_NODE_MISSING_ALIAS", ",", "new", "QName", "(", "input", ".", "getModelNamespace", "(", ")", ",", "input", ".", "getModelName", "(", ")", ")", ",", "(", "(", "DMNBaseNode", ")", "input", ")", ".", "getSource", "(", ")", ")", ";", "return", "null", ";", "}", "return", "importAlias", ".", "get", "(", ")", ";", "}", "}" ]
DMN v1.2 specification, chapter "10.4 Execution Semantics of Decision Services" The qualified name of an element named E that is defined in the same decision model as S is simply E. Otherwise, the qualified name is I.E, where I is the name of the import element that refers to the model where E is defined.
[ "DMN", "v1", ".", "2", "specification", "chapter", "10", ".", "4", "Execution", "Semantics", "of", "Decision", "Services", "The", "qualified", "name", "of", "an", "element", "named", "E", "that", "is", "defined", "in", "the", "same", "decision", "model", "as", "S", "is", "simply", "E", ".", "Otherwise", "the", "qualified", "name", "is", "I", ".", "E", "where", "I", "is", "the", "name", "of", "the", "import", "element", "that", "refers", "to", "the", "model", "where", "E", "is", "defined", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/compiler/DecisionServiceCompiler.java#L88-L107
14,155
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/GuidedDecisionTableUpgradeHelper2.java
GuidedDecisionTableUpgradeHelper2.upgrade
public GuidedDecisionTable52 upgrade(GuidedDecisionTable52 source) { final GuidedDecisionTable52 destination = source; //These are the columns we want to update final int iRowNumberColumnIndex = 0; Integer iSalienceColumnIndex = null; Integer iDurationColumnIndex = null; //Find the Salience and Duration column indexes List<BaseColumn> allColumns = destination.getExpandedColumns(); for (int iCol = 0; iCol < allColumns.size(); iCol++) { final BaseColumn column = allColumns.get(iCol); if (column instanceof AttributeCol52) { AttributeCol52 attributeCol = (AttributeCol52) column; final String attributeName = attributeCol.getAttribute(); if (GuidedDecisionTable52.SALIENCE_ATTR.equals(attributeName)) { iSalienceColumnIndex = iCol; } else if (GuidedDecisionTable52.DURATION_ATTR.equals(attributeName)) { iDurationColumnIndex = iCol; } } } //Update data-types for (List<DTCellValue52> row : destination.getData()) { //Row numbers are Integers final int rowNumberValue = row.get(iRowNumberColumnIndex).getNumericValue().intValue(); row.get(iRowNumberColumnIndex).setNumericValue(rowNumberValue); //Salience should be an Integer if (iSalienceColumnIndex != null) { final Number salienceValue = row.get(iSalienceColumnIndex).getNumericValue(); if (salienceValue == null) { row.get(iSalienceColumnIndex).setNumericValue((Integer) null); } else { row.get(iSalienceColumnIndex).setNumericValue(salienceValue.intValue()); } } //Duration should be a Long if (iDurationColumnIndex != null) { final Number durationValue = row.get(iDurationColumnIndex).getNumericValue(); if (durationValue == null) { row.get(iDurationColumnIndex).setNumericValue((Long) null); } else { row.get(iDurationColumnIndex).setNumericValue(durationValue.longValue()); } } } return destination; }
java
public GuidedDecisionTable52 upgrade(GuidedDecisionTable52 source) { final GuidedDecisionTable52 destination = source; //These are the columns we want to update final int iRowNumberColumnIndex = 0; Integer iSalienceColumnIndex = null; Integer iDurationColumnIndex = null; //Find the Salience and Duration column indexes List<BaseColumn> allColumns = destination.getExpandedColumns(); for (int iCol = 0; iCol < allColumns.size(); iCol++) { final BaseColumn column = allColumns.get(iCol); if (column instanceof AttributeCol52) { AttributeCol52 attributeCol = (AttributeCol52) column; final String attributeName = attributeCol.getAttribute(); if (GuidedDecisionTable52.SALIENCE_ATTR.equals(attributeName)) { iSalienceColumnIndex = iCol; } else if (GuidedDecisionTable52.DURATION_ATTR.equals(attributeName)) { iDurationColumnIndex = iCol; } } } //Update data-types for (List<DTCellValue52> row : destination.getData()) { //Row numbers are Integers final int rowNumberValue = row.get(iRowNumberColumnIndex).getNumericValue().intValue(); row.get(iRowNumberColumnIndex).setNumericValue(rowNumberValue); //Salience should be an Integer if (iSalienceColumnIndex != null) { final Number salienceValue = row.get(iSalienceColumnIndex).getNumericValue(); if (salienceValue == null) { row.get(iSalienceColumnIndex).setNumericValue((Integer) null); } else { row.get(iSalienceColumnIndex).setNumericValue(salienceValue.intValue()); } } //Duration should be a Long if (iDurationColumnIndex != null) { final Number durationValue = row.get(iDurationColumnIndex).getNumericValue(); if (durationValue == null) { row.get(iDurationColumnIndex).setNumericValue((Long) null); } else { row.get(iDurationColumnIndex).setNumericValue(durationValue.longValue()); } } } return destination; }
[ "public", "GuidedDecisionTable52", "upgrade", "(", "GuidedDecisionTable52", "source", ")", "{", "final", "GuidedDecisionTable52", "destination", "=", "source", ";", "//These are the columns we want to update", "final", "int", "iRowNumberColumnIndex", "=", "0", ";", "Integer", "iSalienceColumnIndex", "=", "null", ";", "Integer", "iDurationColumnIndex", "=", "null", ";", "//Find the Salience and Duration column indexes", "List", "<", "BaseColumn", ">", "allColumns", "=", "destination", ".", "getExpandedColumns", "(", ")", ";", "for", "(", "int", "iCol", "=", "0", ";", "iCol", "<", "allColumns", ".", "size", "(", ")", ";", "iCol", "++", ")", "{", "final", "BaseColumn", "column", "=", "allColumns", ".", "get", "(", "iCol", ")", ";", "if", "(", "column", "instanceof", "AttributeCol52", ")", "{", "AttributeCol52", "attributeCol", "=", "(", "AttributeCol52", ")", "column", ";", "final", "String", "attributeName", "=", "attributeCol", ".", "getAttribute", "(", ")", ";", "if", "(", "GuidedDecisionTable52", ".", "SALIENCE_ATTR", ".", "equals", "(", "attributeName", ")", ")", "{", "iSalienceColumnIndex", "=", "iCol", ";", "}", "else", "if", "(", "GuidedDecisionTable52", ".", "DURATION_ATTR", ".", "equals", "(", "attributeName", ")", ")", "{", "iDurationColumnIndex", "=", "iCol", ";", "}", "}", "}", "//Update data-types", "for", "(", "List", "<", "DTCellValue52", ">", "row", ":", "destination", ".", "getData", "(", ")", ")", "{", "//Row numbers are Integers", "final", "int", "rowNumberValue", "=", "row", ".", "get", "(", "iRowNumberColumnIndex", ")", ".", "getNumericValue", "(", ")", ".", "intValue", "(", ")", ";", "row", ".", "get", "(", "iRowNumberColumnIndex", ")", ".", "setNumericValue", "(", "rowNumberValue", ")", ";", "//Salience should be an Integer", "if", "(", "iSalienceColumnIndex", "!=", "null", ")", "{", "final", "Number", "salienceValue", "=", "row", ".", "get", "(", "iSalienceColumnIndex", ")", ".", "getNumericValue", "(", ")", ";", "if", "(", "salienceValue", "==", "null", ")", "{", "row", ".", "get", "(", "iSalienceColumnIndex", ")", ".", "setNumericValue", "(", "(", "Integer", ")", "null", ")", ";", "}", "else", "{", "row", ".", "get", "(", "iSalienceColumnIndex", ")", ".", "setNumericValue", "(", "salienceValue", ".", "intValue", "(", ")", ")", ";", "}", "}", "//Duration should be a Long", "if", "(", "iDurationColumnIndex", "!=", "null", ")", "{", "final", "Number", "durationValue", "=", "row", ".", "get", "(", "iDurationColumnIndex", ")", ".", "getNumericValue", "(", ")", ";", "if", "(", "durationValue", "==", "null", ")", "{", "row", ".", "get", "(", "iDurationColumnIndex", ")", ".", "setNumericValue", "(", "(", "Long", ")", "null", ")", ";", "}", "else", "{", "row", ".", "get", "(", "iDurationColumnIndex", ")", ".", "setNumericValue", "(", "durationValue", ".", "longValue", "(", ")", ")", ";", "}", "}", "}", "return", "destination", ";", "}" ]
Convert the data-types in the Decision Table model @param source @return The new DTModel
[ "Convert", "the", "data", "-", "types", "in", "the", "Decision", "Table", "model" ]
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/GuidedDecisionTableUpgradeHelper2.java#L41-L94
14,156
kiegroup/drools
drools-core/src/main/java/org/drools/core/phreak/AddRemoveRule.java
AddRemoveRule.addRule
public static void addRule(TerminalNode tn, Collection<InternalWorkingMemory> wms, InternalKnowledgeBase kBase) { if (log.isTraceEnabled()) { log.trace("Adding Rule {}", tn.getRule().getName()); } boolean hasProtos = kBase.hasSegmentPrototypes(); boolean hasWms = !wms.isEmpty(); if (!hasProtos && !hasWms) { return; } RuleImpl rule = tn.getRule(); LeftTupleNode firstSplit = getNetworkSplitPoint(tn); PathEndNodes pathEndNodes = getPathEndNodes(kBase, firstSplit, tn, rule, hasProtos, hasWms); // Insert the facts for the new paths. This will iterate each new path from EndNode to the splitStart - but will not process the splitStart itself (as tha already exist). // It does not matter that the prior segments have not yet been processed for splitting, as this will only apply for branches of paths that did not exist before for (InternalWorkingMemory wm : wms) { wm.flushPropagations(); if (NodeTypeEnums.LeftInputAdapterNode == firstSplit.getType() && firstSplit.getAssociationsSize() == 1) { // rule added with no sharing insertLiaFacts(firstSplit, wm); } else { PathEndNodeMemories tnms = getPathEndMemories(wm, pathEndNodes); if (tnms.subjectPmem == null) { // If the existing PathMemories are not yet initialized there are no Segments or tuples to process continue; } Map<PathMemory, SegmentMemory[]> prevSmemsLookup = reInitPathMemories(tnms.otherPmems, null); // must collect all visited SegmentMemories, for link notification Set<SegmentMemory> smemsToNotify = handleExistingPaths(tn, prevSmemsLookup, tnms.otherPmems, wm, ExistingPathStrategy.ADD_STRATEGY); addNewPaths(wm, smemsToNotify, tnms.subjectPmems); processLeftTuples(firstSplit, wm, true, rule); notifySegments(smemsToNotify, wm); } } if (hasWms) { insertFacts( pathEndNodes, wms ); } else { for (PathEndNode node : pathEndNodes.otherEndNodes) { node.resetPathMemSpec( null ); } } }
java
public static void addRule(TerminalNode tn, Collection<InternalWorkingMemory> wms, InternalKnowledgeBase kBase) { if (log.isTraceEnabled()) { log.trace("Adding Rule {}", tn.getRule().getName()); } boolean hasProtos = kBase.hasSegmentPrototypes(); boolean hasWms = !wms.isEmpty(); if (!hasProtos && !hasWms) { return; } RuleImpl rule = tn.getRule(); LeftTupleNode firstSplit = getNetworkSplitPoint(tn); PathEndNodes pathEndNodes = getPathEndNodes(kBase, firstSplit, tn, rule, hasProtos, hasWms); // Insert the facts for the new paths. This will iterate each new path from EndNode to the splitStart - but will not process the splitStart itself (as tha already exist). // It does not matter that the prior segments have not yet been processed for splitting, as this will only apply for branches of paths that did not exist before for (InternalWorkingMemory wm : wms) { wm.flushPropagations(); if (NodeTypeEnums.LeftInputAdapterNode == firstSplit.getType() && firstSplit.getAssociationsSize() == 1) { // rule added with no sharing insertLiaFacts(firstSplit, wm); } else { PathEndNodeMemories tnms = getPathEndMemories(wm, pathEndNodes); if (tnms.subjectPmem == null) { // If the existing PathMemories are not yet initialized there are no Segments or tuples to process continue; } Map<PathMemory, SegmentMemory[]> prevSmemsLookup = reInitPathMemories(tnms.otherPmems, null); // must collect all visited SegmentMemories, for link notification Set<SegmentMemory> smemsToNotify = handleExistingPaths(tn, prevSmemsLookup, tnms.otherPmems, wm, ExistingPathStrategy.ADD_STRATEGY); addNewPaths(wm, smemsToNotify, tnms.subjectPmems); processLeftTuples(firstSplit, wm, true, rule); notifySegments(smemsToNotify, wm); } } if (hasWms) { insertFacts( pathEndNodes, wms ); } else { for (PathEndNode node : pathEndNodes.otherEndNodes) { node.resetPathMemSpec( null ); } } }
[ "public", "static", "void", "addRule", "(", "TerminalNode", "tn", ",", "Collection", "<", "InternalWorkingMemory", ">", "wms", ",", "InternalKnowledgeBase", "kBase", ")", "{", "if", "(", "log", ".", "isTraceEnabled", "(", ")", ")", "{", "log", ".", "trace", "(", "\"Adding Rule {}\"", ",", "tn", ".", "getRule", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "boolean", "hasProtos", "=", "kBase", ".", "hasSegmentPrototypes", "(", ")", ";", "boolean", "hasWms", "=", "!", "wms", ".", "isEmpty", "(", ")", ";", "if", "(", "!", "hasProtos", "&&", "!", "hasWms", ")", "{", "return", ";", "}", "RuleImpl", "rule", "=", "tn", ".", "getRule", "(", ")", ";", "LeftTupleNode", "firstSplit", "=", "getNetworkSplitPoint", "(", "tn", ")", ";", "PathEndNodes", "pathEndNodes", "=", "getPathEndNodes", "(", "kBase", ",", "firstSplit", ",", "tn", ",", "rule", ",", "hasProtos", ",", "hasWms", ")", ";", "// Insert the facts for the new paths. This will iterate each new path from EndNode to the splitStart - but will not process the splitStart itself (as tha already exist).", "// It does not matter that the prior segments have not yet been processed for splitting, as this will only apply for branches of paths that did not exist before", "for", "(", "InternalWorkingMemory", "wm", ":", "wms", ")", "{", "wm", ".", "flushPropagations", "(", ")", ";", "if", "(", "NodeTypeEnums", ".", "LeftInputAdapterNode", "==", "firstSplit", ".", "getType", "(", ")", "&&", "firstSplit", ".", "getAssociationsSize", "(", ")", "==", "1", ")", "{", "// rule added with no sharing", "insertLiaFacts", "(", "firstSplit", ",", "wm", ")", ";", "}", "else", "{", "PathEndNodeMemories", "tnms", "=", "getPathEndMemories", "(", "wm", ",", "pathEndNodes", ")", ";", "if", "(", "tnms", ".", "subjectPmem", "==", "null", ")", "{", "// If the existing PathMemories are not yet initialized there are no Segments or tuples to process", "continue", ";", "}", "Map", "<", "PathMemory", ",", "SegmentMemory", "[", "]", ">", "prevSmemsLookup", "=", "reInitPathMemories", "(", "tnms", ".", "otherPmems", ",", "null", ")", ";", "// must collect all visited SegmentMemories, for link notification", "Set", "<", "SegmentMemory", ">", "smemsToNotify", "=", "handleExistingPaths", "(", "tn", ",", "prevSmemsLookup", ",", "tnms", ".", "otherPmems", ",", "wm", ",", "ExistingPathStrategy", ".", "ADD_STRATEGY", ")", ";", "addNewPaths", "(", "wm", ",", "smemsToNotify", ",", "tnms", ".", "subjectPmems", ")", ";", "processLeftTuples", "(", "firstSplit", ",", "wm", ",", "true", ",", "rule", ")", ";", "notifySegments", "(", "smemsToNotify", ",", "wm", ")", ";", "}", "}", "if", "(", "hasWms", ")", "{", "insertFacts", "(", "pathEndNodes", ",", "wms", ")", ";", "}", "else", "{", "for", "(", "PathEndNode", "node", ":", "pathEndNodes", ".", "otherEndNodes", ")", "{", "node", ".", "resetPathMemSpec", "(", "null", ")", ";", "}", "}", "}" ]
This method is called after the rule nodes have been added to the network For add tuples are processed after the segments and pmems have been adjusted
[ "This", "method", "is", "called", "after", "the", "rule", "nodes", "have", "been", "added", "to", "the", "network", "For", "add", "tuples", "are", "processed", "after", "the", "segments", "and", "pmems", "have", "been", "adjusted" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/phreak/AddRemoveRule.java#L86-L139
14,157
kiegroup/drools
drools-core/src/main/java/org/drools/core/phreak/AddRemoveRule.java
AddRemoveRule.removeRule
public static void removeRule( TerminalNode tn, Collection<InternalWorkingMemory> wms, InternalKnowledgeBase kBase) { if (log.isTraceEnabled()) { log.trace("Removing Rule {}", tn.getRule().getName()); } boolean hasProtos = kBase.hasSegmentPrototypes(); boolean hasWms = !wms.isEmpty(); if (!hasProtos && !hasWms) { return; } RuleImpl rule = tn.getRule(); LeftTupleNode firstSplit = getNetworkSplitPoint(tn); PathEndNodes pathEndNodes = getPathEndNodes(kBase, firstSplit, tn, rule, hasProtos, hasWms); for (InternalWorkingMemory wm : wms) { wm.flushPropagations(); PathEndNodeMemories tnms = getPathEndMemories(wm, pathEndNodes); if ( !tnms.subjectPmems.isEmpty() ) { if (NodeTypeEnums.LeftInputAdapterNode == firstSplit.getType() && firstSplit.getAssociationsSize() == 1) { if (tnms.subjectPmem != null) { flushStagedTuples(firstSplit, tnms.subjectPmem, wm); } processLeftTuples(firstSplit, wm, false, tn.getRule()); removeNewPaths(wm, tnms.subjectPmems); } else { flushStagedTuples(tn, tnms.subjectPmem, pathEndNodes, wm); processLeftTuples(firstSplit, wm, false, tn.getRule()); removeNewPaths(wm, tnms.subjectPmems); Map<PathMemory, SegmentMemory[]> prevSmemsLookup = reInitPathMemories(tnms.otherPmems, tn); // must collect all visited SegmentMemories, for link notification Set<SegmentMemory> smemsToNotify = handleExistingPaths(tn, prevSmemsLookup, tnms.otherPmems, wm, ExistingPathStrategy.REMOVE_STRATEGY); notifySegments(smemsToNotify, wm); } } if (tnms.subjectPmem != null && tnms.subjectPmem.isInitialized() && tnms.subjectPmem.getRuleAgendaItem().isQueued()) { // SubjectPmem can be null, if it was never initialized tnms.subjectPmem.getRuleAgendaItem().dequeue(); } } }
java
public static void removeRule( TerminalNode tn, Collection<InternalWorkingMemory> wms, InternalKnowledgeBase kBase) { if (log.isTraceEnabled()) { log.trace("Removing Rule {}", tn.getRule().getName()); } boolean hasProtos = kBase.hasSegmentPrototypes(); boolean hasWms = !wms.isEmpty(); if (!hasProtos && !hasWms) { return; } RuleImpl rule = tn.getRule(); LeftTupleNode firstSplit = getNetworkSplitPoint(tn); PathEndNodes pathEndNodes = getPathEndNodes(kBase, firstSplit, tn, rule, hasProtos, hasWms); for (InternalWorkingMemory wm : wms) { wm.flushPropagations(); PathEndNodeMemories tnms = getPathEndMemories(wm, pathEndNodes); if ( !tnms.subjectPmems.isEmpty() ) { if (NodeTypeEnums.LeftInputAdapterNode == firstSplit.getType() && firstSplit.getAssociationsSize() == 1) { if (tnms.subjectPmem != null) { flushStagedTuples(firstSplit, tnms.subjectPmem, wm); } processLeftTuples(firstSplit, wm, false, tn.getRule()); removeNewPaths(wm, tnms.subjectPmems); } else { flushStagedTuples(tn, tnms.subjectPmem, pathEndNodes, wm); processLeftTuples(firstSplit, wm, false, tn.getRule()); removeNewPaths(wm, tnms.subjectPmems); Map<PathMemory, SegmentMemory[]> prevSmemsLookup = reInitPathMemories(tnms.otherPmems, tn); // must collect all visited SegmentMemories, for link notification Set<SegmentMemory> smemsToNotify = handleExistingPaths(tn, prevSmemsLookup, tnms.otherPmems, wm, ExistingPathStrategy.REMOVE_STRATEGY); notifySegments(smemsToNotify, wm); } } if (tnms.subjectPmem != null && tnms.subjectPmem.isInitialized() && tnms.subjectPmem.getRuleAgendaItem().isQueued()) { // SubjectPmem can be null, if it was never initialized tnms.subjectPmem.getRuleAgendaItem().dequeue(); } } }
[ "public", "static", "void", "removeRule", "(", "TerminalNode", "tn", ",", "Collection", "<", "InternalWorkingMemory", ">", "wms", ",", "InternalKnowledgeBase", "kBase", ")", "{", "if", "(", "log", ".", "isTraceEnabled", "(", ")", ")", "{", "log", ".", "trace", "(", "\"Removing Rule {}\"", ",", "tn", ".", "getRule", "(", ")", ".", "getName", "(", ")", ")", ";", "}", "boolean", "hasProtos", "=", "kBase", ".", "hasSegmentPrototypes", "(", ")", ";", "boolean", "hasWms", "=", "!", "wms", ".", "isEmpty", "(", ")", ";", "if", "(", "!", "hasProtos", "&&", "!", "hasWms", ")", "{", "return", ";", "}", "RuleImpl", "rule", "=", "tn", ".", "getRule", "(", ")", ";", "LeftTupleNode", "firstSplit", "=", "getNetworkSplitPoint", "(", "tn", ")", ";", "PathEndNodes", "pathEndNodes", "=", "getPathEndNodes", "(", "kBase", ",", "firstSplit", ",", "tn", ",", "rule", ",", "hasProtos", ",", "hasWms", ")", ";", "for", "(", "InternalWorkingMemory", "wm", ":", "wms", ")", "{", "wm", ".", "flushPropagations", "(", ")", ";", "PathEndNodeMemories", "tnms", "=", "getPathEndMemories", "(", "wm", ",", "pathEndNodes", ")", ";", "if", "(", "!", "tnms", ".", "subjectPmems", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "NodeTypeEnums", ".", "LeftInputAdapterNode", "==", "firstSplit", ".", "getType", "(", ")", "&&", "firstSplit", ".", "getAssociationsSize", "(", ")", "==", "1", ")", "{", "if", "(", "tnms", ".", "subjectPmem", "!=", "null", ")", "{", "flushStagedTuples", "(", "firstSplit", ",", "tnms", ".", "subjectPmem", ",", "wm", ")", ";", "}", "processLeftTuples", "(", "firstSplit", ",", "wm", ",", "false", ",", "tn", ".", "getRule", "(", ")", ")", ";", "removeNewPaths", "(", "wm", ",", "tnms", ".", "subjectPmems", ")", ";", "}", "else", "{", "flushStagedTuples", "(", "tn", ",", "tnms", ".", "subjectPmem", ",", "pathEndNodes", ",", "wm", ")", ";", "processLeftTuples", "(", "firstSplit", ",", "wm", ",", "false", ",", "tn", ".", "getRule", "(", ")", ")", ";", "removeNewPaths", "(", "wm", ",", "tnms", ".", "subjectPmems", ")", ";", "Map", "<", "PathMemory", ",", "SegmentMemory", "[", "]", ">", "prevSmemsLookup", "=", "reInitPathMemories", "(", "tnms", ".", "otherPmems", ",", "tn", ")", ";", "// must collect all visited SegmentMemories, for link notification", "Set", "<", "SegmentMemory", ">", "smemsToNotify", "=", "handleExistingPaths", "(", "tn", ",", "prevSmemsLookup", ",", "tnms", ".", "otherPmems", ",", "wm", ",", "ExistingPathStrategy", ".", "REMOVE_STRATEGY", ")", ";", "notifySegments", "(", "smemsToNotify", ",", "wm", ")", ";", "}", "}", "if", "(", "tnms", ".", "subjectPmem", "!=", "null", "&&", "tnms", ".", "subjectPmem", ".", "isInitialized", "(", ")", "&&", "tnms", ".", "subjectPmem", ".", "getRuleAgendaItem", "(", ")", ".", "isQueued", "(", ")", ")", "{", "// SubjectPmem can be null, if it was never initialized", "tnms", ".", "subjectPmem", ".", "getRuleAgendaItem", "(", ")", ".", "dequeue", "(", ")", ";", "}", "}", "}" ]
This method is called before the rule nodes are removed from the network. For remove tuples are processed before the segments and pmems have been adjusted
[ "This", "method", "is", "called", "before", "the", "rule", "nodes", "are", "removed", "from", "the", "network", ".", "For", "remove", "tuples", "are", "processed", "before", "the", "segments", "and", "pmems", "have", "been", "adjusted" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/phreak/AddRemoveRule.java#L145-L196
14,158
kiegroup/drools
drools-core/src/main/java/org/drools/core/phreak/AddRemoveRule.java
AddRemoveRule.insertPeerLeftTuple
private static LeftTuple insertPeerLeftTuple(LeftTuple lt, LeftTupleSinkNode node, InternalWorkingMemory wm) { LeftInputAdapterNode.LiaNodeMemory liaMem = null; if ( node.getLeftTupleSource().getType() == NodeTypeEnums.LeftInputAdapterNode ) { liaMem = wm.getNodeMemory(((LeftInputAdapterNode) node.getLeftTupleSource())); } LeftTuple peer = node.createPeer(lt); Memory memory = wm.getNodeMemories().peekNodeMemory(node); if (memory == null || memory.getSegmentMemory() == null) { throw new IllegalStateException("Defensive Programming: this should not be possilbe, as the addRule code should init child segments if they are needed "); } if ( liaMem == null) { memory.getSegmentMemory().getStagedLeftTuples().addInsert(peer); } else { // If parent is Lian, then this must be called, so that any linking or unlinking can be done. LeftInputAdapterNode.doInsertSegmentMemory(wm, true, liaMem, memory.getSegmentMemory(), peer, node.getLeftTupleSource().isStreamMode()); } return peer; }
java
private static LeftTuple insertPeerLeftTuple(LeftTuple lt, LeftTupleSinkNode node, InternalWorkingMemory wm) { LeftInputAdapterNode.LiaNodeMemory liaMem = null; if ( node.getLeftTupleSource().getType() == NodeTypeEnums.LeftInputAdapterNode ) { liaMem = wm.getNodeMemory(((LeftInputAdapterNode) node.getLeftTupleSource())); } LeftTuple peer = node.createPeer(lt); Memory memory = wm.getNodeMemories().peekNodeMemory(node); if (memory == null || memory.getSegmentMemory() == null) { throw new IllegalStateException("Defensive Programming: this should not be possilbe, as the addRule code should init child segments if they are needed "); } if ( liaMem == null) { memory.getSegmentMemory().getStagedLeftTuples().addInsert(peer); } else { // If parent is Lian, then this must be called, so that any linking or unlinking can be done. LeftInputAdapterNode.doInsertSegmentMemory(wm, true, liaMem, memory.getSegmentMemory(), peer, node.getLeftTupleSource().isStreamMode()); } return peer; }
[ "private", "static", "LeftTuple", "insertPeerLeftTuple", "(", "LeftTuple", "lt", ",", "LeftTupleSinkNode", "node", ",", "InternalWorkingMemory", "wm", ")", "{", "LeftInputAdapterNode", ".", "LiaNodeMemory", "liaMem", "=", "null", ";", "if", "(", "node", ".", "getLeftTupleSource", "(", ")", ".", "getType", "(", ")", "==", "NodeTypeEnums", ".", "LeftInputAdapterNode", ")", "{", "liaMem", "=", "wm", ".", "getNodeMemory", "(", "(", "(", "LeftInputAdapterNode", ")", "node", ".", "getLeftTupleSource", "(", ")", ")", ")", ";", "}", "LeftTuple", "peer", "=", "node", ".", "createPeer", "(", "lt", ")", ";", "Memory", "memory", "=", "wm", ".", "getNodeMemories", "(", ")", ".", "peekNodeMemory", "(", "node", ")", ";", "if", "(", "memory", "==", "null", "||", "memory", ".", "getSegmentMemory", "(", ")", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Defensive Programming: this should not be possilbe, as the addRule code should init child segments if they are needed \"", ")", ";", "}", "if", "(", "liaMem", "==", "null", ")", "{", "memory", ".", "getSegmentMemory", "(", ")", ".", "getStagedLeftTuples", "(", ")", ".", "addInsert", "(", "peer", ")", ";", "}", "else", "{", "// If parent is Lian, then this must be called, so that any linking or unlinking can be done.", "LeftInputAdapterNode", ".", "doInsertSegmentMemory", "(", "wm", ",", "true", ",", "liaMem", ",", "memory", ".", "getSegmentMemory", "(", ")", ",", "peer", ",", "node", ".", "getLeftTupleSource", "(", ")", ".", "isStreamMode", "(", ")", ")", ";", "}", "return", "peer", ";", "}" ]
Create all missing peers
[ "Create", "all", "missing", "peers" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/phreak/AddRemoveRule.java#L1011-L1031
14,159
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/AbstractCompositeConstraint.java
AbstractCompositeConstraint.addAlphaConstraint
public void addAlphaConstraint(AlphaNodeFieldConstraint constraint) { if ( constraint != null ) { AlphaNodeFieldConstraint[] tmp = this.alphaConstraints; this.alphaConstraints = new AlphaNodeFieldConstraint[tmp.length + 1]; System.arraycopy( tmp, 0, this.alphaConstraints, 0, tmp.length ); this.alphaConstraints[this.alphaConstraints.length - 1] = constraint; this.updateRequiredDeclarations( constraint ); } }
java
public void addAlphaConstraint(AlphaNodeFieldConstraint constraint) { if ( constraint != null ) { AlphaNodeFieldConstraint[] tmp = this.alphaConstraints; this.alphaConstraints = new AlphaNodeFieldConstraint[tmp.length + 1]; System.arraycopy( tmp, 0, this.alphaConstraints, 0, tmp.length ); this.alphaConstraints[this.alphaConstraints.length - 1] = constraint; this.updateRequiredDeclarations( constraint ); } }
[ "public", "void", "addAlphaConstraint", "(", "AlphaNodeFieldConstraint", "constraint", ")", "{", "if", "(", "constraint", "!=", "null", ")", "{", "AlphaNodeFieldConstraint", "[", "]", "tmp", "=", "this", ".", "alphaConstraints", ";", "this", ".", "alphaConstraints", "=", "new", "AlphaNodeFieldConstraint", "[", "tmp", ".", "length", "+", "1", "]", ";", "System", ".", "arraycopy", "(", "tmp", ",", "0", ",", "this", ".", "alphaConstraints", ",", "0", ",", "tmp", ".", "length", ")", ";", "this", ".", "alphaConstraints", "[", "this", ".", "alphaConstraints", ".", "length", "-", "1", "]", "=", "constraint", ";", "this", ".", "updateRequiredDeclarations", "(", "constraint", ")", ";", "}", "}" ]
Adds an alpha constraint to the multi field OR constraint @param constraint
[ "Adds", "an", "alpha", "constraint", "to", "the", "multi", "field", "OR", "constraint" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/AbstractCompositeConstraint.java#L86-L98
14,160
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/AbstractCompositeConstraint.java
AbstractCompositeConstraint.addBetaConstraint
public void addBetaConstraint(BetaNodeFieldConstraint constraint) { if ( constraint != null ) { BetaNodeFieldConstraint[] tmp = this.betaConstraints; this.betaConstraints = new BetaNodeFieldConstraint[tmp.length + 1]; System.arraycopy( tmp, 0, this.betaConstraints, 0, tmp.length ); this.betaConstraints[this.betaConstraints.length - 1] = constraint; this.updateRequiredDeclarations( constraint ); this.setType( Constraint.ConstraintType.BETA ); } }
java
public void addBetaConstraint(BetaNodeFieldConstraint constraint) { if ( constraint != null ) { BetaNodeFieldConstraint[] tmp = this.betaConstraints; this.betaConstraints = new BetaNodeFieldConstraint[tmp.length + 1]; System.arraycopy( tmp, 0, this.betaConstraints, 0, tmp.length ); this.betaConstraints[this.betaConstraints.length - 1] = constraint; this.updateRequiredDeclarations( constraint ); this.setType( Constraint.ConstraintType.BETA ); } }
[ "public", "void", "addBetaConstraint", "(", "BetaNodeFieldConstraint", "constraint", ")", "{", "if", "(", "constraint", "!=", "null", ")", "{", "BetaNodeFieldConstraint", "[", "]", "tmp", "=", "this", ".", "betaConstraints", ";", "this", ".", "betaConstraints", "=", "new", "BetaNodeFieldConstraint", "[", "tmp", ".", "length", "+", "1", "]", ";", "System", ".", "arraycopy", "(", "tmp", ",", "0", ",", "this", ".", "betaConstraints", ",", "0", ",", "tmp", ".", "length", ")", ";", "this", ".", "betaConstraints", "[", "this", ".", "betaConstraints", ".", "length", "-", "1", "]", "=", "constraint", ";", "this", ".", "updateRequiredDeclarations", "(", "constraint", ")", ";", "this", ".", "setType", "(", "Constraint", ".", "ConstraintType", ".", "BETA", ")", ";", "}", "}" ]
Adds a beta constraint to this multi field OR constraint @param constraint
[ "Adds", "a", "beta", "constraint", "to", "this", "multi", "field", "OR", "constraint" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/AbstractCompositeConstraint.java#L104-L117
14,161
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/AbstractCompositeConstraint.java
AbstractCompositeConstraint.addConstraint
public void addConstraint(Constraint constraint) { if ( ConstraintType.ALPHA.equals(constraint.getType())) { this.addAlphaConstraint( (AlphaNodeFieldConstraint) constraint ); } else if ( ConstraintType.BETA.equals(constraint.getType())) { this.addBetaConstraint( (BetaNodeFieldConstraint) constraint ); } else { throw new RuntimeException( "Constraint type MUST be known in advance."); } }
java
public void addConstraint(Constraint constraint) { if ( ConstraintType.ALPHA.equals(constraint.getType())) { this.addAlphaConstraint( (AlphaNodeFieldConstraint) constraint ); } else if ( ConstraintType.BETA.equals(constraint.getType())) { this.addBetaConstraint( (BetaNodeFieldConstraint) constraint ); } else { throw new RuntimeException( "Constraint type MUST be known in advance."); } }
[ "public", "void", "addConstraint", "(", "Constraint", "constraint", ")", "{", "if", "(", "ConstraintType", ".", "ALPHA", ".", "equals", "(", "constraint", ".", "getType", "(", ")", ")", ")", "{", "this", ".", "addAlphaConstraint", "(", "(", "AlphaNodeFieldConstraint", ")", "constraint", ")", ";", "}", "else", "if", "(", "ConstraintType", ".", "BETA", ".", "equals", "(", "constraint", ".", "getType", "(", ")", ")", ")", "{", "this", ".", "addBetaConstraint", "(", "(", "BetaNodeFieldConstraint", ")", "constraint", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Constraint type MUST be known in advance.\"", ")", ";", "}", "}" ]
Adds a constraint too all lists it belongs to by checking for its type @param constraint
[ "Adds", "a", "constraint", "too", "all", "lists", "it", "belongs", "to", "by", "checking", "for", "its", "type" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/AbstractCompositeConstraint.java#L123-L131
14,162
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/AbstractCompositeConstraint.java
AbstractCompositeConstraint.updateRequiredDeclarations
protected void updateRequiredDeclarations(Constraint constraint) { Declaration[] decs = constraint.getRequiredDeclarations(); if ( decs != null && decs.length > 0 ) { for (Declaration dec1 : decs) { Declaration dec = dec1; // check for duplications for (Declaration requiredDeclaration : this.requiredDeclarations) { if (dec.equals(requiredDeclaration)) { dec = null; break; } } if (dec != null) { Declaration[] tmp = this.requiredDeclarations; this.requiredDeclarations = new Declaration[tmp.length + 1]; System.arraycopy(tmp, 0, this.requiredDeclarations, 0, tmp.length); this.requiredDeclarations[this.requiredDeclarations.length - 1] = dec; } } } }
java
protected void updateRequiredDeclarations(Constraint constraint) { Declaration[] decs = constraint.getRequiredDeclarations(); if ( decs != null && decs.length > 0 ) { for (Declaration dec1 : decs) { Declaration dec = dec1; // check for duplications for (Declaration requiredDeclaration : this.requiredDeclarations) { if (dec.equals(requiredDeclaration)) { dec = null; break; } } if (dec != null) { Declaration[] tmp = this.requiredDeclarations; this.requiredDeclarations = new Declaration[tmp.length + 1]; System.arraycopy(tmp, 0, this.requiredDeclarations, 0, tmp.length); this.requiredDeclarations[this.requiredDeclarations.length - 1] = dec; } } } }
[ "protected", "void", "updateRequiredDeclarations", "(", "Constraint", "constraint", ")", "{", "Declaration", "[", "]", "decs", "=", "constraint", ".", "getRequiredDeclarations", "(", ")", ";", "if", "(", "decs", "!=", "null", "&&", "decs", ".", "length", ">", "0", ")", "{", "for", "(", "Declaration", "dec1", ":", "decs", ")", "{", "Declaration", "dec", "=", "dec1", ";", "// check for duplications", "for", "(", "Declaration", "requiredDeclaration", ":", "this", ".", "requiredDeclarations", ")", "{", "if", "(", "dec", ".", "equals", "(", "requiredDeclaration", ")", ")", "{", "dec", "=", "null", ";", "break", ";", "}", "}", "if", "(", "dec", "!=", "null", ")", "{", "Declaration", "[", "]", "tmp", "=", "this", ".", "requiredDeclarations", ";", "this", ".", "requiredDeclarations", "=", "new", "Declaration", "[", "tmp", ".", "length", "+", "1", "]", ";", "System", ".", "arraycopy", "(", "tmp", ",", "0", ",", "this", ".", "requiredDeclarations", ",", "0", ",", "tmp", ".", "length", ")", ";", "this", ".", "requiredDeclarations", "[", "this", ".", "requiredDeclarations", ".", "length", "-", "1", "]", "=", "dec", ";", "}", "}", "}", "}" ]
Updades the cached required declaration array @param constraint
[ "Updades", "the", "cached", "required", "declaration", "array" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/AbstractCompositeConstraint.java#L138-L162
14,163
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_1/TFunctionDefinition.java
TFunctionDefinition.getKind
@Override public FunctionKind getKind() { String kindValueOnV11 = this.getAdditionalAttributes().get(KIND_QNAME); if (kindValueOnV11 == null || kindValueOnV11.isEmpty()) { return FunctionKind.FEEL; } else { switch (kindValueOnV11) { case "F": return FunctionKind.FEEL; case "J": return FunctionKind.JAVA; case "P": return FunctionKind.PMML; default: return FunctionKind.FEEL; } } }
java
@Override public FunctionKind getKind() { String kindValueOnV11 = this.getAdditionalAttributes().get(KIND_QNAME); if (kindValueOnV11 == null || kindValueOnV11.isEmpty()) { return FunctionKind.FEEL; } else { switch (kindValueOnV11) { case "F": return FunctionKind.FEEL; case "J": return FunctionKind.JAVA; case "P": return FunctionKind.PMML; default: return FunctionKind.FEEL; } } }
[ "@", "Override", "public", "FunctionKind", "getKind", "(", ")", "{", "String", "kindValueOnV11", "=", "this", ".", "getAdditionalAttributes", "(", ")", ".", "get", "(", "KIND_QNAME", ")", ";", "if", "(", "kindValueOnV11", "==", "null", "||", "kindValueOnV11", ".", "isEmpty", "(", ")", ")", "{", "return", "FunctionKind", ".", "FEEL", ";", "}", "else", "{", "switch", "(", "kindValueOnV11", ")", "{", "case", "\"F\"", ":", "return", "FunctionKind", ".", "FEEL", ";", "case", "\"J\"", ":", "return", "FunctionKind", ".", "JAVA", ";", "case", "\"P\"", ":", "return", "FunctionKind", ".", "PMML", ";", "default", ":", "return", "FunctionKind", ".", "FEEL", ";", "}", "}", "}" ]
Align to DMN v1.2
[ "Align", "to", "DMN", "v1", ".", "2" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_1/TFunctionDefinition.java#L80-L97
14,164
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/RightInputAdapterNode.java
RightInputAdapterNode.createMemory
public RiaNodeMemory createMemory(final RuleBaseConfiguration config, InternalWorkingMemory wm) { RiaNodeMemory rianMem = new RiaNodeMemory(); RiaPathMemory pmem = new RiaPathMemory(this, wm); PathMemSpec pathMemSpec = getPathMemSpec(); pmem.setAllLinkedMaskTest( pathMemSpec.allLinkedTestMask ); pmem.setSegmentMemories( new SegmentMemory[pathMemSpec.smemCount] ); rianMem.setRiaPathMemory(pmem); return rianMem; }
java
public RiaNodeMemory createMemory(final RuleBaseConfiguration config, InternalWorkingMemory wm) { RiaNodeMemory rianMem = new RiaNodeMemory(); RiaPathMemory pmem = new RiaPathMemory(this, wm); PathMemSpec pathMemSpec = getPathMemSpec(); pmem.setAllLinkedMaskTest( pathMemSpec.allLinkedTestMask ); pmem.setSegmentMemories( new SegmentMemory[pathMemSpec.smemCount] ); rianMem.setRiaPathMemory(pmem); return rianMem; }
[ "public", "RiaNodeMemory", "createMemory", "(", "final", "RuleBaseConfiguration", "config", ",", "InternalWorkingMemory", "wm", ")", "{", "RiaNodeMemory", "rianMem", "=", "new", "RiaNodeMemory", "(", ")", ";", "RiaPathMemory", "pmem", "=", "new", "RiaPathMemory", "(", "this", ",", "wm", ")", ";", "PathMemSpec", "pathMemSpec", "=", "getPathMemSpec", "(", ")", ";", "pmem", ".", "setAllLinkedMaskTest", "(", "pathMemSpec", ".", "allLinkedTestMask", ")", ";", "pmem", ".", "setSegmentMemories", "(", "new", "SegmentMemory", "[", "pathMemSpec", ".", "smemCount", "]", ")", ";", "rianMem", ".", "setRiaPathMemory", "(", "pmem", ")", ";", "return", "rianMem", ";", "}" ]
Creates and return the node memory
[ "Creates", "and", "return", "the", "node", "memory" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/RightInputAdapterNode.java#L146-L156
14,165
kiegroup/drools
drools-core/src/main/java/org/drools/core/QueryResultsRowImpl.java
QueryResultsRowImpl.get
public Object get(final Declaration declaration) { return declaration.getValue( (InternalWorkingMemory) workingMemory, getObject( getFactHandle( declaration ) ) ); }
java
public Object get(final Declaration declaration) { return declaration.getValue( (InternalWorkingMemory) workingMemory, getObject( getFactHandle( declaration ) ) ); }
[ "public", "Object", "get", "(", "final", "Declaration", "declaration", ")", "{", "return", "declaration", ".", "getValue", "(", "(", "InternalWorkingMemory", ")", "workingMemory", ",", "getObject", "(", "getFactHandle", "(", "declaration", ")", ")", ")", ";", "}" ]
Return the Object for the given Declaration.
[ "Return", "the", "Object", "for", "the", "given", "Declaration", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/QueryResultsRowImpl.java#L85-L87
14,166
kiegroup/drools
drools-core/src/main/java/org/drools/core/QueryResultsRowImpl.java
QueryResultsRowImpl.getFactHandles
public FactHandle[] getFactHandles() { int size = size(); FactHandle[] subArray = new FactHandle[ size]; System.arraycopy( this.row.getHandles(), 1, subArray, 0, size ); return subArray; }
java
public FactHandle[] getFactHandles() { int size = size(); FactHandle[] subArray = new FactHandle[ size]; System.arraycopy( this.row.getHandles(), 1, subArray, 0, size ); return subArray; }
[ "public", "FactHandle", "[", "]", "getFactHandles", "(", ")", "{", "int", "size", "=", "size", "(", ")", ";", "FactHandle", "[", "]", "subArray", "=", "new", "FactHandle", "[", "size", "]", ";", "System", ".", "arraycopy", "(", "this", ".", "row", ".", "getHandles", "(", ")", ",", "1", ",", "subArray", ",", "0", ",", "size", ")", ";", "return", "subArray", ";", "}" ]
Return the FactHandles for the Tuple. @return
[ "Return", "the", "FactHandles", "for", "the", "Tuple", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/QueryResultsRowImpl.java#L111-L117
14,167
kiegroup/drools
drools-core/src/main/java/org/drools/core/base/evaluators/EvaluatorRegistry.java
EvaluatorRegistry.addEvaluatorDefinition
@SuppressWarnings("unchecked") public void addEvaluatorDefinition( String className ) { try { Class<EvaluatorDefinition> defClass = (Class<EvaluatorDefinition>) this.classloader.loadClass( className ); EvaluatorDefinition def = defClass.newInstance(); addEvaluatorDefinition( def ); } catch ( ClassNotFoundException e ) { throw new RuntimeException( "Class not found for evaluator definition: " + className, e ); } catch ( InstantiationException e ) { throw new RuntimeException( "Error instantiating class for evaluator definition: " + className, e ); } catch ( IllegalAccessException e ) { throw new RuntimeException( "Illegal access instantiating class for evaluator definition: " + className, e ); } }
java
@SuppressWarnings("unchecked") public void addEvaluatorDefinition( String className ) { try { Class<EvaluatorDefinition> defClass = (Class<EvaluatorDefinition>) this.classloader.loadClass( className ); EvaluatorDefinition def = defClass.newInstance(); addEvaluatorDefinition( def ); } catch ( ClassNotFoundException e ) { throw new RuntimeException( "Class not found for evaluator definition: " + className, e ); } catch ( InstantiationException e ) { throw new RuntimeException( "Error instantiating class for evaluator definition: " + className, e ); } catch ( IllegalAccessException e ) { throw new RuntimeException( "Illegal access instantiating class for evaluator definition: " + className, e ); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "void", "addEvaluatorDefinition", "(", "String", "className", ")", "{", "try", "{", "Class", "<", "EvaluatorDefinition", ">", "defClass", "=", "(", "Class", "<", "EvaluatorDefinition", ">", ")", "this", ".", "classloader", ".", "loadClass", "(", "className", ")", ";", "EvaluatorDefinition", "def", "=", "defClass", ".", "newInstance", "(", ")", ";", "addEvaluatorDefinition", "(", "def", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Class not found for evaluator definition: \"", "+", "className", ",", "e", ")", ";", "}", "catch", "(", "InstantiationException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error instantiating class for evaluator definition: \"", "+", "className", ",", "e", ")", ";", "}", "catch", "(", "IllegalAccessException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Illegal access instantiating class for evaluator definition: \"", "+", "className", ",", "e", ")", ";", "}", "}" ]
Adds an evaluator definition class to the registry using the evaluator class name. The class will be loaded and the corresponting evaluator ID will be added to the registry. In case there exists an implementation for that ID already, the new implementation will replace the previous one. @param className the name of the class for the implementation definition. The class must implement the EvaluatorDefinition interface. @return true if the new class implementation is replacing an old implementation for the same evaluator ID. False otherwise.
[ "Adds", "an", "evaluator", "definition", "class", "to", "the", "registry", "using", "the", "evaluator", "class", "name", ".", "The", "class", "will", "be", "loaded", "and", "the", "corresponting", "evaluator", "ID", "will", "be", "added", "to", "the", "registry", ".", "In", "case", "there", "exists", "an", "implementation", "for", "that", "ID", "already", "the", "new", "implementation", "will", "replace", "the", "previous", "one", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/base/evaluators/EvaluatorRegistry.java#L116-L132
14,168
kiegroup/drools
drools-core/src/main/java/org/drools/core/base/evaluators/EvaluatorRegistry.java
EvaluatorRegistry.addEvaluatorDefinition
public void addEvaluatorDefinition( EvaluatorDefinition def ) { for ( String id : def.getEvaluatorIds() ) { this.evaluators.put( id, def ); } }
java
public void addEvaluatorDefinition( EvaluatorDefinition def ) { for ( String id : def.getEvaluatorIds() ) { this.evaluators.put( id, def ); } }
[ "public", "void", "addEvaluatorDefinition", "(", "EvaluatorDefinition", "def", ")", "{", "for", "(", "String", "id", ":", "def", ".", "getEvaluatorIds", "(", ")", ")", "{", "this", ".", "evaluators", ".", "put", "(", "id", ",", "def", ")", ";", "}", "}" ]
Adds an evaluator definition class to the registry. In case there exists an implementation for that evaluator ID already, the new implementation will replace the previous one. @param def the evaluator definition to be added.
[ "Adds", "an", "evaluator", "definition", "class", "to", "the", "registry", ".", "In", "case", "there", "exists", "an", "implementation", "for", "that", "evaluator", "ID", "already", "the", "new", "implementation", "will", "replace", "the", "previous", "one", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/base/evaluators/EvaluatorRegistry.java#L141-L146
14,169
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/GuidedDecisionTableUpgradeHelper3.java
GuidedDecisionTableUpgradeHelper3.upgrade
public GuidedDecisionTable52 upgrade(GuidedDecisionTable52 source) { final GuidedDecisionTable52 destination = source; for (BaseColumn column : source.getExpandedColumns()) { DTColumnConfig52 dtColumn = null; if (column instanceof MetadataCol52) { dtColumn = (DTColumnConfig52) column; } else if (column instanceof AttributeCol52) { dtColumn = (DTColumnConfig52) column; } else if (column instanceof ConditionCol52) { dtColumn = (DTColumnConfig52) column; } else if (column instanceof ActionCol52) { dtColumn = (DTColumnConfig52) column; } if (dtColumn instanceof LimitedEntryCol) { dtColumn = null; } if (dtColumn instanceof BRLVariableColumn) { dtColumn = null; } if (dtColumn != null) { final String legacyDefaultValue = dtColumn.defaultValue; if (legacyDefaultValue != null) { dtColumn.setDefaultValue(new DTCellValue52(legacyDefaultValue)); dtColumn.defaultValue = null; } } } return destination; }
java
public GuidedDecisionTable52 upgrade(GuidedDecisionTable52 source) { final GuidedDecisionTable52 destination = source; for (BaseColumn column : source.getExpandedColumns()) { DTColumnConfig52 dtColumn = null; if (column instanceof MetadataCol52) { dtColumn = (DTColumnConfig52) column; } else if (column instanceof AttributeCol52) { dtColumn = (DTColumnConfig52) column; } else if (column instanceof ConditionCol52) { dtColumn = (DTColumnConfig52) column; } else if (column instanceof ActionCol52) { dtColumn = (DTColumnConfig52) column; } if (dtColumn instanceof LimitedEntryCol) { dtColumn = null; } if (dtColumn instanceof BRLVariableColumn) { dtColumn = null; } if (dtColumn != null) { final String legacyDefaultValue = dtColumn.defaultValue; if (legacyDefaultValue != null) { dtColumn.setDefaultValue(new DTCellValue52(legacyDefaultValue)); dtColumn.defaultValue = null; } } } return destination; }
[ "public", "GuidedDecisionTable52", "upgrade", "(", "GuidedDecisionTable52", "source", ")", "{", "final", "GuidedDecisionTable52", "destination", "=", "source", ";", "for", "(", "BaseColumn", "column", ":", "source", ".", "getExpandedColumns", "(", ")", ")", "{", "DTColumnConfig52", "dtColumn", "=", "null", ";", "if", "(", "column", "instanceof", "MetadataCol52", ")", "{", "dtColumn", "=", "(", "DTColumnConfig52", ")", "column", ";", "}", "else", "if", "(", "column", "instanceof", "AttributeCol52", ")", "{", "dtColumn", "=", "(", "DTColumnConfig52", ")", "column", ";", "}", "else", "if", "(", "column", "instanceof", "ConditionCol52", ")", "{", "dtColumn", "=", "(", "DTColumnConfig52", ")", "column", ";", "}", "else", "if", "(", "column", "instanceof", "ActionCol52", ")", "{", "dtColumn", "=", "(", "DTColumnConfig52", ")", "column", ";", "}", "if", "(", "dtColumn", "instanceof", "LimitedEntryCol", ")", "{", "dtColumn", "=", "null", ";", "}", "if", "(", "dtColumn", "instanceof", "BRLVariableColumn", ")", "{", "dtColumn", "=", "null", ";", "}", "if", "(", "dtColumn", "!=", "null", ")", "{", "final", "String", "legacyDefaultValue", "=", "dtColumn", ".", "defaultValue", ";", "if", "(", "legacyDefaultValue", "!=", "null", ")", "{", "dtColumn", ".", "setDefaultValue", "(", "new", "DTCellValue52", "(", "legacyDefaultValue", ")", ")", ";", "dtColumn", ".", "defaultValue", "=", "null", ";", "}", "}", "}", "return", "destination", ";", "}" ]
Convert the Default Values in the Decision Table model @param source @return The new DTModel
[ "Convert", "the", "Default", "Values", "in", "the", "Decision", "Table", "model" ]
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/GuidedDecisionTableUpgradeHelper3.java#L44-L75
14,170
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDI.java
DMNDI.getDMNDiagram
@Override public List<DMNDiagram> getDMNDiagram() { if (dmnDiagram == null) { dmnDiagram = new ArrayList<DMNDiagram>(); } return this.dmnDiagram; }
java
@Override public List<DMNDiagram> getDMNDiagram() { if (dmnDiagram == null) { dmnDiagram = new ArrayList<DMNDiagram>(); } return this.dmnDiagram; }
[ "@", "Override", "public", "List", "<", "DMNDiagram", ">", "getDMNDiagram", "(", ")", "{", "if", "(", "dmnDiagram", "==", "null", ")", "{", "dmnDiagram", "=", "new", "ArrayList", "<", "DMNDiagram", ">", "(", ")", ";", "}", "return", "this", ".", "dmnDiagram", ";", "}" ]
Gets the value of the dmnDiagram 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 dmnDiagram property. <p> For example, to add a new item, do as follows: <pre> getDMNDiagram().add(newItem); </pre> <p> Objects of the following type(s) are allowed in the list {@link DMNDiagram }
[ "Gets", "the", "value", "of", "the", "dmnDiagram", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDI.java#L59-L65
14,171
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDI.java
DMNDI.getDMNStyle
@Override public List<DMNStyle> getDMNStyle() { if (dmnStyle == null) { dmnStyle = new ArrayList<DMNStyle>(); } return this.dmnStyle; }
java
@Override public List<DMNStyle> getDMNStyle() { if (dmnStyle == null) { dmnStyle = new ArrayList<DMNStyle>(); } return this.dmnStyle; }
[ "@", "Override", "public", "List", "<", "DMNStyle", ">", "getDMNStyle", "(", ")", "{", "if", "(", "dmnStyle", "==", "null", ")", "{", "dmnStyle", "=", "new", "ArrayList", "<", "DMNStyle", ">", "(", ")", ";", "}", "return", "this", ".", "dmnStyle", ";", "}" ]
Gets the value of the dmnStyle 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 dmnStyle property. <p> For example, to add a new item, do as follows: <pre> getDMNStyle().add(newItem); </pre> <p> Objects of the following type(s) are allowed in the list {@link DMNStyle }
[ "Gets", "the", "value", "of", "the", "dmnStyle", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNDI.java#L89-L95
14,172
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/DialectUtil.java
DialectUtil.getUniqueLegalName
public static String getUniqueLegalName(final String packageName, final String name, final int seed, final String ext, final String prefix, final ResourceReader src) { // replaces all non alphanumeric or $ chars with _ final String newName = prefix + "_" + normalizeRuleName( name ); if (ext.equals("java")) { return newName + Math.abs(seed); } final String fileName = packageName.replace('.', '/') + "/" + newName; if (src == null || !src.isAvailable(fileName + "." + ext)) return newName; // make sure the class name does not exist, if it does increase the counter int counter = -1; while (true) { counter++; final String actualName = fileName + "_" + counter + "." + ext; //MVEL:test null to Fix failing test on MVELConsequenceBuilderTest.testImperativeCodeError() if (!src.isAvailable(actualName)) break; } // we have duplicate file names so append counter return newName + "_" + counter; }
java
public static String getUniqueLegalName(final String packageName, final String name, final int seed, final String ext, final String prefix, final ResourceReader src) { // replaces all non alphanumeric or $ chars with _ final String newName = prefix + "_" + normalizeRuleName( name ); if (ext.equals("java")) { return newName + Math.abs(seed); } final String fileName = packageName.replace('.', '/') + "/" + newName; if (src == null || !src.isAvailable(fileName + "." + ext)) return newName; // make sure the class name does not exist, if it does increase the counter int counter = -1; while (true) { counter++; final String actualName = fileName + "_" + counter + "." + ext; //MVEL:test null to Fix failing test on MVELConsequenceBuilderTest.testImperativeCodeError() if (!src.isAvailable(actualName)) break; } // we have duplicate file names so append counter return newName + "_" + counter; }
[ "public", "static", "String", "getUniqueLegalName", "(", "final", "String", "packageName", ",", "final", "String", "name", ",", "final", "int", "seed", ",", "final", "String", "ext", ",", "final", "String", "prefix", ",", "final", "ResourceReader", "src", ")", "{", "// replaces all non alphanumeric or $ chars with _", "final", "String", "newName", "=", "prefix", "+", "\"_\"", "+", "normalizeRuleName", "(", "name", ")", ";", "if", "(", "ext", ".", "equals", "(", "\"java\"", ")", ")", "{", "return", "newName", "+", "Math", ".", "abs", "(", "seed", ")", ";", "}", "final", "String", "fileName", "=", "packageName", ".", "replace", "(", "'", "'", ",", "'", "'", ")", "+", "\"/\"", "+", "newName", ";", "if", "(", "src", "==", "null", "||", "!", "src", ".", "isAvailable", "(", "fileName", "+", "\".\"", "+", "ext", ")", ")", "return", "newName", ";", "// make sure the class name does not exist, if it does increase the counter", "int", "counter", "=", "-", "1", ";", "while", "(", "true", ")", "{", "counter", "++", ";", "final", "String", "actualName", "=", "fileName", "+", "\"_\"", "+", "counter", "+", "\".\"", "+", "ext", ";", "//MVEL:test null to Fix failing test on MVELConsequenceBuilderTest.testImperativeCodeError()", "if", "(", "!", "src", ".", "isAvailable", "(", "actualName", ")", ")", "break", ";", "}", "// we have duplicate file names so append counter", "return", "newName", "+", "\"_\"", "+", "counter", ";", "}" ]
Takes a given name and makes sure that its legal and doesn't already exist. If the file exists it increases counter appender untill it is unique.
[ "Takes", "a", "given", "name", "and", "makes", "sure", "that", "its", "legal", "and", "doesn", "t", "already", "exist", ".", "If", "the", "file", "exists", "it", "increases", "counter", "appender", "untill", "it", "is", "unique", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/rule/builder/dialect/DialectUtil.java#L83-L111
14,173
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/impl/FEELImpl.java
FEELImpl.newEvaluationContext
public EvaluationContextImpl newEvaluationContext(Collection<FEELEventListener> listeners, Map<String, Object> inputVariables) { return newEvaluationContext(this.classLoader, listeners, inputVariables); }
java
public EvaluationContextImpl newEvaluationContext(Collection<FEELEventListener> listeners, Map<String, Object> inputVariables) { return newEvaluationContext(this.classLoader, listeners, inputVariables); }
[ "public", "EvaluationContextImpl", "newEvaluationContext", "(", "Collection", "<", "FEELEventListener", ">", "listeners", ",", "Map", "<", "String", ",", "Object", ">", "inputVariables", ")", "{", "return", "newEvaluationContext", "(", "this", ".", "classLoader", ",", "listeners", ",", "inputVariables", ")", ";", "}" ]
Creates a new EvaluationContext using this FEEL instance classloader, and the supplied parameters listeners and inputVariables
[ "Creates", "a", "new", "EvaluationContext", "using", "this", "FEEL", "instance", "classloader", "and", "the", "supplied", "parameters", "listeners", "and", "inputVariables" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/impl/FEELImpl.java#L170-L172
14,174
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/impl/FEELImpl.java
FEELImpl.newEvaluationContext
public EvaluationContextImpl newEvaluationContext(ClassLoader cl, Collection<FEELEventListener> listeners, Map<String, Object> inputVariables) { FEELEventListenersManager eventsManager = getEventsManager(listeners); EvaluationContextImpl ctx = new EvaluationContextImpl(cl, eventsManager, inputVariables.size()); if (customFrame.isPresent()) { ExecutionFrameImpl globalFrame = (ExecutionFrameImpl) ctx.pop(); ExecutionFrameImpl interveawedFrame = customFrame.get(); interveawedFrame.setParentFrame(ctx.peek()); globalFrame.setParentFrame(interveawedFrame); ctx.push(interveawedFrame); ctx.push(globalFrame); } ctx.setValues(inputVariables); return ctx; }
java
public EvaluationContextImpl newEvaluationContext(ClassLoader cl, Collection<FEELEventListener> listeners, Map<String, Object> inputVariables) { FEELEventListenersManager eventsManager = getEventsManager(listeners); EvaluationContextImpl ctx = new EvaluationContextImpl(cl, eventsManager, inputVariables.size()); if (customFrame.isPresent()) { ExecutionFrameImpl globalFrame = (ExecutionFrameImpl) ctx.pop(); ExecutionFrameImpl interveawedFrame = customFrame.get(); interveawedFrame.setParentFrame(ctx.peek()); globalFrame.setParentFrame(interveawedFrame); ctx.push(interveawedFrame); ctx.push(globalFrame); } ctx.setValues(inputVariables); return ctx; }
[ "public", "EvaluationContextImpl", "newEvaluationContext", "(", "ClassLoader", "cl", ",", "Collection", "<", "FEELEventListener", ">", "listeners", ",", "Map", "<", "String", ",", "Object", ">", "inputVariables", ")", "{", "FEELEventListenersManager", "eventsManager", "=", "getEventsManager", "(", "listeners", ")", ";", "EvaluationContextImpl", "ctx", "=", "new", "EvaluationContextImpl", "(", "cl", ",", "eventsManager", ",", "inputVariables", ".", "size", "(", ")", ")", ";", "if", "(", "customFrame", ".", "isPresent", "(", ")", ")", "{", "ExecutionFrameImpl", "globalFrame", "=", "(", "ExecutionFrameImpl", ")", "ctx", ".", "pop", "(", ")", ";", "ExecutionFrameImpl", "interveawedFrame", "=", "customFrame", ".", "get", "(", ")", ";", "interveawedFrame", ".", "setParentFrame", "(", "ctx", ".", "peek", "(", ")", ")", ";", "globalFrame", ".", "setParentFrame", "(", "interveawedFrame", ")", ";", "ctx", ".", "push", "(", "interveawedFrame", ")", ";", "ctx", ".", "push", "(", "globalFrame", ")", ";", "}", "ctx", ".", "setValues", "(", "inputVariables", ")", ";", "return", "ctx", ";", "}" ]
Creates a new EvaluationContext with the supplied classloader, and the supplied parameters listeners and inputVariables
[ "Creates", "a", "new", "EvaluationContext", "with", "the", "supplied", "classloader", "and", "the", "supplied", "parameters", "listeners", "and", "inputVariables" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/impl/FEELImpl.java#L177-L190
14,175
kiegroup/drools
drools-core/src/main/java/org/drools/core/common/ConcurrentNodeMemories.java
ConcurrentNodeMemories.getNodeMemory
public Memory getNodeMemory(MemoryFactory node, InternalWorkingMemory wm) { if( node.getMemoryId() >= this.memories.length() ) { resize( node ); } Memory memory = this.memories.get( node.getMemoryId() ); if( memory == null ) { memory = createNodeMemory( node, wm ); } return memory; }
java
public Memory getNodeMemory(MemoryFactory node, InternalWorkingMemory wm) { if( node.getMemoryId() >= this.memories.length() ) { resize( node ); } Memory memory = this.memories.get( node.getMemoryId() ); if( memory == null ) { memory = createNodeMemory( node, wm ); } return memory; }
[ "public", "Memory", "getNodeMemory", "(", "MemoryFactory", "node", ",", "InternalWorkingMemory", "wm", ")", "{", "if", "(", "node", ".", "getMemoryId", "(", ")", ">=", "this", ".", "memories", ".", "length", "(", ")", ")", "{", "resize", "(", "node", ")", ";", "}", "Memory", "memory", "=", "this", ".", "memories", ".", "get", "(", "node", ".", "getMemoryId", "(", ")", ")", ";", "if", "(", "memory", "==", "null", ")", "{", "memory", "=", "createNodeMemory", "(", "node", ",", "wm", ")", ";", "}", "return", "memory", ";", "}" ]
The implementation tries to delay locking as much as possible, by running some potentially unsafe operations out of the critical session. In case it fails the checks, it will move into the critical sessions and re-check everything before effectively doing any change on data structures.
[ "The", "implementation", "tries", "to", "delay", "locking", "as", "much", "as", "possible", "by", "running", "some", "potentially", "unsafe", "operations", "out", "of", "the", "critical", "session", ".", "In", "case", "it", "fails", "the", "checks", "it", "will", "move", "into", "the", "critical", "sessions", "and", "re", "-", "check", "everything", "before", "effectively", "doing", "any", "change", "on", "data", "structures", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/common/ConcurrentNodeMemories.java#L79-L90
14,176
kiegroup/drools
drools-core/src/main/java/org/drools/core/common/ConcurrentNodeMemories.java
ConcurrentNodeMemories.createNodeMemory
private Memory createNodeMemory( MemoryFactory node, InternalWorkingMemory wm ) { try { this.lock.lock(); // need to try again in a synchronized code block to make sure // it was not created yet Memory memory = this.memories.get( node.getMemoryId() ); if( memory == null ) { memory = node.createMemory( this.kBase.getConfiguration(), wm ); if( !this.memories.compareAndSet( node.getMemoryId(), null, memory ) ) { memory = this.memories.get( node.getMemoryId() ); } } return memory; } finally { this.lock.unlock(); } }
java
private Memory createNodeMemory( MemoryFactory node, InternalWorkingMemory wm ) { try { this.lock.lock(); // need to try again in a synchronized code block to make sure // it was not created yet Memory memory = this.memories.get( node.getMemoryId() ); if( memory == null ) { memory = node.createMemory( this.kBase.getConfiguration(), wm ); if( !this.memories.compareAndSet( node.getMemoryId(), null, memory ) ) { memory = this.memories.get( node.getMemoryId() ); } } return memory; } finally { this.lock.unlock(); } }
[ "private", "Memory", "createNodeMemory", "(", "MemoryFactory", "node", ",", "InternalWorkingMemory", "wm", ")", "{", "try", "{", "this", ".", "lock", ".", "lock", "(", ")", ";", "// need to try again in a synchronized code block to make sure", "// it was not created yet", "Memory", "memory", "=", "this", ".", "memories", ".", "get", "(", "node", ".", "getMemoryId", "(", ")", ")", ";", "if", "(", "memory", "==", "null", ")", "{", "memory", "=", "node", ".", "createMemory", "(", "this", ".", "kBase", ".", "getConfiguration", "(", ")", ",", "wm", ")", ";", "if", "(", "!", "this", ".", "memories", ".", "compareAndSet", "(", "node", ".", "getMemoryId", "(", ")", ",", "null", ",", "memory", ")", ")", "{", "memory", "=", "this", ".", "memories", ".", "get", "(", "node", ".", "getMemoryId", "(", ")", ")", ";", "}", "}", "return", "memory", ";", "}", "finally", "{", "this", ".", "lock", ".", "unlock", "(", ")", ";", "}", "}" ]
Checks if a memory does not exists for the given node and creates it.
[ "Checks", "if", "a", "memory", "does", "not", "exists", "for", "the", "given", "node", "and", "creates", "it", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/common/ConcurrentNodeMemories.java#L97-L117
14,177
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNShape.java
DMNShape.setDMNDecisionServiceDividerLine
public void setDMNDecisionServiceDividerLine(org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine value) { this.dmnDecisionServiceDividerLine = value; }
java
public void setDMNDecisionServiceDividerLine(org.kie.dmn.model.api.dmndi.DMNDecisionServiceDividerLine value) { this.dmnDecisionServiceDividerLine = value; }
[ "public", "void", "setDMNDecisionServiceDividerLine", "(", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "DMNDecisionServiceDividerLine", "value", ")", "{", "this", ".", "dmnDecisionServiceDividerLine", "=", "value", ";", "}" ]
Sets the value of the dmnDecisionServiceDividerLine property. @param value allowed object is {@link DMNDecisionServiceDividerLine }
[ "Sets", "the", "value", "of", "the", "dmnDecisionServiceDividerLine", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNShape.java#L73-L75
14,178
kiegroup/drools
drools-core/src/main/java/org/drools/core/base/EvaluatorWrapper.java
EvaluatorWrapper.evaluate
public boolean evaluate(InternalWorkingMemory workingMemory, Object left, Object right) { Object leftValue = leftTimestamp != null ? leftTimestamp : left; Object rightValue = rightTimestamp != null ? rightTimestamp : right; return rightLiteral ? evaluator.evaluate( workingMemory, new ConstantValueReader( leftValue ), dummyFactHandleOf( leftValue ), new ObjectFieldImpl( rightValue ) ) : evaluator.evaluate( workingMemory, new ConstantValueReader( leftValue ), dummyFactHandleOf( leftValue ), new ConstantValueReader( rightValue ), dummyFactHandleOf( rightValue ) ); }
java
public boolean evaluate(InternalWorkingMemory workingMemory, Object left, Object right) { Object leftValue = leftTimestamp != null ? leftTimestamp : left; Object rightValue = rightTimestamp != null ? rightTimestamp : right; return rightLiteral ? evaluator.evaluate( workingMemory, new ConstantValueReader( leftValue ), dummyFactHandleOf( leftValue ), new ObjectFieldImpl( rightValue ) ) : evaluator.evaluate( workingMemory, new ConstantValueReader( leftValue ), dummyFactHandleOf( leftValue ), new ConstantValueReader( rightValue ), dummyFactHandleOf( rightValue ) ); }
[ "public", "boolean", "evaluate", "(", "InternalWorkingMemory", "workingMemory", ",", "Object", "left", ",", "Object", "right", ")", "{", "Object", "leftValue", "=", "leftTimestamp", "!=", "null", "?", "leftTimestamp", ":", "left", ";", "Object", "rightValue", "=", "rightTimestamp", "!=", "null", "?", "rightTimestamp", ":", "right", ";", "return", "rightLiteral", "?", "evaluator", ".", "evaluate", "(", "workingMemory", ",", "new", "ConstantValueReader", "(", "leftValue", ")", ",", "dummyFactHandleOf", "(", "leftValue", ")", ",", "new", "ObjectFieldImpl", "(", "rightValue", ")", ")", ":", "evaluator", ".", "evaluate", "(", "workingMemory", ",", "new", "ConstantValueReader", "(", "leftValue", ")", ",", "dummyFactHandleOf", "(", "leftValue", ")", ",", "new", "ConstantValueReader", "(", "rightValue", ")", ",", "dummyFactHandleOf", "(", "rightValue", ")", ")", ";", "}" ]
This method is called when operators are rewritten as function calls. For instance, x after y Is rewritten as after.evaluate( _workingMemory_, x, y ) @return
[ "This", "method", "is", "called", "when", "operators", "are", "rewritten", "as", "function", "calls", ".", "For", "instance" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/base/EvaluatorWrapper.java#L90-L104
14,179
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java
RuleModel.getLHSBoundFact
public FactPattern getLHSBoundFact(final String var) { if (this.lhs == null) { return null; } for (int i = 0; i < this.lhs.length; i++) { IPattern pat = this.lhs[i]; if (pat instanceof FromCompositeFactPattern) { pat = ((FromCompositeFactPattern) pat).getFactPattern(); } if (pat instanceof FactPattern) { final FactPattern p = (FactPattern) pat; if (p.getBoundName() != null && var.equals(p.getBoundName())) { return p; } } } return null; }
java
public FactPattern getLHSBoundFact(final String var) { if (this.lhs == null) { return null; } for (int i = 0; i < this.lhs.length; i++) { IPattern pat = this.lhs[i]; if (pat instanceof FromCompositeFactPattern) { pat = ((FromCompositeFactPattern) pat).getFactPattern(); } if (pat instanceof FactPattern) { final FactPattern p = (FactPattern) pat; if (p.getBoundName() != null && var.equals(p.getBoundName())) { return p; } } } return null; }
[ "public", "FactPattern", "getLHSBoundFact", "(", "final", "String", "var", ")", "{", "if", "(", "this", ".", "lhs", "==", "null", ")", "{", "return", "null", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "lhs", ".", "length", ";", "i", "++", ")", "{", "IPattern", "pat", "=", "this", ".", "lhs", "[", "i", "]", ";", "if", "(", "pat", "instanceof", "FromCompositeFactPattern", ")", "{", "pat", "=", "(", "(", "FromCompositeFactPattern", ")", "pat", ")", ".", "getFactPattern", "(", ")", ";", "}", "if", "(", "pat", "instanceof", "FactPattern", ")", "{", "final", "FactPattern", "p", "=", "(", "FactPattern", ")", "pat", ";", "if", "(", "p", ".", "getBoundName", "(", ")", "!=", "null", "&&", "var", ".", "equals", "(", "p", ".", "getBoundName", "(", ")", ")", ")", "{", "return", "p", ";", "}", "}", "}", "return", "null", ";", "}" ]
This will return the FactPattern that a variable is bound Eto. @param var The bound fact variable (NOT bound field). @return null or the FactPattern found.
[ "This", "will", "return", "the", "FactPattern", "that", "a", "variable", "is", "bound", "Eto", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java#L85-L102
14,180
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java
RuleModel.getLHSBoundField
public SingleFieldConstraint getLHSBoundField(final String var) { if (this.lhs == null) { return null; } for (int i = 0; i < this.lhs.length; i++) { IPattern pat = this.lhs[i]; SingleFieldConstraint fieldConstraint = getLHSBoundField(pat, var); if (fieldConstraint != null) { return fieldConstraint; } } return null; }
java
public SingleFieldConstraint getLHSBoundField(final String var) { if (this.lhs == null) { return null; } for (int i = 0; i < this.lhs.length; i++) { IPattern pat = this.lhs[i]; SingleFieldConstraint fieldConstraint = getLHSBoundField(pat, var); if (fieldConstraint != null) { return fieldConstraint; } } return null; }
[ "public", "SingleFieldConstraint", "getLHSBoundField", "(", "final", "String", "var", ")", "{", "if", "(", "this", ".", "lhs", "==", "null", ")", "{", "return", "null", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "lhs", ".", "length", ";", "i", "++", ")", "{", "IPattern", "pat", "=", "this", ".", "lhs", "[", "i", "]", ";", "SingleFieldConstraint", "fieldConstraint", "=", "getLHSBoundField", "(", "pat", ",", "var", ")", ";", "if", "(", "fieldConstraint", "!=", "null", ")", "{", "return", "fieldConstraint", ";", "}", "}", "return", "null", ";", "}" ]
This will return the FieldConstraint that a variable is bound to. @param var The bound field variable (NOT bound fact). @return null or the FieldConstraint found.
[ "This", "will", "return", "the", "FieldConstraint", "that", "a", "variable", "is", "bound", "to", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java#L110-L125
14,181
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java
RuleModel.getLHSBindingType
public String getLHSBindingType(final String var) { if (this.lhs == null) { return null; } for (int i = 0; i < this.lhs.length; i++) { String type = getLHSBindingType(this.lhs[i], var); if (type != null) { return type; } } return null; }
java
public String getLHSBindingType(final String var) { if (this.lhs == null) { return null; } for (int i = 0; i < this.lhs.length; i++) { String type = getLHSBindingType(this.lhs[i], var); if (type != null) { return type; } } return null; }
[ "public", "String", "getLHSBindingType", "(", "final", "String", "var", ")", "{", "if", "(", "this", ".", "lhs", "==", "null", ")", "{", "return", "null", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "lhs", ".", "length", ";", "i", "++", ")", "{", "String", "type", "=", "getLHSBindingType", "(", "this", ".", "lhs", "[", "i", "]", ",", "var", ")", ";", "if", "(", "type", "!=", "null", ")", "{", "return", "type", ";", "}", "}", "return", "null", ";", "}" ]
Get the data-type associated with the binding @param var @return The data-type, or null if the binding could not be found
[ "Get", "the", "data", "-", "type", "associated", "with", "the", "binding" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java#L166-L178
14,182
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java
RuleModel.getRHSBoundFact
public ActionInsertFact getRHSBoundFact(final String var) { if (this.rhs == null) { return null; } for (int i = 0; i < this.rhs.length; i++) { if (this.rhs[i] instanceof ActionInsertFact) { final ActionInsertFact p = (ActionInsertFact) this.rhs[i]; if (p.getBoundName() != null && var.equals(p.getBoundName())) { return p; } } } return null; }
java
public ActionInsertFact getRHSBoundFact(final String var) { if (this.rhs == null) { return null; } for (int i = 0; i < this.rhs.length; i++) { if (this.rhs[i] instanceof ActionInsertFact) { final ActionInsertFact p = (ActionInsertFact) this.rhs[i]; if (p.getBoundName() != null && var.equals(p.getBoundName())) { return p; } } } return null; }
[ "public", "ActionInsertFact", "getRHSBoundFact", "(", "final", "String", "var", ")", "{", "if", "(", "this", ".", "rhs", "==", "null", ")", "{", "return", "null", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "rhs", ".", "length", ";", "i", "++", ")", "{", "if", "(", "this", ".", "rhs", "[", "i", "]", "instanceof", "ActionInsertFact", ")", "{", "final", "ActionInsertFact", "p", "=", "(", "ActionInsertFact", ")", "this", ".", "rhs", "[", "i", "]", ";", "if", "(", "p", ".", "getBoundName", "(", ")", "!=", "null", "&&", "var", ".", "equals", "(", "p", ".", "getBoundName", "(", ")", ")", ")", "{", "return", "p", ";", "}", "}", "}", "return", "null", ";", "}" ]
This will return the ActionInsertFact that a variable is bound to. @param var The bound fact variable (NOT bound field). @return null or the ActionInsertFact found.
[ "This", "will", "return", "the", "ActionInsertFact", "that", "a", "variable", "is", "bound", "to", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java#L265-L278
14,183
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java
RuleModel.getLHSParentFactPatternForBinding
public FactPattern getLHSParentFactPatternForBinding(final String var) { if (this.lhs == null) { return null; } for (int i = 0; i < this.lhs.length; i++) { IPattern pat = this.lhs[i]; if (pat instanceof FromCompositeFactPattern) { pat = ((FromCompositeFactPattern) pat).getFactPattern(); } if (pat instanceof FactPattern) { final FactPattern p = (FactPattern) pat; if (p.getBoundName() != null && var.equals(p.getBoundName())) { return p; } for (int j = 0; j < p.getFieldConstraints().length; j++) { FieldConstraint fc = p.getFieldConstraints()[j]; List<String> fieldBindings = getFieldBinding(fc); if (fieldBindings.contains(var)) { return p; } } } } return null; }
java
public FactPattern getLHSParentFactPatternForBinding(final String var) { if (this.lhs == null) { return null; } for (int i = 0; i < this.lhs.length; i++) { IPattern pat = this.lhs[i]; if (pat instanceof FromCompositeFactPattern) { pat = ((FromCompositeFactPattern) pat).getFactPattern(); } if (pat instanceof FactPattern) { final FactPattern p = (FactPattern) pat; if (p.getBoundName() != null && var.equals(p.getBoundName())) { return p; } for (int j = 0; j < p.getFieldConstraints().length; j++) { FieldConstraint fc = p.getFieldConstraints()[j]; List<String> fieldBindings = getFieldBinding(fc); if (fieldBindings.contains(var)) { return p; } } } } return null; }
[ "public", "FactPattern", "getLHSParentFactPatternForBinding", "(", "final", "String", "var", ")", "{", "if", "(", "this", ".", "lhs", "==", "null", ")", "{", "return", "null", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "lhs", ".", "length", ";", "i", "++", ")", "{", "IPattern", "pat", "=", "this", ".", "lhs", "[", "i", "]", ";", "if", "(", "pat", "instanceof", "FromCompositeFactPattern", ")", "{", "pat", "=", "(", "(", "FromCompositeFactPattern", ")", "pat", ")", ".", "getFactPattern", "(", ")", ";", "}", "if", "(", "pat", "instanceof", "FactPattern", ")", "{", "final", "FactPattern", "p", "=", "(", "FactPattern", ")", "pat", ";", "if", "(", "p", ".", "getBoundName", "(", ")", "!=", "null", "&&", "var", ".", "equals", "(", "p", ".", "getBoundName", "(", ")", ")", ")", "{", "return", "p", ";", "}", "for", "(", "int", "j", "=", "0", ";", "j", "<", "p", ".", "getFieldConstraints", "(", ")", ".", "length", ";", "j", "++", ")", "{", "FieldConstraint", "fc", "=", "p", ".", "getFieldConstraints", "(", ")", "[", "j", "]", ";", "List", "<", "String", ">", "fieldBindings", "=", "getFieldBinding", "(", "fc", ")", ";", "if", "(", "fieldBindings", ".", "contains", "(", "var", ")", ")", "{", "return", "p", ";", "}", "}", "}", "}", "return", "null", ";", "}" ]
This will return the FactPattern that a variable is bound to. If the variable is bound to a FieldConstraint the parent FactPattern will be returned. @param var The variable binding @return null or the FactPattern found.
[ "This", "will", "return", "the", "FactPattern", "that", "a", "variable", "is", "bound", "to", ".", "If", "the", "variable", "is", "bound", "to", "a", "FieldConstraint", "the", "parent", "FactPattern", "will", "be", "returned", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java#L288-L312
14,184
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java
RuleModel.getAllRHSVariables
public List<String> getAllRHSVariables() { List<String> result = new ArrayList<String>(); for (int i = 0; i < this.rhs.length; i++) { IAction pat = this.rhs[i]; if (pat instanceof ActionInsertFact) { ActionInsertFact fact = (ActionInsertFact) pat; if (fact.isBound()) { result.add(fact.getBoundName()); } } } return result; }
java
public List<String> getAllRHSVariables() { List<String> result = new ArrayList<String>(); for (int i = 0; i < this.rhs.length; i++) { IAction pat = this.rhs[i]; if (pat instanceof ActionInsertFact) { ActionInsertFact fact = (ActionInsertFact) pat; if (fact.isBound()) { result.add(fact.getBoundName()); } } } return result; }
[ "public", "List", "<", "String", ">", "getAllRHSVariables", "(", ")", "{", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "rhs", ".", "length", ";", "i", "++", ")", "{", "IAction", "pat", "=", "this", ".", "rhs", "[", "i", "]", ";", "if", "(", "pat", "instanceof", "ActionInsertFact", ")", "{", "ActionInsertFact", "fact", "=", "(", "ActionInsertFact", ")", "pat", ";", "if", "(", "fact", ".", "isBound", "(", ")", ")", "{", "result", ".", "add", "(", "fact", ".", "getBoundName", "(", ")", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
This will get a list of all RHS bound variables.
[ "This", "will", "get", "a", "list", "of", "all", "RHS", "bound", "variables", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java#L375-L389
14,185
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java
RuleModel.getMetaData
public RuleMetadata getMetaData(String attributeName) { if (metadataList != null && attributeName != null) { for (int i = 0; i < metadataList.length; i++) { if (attributeName.equals(metadataList[i].getAttributeName())) { return metadataList[i]; } } } return null; }
java
public RuleMetadata getMetaData(String attributeName) { if (metadataList != null && attributeName != null) { for (int i = 0; i < metadataList.length; i++) { if (attributeName.equals(metadataList[i].getAttributeName())) { return metadataList[i]; } } } return null; }
[ "public", "RuleMetadata", "getMetaData", "(", "String", "attributeName", ")", "{", "if", "(", "metadataList", "!=", "null", "&&", "attributeName", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "metadataList", ".", "length", ";", "i", "++", ")", "{", "if", "(", "attributeName", ".", "equals", "(", "metadataList", "[", "i", "]", ".", "getAttributeName", "(", ")", ")", ")", "{", "return", "metadataList", "[", "i", "]", ";", "}", "}", "}", "return", "null", ";", "}" ]
Locate metadata element @param attributeName - value to look for @return null if not found
[ "Locate", "metadata", "element" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java#L700-L710
14,186
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java
RuleModel.updateMetadata
public boolean updateMetadata(final RuleMetadata target) { RuleMetadata metaData = getMetaData(target.getAttributeName()); if (metaData != null) { metaData.setValue(target.getValue()); return true; } addMetadata(target); return false; }
java
public boolean updateMetadata(final RuleMetadata target) { RuleMetadata metaData = getMetaData(target.getAttributeName()); if (metaData != null) { metaData.setValue(target.getValue()); return true; } addMetadata(target); return false; }
[ "public", "boolean", "updateMetadata", "(", "final", "RuleMetadata", "target", ")", "{", "RuleMetadata", "metaData", "=", "getMetaData", "(", "target", ".", "getAttributeName", "(", ")", ")", ";", "if", "(", "metaData", "!=", "null", ")", "{", "metaData", ".", "setValue", "(", "target", ".", "getValue", "(", ")", ")", ";", "return", "true", ";", "}", "addMetadata", "(", "target", ")", ";", "return", "false", ";", "}" ]
Update metaData element if it exists or add it otherwise @param target @return true on update of existing element false on added of element
[ "Update", "metaData", "element", "if", "it", "exists", "or", "add", "it", "otherwise" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java#L718-L728
14,187
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java
RuleModel.hasDSLSentences
public boolean hasDSLSentences() { if (this.lhs != null) { for (IPattern pattern : this.lhs) { if (pattern instanceof DSLSentence) { return true; } } } if (this.rhs != null) { for (IAction action : this.rhs) { if (action instanceof DSLSentence) { return true; } } } return false; }
java
public boolean hasDSLSentences() { if (this.lhs != null) { for (IPattern pattern : this.lhs) { if (pattern instanceof DSLSentence) { return true; } } } if (this.rhs != null) { for (IAction action : this.rhs) { if (action instanceof DSLSentence) { return true; } } } return false; }
[ "public", "boolean", "hasDSLSentences", "(", ")", "{", "if", "(", "this", ".", "lhs", "!=", "null", ")", "{", "for", "(", "IPattern", "pattern", ":", "this", ".", "lhs", ")", "{", "if", "(", "pattern", "instanceof", "DSLSentence", ")", "{", "return", "true", ";", "}", "}", "}", "if", "(", "this", ".", "rhs", "!=", "null", ")", "{", "for", "(", "IAction", "action", ":", "this", ".", "rhs", ")", "{", "if", "(", "action", "instanceof", "DSLSentence", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Returns true if any DSLSentences are used.
[ "Returns", "true", "if", "any", "DSLSentences", "are", "used", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/RuleModel.java#L823-L842
14,188
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/DTCellValue52.java
DTCellValue52.cloneDefaultValueCell
public DTCellValue52 cloneDefaultValueCell() { DTCellValue52 cloned = new DTCellValue52(); cloned.valueBoolean = valueBoolean; cloned.valueDate = valueDate; cloned.valueNumeric = valueNumeric; cloned.valueString = valueString; cloned.dataType = dataType; return cloned; }
java
public DTCellValue52 cloneDefaultValueCell() { DTCellValue52 cloned = new DTCellValue52(); cloned.valueBoolean = valueBoolean; cloned.valueDate = valueDate; cloned.valueNumeric = valueNumeric; cloned.valueString = valueString; cloned.dataType = dataType; return cloned; }
[ "public", "DTCellValue52", "cloneDefaultValueCell", "(", ")", "{", "DTCellValue52", "cloned", "=", "new", "DTCellValue52", "(", ")", ";", "cloned", ".", "valueBoolean", "=", "valueBoolean", ";", "cloned", ".", "valueDate", "=", "valueDate", ";", "cloned", ".", "valueNumeric", "=", "valueNumeric", ";", "cloned", ".", "valueString", "=", "valueString", ";", "cloned", ".", "dataType", "=", "dataType", ";", "return", "cloned", ";", "}" ]
Clones this default value instance. @return The cloned instance.
[ "Clones", "this", "default", "value", "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/DTCellValue52.java#L492-L500
14,189
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/WindowNode.java
WindowNode.createMemory
public WindowMemory createMemory(final RuleBaseConfiguration config, InternalWorkingMemory wm) { WindowMemory memory = new WindowMemory(); memory.behaviorContext = this.behavior.createBehaviorContext(); return memory; }
java
public WindowMemory createMemory(final RuleBaseConfiguration config, InternalWorkingMemory wm) { WindowMemory memory = new WindowMemory(); memory.behaviorContext = this.behavior.createBehaviorContext(); return memory; }
[ "public", "WindowMemory", "createMemory", "(", "final", "RuleBaseConfiguration", "config", ",", "InternalWorkingMemory", "wm", ")", "{", "WindowMemory", "memory", "=", "new", "WindowMemory", "(", ")", ";", "memory", ".", "behaviorContext", "=", "this", ".", "behavior", ".", "createBehaviorContext", "(", ")", ";", "return", "memory", ";", "}" ]
Creates the WindowNode's memory.
[ "Creates", "the", "WindowNode", "s", "memory", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/WindowNode.java#L256-L260
14,190
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/hitpolicy/RowPriorityResolver.java
RowPriorityResolver.moveRowsBasedOnPriority
private void moveRowsBasedOnPriority() { for (RowNumber myNumber : overs.keySet()) { Over over = overs.get(myNumber); int newIndex = rowOrder.indexOf(new RowNumber(over.getOver())); rowOrder.remove(myNumber); rowOrder.add(newIndex, myNumber); } }
java
private void moveRowsBasedOnPriority() { for (RowNumber myNumber : overs.keySet()) { Over over = overs.get(myNumber); int newIndex = rowOrder.indexOf(new RowNumber(over.getOver())); rowOrder.remove(myNumber); rowOrder.add(newIndex, myNumber); } }
[ "private", "void", "moveRowsBasedOnPriority", "(", ")", "{", "for", "(", "RowNumber", "myNumber", ":", "overs", ".", "keySet", "(", ")", ")", "{", "Over", "over", "=", "overs", ".", "get", "(", "myNumber", ")", ";", "int", "newIndex", "=", "rowOrder", ".", "indexOf", "(", "new", "RowNumber", "(", "over", ".", "getOver", "(", ")", ")", ")", ";", "rowOrder", ".", "remove", "(", "myNumber", ")", ";", "rowOrder", ".", "add", "(", "newIndex", ",", "myNumber", ")", ";", "}", "}" ]
Move rows on top of the row it has priority over.
[ "Move", "rows", "on", "top", "of", "the", "row", "it", "has", "priority", "over", "." ]
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/hitpolicy/RowPriorityResolver.java#L75-L85
14,191
kiegroup/drools
drools-core/src/main/java/org/drools/core/management/KnowledgeBaseMonitoring.java
KnowledgeBaseMonitoring.initOpenMBeanInfo
private void initOpenMBeanInfo() { OpenMBeanAttributeInfoSupport[] attributes = new OpenMBeanAttributeInfoSupport[4]; OpenMBeanConstructorInfoSupport[] constructors = new OpenMBeanConstructorInfoSupport[1]; OpenMBeanOperationInfoSupport[] operations = new OpenMBeanOperationInfoSupport[2]; MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[0]; try { // Define the attributes attributes[0] = new OpenMBeanAttributeInfoSupport(ATTR_ID, "Knowledge Base Id", SimpleType.STRING, true, false, false); attributes[1] = new OpenMBeanAttributeInfoSupport(ATTR_SESSION_COUNT, "Number of created sessions for this Knowledge Base", SimpleType.LONG, true, false, false); attributes[2] = new OpenMBeanAttributeInfoSupport(ATTR_GLOBALS, "List of globals", globalsTableType, true, false, false ); attributes[3] = new OpenMBeanAttributeInfoSupport( ATTR_PACKAGES, "List of Packages", new ArrayType( 1, SimpleType.STRING ), true, false, false ); //No arg constructor constructors[0] = new OpenMBeanConstructorInfoSupport( "KnowledgeBaseMonitoringMXBean", "Constructs a KnowledgeBaseMonitoringMXBean instance.", new OpenMBeanParameterInfoSupport[0] ); //Operations OpenMBeanParameterInfo[] params = new OpenMBeanParameterInfoSupport[0]; operations[0] = new OpenMBeanOperationInfoSupport( OP_START_INTERNAL_MBEANS, "Creates, registers and starts all the dependent MBeans that allow monitor all the details in this KnowledgeBase.", params, SimpleType.VOID, MBeanOperationInfo.INFO ); operations[1] = new OpenMBeanOperationInfoSupport( OP_STOP_INTERNAL_MBEANS, "Stops and disposes all the dependent MBeans that allow monitor all the details in this KnowledgeBase.", params, SimpleType.VOID, MBeanOperationInfo.INFO ); //Build the info info = new OpenMBeanInfoSupport( this.getClass().getName(), "Knowledge Base Monitor MXBean", attributes, constructors, operations, notifications ); } catch ( Exception e ) { e.printStackTrace(); } }
java
private void initOpenMBeanInfo() { OpenMBeanAttributeInfoSupport[] attributes = new OpenMBeanAttributeInfoSupport[4]; OpenMBeanConstructorInfoSupport[] constructors = new OpenMBeanConstructorInfoSupport[1]; OpenMBeanOperationInfoSupport[] operations = new OpenMBeanOperationInfoSupport[2]; MBeanNotificationInfo[] notifications = new MBeanNotificationInfo[0]; try { // Define the attributes attributes[0] = new OpenMBeanAttributeInfoSupport(ATTR_ID, "Knowledge Base Id", SimpleType.STRING, true, false, false); attributes[1] = new OpenMBeanAttributeInfoSupport(ATTR_SESSION_COUNT, "Number of created sessions for this Knowledge Base", SimpleType.LONG, true, false, false); attributes[2] = new OpenMBeanAttributeInfoSupport(ATTR_GLOBALS, "List of globals", globalsTableType, true, false, false ); attributes[3] = new OpenMBeanAttributeInfoSupport( ATTR_PACKAGES, "List of Packages", new ArrayType( 1, SimpleType.STRING ), true, false, false ); //No arg constructor constructors[0] = new OpenMBeanConstructorInfoSupport( "KnowledgeBaseMonitoringMXBean", "Constructs a KnowledgeBaseMonitoringMXBean instance.", new OpenMBeanParameterInfoSupport[0] ); //Operations OpenMBeanParameterInfo[] params = new OpenMBeanParameterInfoSupport[0]; operations[0] = new OpenMBeanOperationInfoSupport( OP_START_INTERNAL_MBEANS, "Creates, registers and starts all the dependent MBeans that allow monitor all the details in this KnowledgeBase.", params, SimpleType.VOID, MBeanOperationInfo.INFO ); operations[1] = new OpenMBeanOperationInfoSupport( OP_STOP_INTERNAL_MBEANS, "Stops and disposes all the dependent MBeans that allow monitor all the details in this KnowledgeBase.", params, SimpleType.VOID, MBeanOperationInfo.INFO ); //Build the info info = new OpenMBeanInfoSupport( this.getClass().getName(), "Knowledge Base Monitor MXBean", attributes, constructors, operations, notifications ); } catch ( Exception e ) { e.printStackTrace(); } }
[ "private", "void", "initOpenMBeanInfo", "(", ")", "{", "OpenMBeanAttributeInfoSupport", "[", "]", "attributes", "=", "new", "OpenMBeanAttributeInfoSupport", "[", "4", "]", ";", "OpenMBeanConstructorInfoSupport", "[", "]", "constructors", "=", "new", "OpenMBeanConstructorInfoSupport", "[", "1", "]", ";", "OpenMBeanOperationInfoSupport", "[", "]", "operations", "=", "new", "OpenMBeanOperationInfoSupport", "[", "2", "]", ";", "MBeanNotificationInfo", "[", "]", "notifications", "=", "new", "MBeanNotificationInfo", "[", "0", "]", ";", "try", "{", "// Define the attributes ", "attributes", "[", "0", "]", "=", "new", "OpenMBeanAttributeInfoSupport", "(", "ATTR_ID", ",", "\"Knowledge Base Id\"", ",", "SimpleType", ".", "STRING", ",", "true", ",", "false", ",", "false", ")", ";", "attributes", "[", "1", "]", "=", "new", "OpenMBeanAttributeInfoSupport", "(", "ATTR_SESSION_COUNT", ",", "\"Number of created sessions for this Knowledge Base\"", ",", "SimpleType", ".", "LONG", ",", "true", ",", "false", ",", "false", ")", ";", "attributes", "[", "2", "]", "=", "new", "OpenMBeanAttributeInfoSupport", "(", "ATTR_GLOBALS", ",", "\"List of globals\"", ",", "globalsTableType", ",", "true", ",", "false", ",", "false", ")", ";", "attributes", "[", "3", "]", "=", "new", "OpenMBeanAttributeInfoSupport", "(", "ATTR_PACKAGES", ",", "\"List of Packages\"", ",", "new", "ArrayType", "(", "1", ",", "SimpleType", ".", "STRING", ")", ",", "true", ",", "false", ",", "false", ")", ";", "//No arg constructor ", "constructors", "[", "0", "]", "=", "new", "OpenMBeanConstructorInfoSupport", "(", "\"KnowledgeBaseMonitoringMXBean\"", ",", "\"Constructs a KnowledgeBaseMonitoringMXBean instance.\"", ",", "new", "OpenMBeanParameterInfoSupport", "[", "0", "]", ")", ";", "//Operations ", "OpenMBeanParameterInfo", "[", "]", "params", "=", "new", "OpenMBeanParameterInfoSupport", "[", "0", "]", ";", "operations", "[", "0", "]", "=", "new", "OpenMBeanOperationInfoSupport", "(", "OP_START_INTERNAL_MBEANS", ",", "\"Creates, registers and starts all the dependent MBeans that allow monitor all the details in this KnowledgeBase.\"", ",", "params", ",", "SimpleType", ".", "VOID", ",", "MBeanOperationInfo", ".", "INFO", ")", ";", "operations", "[", "1", "]", "=", "new", "OpenMBeanOperationInfoSupport", "(", "OP_STOP_INTERNAL_MBEANS", ",", "\"Stops and disposes all the dependent MBeans that allow monitor all the details in this KnowledgeBase.\"", ",", "params", ",", "SimpleType", ".", "VOID", ",", "MBeanOperationInfo", ".", "INFO", ")", ";", "//Build the info ", "info", "=", "new", "OpenMBeanInfoSupport", "(", "this", ".", "getClass", "(", ")", ".", "getName", "(", ")", ",", "\"Knowledge Base Monitor MXBean\"", ",", "attributes", ",", "constructors", ",", "operations", ",", "notifications", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Initialize the open mbean metadata
[ "Initialize", "the", "open", "mbean", "metadata" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/management/KnowledgeBaseMonitoring.java#L126-L186
14,192
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/DSLSentence.java
DSLSentence.interpolate
public String interpolate() { getValues(); if (definition == null) { return ""; } int variableStart = definition.indexOf("{"); if (variableStart < 0) { return definition; } int index = 0; int variableEnd = 0; StringBuilder sb = new StringBuilder(); while (variableStart >= 0) { sb.append(definition.substring(variableEnd, variableStart)); variableEnd = getIndexForEndOfVariable(definition, variableStart) + 1; variableStart = definition.indexOf("{", variableEnd); sb.append(values.get(index++).getValue()); } if (variableEnd < definition.length()) { sb.append(definition.substring(variableEnd)); } return sb.toString(); }
java
public String interpolate() { getValues(); if (definition == null) { return ""; } int variableStart = definition.indexOf("{"); if (variableStart < 0) { return definition; } int index = 0; int variableEnd = 0; StringBuilder sb = new StringBuilder(); while (variableStart >= 0) { sb.append(definition.substring(variableEnd, variableStart)); variableEnd = getIndexForEndOfVariable(definition, variableStart) + 1; variableStart = definition.indexOf("{", variableEnd); sb.append(values.get(index++).getValue()); } if (variableEnd < definition.length()) { sb.append(definition.substring(variableEnd)); } return sb.toString(); }
[ "public", "String", "interpolate", "(", ")", "{", "getValues", "(", ")", ";", "if", "(", "definition", "==", "null", ")", "{", "return", "\"\"", ";", "}", "int", "variableStart", "=", "definition", ".", "indexOf", "(", "\"{\"", ")", ";", "if", "(", "variableStart", "<", "0", ")", "{", "return", "definition", ";", "}", "int", "index", "=", "0", ";", "int", "variableEnd", "=", "0", ";", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "variableStart", ">=", "0", ")", "{", "sb", ".", "append", "(", "definition", ".", "substring", "(", "variableEnd", ",", "variableStart", ")", ")", ";", "variableEnd", "=", "getIndexForEndOfVariable", "(", "definition", ",", "variableStart", ")", "+", "1", ";", "variableStart", "=", "definition", ".", "indexOf", "(", "\"{\"", ",", "variableEnd", ")", ";", "sb", ".", "append", "(", "values", ".", "get", "(", "index", "++", ")", ".", "getValue", "(", ")", ")", ";", "}", "if", "(", "variableEnd", "<", "definition", ".", "length", "(", ")", ")", "{", "sb", ".", "append", "(", "definition", ".", "substring", "(", "variableEnd", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
This will strip off any "{" stuff, substituting values accordingly
[ "This", "will", "strip", "off", "any", "{", "stuff", "substituting", "values", "accordingly" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/DSLSentence.java#L75-L102
14,193
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/DSLSentence.java
DSLSentence.copy
public DSLSentence copy() { final DSLSentence copy = new DSLSentence(); copy.drl = getDrl(); copy.definition = getDefinition(); copy.values = mapCopy(getValues()); return copy; }
java
public DSLSentence copy() { final DSLSentence copy = new DSLSentence(); copy.drl = getDrl(); copy.definition = getDefinition(); copy.values = mapCopy(getValues()); return copy; }
[ "public", "DSLSentence", "copy", "(", ")", "{", "final", "DSLSentence", "copy", "=", "new", "DSLSentence", "(", ")", ";", "copy", ".", "drl", "=", "getDrl", "(", ")", ";", "copy", ".", "definition", "=", "getDefinition", "(", ")", ";", "copy", ".", "values", "=", "mapCopy", "(", "getValues", "(", ")", ")", ";", "return", "copy", ";", "}" ]
This is used by the GUI when adding a sentence to LHS or RHS. @return
[ "This", "is", "used", "by", "the", "GUI", "when", "adding", "a", "sentence", "to", "LHS", "or", "RHS", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/DSLSentence.java#L108-L116
14,194
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/DSLSentence.java
DSLSentence.parseSentence
private void parseSentence() { if (sentence == null) { return; } definition = sentence; values = new ArrayList<DSLVariableValue>(); sentence = null; int variableStart = definition.indexOf("{"); while (variableStart >= 0) { int variableEnd = getIndexForEndOfVariable(definition, variableStart); String variable = definition.substring(variableStart + 1, variableEnd); values.add(parseValue(variable)); variableStart = definition.indexOf("{", variableEnd); } }
java
private void parseSentence() { if (sentence == null) { return; } definition = sentence; values = new ArrayList<DSLVariableValue>(); sentence = null; int variableStart = definition.indexOf("{"); while (variableStart >= 0) { int variableEnd = getIndexForEndOfVariable(definition, variableStart); String variable = definition.substring(variableStart + 1, variableEnd); values.add(parseValue(variable)); variableStart = definition.indexOf("{", variableEnd); } }
[ "private", "void", "parseSentence", "(", ")", "{", "if", "(", "sentence", "==", "null", ")", "{", "return", ";", "}", "definition", "=", "sentence", ";", "values", "=", "new", "ArrayList", "<", "DSLVariableValue", ">", "(", ")", ";", "sentence", "=", "null", ";", "int", "variableStart", "=", "definition", ".", "indexOf", "(", "\"{\"", ")", ";", "while", "(", "variableStart", ">=", "0", ")", "{", "int", "variableEnd", "=", "getIndexForEndOfVariable", "(", "definition", ",", "variableStart", ")", ";", "String", "variable", "=", "definition", ".", "substring", "(", "variableStart", "+", "1", ",", "variableEnd", ")", ";", "values", ".", "add", "(", "parseValue", "(", "variable", ")", ")", ";", "variableStart", "=", "definition", ".", "indexOf", "(", "\"{\"", ",", "variableEnd", ")", ";", "}", "}" ]
to differentiate value, from data-type, from restriction
[ "to", "differentiate", "value", "from", "data", "-", "type", "from", "restriction" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/DSLSentence.java#L191-L209
14,195
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/DSLSentence.java
DSLSentence.parseDefinition
private void parseDefinition() { values = new ArrayList<DSLVariableValue>(); if (getDefinition() == null) { return; } int variableStart = definition.indexOf("{"); while (variableStart >= 0) { int variableEnd = getIndexForEndOfVariable(definition, variableStart); String variable = definition.substring(variableStart + 1, variableEnd); values.add(parseValue(variable)); variableStart = definition.indexOf("{", variableEnd); } }
java
private void parseDefinition() { values = new ArrayList<DSLVariableValue>(); if (getDefinition() == null) { return; } int variableStart = definition.indexOf("{"); while (variableStart >= 0) { int variableEnd = getIndexForEndOfVariable(definition, variableStart); String variable = definition.substring(variableStart + 1, variableEnd); values.add(parseValue(variable)); variableStart = definition.indexOf("{", variableEnd); } }
[ "private", "void", "parseDefinition", "(", ")", "{", "values", "=", "new", "ArrayList", "<", "DSLVariableValue", ">", "(", ")", ";", "if", "(", "getDefinition", "(", ")", "==", "null", ")", "{", "return", ";", "}", "int", "variableStart", "=", "definition", ".", "indexOf", "(", "\"{\"", ")", ";", "while", "(", "variableStart", ">=", "0", ")", "{", "int", "variableEnd", "=", "getIndexForEndOfVariable", "(", "definition", ",", "variableStart", ")", ";", "String", "variable", "=", "definition", ".", "substring", "(", "variableStart", "+", "1", ",", "variableEnd", ")", ";", "values", ".", "add", "(", "parseValue", "(", "variable", ")", ")", ";", "variableStart", "=", "definition", ".", "indexOf", "(", "\"{\"", ",", "variableEnd", ")", ";", "}", "}" ]
Build the Values from the Definition.
[ "Build", "the", "Values", "from", "the", "Definition", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/DSLSentence.java#L212-L228
14,196
kiegroup/drools
kie-pmml/src/main/java/org/kie/pmml/assembler/PMMLAssemblerService.java
PMMLAssemblerService.addPackage
private void addPackage(Resource resource) throws DroolsParserException, IOException { if (pmmlCompiler != null) { if (pmmlCompiler.getResults().isEmpty()) { addPMMLPojos(pmmlCompiler, resource); if (pmmlCompiler.getResults().isEmpty()) { List<PackageDescr> packages = getPackageDescrs(resource); if (packages != null && !packages.isEmpty()) { for (PackageDescr descr : packages) { this.kbuilder.addPackage(descr); } } } } } }
java
private void addPackage(Resource resource) throws DroolsParserException, IOException { if (pmmlCompiler != null) { if (pmmlCompiler.getResults().isEmpty()) { addPMMLPojos(pmmlCompiler, resource); if (pmmlCompiler.getResults().isEmpty()) { List<PackageDescr> packages = getPackageDescrs(resource); if (packages != null && !packages.isEmpty()) { for (PackageDescr descr : packages) { this.kbuilder.addPackage(descr); } } } } } }
[ "private", "void", "addPackage", "(", "Resource", "resource", ")", "throws", "DroolsParserException", ",", "IOException", "{", "if", "(", "pmmlCompiler", "!=", "null", ")", "{", "if", "(", "pmmlCompiler", ".", "getResults", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "addPMMLPojos", "(", "pmmlCompiler", ",", "resource", ")", ";", "if", "(", "pmmlCompiler", ".", "getResults", "(", ")", ".", "isEmpty", "(", ")", ")", "{", "List", "<", "PackageDescr", ">", "packages", "=", "getPackageDescrs", "(", "resource", ")", ";", "if", "(", "packages", "!=", "null", "&&", "!", "packages", ".", "isEmpty", "(", ")", ")", "{", "for", "(", "PackageDescr", "descr", ":", "packages", ")", "{", "this", ".", "kbuilder", ".", "addPackage", "(", "descr", ")", ";", "}", "}", "}", "}", "}", "}" ]
This method does the work of calling the PMML compiler and then assembling the results into packages that are added to the KnowledgeBuilder @param resource @throws DroolsParserException @throws IOException
[ "This", "method", "does", "the", "work", "of", "calling", "the", "PMML", "compiler", "and", "then", "assembling", "the", "results", "into", "packages", "that", "are", "added", "to", "the", "KnowledgeBuilder" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-pmml/src/main/java/org/kie/pmml/assembler/PMMLAssemblerService.java#L100-L114
14,197
kiegroup/drools
kie-pmml/src/main/java/org/kie/pmml/assembler/PMMLAssemblerService.java
PMMLAssemblerService.getPackageDescrs
private List<PackageDescr> getPackageDescrs(Resource resource) throws DroolsParserException, IOException { List<PMMLResource> resources = pmmlCompiler.precompile(resource.getInputStream(), null, null); if (resources != null && !resources.isEmpty()) { return generatedResourcesToPackageDescr(resource, resources); } return null; }
java
private List<PackageDescr> getPackageDescrs(Resource resource) throws DroolsParserException, IOException { List<PMMLResource> resources = pmmlCompiler.precompile(resource.getInputStream(), null, null); if (resources != null && !resources.isEmpty()) { return generatedResourcesToPackageDescr(resource, resources); } return null; }
[ "private", "List", "<", "PackageDescr", ">", "getPackageDescrs", "(", "Resource", "resource", ")", "throws", "DroolsParserException", ",", "IOException", "{", "List", "<", "PMMLResource", ">", "resources", "=", "pmmlCompiler", ".", "precompile", "(", "resource", ".", "getInputStream", "(", ")", ",", "null", ",", "null", ")", ";", "if", "(", "resources", "!=", "null", "&&", "!", "resources", ".", "isEmpty", "(", ")", ")", "{", "return", "generatedResourcesToPackageDescr", "(", "resource", ",", "resources", ")", ";", "}", "return", "null", ";", "}" ]
This method calls the PMML compiler to get PMMLResource objects which are used to create one or more PackageDescr objects @param resource @return @throws DroolsParserException @throws IOException
[ "This", "method", "calls", "the", "PMML", "compiler", "to", "get", "PMMLResource", "objects", "which", "are", "used", "to", "create", "one", "or", "more", "PackageDescr", "objects" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-pmml/src/main/java/org/kie/pmml/assembler/PMMLAssemblerService.java#L124-L130
14,198
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-template/src/main/java/org/drools/workbench/models/guided/template/backend/upgrade/RuleModelUpgradeHelper1.java
RuleModelUpgradeHelper1.updateMethodCall
private RuleModel updateMethodCall(RuleModel model) { for (int i = 0; i < model.rhs.length; i++) { if (model.rhs[i] instanceof ActionCallMethod) { ActionCallMethod action = (ActionCallMethod) model.rhs[i]; // Check if method name is filled, if not this was made with an older Guvnor version if (action.getMethodName() == null || "".equals(action.getMethodName())) { if (action.getFieldValues() != null && action.getFieldValues().length >= 1) { action.setMethodName(action.getFieldValues()[0].getField()); action.setFieldValues(new ActionFieldValue[0]); action.setState(ActionCallMethod.TYPE_DEFINED); } } } } return model; }
java
private RuleModel updateMethodCall(RuleModel model) { for (int i = 0; i < model.rhs.length; i++) { if (model.rhs[i] instanceof ActionCallMethod) { ActionCallMethod action = (ActionCallMethod) model.rhs[i]; // Check if method name is filled, if not this was made with an older Guvnor version if (action.getMethodName() == null || "".equals(action.getMethodName())) { if (action.getFieldValues() != null && action.getFieldValues().length >= 1) { action.setMethodName(action.getFieldValues()[0].getField()); action.setFieldValues(new ActionFieldValue[0]); action.setState(ActionCallMethod.TYPE_DEFINED); } } } } return model; }
[ "private", "RuleModel", "updateMethodCall", "(", "RuleModel", "model", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "model", ".", "rhs", ".", "length", ";", "i", "++", ")", "{", "if", "(", "model", ".", "rhs", "[", "i", "]", "instanceof", "ActionCallMethod", ")", "{", "ActionCallMethod", "action", "=", "(", "ActionCallMethod", ")", "model", ".", "rhs", "[", "i", "]", ";", "// Check if method name is filled, if not this was made with an older Guvnor version", "if", "(", "action", ".", "getMethodName", "(", ")", "==", "null", "||", "\"\"", ".", "equals", "(", "action", ".", "getMethodName", "(", ")", ")", ")", "{", "if", "(", "action", ".", "getFieldValues", "(", ")", "!=", "null", "&&", "action", ".", "getFieldValues", "(", ")", ".", "length", ">=", "1", ")", "{", "action", ".", "setMethodName", "(", "action", ".", "getFieldValues", "(", ")", "[", "0", "]", ".", "getField", "(", ")", ")", ";", "action", ".", "setFieldValues", "(", "new", "ActionFieldValue", "[", "0", "]", ")", ";", "action", ".", "setState", "(", "ActionCallMethod", ".", "TYPE_DEFINED", ")", ";", "}", "}", "}", "}", "return", "model", ";", "}" ]
before that needs to be updated.
[ "before", "that", "needs", "to", "be", "updated", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-template/src/main/java/org/drools/workbench/models/guided/template/backend/upgrade/RuleModelUpgradeHelper1.java#L46-L64
14,199
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java
EvalHelper.isValidChar
private static boolean isValidChar(char c) { if ( c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' ) { return true; } return c != ' ' && c != '\u00A0' && !Character.isWhitespace(c) && !Character.isWhitespace(c); }
java
private static boolean isValidChar(char c) { if ( c >= '0' && c <= '9' || c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z' ) { return true; } return c != ' ' && c != '\u00A0' && !Character.isWhitespace(c) && !Character.isWhitespace(c); }
[ "private", "static", "boolean", "isValidChar", "(", "char", "c", ")", "{", "if", "(", "c", ">=", "'", "'", "&&", "c", "<=", "'", "'", "||", "c", ">=", "'", "'", "&&", "c", "<=", "'", "'", "||", "c", ">=", "'", "'", "&&", "c", "<=", "'", "'", ")", "{", "return", "true", ";", "}", "return", "c", "!=", "'", "'", "&&", "c", "!=", "'", "'", "&&", "!", "Character", ".", "isWhitespace", "(", "c", ")", "&&", "!", "Character", ".", "isWhitespace", "(", "c", ")", ";", "}" ]
This method defines what characters are valid for the output of normalizeVariableName. Spaces and control characters are invalid. There is a fast-path for well known characters
[ "This", "method", "defines", "what", "characters", "are", "valid", "for", "the", "output", "of", "normalizeVariableName", ".", "Spaces", "and", "control", "characters", "are", "invalid", ".", "There", "is", "a", "fast", "-", "path", "for", "well", "known", "characters" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/EvalHelper.java#L140-L145