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,300
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNStyle.java
DMNStyle.setStrokeColor
public void setStrokeColor(org.kie.dmn.model.api.dmndi.Color value) { this.strokeColor = value; }
java
public void setStrokeColor(org.kie.dmn.model.api.dmndi.Color value) { this.strokeColor = value; }
[ "public", "void", "setStrokeColor", "(", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "Color", "value", ")", "{", "this", ".", "strokeColor", "=", "value", ";", "}" ]
Sets the value of the strokeColor property. @param value allowed object is {@link Color }
[ "Sets", "the", "value", "of", "the", "strokeColor", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNStyle.java#L80-L82
14,301
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNStyle.java
DMNStyle.setFontColor
public void setFontColor(org.kie.dmn.model.api.dmndi.Color value) { this.fontColor = value; }
java
public void setFontColor(org.kie.dmn.model.api.dmndi.Color value) { this.fontColor = value; }
[ "public", "void", "setFontColor", "(", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "Color", "value", ")", "{", "this", ".", "fontColor", "=", "value", ";", "}" ]
Sets the value of the fontColor property. @param value allowed object is {@link Color }
[ "Sets", "the", "value", "of", "the", "fontColor", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DMNStyle.java#L104-L106
14,302
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/conversion/ConversionResult.java
ConversionResult.getMessages
public List<ConversionMessage> getMessages( ConversionMessageType messageType ) { List<ConversionMessage> messages = new ArrayList<ConversionMessage>(); for ( ConversionMessage message : this.messages ) { if ( message.getMessageType() == messageType ) { messages.add( message ); } } return messages; }
java
public List<ConversionMessage> getMessages( ConversionMessageType messageType ) { List<ConversionMessage> messages = new ArrayList<ConversionMessage>(); for ( ConversionMessage message : this.messages ) { if ( message.getMessageType() == messageType ) { messages.add( message ); } } return messages; }
[ "public", "List", "<", "ConversionMessage", ">", "getMessages", "(", "ConversionMessageType", "messageType", ")", "{", "List", "<", "ConversionMessage", ">", "messages", "=", "new", "ArrayList", "<", "ConversionMessage", ">", "(", ")", ";", "for", "(", "ConversionMessage", "message", ":", "this", ".", "messages", ")", "{", "if", "(", "message", ".", "getMessageType", "(", ")", "==", "messageType", ")", "{", "messages", ".", "add", "(", "message", ")", ";", "}", "}", "return", "messages", ";", "}" ]
Get all messages of a particular type @param messageType @return
[ "Get", "all", "messages", "of", "a", "particular", "type" ]
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/conversion/ConversionResult.java#L68-L76
14,303
kiegroup/drools
drools-beliefs/src/main/java/org/drools/beliefs/bayes/JunctionTreeBuilder.java
JunctionTreeBuilder.cloneAdjacencyMarix
public static boolean[][] cloneAdjacencyMarix(boolean[][] src) { int length = src.length; boolean[][] target = new boolean[length][src[0].length]; for (int i = 0; i < length; i++) { System.arraycopy(src[i], 0, target[i], 0, src[i].length); } return target; }
java
public static boolean[][] cloneAdjacencyMarix(boolean[][] src) { int length = src.length; boolean[][] target = new boolean[length][src[0].length]; for (int i = 0; i < length; i++) { System.arraycopy(src[i], 0, target[i], 0, src[i].length); } return target; }
[ "public", "static", "boolean", "[", "]", "[", "]", "cloneAdjacencyMarix", "(", "boolean", "[", "]", "[", "]", "src", ")", "{", "int", "length", "=", "src", ".", "length", ";", "boolean", "[", "]", "[", "]", "target", "=", "new", "boolean", "[", "length", "]", "[", "src", "[", "0", "]", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")", "{", "System", ".", "arraycopy", "(", "src", "[", "i", "]", ",", "0", ",", "target", "[", "i", "]", ",", "0", ",", "src", "[", "i", "]", ".", "length", ")", ";", "}", "return", "target", ";", "}" ]
Clones the provided array @param src @return a new clone of the provided array
[ "Clones", "the", "provided", "array" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-beliefs/src/main/java/org/drools/beliefs/bayes/JunctionTreeBuilder.java#L217-L224
14,304
kiegroup/drools
drools-beliefs/src/main/java/org/drools/beliefs/bayes/JunctionTreeBuilder.java
JunctionTreeBuilder.mapNodeToCliqueFamily
public void mapNodeToCliqueFamily(OpenBitSet[] varNodeToCliques, JunctionTreeClique[] jtNodes) { for ( int i = 0; i < varNodeToCliques.length; i++ ) { GraphNode<BayesVariable> varNode = graph.getNode( i ); // Get OpenBitSet for parents OpenBitSet parents = new OpenBitSet(); int count = 0; for ( Edge edge : varNode.getInEdges() ) { parents.set( edge.getOutGraphNode().getId() ); count++; } if ( count == 0 ) { // node has no parents, so simply find the smallest clique it's in. } OpenBitSet cliques = varNodeToCliques[i]; if ( cliques == null ) { throw new IllegalStateException("Node exists, that is not part of a clique. " + varNode.toString()); } int bestWeight = -1; int clique = -1; // finds the smallest node, that contains all the parents for ( int j = cliques.nextSetBit(0); j >= 0; j = cliques.nextSetBit( j+ 1 ) ) { JunctionTreeClique jtNode = jtNodes[j]; // if the node has parents, we find the small clique it's in. // If it has parents then is jtNode a supserset of parents, visa-vis is parents a subset of jtNode if ( (count == 0 || OpenBitSet.andNotCount(parents, jtNode.getBitSet()) == 0 ) && ( clique == -1 || jtNode.getBitSet().cardinality() < bestWeight ) ) { bestWeight = (int) jtNode.getBitSet().cardinality(); clique = j; } } if ( clique == -1 ) { throw new IllegalStateException("No clique for node found." + varNode.toString()); } varNode.getContent().setFamily( clique ); jtNodes[clique].addToFamily( varNode.getContent() ); } }
java
public void mapNodeToCliqueFamily(OpenBitSet[] varNodeToCliques, JunctionTreeClique[] jtNodes) { for ( int i = 0; i < varNodeToCliques.length; i++ ) { GraphNode<BayesVariable> varNode = graph.getNode( i ); // Get OpenBitSet for parents OpenBitSet parents = new OpenBitSet(); int count = 0; for ( Edge edge : varNode.getInEdges() ) { parents.set( edge.getOutGraphNode().getId() ); count++; } if ( count == 0 ) { // node has no parents, so simply find the smallest clique it's in. } OpenBitSet cliques = varNodeToCliques[i]; if ( cliques == null ) { throw new IllegalStateException("Node exists, that is not part of a clique. " + varNode.toString()); } int bestWeight = -1; int clique = -1; // finds the smallest node, that contains all the parents for ( int j = cliques.nextSetBit(0); j >= 0; j = cliques.nextSetBit( j+ 1 ) ) { JunctionTreeClique jtNode = jtNodes[j]; // if the node has parents, we find the small clique it's in. // If it has parents then is jtNode a supserset of parents, visa-vis is parents a subset of jtNode if ( (count == 0 || OpenBitSet.andNotCount(parents, jtNode.getBitSet()) == 0 ) && ( clique == -1 || jtNode.getBitSet().cardinality() < bestWeight ) ) { bestWeight = (int) jtNode.getBitSet().cardinality(); clique = j; } } if ( clique == -1 ) { throw new IllegalStateException("No clique for node found." + varNode.toString()); } varNode.getContent().setFamily( clique ); jtNodes[clique].addToFamily( varNode.getContent() ); } }
[ "public", "void", "mapNodeToCliqueFamily", "(", "OpenBitSet", "[", "]", "varNodeToCliques", ",", "JunctionTreeClique", "[", "]", "jtNodes", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "varNodeToCliques", ".", "length", ";", "i", "++", ")", "{", "GraphNode", "<", "BayesVariable", ">", "varNode", "=", "graph", ".", "getNode", "(", "i", ")", ";", "// Get OpenBitSet for parents", "OpenBitSet", "parents", "=", "new", "OpenBitSet", "(", ")", ";", "int", "count", "=", "0", ";", "for", "(", "Edge", "edge", ":", "varNode", ".", "getInEdges", "(", ")", ")", "{", "parents", ".", "set", "(", "edge", ".", "getOutGraphNode", "(", ")", ".", "getId", "(", ")", ")", ";", "count", "++", ";", "}", "if", "(", "count", "==", "0", ")", "{", "// node has no parents, so simply find the smallest clique it's in.", "}", "OpenBitSet", "cliques", "=", "varNodeToCliques", "[", "i", "]", ";", "if", "(", "cliques", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Node exists, that is not part of a clique. \"", "+", "varNode", ".", "toString", "(", ")", ")", ";", "}", "int", "bestWeight", "=", "-", "1", ";", "int", "clique", "=", "-", "1", ";", "// finds the smallest node, that contains all the parents", "for", "(", "int", "j", "=", "cliques", ".", "nextSetBit", "(", "0", ")", ";", "j", ">=", "0", ";", "j", "=", "cliques", ".", "nextSetBit", "(", "j", "+", "1", ")", ")", "{", "JunctionTreeClique", "jtNode", "=", "jtNodes", "[", "j", "]", ";", "// if the node has parents, we find the small clique it's in.", "// If it has parents then is jtNode a supserset of parents, visa-vis is parents a subset of jtNode", "if", "(", "(", "count", "==", "0", "||", "OpenBitSet", ".", "andNotCount", "(", "parents", ",", "jtNode", ".", "getBitSet", "(", ")", ")", "==", "0", ")", "&&", "(", "clique", "==", "-", "1", "||", "jtNode", ".", "getBitSet", "(", ")", ".", "cardinality", "(", ")", "<", "bestWeight", ")", ")", "{", "bestWeight", "=", "(", "int", ")", "jtNode", ".", "getBitSet", "(", ")", ".", "cardinality", "(", ")", ";", "clique", "=", "j", ";", "}", "}", "if", "(", "clique", "==", "-", "1", ")", "{", "throw", "new", "IllegalStateException", "(", "\"No clique for node found.\"", "+", "varNode", ".", "toString", "(", ")", ")", ";", "}", "varNode", ".", "getContent", "(", ")", ".", "setFamily", "(", "clique", ")", ";", "jtNodes", "[", "clique", "]", ".", "addToFamily", "(", "varNode", ".", "getContent", "(", ")", ")", ";", "}", "}" ]
Given the set of cliques, mapped via ID in a Bitset, for a given bayes node, Find the best clique. Where best clique is one that contains all it's parents with the smallest number of nodes in that clique. When there are no parents then simply pick the clique with the smallest number nodes. @param varNodeToCliques @param jtNodes
[ "Given", "the", "set", "of", "cliques", "mapped", "via", "ID", "in", "a", "Bitset", "for", "a", "given", "bayes", "node", "Find", "the", "best", "clique", ".", "Where", "best", "clique", "is", "one", "that", "contains", "all", "it", "s", "parents", "with", "the", "smallest", "number", "of", "nodes", "in", "that", "clique", ".", "When", "there", "are", "no", "parents", "then", "simply", "pick", "the", "clique", "with", "the", "smallest", "number", "nodes", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-beliefs/src/main/java/org/drools/beliefs/bayes/JunctionTreeBuilder.java#L331-L372
14,305
kiegroup/drools
drools-beliefs/src/main/java/org/drools/beliefs/bayes/JunctionTreeBuilder.java
JunctionTreeBuilder.mapVarNodeToCliques
public void mapVarNodeToCliques(OpenBitSet[] nodeToCliques, int id, OpenBitSet clique) { for ( int i = clique.nextSetBit(0); i >= 0; i = clique.nextSetBit( i + 1 ) ) { OpenBitSet cliques = nodeToCliques[i]; if ( cliques == null ) { cliques = new OpenBitSet(); nodeToCliques[i] = cliques; } cliques.set(id); } }
java
public void mapVarNodeToCliques(OpenBitSet[] nodeToCliques, int id, OpenBitSet clique) { for ( int i = clique.nextSetBit(0); i >= 0; i = clique.nextSetBit( i + 1 ) ) { OpenBitSet cliques = nodeToCliques[i]; if ( cliques == null ) { cliques = new OpenBitSet(); nodeToCliques[i] = cliques; } cliques.set(id); } }
[ "public", "void", "mapVarNodeToCliques", "(", "OpenBitSet", "[", "]", "nodeToCliques", ",", "int", "id", ",", "OpenBitSet", "clique", ")", "{", "for", "(", "int", "i", "=", "clique", ".", "nextSetBit", "(", "0", ")", ";", "i", ">=", "0", ";", "i", "=", "clique", ".", "nextSetBit", "(", "i", "+", "1", ")", ")", "{", "OpenBitSet", "cliques", "=", "nodeToCliques", "[", "i", "]", ";", "if", "(", "cliques", "==", "null", ")", "{", "cliques", "=", "new", "OpenBitSet", "(", ")", ";", "nodeToCliques", "[", "i", "]", "=", "cliques", ";", "}", "cliques", ".", "set", "(", "id", ")", ";", "}", "}" ]
Maps each Bayes node to cliques it's in. It uses a BitSet to map the ID of the cliques @param nodeToCliques @param id @param clique
[ "Maps", "each", "Bayes", "node", "to", "cliques", "it", "s", "in", ".", "It", "uses", "a", "BitSet", "to", "map", "the", "ID", "of", "the", "cliques" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-beliefs/src/main/java/org/drools/beliefs/bayes/JunctionTreeBuilder.java#L381-L390
14,306
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/util/GuidedDTDRLUtilities.java
GuidedDTDRLUtilities.convertDTCellValueToString
public static String convertDTCellValueToString( DTCellValue52 dcv ) { switch ( dcv.getDataType() ) { case BOOLEAN: Boolean booleanValue = dcv.getBooleanValue(); return ( booleanValue == null ? null : booleanValue.toString() ); case DATE: Date dateValue = dcv.getDateValue(); return ( dateValue == null ? null : DateUtils.format( dcv.getDateValue() ) ); case NUMERIC: BigDecimal numericValue = (BigDecimal) dcv.getNumericValue(); return ( numericValue == null ? null : numericValue.toPlainString() ); case NUMERIC_BIGDECIMAL: BigDecimal bigDecimalValue = (BigDecimal) dcv.getNumericValue(); return ( bigDecimalValue == null ? null : bigDecimalValue.toPlainString() ); case NUMERIC_BIGINTEGER: BigInteger bigIntegerValue = (BigInteger) dcv.getNumericValue(); return ( bigIntegerValue == null ? null : bigIntegerValue.toString() ); case NUMERIC_BYTE: Byte byteValue = (Byte) dcv.getNumericValue(); return ( byteValue == null ? null : byteValue.toString() ); case NUMERIC_DOUBLE: Double doubleValue = (Double) dcv.getNumericValue(); return ( doubleValue == null ? null : doubleValue.toString() ); case NUMERIC_FLOAT: Float floatValue = (Float) dcv.getNumericValue(); return ( floatValue == null ? null : floatValue.toString() ); case NUMERIC_INTEGER: Integer integerValue = (Integer) dcv.getNumericValue(); return ( integerValue == null ? null : integerValue.toString() ); case NUMERIC_LONG: Long longValue = (Long) dcv.getNumericValue(); return ( longValue == null ? null : longValue.toString() ); case NUMERIC_SHORT: Short shortValue = (Short) dcv.getNumericValue(); return ( shortValue == null ? null : shortValue.toString() ); default: return dcv.getStringValue(); } }
java
public static String convertDTCellValueToString( DTCellValue52 dcv ) { switch ( dcv.getDataType() ) { case BOOLEAN: Boolean booleanValue = dcv.getBooleanValue(); return ( booleanValue == null ? null : booleanValue.toString() ); case DATE: Date dateValue = dcv.getDateValue(); return ( dateValue == null ? null : DateUtils.format( dcv.getDateValue() ) ); case NUMERIC: BigDecimal numericValue = (BigDecimal) dcv.getNumericValue(); return ( numericValue == null ? null : numericValue.toPlainString() ); case NUMERIC_BIGDECIMAL: BigDecimal bigDecimalValue = (BigDecimal) dcv.getNumericValue(); return ( bigDecimalValue == null ? null : bigDecimalValue.toPlainString() ); case NUMERIC_BIGINTEGER: BigInteger bigIntegerValue = (BigInteger) dcv.getNumericValue(); return ( bigIntegerValue == null ? null : bigIntegerValue.toString() ); case NUMERIC_BYTE: Byte byteValue = (Byte) dcv.getNumericValue(); return ( byteValue == null ? null : byteValue.toString() ); case NUMERIC_DOUBLE: Double doubleValue = (Double) dcv.getNumericValue(); return ( doubleValue == null ? null : doubleValue.toString() ); case NUMERIC_FLOAT: Float floatValue = (Float) dcv.getNumericValue(); return ( floatValue == null ? null : floatValue.toString() ); case NUMERIC_INTEGER: Integer integerValue = (Integer) dcv.getNumericValue(); return ( integerValue == null ? null : integerValue.toString() ); case NUMERIC_LONG: Long longValue = (Long) dcv.getNumericValue(); return ( longValue == null ? null : longValue.toString() ); case NUMERIC_SHORT: Short shortValue = (Short) dcv.getNumericValue(); return ( shortValue == null ? null : shortValue.toString() ); default: return dcv.getStringValue(); } }
[ "public", "static", "String", "convertDTCellValueToString", "(", "DTCellValue52", "dcv", ")", "{", "switch", "(", "dcv", ".", "getDataType", "(", ")", ")", "{", "case", "BOOLEAN", ":", "Boolean", "booleanValue", "=", "dcv", ".", "getBooleanValue", "(", ")", ";", "return", "(", "booleanValue", "==", "null", "?", "null", ":", "booleanValue", ".", "toString", "(", ")", ")", ";", "case", "DATE", ":", "Date", "dateValue", "=", "dcv", ".", "getDateValue", "(", ")", ";", "return", "(", "dateValue", "==", "null", "?", "null", ":", "DateUtils", ".", "format", "(", "dcv", ".", "getDateValue", "(", ")", ")", ")", ";", "case", "NUMERIC", ":", "BigDecimal", "numericValue", "=", "(", "BigDecimal", ")", "dcv", ".", "getNumericValue", "(", ")", ";", "return", "(", "numericValue", "==", "null", "?", "null", ":", "numericValue", ".", "toPlainString", "(", ")", ")", ";", "case", "NUMERIC_BIGDECIMAL", ":", "BigDecimal", "bigDecimalValue", "=", "(", "BigDecimal", ")", "dcv", ".", "getNumericValue", "(", ")", ";", "return", "(", "bigDecimalValue", "==", "null", "?", "null", ":", "bigDecimalValue", ".", "toPlainString", "(", ")", ")", ";", "case", "NUMERIC_BIGINTEGER", ":", "BigInteger", "bigIntegerValue", "=", "(", "BigInteger", ")", "dcv", ".", "getNumericValue", "(", ")", ";", "return", "(", "bigIntegerValue", "==", "null", "?", "null", ":", "bigIntegerValue", ".", "toString", "(", ")", ")", ";", "case", "NUMERIC_BYTE", ":", "Byte", "byteValue", "=", "(", "Byte", ")", "dcv", ".", "getNumericValue", "(", ")", ";", "return", "(", "byteValue", "==", "null", "?", "null", ":", "byteValue", ".", "toString", "(", ")", ")", ";", "case", "NUMERIC_DOUBLE", ":", "Double", "doubleValue", "=", "(", "Double", ")", "dcv", ".", "getNumericValue", "(", ")", ";", "return", "(", "doubleValue", "==", "null", "?", "null", ":", "doubleValue", ".", "toString", "(", ")", ")", ";", "case", "NUMERIC_FLOAT", ":", "Float", "floatValue", "=", "(", "Float", ")", "dcv", ".", "getNumericValue", "(", ")", ";", "return", "(", "floatValue", "==", "null", "?", "null", ":", "floatValue", ".", "toString", "(", ")", ")", ";", "case", "NUMERIC_INTEGER", ":", "Integer", "integerValue", "=", "(", "Integer", ")", "dcv", ".", "getNumericValue", "(", ")", ";", "return", "(", "integerValue", "==", "null", "?", "null", ":", "integerValue", ".", "toString", "(", ")", ")", ";", "case", "NUMERIC_LONG", ":", "Long", "longValue", "=", "(", "Long", ")", "dcv", ".", "getNumericValue", "(", ")", ";", "return", "(", "longValue", "==", "null", "?", "null", ":", "longValue", ".", "toString", "(", ")", ")", ";", "case", "NUMERIC_SHORT", ":", "Short", "shortValue", "=", "(", "Short", ")", "dcv", ".", "getNumericValue", "(", ")", ";", "return", "(", "shortValue", "==", "null", "?", "null", ":", "shortValue", ".", "toString", "(", ")", ")", ";", "default", ":", "return", "dcv", ".", "getStringValue", "(", ")", ";", "}", "}" ]
Utility method to convert DTCellValues to their String representation @param dcv @return
[ "Utility", "method", "to", "convert", "DTCellValues", "to", "their", "String", "representation" ]
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/GuidedDTDRLUtilities.java#L35-L73
14,307
kiegroup/drools
drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java
RuleModelDRLPersistenceImpl.marshalPackageHeader
protected void marshalPackageHeader(final RuleModel model, final StringBuilder buf) { PackageNameWriter.write(buf, model); ImportsWriter.write(buf, model); }
java
protected void marshalPackageHeader(final RuleModel model, final StringBuilder buf) { PackageNameWriter.write(buf, model); ImportsWriter.write(buf, model); }
[ "protected", "void", "marshalPackageHeader", "(", "final", "RuleModel", "model", ",", "final", "StringBuilder", "buf", ")", "{", "PackageNameWriter", ".", "write", "(", "buf", ",", "model", ")", ";", "ImportsWriter", ".", "write", "(", "buf", ",", "model", ")", ";", "}" ]
Append package name and imports to DRL
[ "Append", "package", "name", "and", "imports", "to", "DRL" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java#L258-L264
14,308
kiegroup/drools
drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java
RuleModelDRLPersistenceImpl.marshalRuleHeader
protected void marshalRuleHeader(final RuleModel model, final StringBuilder buf) { buf.append("rule \"" + marshalRuleName(model) + "\""); if (null != model.parentName && model.parentName.length() > 0) { buf.append(" extends \"" + model.parentName + "\"\n"); } else { buf.append('\n'); } }
java
protected void marshalRuleHeader(final RuleModel model, final StringBuilder buf) { buf.append("rule \"" + marshalRuleName(model) + "\""); if (null != model.parentName && model.parentName.length() > 0) { buf.append(" extends \"" + model.parentName + "\"\n"); } else { buf.append('\n'); } }
[ "protected", "void", "marshalRuleHeader", "(", "final", "RuleModel", "model", ",", "final", "StringBuilder", "buf", ")", "{", "buf", ".", "append", "(", "\"rule \\\"\"", "+", "marshalRuleName", "(", "model", ")", "+", "\"\\\"\"", ")", ";", "if", "(", "null", "!=", "model", ".", "parentName", "&&", "model", ".", "parentName", ".", "length", "(", ")", ">", "0", ")", "{", "buf", ".", "append", "(", "\" extends \\\"\"", "+", "model", ".", "parentName", "+", "\"\\\"\\n\"", ")", ";", "}", "else", "{", "buf", ".", "append", "(", "'", "'", ")", ";", "}", "}" ]
Append rule header
[ "Append", "rule", "header" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java#L267-L275
14,309
kiegroup/drools
drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java
RuleModelDRLPersistenceImpl.marshalAttributes
protected void marshalAttributes(final StringBuilder buf, final RuleModel model) { boolean hasDialect = false; for (int i = 0; i < model.attributes.length; i++) { RuleAttribute attr = model.attributes[i]; buf.append("\t"); buf.append(attr); buf.append("\n"); if (attr.getAttributeName().equals("dialect")) { constraintValueBuilder = DRLConstraintValueBuilder.getBuilder(attr.getValue()); hasDialect = true; } } // Un comment below for mvel if (!hasDialect) { RuleAttribute attr = new RuleAttribute("dialect", DRLConstraintValueBuilder.DEFAULT_DIALECT); buf.append("\t"); buf.append(attr); buf.append("\n"); } }
java
protected void marshalAttributes(final StringBuilder buf, final RuleModel model) { boolean hasDialect = false; for (int i = 0; i < model.attributes.length; i++) { RuleAttribute attr = model.attributes[i]; buf.append("\t"); buf.append(attr); buf.append("\n"); if (attr.getAttributeName().equals("dialect")) { constraintValueBuilder = DRLConstraintValueBuilder.getBuilder(attr.getValue()); hasDialect = true; } } // Un comment below for mvel if (!hasDialect) { RuleAttribute attr = new RuleAttribute("dialect", DRLConstraintValueBuilder.DEFAULT_DIALECT); buf.append("\t"); buf.append(attr); buf.append("\n"); } }
[ "protected", "void", "marshalAttributes", "(", "final", "StringBuilder", "buf", ",", "final", "RuleModel", "model", ")", "{", "boolean", "hasDialect", "=", "false", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "model", ".", "attributes", ".", "length", ";", "i", "++", ")", "{", "RuleAttribute", "attr", "=", "model", ".", "attributes", "[", "i", "]", ";", "buf", ".", "append", "(", "\"\\t\"", ")", ";", "buf", ".", "append", "(", "attr", ")", ";", "buf", ".", "append", "(", "\"\\n\"", ")", ";", "if", "(", "attr", ".", "getAttributeName", "(", ")", ".", "equals", "(", "\"dialect\"", ")", ")", "{", "constraintValueBuilder", "=", "DRLConstraintValueBuilder", ".", "getBuilder", "(", "attr", ".", "getValue", "(", ")", ")", ";", "hasDialect", "=", "true", ";", "}", "}", "// Un comment below for mvel", "if", "(", "!", "hasDialect", ")", "{", "RuleAttribute", "attr", "=", "new", "RuleAttribute", "(", "\"dialect\"", ",", "DRLConstraintValueBuilder", ".", "DEFAULT_DIALECT", ")", ";", "buf", ".", "append", "(", "\"\\t\"", ")", ";", "buf", ".", "append", "(", "attr", ")", ";", "buf", ".", "append", "(", "\"\\n\"", ")", ";", "}", "}" ]
Marshal model attributes @param buf @param model
[ "Marshal", "model", "attributes" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java#L286-L309
14,310
kiegroup/drools
drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java
RuleModelDRLPersistenceImpl.marshalMetadata
protected void marshalMetadata(final StringBuilder buf, final RuleModel model) { if (model.metadataList != null) { for (int i = 0; i < model.metadataList.length; i++) { buf.append("\t").append(model.metadataList[i]).append("\n"); } } }
java
protected void marshalMetadata(final StringBuilder buf, final RuleModel model) { if (model.metadataList != null) { for (int i = 0; i < model.metadataList.length; i++) { buf.append("\t").append(model.metadataList[i]).append("\n"); } } }
[ "protected", "void", "marshalMetadata", "(", "final", "StringBuilder", "buf", ",", "final", "RuleModel", "model", ")", "{", "if", "(", "model", ".", "metadataList", "!=", "null", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "model", ".", "metadataList", ".", "length", ";", "i", "++", ")", "{", "buf", ".", "append", "(", "\"\\t\"", ")", ".", "append", "(", "model", ".", "metadataList", "[", "i", "]", ")", ".", "append", "(", "\"\\n\"", ")", ";", "}", "}", "}" ]
Marshal model metadata @param buf @param model
[ "Marshal", "model", "metadata" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java#L316-L323
14,311
kiegroup/drools
drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java
RuleModelDRLPersistenceImpl.marshalLHS
protected void marshalLHS(final StringBuilder buf, final RuleModel model, final boolean isDSLEnhanced, final LHSGeneratorContextFactory generatorContextFactory) { String indentation = "\t\t"; String nestedIndentation = indentation; boolean isNegated = model.isNegated(); if (model.lhs != null) { if (isNegated) { nestedIndentation += "\t"; buf.append(indentation); buf.append("not (\n"); } LHSPatternVisitor visitor = getLHSPatternVisitor(isDSLEnhanced, buf, nestedIndentation, isNegated, generatorContextFactory); for (IPattern cond : model.lhs) { visitor.visit(cond); } if (model.isNegated()) { //Delete the spurious " and ", added by LHSPatternVisitor.visitFactPattern, when the rule is negated buf.delete(buf.length() - 5, buf.length()); buf.append("\n"); buf.append(indentation); buf.append(")\n"); } } }
java
protected void marshalLHS(final StringBuilder buf, final RuleModel model, final boolean isDSLEnhanced, final LHSGeneratorContextFactory generatorContextFactory) { String indentation = "\t\t"; String nestedIndentation = indentation; boolean isNegated = model.isNegated(); if (model.lhs != null) { if (isNegated) { nestedIndentation += "\t"; buf.append(indentation); buf.append("not (\n"); } LHSPatternVisitor visitor = getLHSPatternVisitor(isDSLEnhanced, buf, nestedIndentation, isNegated, generatorContextFactory); for (IPattern cond : model.lhs) { visitor.visit(cond); } if (model.isNegated()) { //Delete the spurious " and ", added by LHSPatternVisitor.visitFactPattern, when the rule is negated buf.delete(buf.length() - 5, buf.length()); buf.append("\n"); buf.append(indentation); buf.append(")\n"); } } }
[ "protected", "void", "marshalLHS", "(", "final", "StringBuilder", "buf", ",", "final", "RuleModel", "model", ",", "final", "boolean", "isDSLEnhanced", ",", "final", "LHSGeneratorContextFactory", "generatorContextFactory", ")", "{", "String", "indentation", "=", "\"\\t\\t\"", ";", "String", "nestedIndentation", "=", "indentation", ";", "boolean", "isNegated", "=", "model", ".", "isNegated", "(", ")", ";", "if", "(", "model", ".", "lhs", "!=", "null", ")", "{", "if", "(", "isNegated", ")", "{", "nestedIndentation", "+=", "\"\\t\"", ";", "buf", ".", "append", "(", "indentation", ")", ";", "buf", ".", "append", "(", "\"not (\\n\"", ")", ";", "}", "LHSPatternVisitor", "visitor", "=", "getLHSPatternVisitor", "(", "isDSLEnhanced", ",", "buf", ",", "nestedIndentation", ",", "isNegated", ",", "generatorContextFactory", ")", ";", "for", "(", "IPattern", "cond", ":", "model", ".", "lhs", ")", "{", "visitor", ".", "visit", "(", "cond", ")", ";", "}", "if", "(", "model", ".", "isNegated", "(", ")", ")", "{", "//Delete the spurious \" and \", added by LHSPatternVisitor.visitFactPattern, when the rule is negated", "buf", ".", "delete", "(", "buf", ".", "length", "(", ")", "-", "5", ",", "buf", ".", "length", "(", ")", ")", ";", "buf", ".", "append", "(", "\"\\n\"", ")", ";", "buf", ".", "append", "(", "indentation", ")", ";", "buf", ".", "append", "(", "\")\\n\"", ")", ";", "}", "}", "}" ]
Marshal LHS patterns @param buf @param model
[ "Marshal", "LHS", "patterns" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java#L330-L361
14,312
kiegroup/drools
drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java
RuleModelDRLPersistenceImpl.getExpressionPart
private static ExpressionPart getExpressionPart(String expressionPart, ModelField currentFact) { if (currentFact == null) { return new ExpressionText(expressionPart); } else { return new ExpressionVariable(expressionPart, currentFact.getClassName(), currentFact.getType()); } }
java
private static ExpressionPart getExpressionPart(String expressionPart, ModelField currentFact) { if (currentFact == null) { return new ExpressionText(expressionPart); } else { return new ExpressionVariable(expressionPart, currentFact.getClassName(), currentFact.getType()); } }
[ "private", "static", "ExpressionPart", "getExpressionPart", "(", "String", "expressionPart", ",", "ModelField", "currentFact", ")", "{", "if", "(", "currentFact", "==", "null", ")", "{", "return", "new", "ExpressionText", "(", "expressionPart", ")", ";", "}", "else", "{", "return", "new", "ExpressionVariable", "(", "expressionPart", ",", "currentFact", ".", "getClassName", "(", ")", ",", "currentFact", ".", "getType", "(", ")", ")", ";", "}", "}" ]
If the bound type is not in the DMO it probably hasn't been imported. So we have little option than to fall back to keeping the value as Text.
[ "If", "the", "bound", "type", "is", "not", "in", "the", "DMO", "it", "probably", "hasn", "t", "been", "imported", ".", "So", "we", "have", "little", "option", "than", "to", "fall", "back", "to", "keeping", "the", "value", "as", "Text", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java#L4170-L4179
14,313
kiegroup/drools
drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java
RuleModelDRLPersistenceImpl.getSimpleRuleModel
public RuleModel getSimpleRuleModel(final String drl) { final RuleModel rm = new RuleModel(); rm.setPackageName(PackageNameParser.parsePackageName(drl)); rm.setImports(ImportsParser.parseImports(drl)); final Pattern rulePattern = Pattern.compile(".*\\s?rule\\s+(.+?)\\s+.*", Pattern.DOTALL); final Pattern lhsPattern = Pattern.compile(".*\\s+when\\s+(.+?)\\s+then.*", Pattern.DOTALL); final Pattern rhsPattern = Pattern.compile(".*\\s+then\\s+(.+?)\\s+end.*", Pattern.DOTALL); final Matcher ruleMatcher = rulePattern.matcher(drl); if (ruleMatcher.matches()) { String name = ruleMatcher.group(1); if (name.startsWith("\"")) { name = name.substring(1); } if (name.endsWith("\"")) { name = name.substring(0, name.length() - 1); } rm.name = name; } final Matcher lhsMatcher = lhsPattern.matcher(drl); if (lhsMatcher.matches()) { final FreeFormLine lhs = new FreeFormLine(); lhs.setText(lhsMatcher.group(1) == null ? "" : lhsMatcher.group(1).trim()); rm.addLhsItem(lhs); } final Matcher rhsMatcher = rhsPattern.matcher(drl); if (rhsMatcher.matches()) { final FreeFormLine rhs = new FreeFormLine(); rhs.setText(rhsMatcher.group(1) == null ? "" : rhsMatcher.group(1).trim()); rm.addRhsItem(rhs); } return rm; }
java
public RuleModel getSimpleRuleModel(final String drl) { final RuleModel rm = new RuleModel(); rm.setPackageName(PackageNameParser.parsePackageName(drl)); rm.setImports(ImportsParser.parseImports(drl)); final Pattern rulePattern = Pattern.compile(".*\\s?rule\\s+(.+?)\\s+.*", Pattern.DOTALL); final Pattern lhsPattern = Pattern.compile(".*\\s+when\\s+(.+?)\\s+then.*", Pattern.DOTALL); final Pattern rhsPattern = Pattern.compile(".*\\s+then\\s+(.+?)\\s+end.*", Pattern.DOTALL); final Matcher ruleMatcher = rulePattern.matcher(drl); if (ruleMatcher.matches()) { String name = ruleMatcher.group(1); if (name.startsWith("\"")) { name = name.substring(1); } if (name.endsWith("\"")) { name = name.substring(0, name.length() - 1); } rm.name = name; } final Matcher lhsMatcher = lhsPattern.matcher(drl); if (lhsMatcher.matches()) { final FreeFormLine lhs = new FreeFormLine(); lhs.setText(lhsMatcher.group(1) == null ? "" : lhsMatcher.group(1).trim()); rm.addLhsItem(lhs); } final Matcher rhsMatcher = rhsPattern.matcher(drl); if (rhsMatcher.matches()) { final FreeFormLine rhs = new FreeFormLine(); rhs.setText(rhsMatcher.group(1) == null ? "" : rhsMatcher.group(1).trim()); rm.addRhsItem(rhs); } return rm; }
[ "public", "RuleModel", "getSimpleRuleModel", "(", "final", "String", "drl", ")", "{", "final", "RuleModel", "rm", "=", "new", "RuleModel", "(", ")", ";", "rm", ".", "setPackageName", "(", "PackageNameParser", ".", "parsePackageName", "(", "drl", ")", ")", ";", "rm", ".", "setImports", "(", "ImportsParser", ".", "parseImports", "(", "drl", ")", ")", ";", "final", "Pattern", "rulePattern", "=", "Pattern", ".", "compile", "(", "\".*\\\\s?rule\\\\s+(.+?)\\\\s+.*\"", ",", "Pattern", ".", "DOTALL", ")", ";", "final", "Pattern", "lhsPattern", "=", "Pattern", ".", "compile", "(", "\".*\\\\s+when\\\\s+(.+?)\\\\s+then.*\"", ",", "Pattern", ".", "DOTALL", ")", ";", "final", "Pattern", "rhsPattern", "=", "Pattern", ".", "compile", "(", "\".*\\\\s+then\\\\s+(.+?)\\\\s+end.*\"", ",", "Pattern", ".", "DOTALL", ")", ";", "final", "Matcher", "ruleMatcher", "=", "rulePattern", ".", "matcher", "(", "drl", ")", ";", "if", "(", "ruleMatcher", ".", "matches", "(", ")", ")", "{", "String", "name", "=", "ruleMatcher", ".", "group", "(", "1", ")", ";", "if", "(", "name", ".", "startsWith", "(", "\"\\\"\"", ")", ")", "{", "name", "=", "name", ".", "substring", "(", "1", ")", ";", "}", "if", "(", "name", ".", "endsWith", "(", "\"\\\"\"", ")", ")", "{", "name", "=", "name", ".", "substring", "(", "0", ",", "name", ".", "length", "(", ")", "-", "1", ")", ";", "}", "rm", ".", "name", "=", "name", ";", "}", "final", "Matcher", "lhsMatcher", "=", "lhsPattern", ".", "matcher", "(", "drl", ")", ";", "if", "(", "lhsMatcher", ".", "matches", "(", ")", ")", "{", "final", "FreeFormLine", "lhs", "=", "new", "FreeFormLine", "(", ")", ";", "lhs", ".", "setText", "(", "lhsMatcher", ".", "group", "(", "1", ")", "==", "null", "?", "\"\"", ":", "lhsMatcher", ".", "group", "(", "1", ")", ".", "trim", "(", ")", ")", ";", "rm", ".", "addLhsItem", "(", "lhs", ")", ";", "}", "final", "Matcher", "rhsMatcher", "=", "rhsPattern", ".", "matcher", "(", "drl", ")", ";", "if", "(", "rhsMatcher", ".", "matches", "(", ")", ")", "{", "final", "FreeFormLine", "rhs", "=", "new", "FreeFormLine", "(", ")", ";", "rhs", ".", "setText", "(", "rhsMatcher", ".", "group", "(", "1", ")", "==", "null", "?", "\"\"", ":", "rhsMatcher", ".", "group", "(", "1", ")", ".", "trim", "(", ")", ")", ";", "rm", ".", "addRhsItem", "(", "rhs", ")", ";", "}", "return", "rm", ";", "}" ]
Simple fall-back parser of DRL
[ "Simple", "fall", "-", "back", "parser", "of", "DRL" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java#L4245-L4285
14,314
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/CompositeFieldConstraint.java
CompositeFieldConstraint.removeConstraint
public void removeConstraint( final int idx ) { //If the constraint being is a parent of another correct the other constraint's parent accordingly FieldConstraint constraintToRemove = this.constraints[ idx ]; if ( constraintToRemove instanceof SingleFieldConstraint ) { final SingleFieldConstraint sfc = (SingleFieldConstraint) constraintToRemove; FieldConstraint parent = sfc.getParent(); for ( FieldConstraint child : this.constraints ) { if ( child instanceof SingleFieldConstraint ) { SingleFieldConstraint sfcChild = (SingleFieldConstraint) child; if ( sfcChild.getParent() == constraintToRemove ) { sfcChild.setParent( parent ); break; } } } } final FieldConstraint[] newList = new FieldConstraint[ this.constraints.length - 1 ]; int newIdx = 0; for ( int i = 0; i < this.constraints.length; i++ ) { if ( i != idx ) { newList[ newIdx ] = this.constraints[ i ]; newIdx++; } } this.constraints = newList; }
java
public void removeConstraint( final int idx ) { //If the constraint being is a parent of another correct the other constraint's parent accordingly FieldConstraint constraintToRemove = this.constraints[ idx ]; if ( constraintToRemove instanceof SingleFieldConstraint ) { final SingleFieldConstraint sfc = (SingleFieldConstraint) constraintToRemove; FieldConstraint parent = sfc.getParent(); for ( FieldConstraint child : this.constraints ) { if ( child instanceof SingleFieldConstraint ) { SingleFieldConstraint sfcChild = (SingleFieldConstraint) child; if ( sfcChild.getParent() == constraintToRemove ) { sfcChild.setParent( parent ); break; } } } } final FieldConstraint[] newList = new FieldConstraint[ this.constraints.length - 1 ]; int newIdx = 0; for ( int i = 0; i < this.constraints.length; i++ ) { if ( i != idx ) { newList[ newIdx ] = this.constraints[ i ]; newIdx++; } } this.constraints = newList; }
[ "public", "void", "removeConstraint", "(", "final", "int", "idx", ")", "{", "//If the constraint being is a parent of another correct the other constraint's parent accordingly", "FieldConstraint", "constraintToRemove", "=", "this", ".", "constraints", "[", "idx", "]", ";", "if", "(", "constraintToRemove", "instanceof", "SingleFieldConstraint", ")", "{", "final", "SingleFieldConstraint", "sfc", "=", "(", "SingleFieldConstraint", ")", "constraintToRemove", ";", "FieldConstraint", "parent", "=", "sfc", ".", "getParent", "(", ")", ";", "for", "(", "FieldConstraint", "child", ":", "this", ".", "constraints", ")", "{", "if", "(", "child", "instanceof", "SingleFieldConstraint", ")", "{", "SingleFieldConstraint", "sfcChild", "=", "(", "SingleFieldConstraint", ")", "child", ";", "if", "(", "sfcChild", ".", "getParent", "(", ")", "==", "constraintToRemove", ")", "{", "sfcChild", ".", "setParent", "(", "parent", ")", ";", "break", ";", "}", "}", "}", "}", "final", "FieldConstraint", "[", "]", "newList", "=", "new", "FieldConstraint", "[", "this", ".", "constraints", ".", "length", "-", "1", "]", ";", "int", "newIdx", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "constraints", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "idx", ")", "{", "newList", "[", "newIdx", "]", "=", "this", ".", "constraints", "[", "i", "]", ";", "newIdx", "++", ";", "}", "}", "this", ".", "constraints", "=", "newList", ";", "}" ]
at this point in time.
[ "at", "this", "point", "in", "time", "." ]
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/CompositeFieldConstraint.java#L77-L105
14,315
kiegroup/drools
drools-core/src/main/java/org/drools/core/util/index/TupleIndexHashTable.java
TupleIndexHashTable.getOrCreate
private TupleList getOrCreate(final Tuple tuple) { final int hashCode = this.index.hashCodeOf( tuple, left ); final int index = indexOf( hashCode, this.table.length ); TupleList entry = (TupleList) this.table[index]; // search to find an existing entry while ( entry != null ) { if ( matches( entry, tuple, hashCode, !left ) ) { return entry; } entry = entry.getNext(); } // entry does not exist, so create entry = this.index.createEntry( tuple, hashCode, left ); entry.setNext( (TupleList) this.table[index] ); this.table[index] = entry; if ( this.size++ >= this.threshold ) { resize( 2 * this.table.length ); } return entry; }
java
private TupleList getOrCreate(final Tuple tuple) { final int hashCode = this.index.hashCodeOf( tuple, left ); final int index = indexOf( hashCode, this.table.length ); TupleList entry = (TupleList) this.table[index]; // search to find an existing entry while ( entry != null ) { if ( matches( entry, tuple, hashCode, !left ) ) { return entry; } entry = entry.getNext(); } // entry does not exist, so create entry = this.index.createEntry( tuple, hashCode, left ); entry.setNext( (TupleList) this.table[index] ); this.table[index] = entry; if ( this.size++ >= this.threshold ) { resize( 2 * this.table.length ); } return entry; }
[ "private", "TupleList", "getOrCreate", "(", "final", "Tuple", "tuple", ")", "{", "final", "int", "hashCode", "=", "this", ".", "index", ".", "hashCodeOf", "(", "tuple", ",", "left", ")", ";", "final", "int", "index", "=", "indexOf", "(", "hashCode", ",", "this", ".", "table", ".", "length", ")", ";", "TupleList", "entry", "=", "(", "TupleList", ")", "this", ".", "table", "[", "index", "]", ";", "// search to find an existing entry", "while", "(", "entry", "!=", "null", ")", "{", "if", "(", "matches", "(", "entry", ",", "tuple", ",", "hashCode", ",", "!", "left", ")", ")", "{", "return", "entry", ";", "}", "entry", "=", "entry", ".", "getNext", "(", ")", ";", "}", "// entry does not exist, so create", "entry", "=", "this", ".", "index", ".", "createEntry", "(", "tuple", ",", "hashCode", ",", "left", ")", ";", "entry", ".", "setNext", "(", "(", "TupleList", ")", "this", ".", "table", "[", "index", "]", ")", ";", "this", ".", "table", "[", "index", "]", "=", "entry", ";", "if", "(", "this", ".", "size", "++", ">=", "this", ".", "threshold", ")", "{", "resize", "(", "2", "*", "this", ".", "table", ".", "length", ")", ";", "}", "return", "entry", ";", "}" ]
We use this method to aviod to table lookups for the same hashcode; which is what we would have to do if we did a get and then a create if the value is null.
[ "We", "use", "this", "method", "to", "aviod", "to", "table", "lookups", "for", "the", "same", "hashcode", ";", "which", "is", "what", "we", "would", "have", "to", "do", "if", "we", "did", "a", "get", "and", "then", "a", "create", "if", "the", "value", "is", "null", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/util/index/TupleIndexHashTable.java#L391-L413
14,316
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/auditlog/MetadataColumnDetails.java
MetadataColumnDetails.getColumnHeader
public String getColumnHeader() { String result = super.getColumnHeader(); if (result == null || result.trim().length() == 0) result = metadata; return result; }
java
public String getColumnHeader() { String result = super.getColumnHeader(); if (result == null || result.trim().length() == 0) result = metadata; return result; }
[ "public", "String", "getColumnHeader", "(", ")", "{", "String", "result", "=", "super", ".", "getColumnHeader", "(", ")", ";", "if", "(", "result", "==", "null", "||", "result", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "result", "=", "metadata", ";", "return", "result", ";", "}" ]
Returns the header for the metadata column. @return The metadata column's header. If the header is not present, returns the metadata string.
[ "Returns", "the", "header", "for", "the", "metadata", "column", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/auditlog/MetadataColumnDetails.java#L46-L50
14,317
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/Edge.java
Edge.getWaypoint
public List<org.kie.dmn.model.api.dmndi.Point> getWaypoint() { if (waypoint == null) { waypoint = new ArrayList<>(); } return this.waypoint; }
java
public List<org.kie.dmn.model.api.dmndi.Point> getWaypoint() { if (waypoint == null) { waypoint = new ArrayList<>(); } return this.waypoint; }
[ "public", "List", "<", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "Point", ">", "getWaypoint", "(", ")", "{", "if", "(", "waypoint", "==", "null", ")", "{", "waypoint", "=", "new", "ArrayList", "<>", "(", ")", ";", "}", "return", "this", ".", "waypoint", ";", "}" ]
Gets the value of the waypoint 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 waypoint property. <p> For example, to add a new item, do as follows: <pre> getWaypoint().add(newItem); </pre> <p> Objects of the following type(s) are allowed in the list {@link Point }
[ "Gets", "the", "value", "of", "the", "waypoint", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/Edge.java#L48-L53
14,318
kiegroup/drools
drools-verifier/drools-verifier-core/src/main/java/org/drools/verifier/core/util/PortablePreconditions.java
PortablePreconditions.checkEachParameterNotNull
public static <T> void checkEachParameterNotNull(final String name, final T... parameters) { if (parameters == null) { throw new IllegalArgumentException("Parameter named '" + name + "' should be not null!"); } for (final Object parameter : parameters) { if (parameter == null) { throw new IllegalArgumentException("Parameter named '" + name + "' should be not null!"); } } }
java
public static <T> void checkEachParameterNotNull(final String name, final T... parameters) { if (parameters == null) { throw new IllegalArgumentException("Parameter named '" + name + "' should be not null!"); } for (final Object parameter : parameters) { if (parameter == null) { throw new IllegalArgumentException("Parameter named '" + name + "' should be not null!"); } } }
[ "public", "static", "<", "T", ">", "void", "checkEachParameterNotNull", "(", "final", "String", "name", ",", "final", "T", "...", "parameters", ")", "{", "if", "(", "parameters", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Parameter named '\"", "+", "name", "+", "\"' should be not null!\"", ")", ";", "}", "for", "(", "final", "Object", "parameter", ":", "parameters", ")", "{", "if", "(", "parameter", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Parameter named '\"", "+", "name", "+", "\"' should be not null!\"", ")", ";", "}", "}", "}" ]
Assert that this parameter is not null, as also each item of the array is not null. @param <T> parameter type @param name of parameter @param parameters itself
[ "Assert", "that", "this", "parameter", "is", "not", "null", "as", "also", "each", "item", "of", "the", "array", "is", "not", "null", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-verifier/drools-verifier-core/src/main/java/org/drools/verifier/core/util/PortablePreconditions.java#L36-L46
14,319
kiegroup/drools
drools-verifier/drools-verifier-core/src/main/java/org/drools/verifier/core/util/PortablePreconditions.java
PortablePreconditions.checkNotEmpty
public static String checkNotEmpty(final String name, final String parameter) { if (parameter == null || parameter.trim().length() == 0) { throw new IllegalArgumentException("Parameter named '" + name + "' should be filled!"); } return parameter; }
java
public static String checkNotEmpty(final String name, final String parameter) { if (parameter == null || parameter.trim().length() == 0) { throw new IllegalArgumentException("Parameter named '" + name + "' should be filled!"); } return parameter; }
[ "public", "static", "String", "checkNotEmpty", "(", "final", "String", "name", ",", "final", "String", "parameter", ")", "{", "if", "(", "parameter", "==", "null", "||", "parameter", ".", "trim", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Parameter named '\"", "+", "name", "+", "\"' should be filled!\"", ")", ";", "}", "return", "parameter", ";", "}" ]
Assert that this parameter is not empty. It trims the parameter to see if have any valid data on that. @param name of parameter @param parameter itself
[ "Assert", "that", "this", "parameter", "is", "not", "empty", ".", "It", "trims", "the", "parameter", "to", "see", "if", "have", "any", "valid", "data", "on", "that", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-verifier/drools-verifier-core/src/main/java/org/drools/verifier/core/util/PortablePreconditions.java#L78-L84
14,320
kiegroup/drools
drools-verifier/drools-verifier-core/src/main/java/org/drools/verifier/core/util/PortablePreconditions.java
PortablePreconditions.checkNotNull
public static <T> T checkNotNull(final String name, final T parameter) { if (parameter == null) { throw new IllegalArgumentException("Parameter named '" + name + "' should be not null!"); } return parameter; }
java
public static <T> T checkNotNull(final String name, final T parameter) { if (parameter == null) { throw new IllegalArgumentException("Parameter named '" + name + "' should be not null!"); } return parameter; }
[ "public", "static", "<", "T", ">", "T", "checkNotNull", "(", "final", "String", "name", ",", "final", "T", "parameter", ")", "{", "if", "(", "parameter", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Parameter named '\"", "+", "name", "+", "\"' should be not null!\"", ")", ";", "}", "return", "parameter", ";", "}" ]
Assert that this parameter is not null. @param name of parameter @param parameter itself
[ "Assert", "that", "this", "parameter", "is", "not", "null", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-verifier/drools-verifier-core/src/main/java/org/drools/verifier/core/util/PortablePreconditions.java#L105-L111
14,321
kiegroup/drools
drools-persistence/drools-persistence-jpa/src/main/java/org/drools/persistence/jpa/marshaller/JPAPlaceholderResolverStrategy.java
JPAPlaceholderResolverStrategy.isEntity
private boolean isEntity(Object o){ Class<? extends Object> varClass = o.getClass(); return managedClasses.contains( varClass.getCanonicalName() ); }
java
private boolean isEntity(Object o){ Class<? extends Object> varClass = o.getClass(); return managedClasses.contains( varClass.getCanonicalName() ); }
[ "private", "boolean", "isEntity", "(", "Object", "o", ")", "{", "Class", "<", "?", "extends", "Object", ">", "varClass", "=", "o", ".", "getClass", "(", ")", ";", "return", "managedClasses", ".", "contains", "(", "varClass", ".", "getCanonicalName", "(", ")", ")", ";", "}" ]
Changed implementation, using EntityManager Metamodel in spite of Reflection. @param o @return
[ "Changed", "implementation", "using", "EntityManager", "Metamodel", "in", "spite", "of", "Reflection", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-persistence/drools-persistence-jpa/src/main/java/org/drools/persistence/jpa/marshaller/JPAPlaceholderResolverStrategy.java#L199-L202
14,322
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/rule/builder/PatternBuilder.java
PatternBuilder.build
public RuleConditionElement build(RuleBuildContext context, PatternDescr patternDescr, Pattern prefixPattern) { if (patternDescr.getObjectType() == null) { lookupObjectType(context, patternDescr); } if (patternDescr.getObjectType() == null || patternDescr.getObjectType().equals("")) { registerDescrBuildError(context, patternDescr, "ObjectType not correctly defined"); return null; } ObjectType objectType = getObjectType(context, patternDescr); if (objectType == null) { // if the objectType doesn't exist it has to be query return buildQuery(context, patternDescr, patternDescr); } Pattern pattern = buildPattern(context, patternDescr, objectType); processClassObjectType(context, objectType, pattern); processAnnotations(context, patternDescr, pattern); processSource(context, patternDescr, pattern); processConstraintsAndBinds(context, patternDescr, pattern); processBehaviors(context, patternDescr, pattern); if (!pattern.hasNegativeConstraint() && "on".equals(System.getProperty("drools.negatable"))) { // this is a non-negative pattern, so we must inject the constraint pattern.addConstraint(new NegConstraint(false)); } // poping the pattern context.getDeclarationResolver().popBuildStack(); return pattern; }
java
public RuleConditionElement build(RuleBuildContext context, PatternDescr patternDescr, Pattern prefixPattern) { if (patternDescr.getObjectType() == null) { lookupObjectType(context, patternDescr); } if (patternDescr.getObjectType() == null || patternDescr.getObjectType().equals("")) { registerDescrBuildError(context, patternDescr, "ObjectType not correctly defined"); return null; } ObjectType objectType = getObjectType(context, patternDescr); if (objectType == null) { // if the objectType doesn't exist it has to be query return buildQuery(context, patternDescr, patternDescr); } Pattern pattern = buildPattern(context, patternDescr, objectType); processClassObjectType(context, objectType, pattern); processAnnotations(context, patternDescr, pattern); processSource(context, patternDescr, pattern); processConstraintsAndBinds(context, patternDescr, pattern); processBehaviors(context, patternDescr, pattern); if (!pattern.hasNegativeConstraint() && "on".equals(System.getProperty("drools.negatable"))) { // this is a non-negative pattern, so we must inject the constraint pattern.addConstraint(new NegConstraint(false)); } // poping the pattern context.getDeclarationResolver().popBuildStack(); return pattern; }
[ "public", "RuleConditionElement", "build", "(", "RuleBuildContext", "context", ",", "PatternDescr", "patternDescr", ",", "Pattern", "prefixPattern", ")", "{", "if", "(", "patternDescr", ".", "getObjectType", "(", ")", "==", "null", ")", "{", "lookupObjectType", "(", "context", ",", "patternDescr", ")", ";", "}", "if", "(", "patternDescr", ".", "getObjectType", "(", ")", "==", "null", "||", "patternDescr", ".", "getObjectType", "(", ")", ".", "equals", "(", "\"\"", ")", ")", "{", "registerDescrBuildError", "(", "context", ",", "patternDescr", ",", "\"ObjectType not correctly defined\"", ")", ";", "return", "null", ";", "}", "ObjectType", "objectType", "=", "getObjectType", "(", "context", ",", "patternDescr", ")", ";", "if", "(", "objectType", "==", "null", ")", "{", "// if the objectType doesn't exist it has to be query", "return", "buildQuery", "(", "context", ",", "patternDescr", ",", "patternDescr", ")", ";", "}", "Pattern", "pattern", "=", "buildPattern", "(", "context", ",", "patternDescr", ",", "objectType", ")", ";", "processClassObjectType", "(", "context", ",", "objectType", ",", "pattern", ")", ";", "processAnnotations", "(", "context", ",", "patternDescr", ",", "pattern", ")", ";", "processSource", "(", "context", ",", "patternDescr", ",", "pattern", ")", ";", "processConstraintsAndBinds", "(", "context", ",", "patternDescr", ",", "pattern", ")", ";", "processBehaviors", "(", "context", ",", "patternDescr", ",", "pattern", ")", ";", "if", "(", "!", "pattern", ".", "hasNegativeConstraint", "(", ")", "&&", "\"on\"", ".", "equals", "(", "System", ".", "getProperty", "(", "\"drools.negatable\"", ")", ")", ")", "{", "// this is a non-negative pattern, so we must inject the constraint", "pattern", ".", "addConstraint", "(", "new", "NegConstraint", "(", "false", ")", ")", ";", "}", "// poping the pattern", "context", ".", "getDeclarationResolver", "(", ")", ".", "popBuildStack", "(", ")", ";", "return", "pattern", ";", "}" ]
Build a pattern for the given descriptor in the current context and using the given utils object
[ "Build", "a", "pattern", "for", "the", "given", "descriptor", "in", "the", "current", "context", "and", "using", "the", "given", "utils", "object" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/rule/builder/PatternBuilder.java#L166-L199
14,323
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/rule/builder/PatternBuilder.java
PatternBuilder.processConstraintsAndBinds
protected void processConstraintsAndBinds(final RuleBuildContext context, final PatternDescr patternDescr, final Pattern pattern) { MVELDumper.MVELDumperContext mvelCtx = new MVELDumper.MVELDumperContext().setRuleContext(context); for (BaseDescr b : patternDescr.getDescrs()) { String expression; boolean isPositional = false; if (b instanceof BindingDescr) { BindingDescr bind = (BindingDescr) b; expression = bind.getVariable() + (bind.isUnification() ? " := " : " : ") + bind.getExpression(); } else if (b instanceof ExprConstraintDescr) { ExprConstraintDescr descr = (ExprConstraintDescr) b; expression = descr.getExpression(); isPositional = descr.getType() == ExprConstraintDescr.Type.POSITIONAL; } else { expression = b.getText(); } ConstraintConnectiveDescr result = parseExpression(context, patternDescr, b, expression); if (result == null) { return; } isPositional &= !(result.getDescrs().size() == 1 && result.getDescrs().get(0) instanceof BindingDescr); if (isPositional) { processPositional(context, patternDescr, pattern, (ExprConstraintDescr) b); } else { // need to build the actual constraint List<Constraint> constraints = build(context, patternDescr, pattern, result, mvelCtx); pattern.addConstraints(constraints); } } TypeDeclaration typeDeclaration = getTypeDeclaration(pattern, context); if (typeDeclaration != null && typeDeclaration.isPropertyReactive()) { for (String field : context.getRuleDescr().lookAheadFieldsOfIdentifier(patternDescr)) { addFieldToPatternWatchlist(pattern, typeDeclaration, field); } } combineConstraints(context, pattern, mvelCtx); }
java
protected void processConstraintsAndBinds(final RuleBuildContext context, final PatternDescr patternDescr, final Pattern pattern) { MVELDumper.MVELDumperContext mvelCtx = new MVELDumper.MVELDumperContext().setRuleContext(context); for (BaseDescr b : patternDescr.getDescrs()) { String expression; boolean isPositional = false; if (b instanceof BindingDescr) { BindingDescr bind = (BindingDescr) b; expression = bind.getVariable() + (bind.isUnification() ? " := " : " : ") + bind.getExpression(); } else if (b instanceof ExprConstraintDescr) { ExprConstraintDescr descr = (ExprConstraintDescr) b; expression = descr.getExpression(); isPositional = descr.getType() == ExprConstraintDescr.Type.POSITIONAL; } else { expression = b.getText(); } ConstraintConnectiveDescr result = parseExpression(context, patternDescr, b, expression); if (result == null) { return; } isPositional &= !(result.getDescrs().size() == 1 && result.getDescrs().get(0) instanceof BindingDescr); if (isPositional) { processPositional(context, patternDescr, pattern, (ExprConstraintDescr) b); } else { // need to build the actual constraint List<Constraint> constraints = build(context, patternDescr, pattern, result, mvelCtx); pattern.addConstraints(constraints); } } TypeDeclaration typeDeclaration = getTypeDeclaration(pattern, context); if (typeDeclaration != null && typeDeclaration.isPropertyReactive()) { for (String field : context.getRuleDescr().lookAheadFieldsOfIdentifier(patternDescr)) { addFieldToPatternWatchlist(pattern, typeDeclaration, field); } } combineConstraints(context, pattern, mvelCtx); }
[ "protected", "void", "processConstraintsAndBinds", "(", "final", "RuleBuildContext", "context", ",", "final", "PatternDescr", "patternDescr", ",", "final", "Pattern", "pattern", ")", "{", "MVELDumper", ".", "MVELDumperContext", "mvelCtx", "=", "new", "MVELDumper", ".", "MVELDumperContext", "(", ")", ".", "setRuleContext", "(", "context", ")", ";", "for", "(", "BaseDescr", "b", ":", "patternDescr", ".", "getDescrs", "(", ")", ")", "{", "String", "expression", ";", "boolean", "isPositional", "=", "false", ";", "if", "(", "b", "instanceof", "BindingDescr", ")", "{", "BindingDescr", "bind", "=", "(", "BindingDescr", ")", "b", ";", "expression", "=", "bind", ".", "getVariable", "(", ")", "+", "(", "bind", ".", "isUnification", "(", ")", "?", "\" := \"", ":", "\" : \"", ")", "+", "bind", ".", "getExpression", "(", ")", ";", "}", "else", "if", "(", "b", "instanceof", "ExprConstraintDescr", ")", "{", "ExprConstraintDescr", "descr", "=", "(", "ExprConstraintDescr", ")", "b", ";", "expression", "=", "descr", ".", "getExpression", "(", ")", ";", "isPositional", "=", "descr", ".", "getType", "(", ")", "==", "ExprConstraintDescr", ".", "Type", ".", "POSITIONAL", ";", "}", "else", "{", "expression", "=", "b", ".", "getText", "(", ")", ";", "}", "ConstraintConnectiveDescr", "result", "=", "parseExpression", "(", "context", ",", "patternDescr", ",", "b", ",", "expression", ")", ";", "if", "(", "result", "==", "null", ")", "{", "return", ";", "}", "isPositional", "&=", "!", "(", "result", ".", "getDescrs", "(", ")", ".", "size", "(", ")", "==", "1", "&&", "result", ".", "getDescrs", "(", ")", ".", "get", "(", "0", ")", "instanceof", "BindingDescr", ")", ";", "if", "(", "isPositional", ")", "{", "processPositional", "(", "context", ",", "patternDescr", ",", "pattern", ",", "(", "ExprConstraintDescr", ")", "b", ")", ";", "}", "else", "{", "// need to build the actual constraint", "List", "<", "Constraint", ">", "constraints", "=", "build", "(", "context", ",", "patternDescr", ",", "pattern", ",", "result", ",", "mvelCtx", ")", ";", "pattern", ".", "addConstraints", "(", "constraints", ")", ";", "}", "}", "TypeDeclaration", "typeDeclaration", "=", "getTypeDeclaration", "(", "pattern", ",", "context", ")", ";", "if", "(", "typeDeclaration", "!=", "null", "&&", "typeDeclaration", ".", "isPropertyReactive", "(", ")", ")", "{", "for", "(", "String", "field", ":", "context", ".", "getRuleDescr", "(", ")", ".", "lookAheadFieldsOfIdentifier", "(", "patternDescr", ")", ")", "{", "addFieldToPatternWatchlist", "(", "pattern", ",", "typeDeclaration", ",", "field", ")", ";", "}", "}", "combineConstraints", "(", "context", ",", "pattern", ",", "mvelCtx", ")", ";", "}" ]
Process all constraints and bindings on this pattern
[ "Process", "all", "constraints", "and", "bindings", "on", "this", "pattern" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/rule/builder/PatternBuilder.java#L584-L633
14,324
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/rule/builder/PatternBuilder.java
PatternBuilder.createDeclarationObject
protected static Declaration createDeclarationObject(final RuleBuildContext context, final String identifier, final Pattern pattern) { return createDeclarationObject(context, identifier, identifier, pattern); }
java
protected static Declaration createDeclarationObject(final RuleBuildContext context, final String identifier, final Pattern pattern) { return createDeclarationObject(context, identifier, identifier, pattern); }
[ "protected", "static", "Declaration", "createDeclarationObject", "(", "final", "RuleBuildContext", "context", ",", "final", "String", "identifier", ",", "final", "Pattern", "pattern", ")", "{", "return", "createDeclarationObject", "(", "context", ",", "identifier", ",", "identifier", ",", "pattern", ")", ";", "}" ]
Creates a declaration object for the field identified by the given identifier on the give pattern object
[ "Creates", "a", "declaration", "object", "for", "the", "field", "identified", "by", "the", "given", "identifier", "on", "the", "give", "pattern", "object" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/rule/builder/PatternBuilder.java#L1694-L1698
14,325
kiegroup/drools
drools-examples/src/main/java/org/drools/examples/sudoku/SetOfNine.java
SetOfNine.blockExcept
public void blockExcept(Integer... values) { free.clear(); for( Integer value: values ){ free.add(value); } }
java
public void blockExcept(Integer... values) { free.clear(); for( Integer value: values ){ free.add(value); } }
[ "public", "void", "blockExcept", "(", "Integer", "...", "values", ")", "{", "free", ".", "clear", "(", ")", ";", "for", "(", "Integer", "value", ":", "values", ")", "{", "free", ".", "add", "(", "value", ")", ";", "}", "}" ]
Redefine the set of acceptable values for this cell. @param values the Integer objects representing the new set of acceptable values.
[ "Redefine", "the", "set", "of", "acceptable", "values", "for", "this", "cell", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-examples/src/main/java/org/drools/examples/sudoku/SetOfNine.java#L36-L41
14,326
kiegroup/drools
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/impl/DMNKnowledgeBuilderError.java
DMNKnowledgeBuilderError.from
public static DMNKnowledgeBuilderError from(Resource resource, String namespace, DMNMessage m) { ResultSeverity rs = ResultSeverity.ERROR; switch (m.getLevel()) { case ERROR: rs = ResultSeverity.ERROR; break; case INFO: rs = ResultSeverity.INFO; break; case WARNING: rs = ResultSeverity.WARNING; break; default: rs = ResultSeverity.ERROR; break; } DMNKnowledgeBuilderError res = new DMNKnowledgeBuilderError(rs, resource, namespace, m.getMessage()); res.dmnMessage = m; return res; }
java
public static DMNKnowledgeBuilderError from(Resource resource, String namespace, DMNMessage m) { ResultSeverity rs = ResultSeverity.ERROR; switch (m.getLevel()) { case ERROR: rs = ResultSeverity.ERROR; break; case INFO: rs = ResultSeverity.INFO; break; case WARNING: rs = ResultSeverity.WARNING; break; default: rs = ResultSeverity.ERROR; break; } DMNKnowledgeBuilderError res = new DMNKnowledgeBuilderError(rs, resource, namespace, m.getMessage()); res.dmnMessage = m; return res; }
[ "public", "static", "DMNKnowledgeBuilderError", "from", "(", "Resource", "resource", ",", "String", "namespace", ",", "DMNMessage", "m", ")", "{", "ResultSeverity", "rs", "=", "ResultSeverity", ".", "ERROR", ";", "switch", "(", "m", ".", "getLevel", "(", ")", ")", "{", "case", "ERROR", ":", "rs", "=", "ResultSeverity", ".", "ERROR", ";", "break", ";", "case", "INFO", ":", "rs", "=", "ResultSeverity", ".", "INFO", ";", "break", ";", "case", "WARNING", ":", "rs", "=", "ResultSeverity", ".", "WARNING", ";", "break", ";", "default", ":", "rs", "=", "ResultSeverity", ".", "ERROR", ";", "break", ";", "}", "DMNKnowledgeBuilderError", "res", "=", "new", "DMNKnowledgeBuilderError", "(", "rs", ",", "resource", ",", "namespace", ",", "m", ".", "getMessage", "(", ")", ")", ";", "res", ".", "dmnMessage", "=", "m", ";", "return", "res", ";", "}" ]
Builds a DMNKnowledgeBuilderError from a DMNMessage associated with the given Resource @param resource the DMN model resource @param namespace @param m the DMNMessage belonging to the given DMN model resource @return
[ "Builds", "a", "DMNKnowledgeBuilderError", "from", "a", "DMNMessage", "associated", "with", "the", "given", "Resource" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/impl/DMNKnowledgeBuilderError.java#L40-L59
14,327
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/dsl/DSLMappingFile.java
DSLMappingFile.saveMapping
public void saveMapping(final Writer out) throws IOException { for ( final Iterator it = this.mapping.getEntries().iterator(); it.hasNext(); ) { out.write( it.next().toString() ); out.write( "\n" ); } }
java
public void saveMapping(final Writer out) throws IOException { for ( final Iterator it = this.mapping.getEntries().iterator(); it.hasNext(); ) { out.write( it.next().toString() ); out.write( "\n" ); } }
[ "public", "void", "saveMapping", "(", "final", "Writer", "out", ")", "throws", "IOException", "{", "for", "(", "final", "Iterator", "it", "=", "this", ".", "mapping", ".", "getEntries", "(", ")", ".", "iterator", "(", ")", ";", "it", ".", "hasNext", "(", ")", ";", ")", "{", "out", ".", "write", "(", "it", ".", "next", "(", ")", ".", "toString", "(", ")", ")", ";", "out", ".", "write", "(", "\"\\n\"", ")", ";", "}", "}" ]
Saves current mapping into a DSL mapping file @param out @throws IOException
[ "Saves", "current", "mapping", "into", "a", "DSL", "mapping", "file" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/dsl/DSLMappingFile.java#L83-L88
14,328
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/dsl/DSLMappingFile.java
DSLMappingFile.saveMapping
public static void saveMapping(final Writer out, final DSLMapping mapping) throws IOException { for (DSLMappingEntry dslMappingEntry : mapping.getEntries()) { out.write(dslMappingEntry.toString()); out.write("\n"); } }
java
public static void saveMapping(final Writer out, final DSLMapping mapping) throws IOException { for (DSLMappingEntry dslMappingEntry : mapping.getEntries()) { out.write(dslMappingEntry.toString()); out.write("\n"); } }
[ "public", "static", "void", "saveMapping", "(", "final", "Writer", "out", ",", "final", "DSLMapping", "mapping", ")", "throws", "IOException", "{", "for", "(", "DSLMappingEntry", "dslMappingEntry", ":", "mapping", ".", "getEntries", "(", ")", ")", "{", "out", ".", "write", "(", "dslMappingEntry", ".", "toString", "(", ")", ")", ";", "out", ".", "write", "(", "\"\\n\"", ")", ";", "}", "}" ]
Saves the given mapping into a DSL mapping file @param out @param mapping @throws IOException
[ "Saves", "the", "given", "mapping", "into", "a", "DSL", "mapping", "file" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/dsl/DSLMappingFile.java#L97-L103
14,329
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/dsl/DSLMappingFile.java
DSLMappingFile.dumpFile
public String dumpFile() { final StringBuilder buf = new StringBuilder(); for (DSLMappingEntry dslMappingEntry : this.mapping.getEntries()) { buf.append(dslMappingEntry); buf.append("\n"); } return buf.toString(); }
java
public String dumpFile() { final StringBuilder buf = new StringBuilder(); for (DSLMappingEntry dslMappingEntry : this.mapping.getEntries()) { buf.append(dslMappingEntry); buf.append("\n"); } return buf.toString(); }
[ "public", "String", "dumpFile", "(", ")", "{", "final", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "DSLMappingEntry", "dslMappingEntry", ":", "this", ".", "mapping", ".", "getEntries", "(", ")", ")", "{", "buf", ".", "append", "(", "dslMappingEntry", ")", ";", "buf", ".", "append", "(", "\"\\n\"", ")", ";", "}", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
Method to return the current mapping as a String object @return
[ "Method", "to", "return", "the", "current", "mapping", "as", "a", "String", "object" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/dsl/DSLMappingFile.java#L109-L116
14,330
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/marshaller/FEELCodeMarshaller.java
FEELCodeMarshaller.unmarshall
@Override public Object unmarshall(Type feelType, String value) { return feel.evaluate( value ); }
java
@Override public Object unmarshall(Type feelType, String value) { return feel.evaluate( value ); }
[ "@", "Override", "public", "Object", "unmarshall", "(", "Type", "feelType", ",", "String", "value", ")", "{", "return", "feel", ".", "evaluate", "(", "value", ")", ";", "}" ]
Unmarshalls the string into a FEEL value by executing it. @param feelType this parameter is ignored by this marshaller and can be set to null @param value the FEEL code to execute for unmarshalling @return the value resulting from executing the code
[ "Unmarshalls", "the", "string", "into", "a", "FEEL", "value", "by", "executing", "it", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/marshaller/FEELCodeMarshaller.java#L70-L73
14,331
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/BaseColumnFieldDiffImpl.java
BaseColumnFieldDiffImpl.isEqualOrNull
public static boolean isEqualOrNull( List s1, List s2 ) { if ( s1 == null && s2 == null ) { return true; } else if ( s1 != null && s2 != null && s1.size() == s2.size() ) { return true; } return false; }
java
public static boolean isEqualOrNull( List s1, List s2 ) { if ( s1 == null && s2 == null ) { return true; } else if ( s1 != null && s2 != null && s1.size() == s2.size() ) { return true; } return false; }
[ "public", "static", "boolean", "isEqualOrNull", "(", "List", "s1", ",", "List", "s2", ")", "{", "if", "(", "s1", "==", "null", "&&", "s2", "==", "null", ")", "{", "return", "true", ";", "}", "else", "if", "(", "s1", "!=", "null", "&&", "s2", "!=", "null", "&&", "s1", ".", "size", "(", ")", "==", "s2", ".", "size", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check whether two List are same size or both null. @param s1 The fist list.. @param s2 The other list. @return Whether two List are same size or both null
[ "Check", "whether", "two", "List", "are", "same", "size", "or", "both", "null", "." ]
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/BaseColumnFieldDiffImpl.java#L197-L208
14,332
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/BaseColumnFieldDiffImpl.java
BaseColumnFieldDiffImpl.isEqualOrNull
public static boolean isEqualOrNull( Map s1, Map s2 ) { if ( s1 == null && s2 == null ) { return true; } else if ( s1 != null && s2 != null && s1.size() == s2.size() ) { return true; } return false; }
java
public static boolean isEqualOrNull( Map s1, Map s2 ) { if ( s1 == null && s2 == null ) { return true; } else if ( s1 != null && s2 != null && s1.size() == s2.size() ) { return true; } return false; }
[ "public", "static", "boolean", "isEqualOrNull", "(", "Map", "s1", ",", "Map", "s2", ")", "{", "if", "(", "s1", "==", "null", "&&", "s2", "==", "null", ")", "{", "return", "true", ";", "}", "else", "if", "(", "s1", "!=", "null", "&&", "s2", "!=", "null", "&&", "s1", ".", "size", "(", ")", "==", "s2", ".", "size", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check whether two Map are same size or both null. @param s1 The fist Map.. @param s2 The other Map. @return Whether two Map are same size or both null
[ "Check", "whether", "two", "Map", "are", "same", "size", "or", "both", "null", "." ]
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/BaseColumnFieldDiffImpl.java#L219-L230
14,333
kiegroup/drools
kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/dtanalysis/model/Bound.java
Bound.adOrOver
public static boolean adOrOver(Bound<?> left, Bound<?> right) { boolean isValueEqual = left.getValue().equals(right.getValue()); boolean isBothOpen = left.getBoundaryType() == RangeBoundary.OPEN && right.getBoundaryType() == RangeBoundary.OPEN; return isValueEqual && !isBothOpen; }
java
public static boolean adOrOver(Bound<?> left, Bound<?> right) { boolean isValueEqual = left.getValue().equals(right.getValue()); boolean isBothOpen = left.getBoundaryType() == RangeBoundary.OPEN && right.getBoundaryType() == RangeBoundary.OPEN; return isValueEqual && !isBothOpen; }
[ "public", "static", "boolean", "adOrOver", "(", "Bound", "<", "?", ">", "left", ",", "Bound", "<", "?", ">", "right", ")", "{", "boolean", "isValueEqual", "=", "left", ".", "getValue", "(", ")", ".", "equals", "(", "right", ".", "getValue", "(", ")", ")", ";", "boolean", "isBothOpen", "=", "left", ".", "getBoundaryType", "(", ")", "==", "RangeBoundary", ".", "OPEN", "&&", "right", ".", "getBoundaryType", "(", ")", "==", "RangeBoundary", ".", "OPEN", ";", "return", "isValueEqual", "&&", "!", "isBothOpen", ";", "}" ]
Returns true if left is overlapping or adjacent to right
[ "Returns", "true", "if", "left", "is", "overlapping", "or", "adjacent", "to", "right" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-validation/src/main/java/org/kie/dmn/validation/dtanalysis/model/Bound.java#L153-L157
14,334
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/MetadataCol52.java
MetadataCol52.cloneColumn
public MetadataCol52 cloneColumn() { MetadataCol52 cloned = new MetadataCol52(); cloned.setMetadata( getMetadata() ); cloned.cloneCommonColumnConfigFrom( this ); return cloned; }
java
public MetadataCol52 cloneColumn() { MetadataCol52 cloned = new MetadataCol52(); cloned.setMetadata( getMetadata() ); cloned.cloneCommonColumnConfigFrom( this ); return cloned; }
[ "public", "MetadataCol52", "cloneColumn", "(", ")", "{", "MetadataCol52", "cloned", "=", "new", "MetadataCol52", "(", ")", ";", "cloned", ".", "setMetadata", "(", "getMetadata", "(", ")", ")", ";", "cloned", ".", "cloneCommonColumnConfigFrom", "(", "this", ")", ";", "return", "cloned", ";", "}" ]
Clones this metadata column instance. @return The cloned instance.
[ "Clones", "this", "metadata", "column", "instance", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/MetadataCol52.java#L64-L69
14,335
kiegroup/drools
drools-core/src/main/java/org/drools/core/spi/DeclarationScopeResolver.java
DeclarationScopeResolver.getDeclarations
public Map<String, Declaration> getDeclarations(RuleImpl rule, String consequenceName) { Map<String, Declaration> declarations = new HashMap<String, Declaration>(); for (RuleConditionElement aBuildStack : this.buildStack) { // if we are inside of an OR we don't want each previous stack entry added because we can't see those variables if (aBuildStack instanceof GroupElement && ((GroupElement)aBuildStack).getType() == GroupElement.Type.OR) { continue; } // this may be optimized in the future to only re-add elements at // scope breaks, like "NOT" and "EXISTS" Map<String,Declaration> innerDeclarations = aBuildStack instanceof GroupElement ? ((GroupElement)aBuildStack).getInnerDeclarations(consequenceName) : aBuildStack.getInnerDeclarations(); declarations.putAll(innerDeclarations); } if ( null != rule.getParent() ) { return getAllExtendedDeclaration( rule.getParent(), declarations ); } return declarations; }
java
public Map<String, Declaration> getDeclarations(RuleImpl rule, String consequenceName) { Map<String, Declaration> declarations = new HashMap<String, Declaration>(); for (RuleConditionElement aBuildStack : this.buildStack) { // if we are inside of an OR we don't want each previous stack entry added because we can't see those variables if (aBuildStack instanceof GroupElement && ((GroupElement)aBuildStack).getType() == GroupElement.Type.OR) { continue; } // this may be optimized in the future to only re-add elements at // scope breaks, like "NOT" and "EXISTS" Map<String,Declaration> innerDeclarations = aBuildStack instanceof GroupElement ? ((GroupElement)aBuildStack).getInnerDeclarations(consequenceName) : aBuildStack.getInnerDeclarations(); declarations.putAll(innerDeclarations); } if ( null != rule.getParent() ) { return getAllExtendedDeclaration( rule.getParent(), declarations ); } return declarations; }
[ "public", "Map", "<", "String", ",", "Declaration", ">", "getDeclarations", "(", "RuleImpl", "rule", ",", "String", "consequenceName", ")", "{", "Map", "<", "String", ",", "Declaration", ">", "declarations", "=", "new", "HashMap", "<", "String", ",", "Declaration", ">", "(", ")", ";", "for", "(", "RuleConditionElement", "aBuildStack", ":", "this", ".", "buildStack", ")", "{", "// if we are inside of an OR we don't want each previous stack entry added because we can't see those variables", "if", "(", "aBuildStack", "instanceof", "GroupElement", "&&", "(", "(", "GroupElement", ")", "aBuildStack", ")", ".", "getType", "(", ")", "==", "GroupElement", ".", "Type", ".", "OR", ")", "{", "continue", ";", "}", "// this may be optimized in the future to only re-add elements at", "// scope breaks, like \"NOT\" and \"EXISTS\"", "Map", "<", "String", ",", "Declaration", ">", "innerDeclarations", "=", "aBuildStack", "instanceof", "GroupElement", "?", "(", "(", "GroupElement", ")", "aBuildStack", ")", ".", "getInnerDeclarations", "(", "consequenceName", ")", ":", "aBuildStack", ".", "getInnerDeclarations", "(", ")", ";", "declarations", ".", "putAll", "(", "innerDeclarations", ")", ";", "}", "if", "(", "null", "!=", "rule", ".", "getParent", "(", ")", ")", "{", "return", "getAllExtendedDeclaration", "(", "rule", ".", "getParent", "(", ")", ",", "declarations", ")", ";", "}", "return", "declarations", ";", "}" ]
Return all declarations scoped to the current RuleConditionElement in the build stack
[ "Return", "all", "declarations", "scoped", "to", "the", "current", "RuleConditionElement", "in", "the", "build", "stack" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/spi/DeclarationScopeResolver.java#L253-L272
14,336
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/ObjectTypeNode.java
ObjectTypeNode.attach
public void attach(BuildContext context) { this.source.addObjectSink(this); Class<?> nodeTypeClass = objectType.getClassType(); if (nodeTypeClass == null) { return; } EntryPointNode epn = context.getKnowledgeBase().getRete().getEntryPointNode( ((EntryPointNode) source).getEntryPoint() ); if (epn == null) { return; } ObjectTypeConf objectTypeConf = epn.getTypeConfReg().getObjectTypeConfByClass( nodeTypeClass ); if ( objectTypeConf != null ) { objectTypeConf.resetCache(); } }
java
public void attach(BuildContext context) { this.source.addObjectSink(this); Class<?> nodeTypeClass = objectType.getClassType(); if (nodeTypeClass == null) { return; } EntryPointNode epn = context.getKnowledgeBase().getRete().getEntryPointNode( ((EntryPointNode) source).getEntryPoint() ); if (epn == null) { return; } ObjectTypeConf objectTypeConf = epn.getTypeConfReg().getObjectTypeConfByClass( nodeTypeClass ); if ( objectTypeConf != null ) { objectTypeConf.resetCache(); } }
[ "public", "void", "attach", "(", "BuildContext", "context", ")", "{", "this", ".", "source", ".", "addObjectSink", "(", "this", ")", ";", "Class", "<", "?", ">", "nodeTypeClass", "=", "objectType", ".", "getClassType", "(", ")", ";", "if", "(", "nodeTypeClass", "==", "null", ")", "{", "return", ";", "}", "EntryPointNode", "epn", "=", "context", ".", "getKnowledgeBase", "(", ")", ".", "getRete", "(", ")", ".", "getEntryPointNode", "(", "(", "(", "EntryPointNode", ")", "source", ")", ".", "getEntryPoint", "(", ")", ")", ";", "if", "(", "epn", "==", "null", ")", "{", "return", ";", "}", "ObjectTypeConf", "objectTypeConf", "=", "epn", ".", "getTypeConfReg", "(", ")", ".", "getObjectTypeConfByClass", "(", "nodeTypeClass", ")", ";", "if", "(", "objectTypeConf", "!=", "null", ")", "{", "objectTypeConf", ".", "resetCache", "(", ")", ";", "}", "}" ]
Rete needs to know that this ObjectTypeNode has been added
[ "Rete", "needs", "to", "know", "that", "this", "ObjectTypeNode", "has", "been", "added" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/ObjectTypeNode.java#L455-L472
14,337
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/ObjectTypeNode.java
ObjectTypeNode.createMemory
public ObjectTypeNodeMemory createMemory(final RuleBaseConfiguration config, InternalWorkingMemory wm) { Class<?> classType = ((ClassObjectType) getObjectType()).getClassType(); if (InitialFact.class.isAssignableFrom(classType)) { return new InitialFactObjectTypeNodeMemory(classType); } return new ObjectTypeNodeMemory(classType, wm); }
java
public ObjectTypeNodeMemory createMemory(final RuleBaseConfiguration config, InternalWorkingMemory wm) { Class<?> classType = ((ClassObjectType) getObjectType()).getClassType(); if (InitialFact.class.isAssignableFrom(classType)) { return new InitialFactObjectTypeNodeMemory(classType); } return new ObjectTypeNodeMemory(classType, wm); }
[ "public", "ObjectTypeNodeMemory", "createMemory", "(", "final", "RuleBaseConfiguration", "config", ",", "InternalWorkingMemory", "wm", ")", "{", "Class", "<", "?", ">", "classType", "=", "(", "(", "ClassObjectType", ")", "getObjectType", "(", ")", ")", ".", "getClassType", "(", ")", ";", "if", "(", "InitialFact", ".", "class", ".", "isAssignableFrom", "(", "classType", ")", ")", "{", "return", "new", "InitialFactObjectTypeNodeMemory", "(", "classType", ")", ";", "}", "return", "new", "ObjectTypeNodeMemory", "(", "classType", ",", "wm", ")", ";", "}" ]
Creates memory for the node using PrimitiveLongMap as its optimised for storage and reteivals of Longs. However PrimitiveLongMap is not ideal for spase data. So it should be monitored incase its more optimal to switch back to a standard HashMap.
[ "Creates", "memory", "for", "the", "node", "using", "PrimitiveLongMap", "as", "its", "optimised", "for", "storage", "and", "reteivals", "of", "Longs", ".", "However", "PrimitiveLongMap", "is", "not", "ideal", "for", "spase", "data", ".", "So", "it", "should", "be", "monitored", "incase", "its", "more", "optimal", "to", "switch", "back", "to", "a", "standard", "HashMap", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/ObjectTypeNode.java#L524-L530
14,338
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DurationFunction.java
DurationFunction.invoke
public FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) TemporalAmount val) { if ( val == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "cannot be null")); } return FEELFnResult.ofResult( val ); }
java
public FEELFnResult<TemporalAmount> invoke(@ParameterName( "from" ) TemporalAmount val) { if ( val == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "from", "cannot be null")); } return FEELFnResult.ofResult( val ); }
[ "public", "FEELFnResult", "<", "TemporalAmount", ">", "invoke", "(", "@", "ParameterName", "(", "\"from\"", ")", "TemporalAmount", "val", ")", "{", "if", "(", "val", "==", "null", ")", "{", "return", "FEELFnResult", ".", "ofError", "(", "new", "InvalidParametersEvent", "(", "Severity", ".", "ERROR", ",", "\"from\"", ",", "\"cannot be null\"", ")", ")", ";", "}", "return", "FEELFnResult", ".", "ofResult", "(", "val", ")", ";", "}" ]
This is the identity function implementation @param val @return
[ "This", "is", "the", "identity", "function", "implementation" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DurationFunction.java#L67-L72
14,339
kiegroup/drools
kie-ci/src/main/java/org/kie/api/builder/helper/KieModuleDeploymentHelperImpl.java
KieModuleDeploymentHelperImpl.internalCreateAndDeployKjarToMaven
private synchronized void internalCreateAndDeployKjarToMaven(ReleaseId releaseId, String kbaseName, String ksessionName, List<String> resourceFilePaths, List<Class<?>> classes, List<String> dependencies) { InternalKieModule kjar = (InternalKieModule) internalCreateKieJar(releaseId, kbaseName, ksessionName, resourceFilePaths, classes, dependencies); String pomFileName = MavenRepository.toFileName(releaseId, null) + ".pom"; File pomFile = new File(System.getProperty("java.io.tmpdir"), pomFileName); try { FileOutputStream fos = new FileOutputStream(pomFile); fos.write(config.pomText.getBytes(IoUtils.UTF8_CHARSET)); fos.flush(); fos.close(); } catch (IOException ioe) { throw new RuntimeException("Unable to write pom.xml to temporary file : " + ioe.getMessage(), ioe); } KieMavenRepository repository = getKieMavenRepository(); repository.installArtifact(releaseId, kjar, pomFile); }
java
private synchronized void internalCreateAndDeployKjarToMaven(ReleaseId releaseId, String kbaseName, String ksessionName, List<String> resourceFilePaths, List<Class<?>> classes, List<String> dependencies) { InternalKieModule kjar = (InternalKieModule) internalCreateKieJar(releaseId, kbaseName, ksessionName, resourceFilePaths, classes, dependencies); String pomFileName = MavenRepository.toFileName(releaseId, null) + ".pom"; File pomFile = new File(System.getProperty("java.io.tmpdir"), pomFileName); try { FileOutputStream fos = new FileOutputStream(pomFile); fos.write(config.pomText.getBytes(IoUtils.UTF8_CHARSET)); fos.flush(); fos.close(); } catch (IOException ioe) { throw new RuntimeException("Unable to write pom.xml to temporary file : " + ioe.getMessage(), ioe); } KieMavenRepository repository = getKieMavenRepository(); repository.installArtifact(releaseId, kjar, pomFile); }
[ "private", "synchronized", "void", "internalCreateAndDeployKjarToMaven", "(", "ReleaseId", "releaseId", ",", "String", "kbaseName", ",", "String", "ksessionName", ",", "List", "<", "String", ">", "resourceFilePaths", ",", "List", "<", "Class", "<", "?", ">", ">", "classes", ",", "List", "<", "String", ">", "dependencies", ")", "{", "InternalKieModule", "kjar", "=", "(", "InternalKieModule", ")", "internalCreateKieJar", "(", "releaseId", ",", "kbaseName", ",", "ksessionName", ",", "resourceFilePaths", ",", "classes", ",", "dependencies", ")", ";", "String", "pomFileName", "=", "MavenRepository", ".", "toFileName", "(", "releaseId", ",", "null", ")", "+", "\".pom\"", ";", "File", "pomFile", "=", "new", "File", "(", "System", ".", "getProperty", "(", "\"java.io.tmpdir\"", ")", ",", "pomFileName", ")", ";", "try", "{", "FileOutputStream", "fos", "=", "new", "FileOutputStream", "(", "pomFile", ")", ";", "fos", ".", "write", "(", "config", ".", "pomText", ".", "getBytes", "(", "IoUtils", ".", "UTF8_CHARSET", ")", ")", ";", "fos", ".", "flush", "(", ")", ";", "fos", ".", "close", "(", ")", ";", "}", "catch", "(", "IOException", "ioe", ")", "{", "throw", "new", "RuntimeException", "(", "\"Unable to write pom.xml to temporary file : \"", "+", "ioe", ".", "getMessage", "(", ")", ",", "ioe", ")", ";", "}", "KieMavenRepository", "repository", "=", "getKieMavenRepository", "(", ")", ";", "repository", ".", "installArtifact", "(", "releaseId", ",", "kjar", ",", "pomFile", ")", ";", "}" ]
Create a KJar and deploy it to maven. @param releaseId The {@link ReleaseId} of the jar. @param kbaseName The name to use for the (default) {@link KieBase} in the kmodule.xml. @param ksessionName The name to use for the (default) {@link KieSession} in the kmodule.xml. @param resourceFilePaths A (possibly null) list of files to be added to the kjar. @param classes @param dependencies
[ "Create", "a", "KJar", "and", "deploy", "it", "to", "maven", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-ci/src/main/java/org/kie/api/builder/helper/KieModuleDeploymentHelperImpl.java#L257-L282
14,340
kiegroup/drools
kie-ci/src/main/java/org/kie/api/builder/helper/KieModuleDeploymentHelperImpl.java
KieModuleDeploymentHelperImpl.internalCreateKieJar
private synchronized KieModule internalCreateKieJar(ReleaseId releaseId, String kbaseName, String ksessionName, List<String> resourceFilePaths, List<Class<?>> classes, List<String> dependencies) { ReleaseId [] releaseIds = { }; if( dependencies != null && dependencies.size() > 0 ) { List<ReleaseId> depReleaseIds = new ArrayList<ReleaseId>(); for( String dep : dependencies ) { String [] gav = dep.split(":"); if( gav.length != 3 ) { throw new IllegalArgumentException("Dependendency id '" + dep + "' does not conform to the format <groupId>:<artifactId>:<version> (Classifiers are not accepted)."); } depReleaseIds.add(new ReleaseIdImpl(gav[0], gav[1], gav[2])); } releaseIds = depReleaseIds.toArray(new ReleaseId[depReleaseIds.size()]); } config.pomText = getPomText(releaseId, releaseIds); KieFileSystem kfs = createKieFileSystemWithKProject(kbaseName, ksessionName); kfs.writePomXML(this.config.pomText); List<KJarResource> resourceFiles = loadResources(resourceFilePaths); for (KJarResource resource : resourceFiles) { kfs.write("src/main/resources/" + kbaseName + "/" + resource.name, resource.content); } if( classes != null ) { for( Class<?> userClass : classes ) { addClass(userClass, kfs); } } KieBuilder kieBuilder = config.getKieServicesInstance().newKieBuilder(kfs); int buildMsgs = 0; for( Message buildMsg : kieBuilder.buildAll().getResults().getMessages() ) { System.out.println( buildMsg.getPath() + " : " + buildMsg.getText() ); ++buildMsgs; } if( buildMsgs > 0 ) { throw new RuntimeException("Unable to build KieModule, see the " + buildMsgs + " messages above."); } return (InternalKieModule) kieBuilder.getKieModule(); }
java
private synchronized KieModule internalCreateKieJar(ReleaseId releaseId, String kbaseName, String ksessionName, List<String> resourceFilePaths, List<Class<?>> classes, List<String> dependencies) { ReleaseId [] releaseIds = { }; if( dependencies != null && dependencies.size() > 0 ) { List<ReleaseId> depReleaseIds = new ArrayList<ReleaseId>(); for( String dep : dependencies ) { String [] gav = dep.split(":"); if( gav.length != 3 ) { throw new IllegalArgumentException("Dependendency id '" + dep + "' does not conform to the format <groupId>:<artifactId>:<version> (Classifiers are not accepted)."); } depReleaseIds.add(new ReleaseIdImpl(gav[0], gav[1], gav[2])); } releaseIds = depReleaseIds.toArray(new ReleaseId[depReleaseIds.size()]); } config.pomText = getPomText(releaseId, releaseIds); KieFileSystem kfs = createKieFileSystemWithKProject(kbaseName, ksessionName); kfs.writePomXML(this.config.pomText); List<KJarResource> resourceFiles = loadResources(resourceFilePaths); for (KJarResource resource : resourceFiles) { kfs.write("src/main/resources/" + kbaseName + "/" + resource.name, resource.content); } if( classes != null ) { for( Class<?> userClass : classes ) { addClass(userClass, kfs); } } KieBuilder kieBuilder = config.getKieServicesInstance().newKieBuilder(kfs); int buildMsgs = 0; for( Message buildMsg : kieBuilder.buildAll().getResults().getMessages() ) { System.out.println( buildMsg.getPath() + " : " + buildMsg.getText() ); ++buildMsgs; } if( buildMsgs > 0 ) { throw new RuntimeException("Unable to build KieModule, see the " + buildMsgs + " messages above."); } return (InternalKieModule) kieBuilder.getKieModule(); }
[ "private", "synchronized", "KieModule", "internalCreateKieJar", "(", "ReleaseId", "releaseId", ",", "String", "kbaseName", ",", "String", "ksessionName", ",", "List", "<", "String", ">", "resourceFilePaths", ",", "List", "<", "Class", "<", "?", ">", ">", "classes", ",", "List", "<", "String", ">", "dependencies", ")", "{", "ReleaseId", "[", "]", "releaseIds", "=", "{", "}", ";", "if", "(", "dependencies", "!=", "null", "&&", "dependencies", ".", "size", "(", ")", ">", "0", ")", "{", "List", "<", "ReleaseId", ">", "depReleaseIds", "=", "new", "ArrayList", "<", "ReleaseId", ">", "(", ")", ";", "for", "(", "String", "dep", ":", "dependencies", ")", "{", "String", "[", "]", "gav", "=", "dep", ".", "split", "(", "\":\"", ")", ";", "if", "(", "gav", ".", "length", "!=", "3", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Dependendency id '\"", "+", "dep", "+", "\"' does not conform to the format <groupId>:<artifactId>:<version> (Classifiers are not accepted).\"", ")", ";", "}", "depReleaseIds", ".", "add", "(", "new", "ReleaseIdImpl", "(", "gav", "[", "0", "]", ",", "gav", "[", "1", "]", ",", "gav", "[", "2", "]", ")", ")", ";", "}", "releaseIds", "=", "depReleaseIds", ".", "toArray", "(", "new", "ReleaseId", "[", "depReleaseIds", ".", "size", "(", ")", "]", ")", ";", "}", "config", ".", "pomText", "=", "getPomText", "(", "releaseId", ",", "releaseIds", ")", ";", "KieFileSystem", "kfs", "=", "createKieFileSystemWithKProject", "(", "kbaseName", ",", "ksessionName", ")", ";", "kfs", ".", "writePomXML", "(", "this", ".", "config", ".", "pomText", ")", ";", "List", "<", "KJarResource", ">", "resourceFiles", "=", "loadResources", "(", "resourceFilePaths", ")", ";", "for", "(", "KJarResource", "resource", ":", "resourceFiles", ")", "{", "kfs", ".", "write", "(", "\"src/main/resources/\"", "+", "kbaseName", "+", "\"/\"", "+", "resource", ".", "name", ",", "resource", ".", "content", ")", ";", "}", "if", "(", "classes", "!=", "null", ")", "{", "for", "(", "Class", "<", "?", ">", "userClass", ":", "classes", ")", "{", "addClass", "(", "userClass", ",", "kfs", ")", ";", "}", "}", "KieBuilder", "kieBuilder", "=", "config", ".", "getKieServicesInstance", "(", ")", ".", "newKieBuilder", "(", "kfs", ")", ";", "int", "buildMsgs", "=", "0", ";", "for", "(", "Message", "buildMsg", ":", "kieBuilder", ".", "buildAll", "(", ")", ".", "getResults", "(", ")", ".", "getMessages", "(", ")", ")", "{", "System", ".", "out", ".", "println", "(", "buildMsg", ".", "getPath", "(", ")", "+", "\" : \"", "+", "buildMsg", ".", "getText", "(", ")", ")", ";", "++", "buildMsgs", ";", "}", "if", "(", "buildMsgs", ">", "0", ")", "{", "throw", "new", "RuntimeException", "(", "\"Unable to build KieModule, see the \"", "+", "buildMsgs", "+", "\" messages above.\"", ")", ";", "}", "return", "(", "InternalKieModule", ")", "kieBuilder", ".", "getKieModule", "(", ")", ";", "}" ]
Create a KJar for deployment; @param releaseId Release (deployment) id. @param resourceFilePaths List of resource file paths @param kbaseName The name of the {@link KieBase} @param ksessionName The name of the {@link KieSession}. @param dependencies List of dependencies to add @return The {@link InternalKieModule} which represents the KJar.
[ "Create", "a", "KJar", "for", "deployment", ";" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-ci/src/main/java/org/kie/api/builder/helper/KieModuleDeploymentHelperImpl.java#L295-L342
14,341
kiegroup/drools
kie-ci/src/main/java/org/kie/api/builder/helper/KieModuleDeploymentHelperImpl.java
KieModuleDeploymentHelperImpl.getPomText
private static String getPomText(ReleaseId releaseId, ReleaseId... dependencies) { String pom = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n" + " <modelVersion>4.0.0</modelVersion>\n" + "\n" + " <groupId>" + releaseId.getGroupId() + "</groupId>\n" + " <artifactId>" + releaseId.getArtifactId() + "</artifactId>\n" + " <version>" + releaseId.getVersion() + "</version>\n" + "\n"; if (dependencies != null && dependencies.length > 0) { pom += "<dependencies>\n"; for (ReleaseId dep : dependencies) { pom += "<dependency>\n"; pom += " <groupId>" + dep.getGroupId() + "</groupId>\n"; pom += " <artifactId>" + dep.getArtifactId() + "</artifactId>\n"; pom += " <version>" + dep.getVersion() + "</version>\n"; pom += "</dependency>\n"; } pom += "</dependencies>\n"; } pom += "</project>"; return pom; }
java
private static String getPomText(ReleaseId releaseId, ReleaseId... dependencies) { String pom = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<project xmlns=\"http://maven.apache.org/POM/4.0.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">\n" + " <modelVersion>4.0.0</modelVersion>\n" + "\n" + " <groupId>" + releaseId.getGroupId() + "</groupId>\n" + " <artifactId>" + releaseId.getArtifactId() + "</artifactId>\n" + " <version>" + releaseId.getVersion() + "</version>\n" + "\n"; if (dependencies != null && dependencies.length > 0) { pom += "<dependencies>\n"; for (ReleaseId dep : dependencies) { pom += "<dependency>\n"; pom += " <groupId>" + dep.getGroupId() + "</groupId>\n"; pom += " <artifactId>" + dep.getArtifactId() + "</artifactId>\n"; pom += " <version>" + dep.getVersion() + "</version>\n"; pom += "</dependency>\n"; } pom += "</dependencies>\n"; } pom += "</project>"; return pom; }
[ "private", "static", "String", "getPomText", "(", "ReleaseId", "releaseId", ",", "ReleaseId", "...", "dependencies", ")", "{", "String", "pom", "=", "\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\"", "+", "\"<project xmlns=\\\"http://maven.apache.org/POM/4.0.0\\\" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"\\n\"", "+", "\" xsi:schemaLocation=\\\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\\\">\\n\"", "+", "\" <modelVersion>4.0.0</modelVersion>\\n\"", "+", "\"\\n\"", "+", "\" <groupId>\"", "+", "releaseId", ".", "getGroupId", "(", ")", "+", "\"</groupId>\\n\"", "+", "\" <artifactId>\"", "+", "releaseId", ".", "getArtifactId", "(", ")", "+", "\"</artifactId>\\n\"", "+", "\" <version>\"", "+", "releaseId", ".", "getVersion", "(", ")", "+", "\"</version>\\n\"", "+", "\"\\n\"", ";", "if", "(", "dependencies", "!=", "null", "&&", "dependencies", ".", "length", ">", "0", ")", "{", "pom", "+=", "\"<dependencies>\\n\"", ";", "for", "(", "ReleaseId", "dep", ":", "dependencies", ")", "{", "pom", "+=", "\"<dependency>\\n\"", ";", "pom", "+=", "\" <groupId>\"", "+", "dep", ".", "getGroupId", "(", ")", "+", "\"</groupId>\\n\"", ";", "pom", "+=", "\" <artifactId>\"", "+", "dep", ".", "getArtifactId", "(", ")", "+", "\"</artifactId>\\n\"", ";", "pom", "+=", "\" <version>\"", "+", "dep", ".", "getVersion", "(", ")", "+", "\"</version>\\n\"", ";", "pom", "+=", "\"</dependency>\\n\"", ";", "}", "pom", "+=", "\"</dependencies>\\n\"", ";", "}", "pom", "+=", "\"</project>\"", ";", "return", "pom", ";", "}" ]
Create the pom that will be placed in the KJar. @param releaseId The release (deployment) id. @param dependencies The list of dependendencies to be added to the pom @return A string representation of the pom.
[ "Create", "the", "pom", "that", "will", "be", "placed", "in", "the", "KJar", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-ci/src/main/java/org/kie/api/builder/helper/KieModuleDeploymentHelperImpl.java#L365-L390
14,342
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/BehaviorManager.java
BehaviorManager.createBehaviorContext
public Behavior.Context[] createBehaviorContext() { Behavior.Context[] behaviorCtx = new Behavior.Context[behaviors.length]; for ( int i = 0; i < behaviors.length; i++ ) { behaviorCtx[i] = behaviors[i].createContext(); } return behaviorCtx; }
java
public Behavior.Context[] createBehaviorContext() { Behavior.Context[] behaviorCtx = new Behavior.Context[behaviors.length]; for ( int i = 0; i < behaviors.length; i++ ) { behaviorCtx[i] = behaviors[i].createContext(); } return behaviorCtx; }
[ "public", "Behavior", ".", "Context", "[", "]", "createBehaviorContext", "(", ")", "{", "Behavior", ".", "Context", "[", "]", "behaviorCtx", "=", "new", "Behavior", ".", "Context", "[", "behaviors", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "behaviors", ".", "length", ";", "i", "++", ")", "{", "behaviorCtx", "[", "i", "]", "=", "behaviors", "[", "i", "]", ".", "createContext", "(", ")", ";", "}", "return", "behaviorCtx", ";", "}" ]
Creates the behaviors' context
[ "Creates", "the", "behaviors", "context" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/BehaviorManager.java#L66-L72
14,343
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/BehaviorManager.java
BehaviorManager.assertFact
public boolean assertFact(final Object behaviorContext, final InternalFactHandle factHandle, final PropagationContext pctx, final InternalWorkingMemory workingMemory) { boolean result = true; for ( int i = 0; i < behaviors.length; i++ ) { result = result && behaviors[i].assertFact( ((Object[]) behaviorContext)[i], factHandle, pctx, workingMemory ); } return result; }
java
public boolean assertFact(final Object behaviorContext, final InternalFactHandle factHandle, final PropagationContext pctx, final InternalWorkingMemory workingMemory) { boolean result = true; for ( int i = 0; i < behaviors.length; i++ ) { result = result && behaviors[i].assertFact( ((Object[]) behaviorContext)[i], factHandle, pctx, workingMemory ); } return result; }
[ "public", "boolean", "assertFact", "(", "final", "Object", "behaviorContext", ",", "final", "InternalFactHandle", "factHandle", ",", "final", "PropagationContext", "pctx", ",", "final", "InternalWorkingMemory", "workingMemory", ")", "{", "boolean", "result", "=", "true", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "behaviors", ".", "length", ";", "i", "++", ")", "{", "result", "=", "result", "&&", "behaviors", "[", "i", "]", ".", "assertFact", "(", "(", "(", "Object", "[", "]", ")", "behaviorContext", ")", "[", "i", "]", ",", "factHandle", ",", "pctx", ",", "workingMemory", ")", ";", "}", "return", "result", ";", "}" ]
Register a newly asserted right tuple into the behaviors' context
[ "Register", "a", "newly", "asserted", "right", "tuple", "into", "the", "behaviors", "context" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/BehaviorManager.java#L77-L89
14,344
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/BehaviorManager.java
BehaviorManager.retractFact
public void retractFact(final Object behaviorContext, final InternalFactHandle factHandle, final PropagationContext pctx, final InternalWorkingMemory workingMemory) { for ( int i = 0; i < behaviors.length; i++ ) { behaviors[i].retractFact( ((Object[]) behaviorContext)[i], factHandle, pctx, workingMemory ); } }
java
public void retractFact(final Object behaviorContext, final InternalFactHandle factHandle, final PropagationContext pctx, final InternalWorkingMemory workingMemory) { for ( int i = 0; i < behaviors.length; i++ ) { behaviors[i].retractFact( ((Object[]) behaviorContext)[i], factHandle, pctx, workingMemory ); } }
[ "public", "void", "retractFact", "(", "final", "Object", "behaviorContext", ",", "final", "InternalFactHandle", "factHandle", ",", "final", "PropagationContext", "pctx", ",", "final", "InternalWorkingMemory", "workingMemory", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "behaviors", ".", "length", ";", "i", "++", ")", "{", "behaviors", "[", "i", "]", ".", "retractFact", "(", "(", "(", "Object", "[", "]", ")", "behaviorContext", ")", "[", "i", "]", ",", "factHandle", ",", "pctx", ",", "workingMemory", ")", ";", "}", "}" ]
Removes a newly asserted fact handle from the behaviors' context
[ "Removes", "a", "newly", "asserted", "fact", "handle", "from", "the", "behaviors", "context" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/BehaviorManager.java#L94-L104
14,345
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/builder/impl/errors/ErrorHandler.java
ErrorHandler.collectCompilerProblems
protected CompilationProblem[] collectCompilerProblems() { if (this.errors.isEmpty()) { return null; } else { final CompilationProblem[] list = new CompilationProblem[this.errors.size()]; this.errors.toArray(list); return list; } }
java
protected CompilationProblem[] collectCompilerProblems() { if (this.errors.isEmpty()) { return null; } else { final CompilationProblem[] list = new CompilationProblem[this.errors.size()]; this.errors.toArray(list); return list; } }
[ "protected", "CompilationProblem", "[", "]", "collectCompilerProblems", "(", ")", "{", "if", "(", "this", ".", "errors", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "final", "CompilationProblem", "[", "]", "list", "=", "new", "CompilationProblem", "[", "this", ".", "errors", ".", "size", "(", ")", "]", ";", "this", ".", "errors", ".", "toArray", "(", "list", ")", ";", "return", "list", ";", "}", "}" ]
We must use an error of JCI problem objects. If there are no problems, null is returned. These errors are placed in the DroolsError instances. Its not 1 to 1 with reported errors.
[ "We", "must", "use", "an", "error", "of", "JCI", "problem", "objects", ".", "If", "there", "are", "no", "problems", "null", "is", "returned", ".", "These", "errors", "are", "placed", "in", "the", "DroolsError", "instances", ".", "Its", "not", "1", "to", "1", "with", "reported", "errors", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/builder/impl/errors/ErrorHandler.java#L65-L73
14,346
kiegroup/drools
drools-examples-cdi/cdi-example-scopes/src/main/java/org/drools/example/cdi/scopes/KieBusinessScopeContext.java
KieBusinessScopeContext.get
@Override @SuppressWarnings("unchecked") public <T> T get(Contextual<T> contextual) { Bean bean = (Bean) contextual; // you can store the bean somewhere if (somewhere.containsKey(bean.getName())) { return (T) somewhere.get(bean.getName()); } else { return null; } }
java
@Override @SuppressWarnings("unchecked") public <T> T get(Contextual<T> contextual) { Bean bean = (Bean) contextual; // you can store the bean somewhere if (somewhere.containsKey(bean.getName())) { return (T) somewhere.get(bean.getName()); } else { return null; } }
[ "@", "Override", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "get", "(", "Contextual", "<", "T", ">", "contextual", ")", "{", "Bean", "bean", "=", "(", "Bean", ")", "contextual", ";", "// you can store the bean somewhere", "if", "(", "somewhere", ".", "containsKey", "(", "bean", ".", "getName", "(", ")", ")", ")", "{", "return", "(", "T", ")", "somewhere", ".", "get", "(", "bean", ".", "getName", "(", ")", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Return an existing instance of a certain contextual type or a null value.
[ "Return", "an", "existing", "instance", "of", "a", "certain", "contextual", "type", "or", "a", "null", "value", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-examples-cdi/cdi-example-scopes/src/main/java/org/drools/example/cdi/scopes/KieBusinessScopeContext.java#L61-L71
14,347
kiegroup/drools
drools-core/src/main/java/org/drools/core/reteoo/compiled/AbstractCompilerHandler.java
AbstractCompilerHandler.getVariableName
private String getVariableName(Class clazz, int nodeId) { String type = clazz.getSimpleName(); return Character.toLowerCase(type.charAt(0)) + type.substring(1) + nodeId; }
java
private String getVariableName(Class clazz, int nodeId) { String type = clazz.getSimpleName(); return Character.toLowerCase(type.charAt(0)) + type.substring(1) + nodeId; }
[ "private", "String", "getVariableName", "(", "Class", "clazz", ",", "int", "nodeId", ")", "{", "String", "type", "=", "clazz", ".", "getSimpleName", "(", ")", ";", "return", "Character", ".", "toLowerCase", "(", "type", ".", "charAt", "(", "0", ")", ")", "+", "type", ".", "substring", "(", "1", ")", "+", "nodeId", ";", "}" ]
Returns a variable name based on the simple name of the specified class appended with the specified nodeId. @param clazz class whose simple name is lowercased and user as the prefix of the variable name @param nodeId id of {@link org.kie.common.NetworkNode} @return variable name @see Class#getSimpleName()
[ "Returns", "a", "variable", "name", "based", "on", "the", "simple", "name", "of", "the", "specified", "class", "appended", "with", "the", "specified", "nodeId", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/reteoo/compiled/AbstractCompilerHandler.java#L76-L79
14,348
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/TDefinitions.java
TDefinitions.getDecisionService
@Override public List<DecisionService> getDecisionService() { return drgElement.stream().filter(DecisionService.class::isInstance).map(DecisionService.class::cast).collect(Collectors.toList()); }
java
@Override public List<DecisionService> getDecisionService() { return drgElement.stream().filter(DecisionService.class::isInstance).map(DecisionService.class::cast).collect(Collectors.toList()); }
[ "@", "Override", "public", "List", "<", "DecisionService", ">", "getDecisionService", "(", ")", "{", "return", "drgElement", ".", "stream", "(", ")", ".", "filter", "(", "DecisionService", ".", "class", "::", "isInstance", ")", ".", "map", "(", "DecisionService", ".", "class", "::", "cast", ")", ".", "collect", "(", "Collectors", ".", "toList", "(", ")", ")", ";", "}" ]
Implementing support for internal model
[ "Implementing", "support", "for", "internal", "model" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/TDefinitions.java#L175-L178
14,349
kiegroup/drools
drools-core/src/main/java/org/drools/core/io/impl/UrlResource.java
UrlResource.cacheStream
private void cacheStream() { try { File fi = getTemproralCacheFile(); if (fi.exists()) { if (!fi.delete()) { throw new IllegalStateException("Cannot delete file " + fi.getAbsolutePath() + "!"); } } FileOutputStream fout = new FileOutputStream(fi); InputStream in = grabStream(); byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; int n; while (-1 != (n = in.read(buffer))) { fout.write(buffer, 0, n); } fout.flush(); fout.close(); in.close(); File cacheFile = getCacheFile(); if (!fi.renameTo(cacheFile)) { throw new IllegalStateException("Cannot rename file \"" + fi.getAbsolutePath() + "\" to \"" + cacheFile.getAbsolutePath() + "\"!"); } } catch (Exception e) { e.printStackTrace(); } }
java
private void cacheStream() { try { File fi = getTemproralCacheFile(); if (fi.exists()) { if (!fi.delete()) { throw new IllegalStateException("Cannot delete file " + fi.getAbsolutePath() + "!"); } } FileOutputStream fout = new FileOutputStream(fi); InputStream in = grabStream(); byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; int n; while (-1 != (n = in.read(buffer))) { fout.write(buffer, 0, n); } fout.flush(); fout.close(); in.close(); File cacheFile = getCacheFile(); if (!fi.renameTo(cacheFile)) { throw new IllegalStateException("Cannot rename file \"" + fi.getAbsolutePath() + "\" to \"" + cacheFile.getAbsolutePath() + "\"!"); } } catch (Exception e) { e.printStackTrace(); } }
[ "private", "void", "cacheStream", "(", ")", "{", "try", "{", "File", "fi", "=", "getTemproralCacheFile", "(", ")", ";", "if", "(", "fi", ".", "exists", "(", ")", ")", "{", "if", "(", "!", "fi", ".", "delete", "(", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Cannot delete file \"", "+", "fi", ".", "getAbsolutePath", "(", ")", "+", "\"!\"", ")", ";", "}", "}", "FileOutputStream", "fout", "=", "new", "FileOutputStream", "(", "fi", ")", ";", "InputStream", "in", "=", "grabStream", "(", ")", ";", "byte", "[", "]", "buffer", "=", "new", "byte", "[", "DEFAULT_BUFFER_SIZE", "]", ";", "int", "n", ";", "while", "(", "-", "1", "!=", "(", "n", "=", "in", ".", "read", "(", "buffer", ")", ")", ")", "{", "fout", ".", "write", "(", "buffer", ",", "0", ",", "n", ")", ";", "}", "fout", ".", "flush", "(", ")", ";", "fout", ".", "close", "(", ")", ";", "in", ".", "close", "(", ")", ";", "File", "cacheFile", "=", "getCacheFile", "(", ")", ";", "if", "(", "!", "fi", ".", "renameTo", "(", "cacheFile", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Cannot rename file \\\"\"", "+", "fi", ".", "getAbsolutePath", "(", ")", "+", "\"\\\" to \\\"\"", "+", "cacheFile", ".", "getAbsolutePath", "(", ")", "+", "\"\\\"!\"", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "e", ".", "printStackTrace", "(", ")", ";", "}", "}" ]
Save a copy in the local cache - in case remote source is not available in future.
[ "Save", "a", "copy", "in", "the", "local", "cache", "-", "in", "case", "remote", "source", "is", "not", "available", "in", "future", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/io/impl/UrlResource.java#L214-L240
14,350
kiegroup/drools
drools-core/src/main/java/org/drools/core/io/impl/UrlResource.java
UrlResource.getCleanedUrl
private URL getCleanedUrl(URL originalUrl, String originalPath) { try { return new URL(StringUtils.cleanPath(originalPath)); } catch (MalformedURLException ex) { // Cleaned URL path cannot be converted to URL // -> take original URL. return originalUrl; } }
java
private URL getCleanedUrl(URL originalUrl, String originalPath) { try { return new URL(StringUtils.cleanPath(originalPath)); } catch (MalformedURLException ex) { // Cleaned URL path cannot be converted to URL // -> take original URL. return originalUrl; } }
[ "private", "URL", "getCleanedUrl", "(", "URL", "originalUrl", ",", "String", "originalPath", ")", "{", "try", "{", "return", "new", "URL", "(", "StringUtils", ".", "cleanPath", "(", "originalPath", ")", ")", ";", "}", "catch", "(", "MalformedURLException", "ex", ")", "{", "// Cleaned URL path cannot be converted to URL", "// -> take original URL.", "return", "originalUrl", ";", "}", "}" ]
Determine a cleaned URL for the given original URL. @param originalUrl the original URL @param originalPath the original URL path @return the cleaned URL
[ "Determine", "a", "cleaned", "URL", "for", "the", "given", "original", "URL", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/io/impl/UrlResource.java#L281-L290
14,351
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DroolsParserExceptionFactory.java
DroolsParserExceptionFactory.createTrailingSemicolonException
public DroolsParserException createTrailingSemicolonException( int line, int column, int offset ) { String message = String .format( TRAILING_SEMI_COLON_NOT_ALLOWED_MESSAGE, line, column, formatParserLocation() ); return new DroolsParserException( "ERR 104", message, line, column, offset, null ); }
java
public DroolsParserException createTrailingSemicolonException( int line, int column, int offset ) { String message = String .format( TRAILING_SEMI_COLON_NOT_ALLOWED_MESSAGE, line, column, formatParserLocation() ); return new DroolsParserException( "ERR 104", message, line, column, offset, null ); }
[ "public", "DroolsParserException", "createTrailingSemicolonException", "(", "int", "line", ",", "int", "column", ",", "int", "offset", ")", "{", "String", "message", "=", "String", ".", "format", "(", "TRAILING_SEMI_COLON_NOT_ALLOWED_MESSAGE", ",", "line", ",", "column", ",", "formatParserLocation", "(", ")", ")", ";", "return", "new", "DroolsParserException", "(", "\"ERR 104\"", ",", "message", ",", "line", ",", "column", ",", "offset", ",", "null", ")", ";", "}" ]
This method creates a DroolsParserException for trailing semicolon exception, full of information. @param line line number @param column column position @param offset char offset @return DroolsParserException filled.
[ "This", "method", "creates", "a", "DroolsParserException", "for", "trailing", "semicolon", "exception", "full", "of", "information", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DroolsParserExceptionFactory.java#L94-L110
14,352
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DroolsParserExceptionFactory.java
DroolsParserExceptionFactory.createDroolsException
public DroolsParserException createDroolsException( RecognitionException e ) { List<String> codeAndMessage = createErrorMessage( e ); return new DroolsParserException( codeAndMessage.get( 1 ), codeAndMessage .get( 0 ), e.line, e.charPositionInLine, e.index, e ); }
java
public DroolsParserException createDroolsException( RecognitionException e ) { List<String> codeAndMessage = createErrorMessage( e ); return new DroolsParserException( codeAndMessage.get( 1 ), codeAndMessage .get( 0 ), e.line, e.charPositionInLine, e.index, e ); }
[ "public", "DroolsParserException", "createDroolsException", "(", "RecognitionException", "e", ")", "{", "List", "<", "String", ">", "codeAndMessage", "=", "createErrorMessage", "(", "e", ")", ";", "return", "new", "DroolsParserException", "(", "codeAndMessage", ".", "get", "(", "1", ")", ",", "codeAndMessage", ".", "get", "(", "0", ")", ",", "e", ".", "line", ",", "e", ".", "charPositionInLine", ",", "e", ".", "index", ",", "e", ")", ";", "}" ]
This method creates a DroolsParserException full of information. @param e original exception @return DroolsParserException filled.
[ "This", "method", "creates", "a", "DroolsParserException", "full", "of", "information", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DroolsParserExceptionFactory.java#L119-L128
14,353
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DroolsParserExceptionFactory.java
DroolsParserExceptionFactory.formatParserLocation
private String formatParserLocation() { StringBuilder sb = new StringBuilder(); if ( paraphrases != null ) { for ( Map<DroolsParaphraseTypes, String> map : paraphrases ) { for ( Entry<DroolsParaphraseTypes, String> activeEntry : map.entrySet() ) { if ( activeEntry.getValue().length() == 0 ) { String kStr = getLocationName( activeEntry.getKey() ); if( kStr.length() > 0 ){ sb.append( String.format( PARSER_LOCATION_MESSAGE_PART, kStr ) ); } } else { sb.append( String.format( PARSER_LOCATION_MESSAGE_COMPLETE, getLocationName( activeEntry.getKey() ), activeEntry.getValue() ) ); } } } } return sb.toString(); }
java
private String formatParserLocation() { StringBuilder sb = new StringBuilder(); if ( paraphrases != null ) { for ( Map<DroolsParaphraseTypes, String> map : paraphrases ) { for ( Entry<DroolsParaphraseTypes, String> activeEntry : map.entrySet() ) { if ( activeEntry.getValue().length() == 0 ) { String kStr = getLocationName( activeEntry.getKey() ); if( kStr.length() > 0 ){ sb.append( String.format( PARSER_LOCATION_MESSAGE_PART, kStr ) ); } } else { sb.append( String.format( PARSER_LOCATION_MESSAGE_COMPLETE, getLocationName( activeEntry.getKey() ), activeEntry.getValue() ) ); } } } } return sb.toString(); }
[ "private", "String", "formatParserLocation", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "paraphrases", "!=", "null", ")", "{", "for", "(", "Map", "<", "DroolsParaphraseTypes", ",", "String", ">", "map", ":", "paraphrases", ")", "{", "for", "(", "Entry", "<", "DroolsParaphraseTypes", ",", "String", ">", "activeEntry", ":", "map", ".", "entrySet", "(", ")", ")", "{", "if", "(", "activeEntry", ".", "getValue", "(", ")", ".", "length", "(", ")", "==", "0", ")", "{", "String", "kStr", "=", "getLocationName", "(", "activeEntry", ".", "getKey", "(", ")", ")", ";", "if", "(", "kStr", ".", "length", "(", ")", ">", "0", ")", "{", "sb", ".", "append", "(", "String", ".", "format", "(", "PARSER_LOCATION_MESSAGE_PART", ",", "kStr", ")", ")", ";", "}", "}", "else", "{", "sb", ".", "append", "(", "String", ".", "format", "(", "PARSER_LOCATION_MESSAGE_COMPLETE", ",", "getLocationName", "(", "activeEntry", ".", "getKey", "(", ")", ")", ",", "activeEntry", ".", "getValue", "(", ")", ")", ")", ";", "}", "}", "}", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
This will take Paraphrases stack, and create a sensible location
[ "This", "will", "take", "Paraphrases", "stack", "and", "create", "a", "sensible", "location" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DroolsParserExceptionFactory.java#L291-L310
14,354
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DroolsParserExceptionFactory.java
DroolsParserExceptionFactory.getLocationName
private String getLocationName( DroolsParaphraseTypes type ) { switch ( type ) { case PACKAGE : return "package"; case IMPORT : return "import"; case FUNCTION_IMPORT : return "function import"; case ACCUMULATE_IMPORT : return "accumulate import"; case GLOBAL : return "global"; case FUNCTION : return "function"; case QUERY : return "query"; case TEMPLATE : return "template"; case RULE : return "rule"; case RULE_ATTRIBUTE : return "rule attribute"; case PATTERN : return "pattern"; case EVAL : return "eval"; default : return ""; } }
java
private String getLocationName( DroolsParaphraseTypes type ) { switch ( type ) { case PACKAGE : return "package"; case IMPORT : return "import"; case FUNCTION_IMPORT : return "function import"; case ACCUMULATE_IMPORT : return "accumulate import"; case GLOBAL : return "global"; case FUNCTION : return "function"; case QUERY : return "query"; case TEMPLATE : return "template"; case RULE : return "rule"; case RULE_ATTRIBUTE : return "rule attribute"; case PATTERN : return "pattern"; case EVAL : return "eval"; default : return ""; } }
[ "private", "String", "getLocationName", "(", "DroolsParaphraseTypes", "type", ")", "{", "switch", "(", "type", ")", "{", "case", "PACKAGE", ":", "return", "\"package\"", ";", "case", "IMPORT", ":", "return", "\"import\"", ";", "case", "FUNCTION_IMPORT", ":", "return", "\"function import\"", ";", "case", "ACCUMULATE_IMPORT", ":", "return", "\"accumulate import\"", ";", "case", "GLOBAL", ":", "return", "\"global\"", ";", "case", "FUNCTION", ":", "return", "\"function\"", ";", "case", "QUERY", ":", "return", "\"query\"", ";", "case", "TEMPLATE", ":", "return", "\"template\"", ";", "case", "RULE", ":", "return", "\"rule\"", ";", "case", "RULE_ATTRIBUTE", ":", "return", "\"rule attribute\"", ";", "case", "PATTERN", ":", "return", "\"pattern\"", ";", "case", "EVAL", ":", "return", "\"eval\"", ";", "default", ":", "return", "\"\"", ";", "}", "}" ]
Returns a string based on Paraphrase Type @param type Paraphrase Type @return a string representing the
[ "Returns", "a", "string", "based", "on", "Paraphrase", "Type" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DroolsParserExceptionFactory.java#L319-L348
14,355
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/GuidedDTDRLPersistence.java
GuidedDTDRLPersistence.makeInList
String makeInList(final String cell) { if (cell.startsWith("(")) { return cell; } String result = ""; Iterator<String> iterator = Arrays.asList(ListSplitter.split("\"", true, cell)).iterator(); while (iterator.hasNext()) { final String item = iterator.next(); if (item.startsWith("\"")) { result += item; } else { result += "\"" + item + "\""; } if (iterator.hasNext()) { result += ", "; } } return "(" + result + ")"; }
java
String makeInList(final String cell) { if (cell.startsWith("(")) { return cell; } String result = ""; Iterator<String> iterator = Arrays.asList(ListSplitter.split("\"", true, cell)).iterator(); while (iterator.hasNext()) { final String item = iterator.next(); if (item.startsWith("\"")) { result += item; } else { result += "\"" + item + "\""; } if (iterator.hasNext()) { result += ", "; } } return "(" + result + ")"; }
[ "String", "makeInList", "(", "final", "String", "cell", ")", "{", "if", "(", "cell", ".", "startsWith", "(", "\"(\"", ")", ")", "{", "return", "cell", ";", "}", "String", "result", "=", "\"\"", ";", "Iterator", "<", "String", ">", "iterator", "=", "Arrays", ".", "asList", "(", "ListSplitter", ".", "split", "(", "\"\\\"\"", ",", "true", ",", "cell", ")", ")", ".", "iterator", "(", ")", ";", "while", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "final", "String", "item", "=", "iterator", ".", "next", "(", ")", ";", "if", "(", "item", ".", "startsWith", "(", "\"\\\"\"", ")", ")", "{", "result", "+=", "item", ";", "}", "else", "{", "result", "+=", "\"\\\"\"", "+", "item", "+", "\"\\\"\"", ";", "}", "if", "(", "iterator", ".", "hasNext", "(", ")", ")", "{", "result", "+=", "\", \"", ";", "}", "}", "return", "\"(\"", "+", "result", "+", "\")\"", ";", "}" ]
take a CSV list and turn it into DRL syntax
[ "take", "a", "CSV", "list", "and", "turn", "it", "into", "DRL", "syntax" ]
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/GuidedDTDRLPersistence.java#L772-L796
14,356
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/GuidedDTDRLPersistence.java
GuidedDTDRLPersistence.makeSingleFieldConstraint
private FieldConstraint makeSingleFieldConstraint(ConditionCol52 c, String cell) { SingleFieldConstraint sfc = new SingleFieldConstraint(c.getFactField()); //Condition columns can be defined as having no operator, in which case the operator //is taken from the cell's value. Pretty yucky really if we're to be able to perform //expansion and contraction of decision table columns.... this might have to go. if (no(c.getOperator())) { String[] a = cell.split("\\s"); if (a.length > 1) { //Operator might be 1 part (e.g. "==") or two parts (e.g. "not in") StringBuilder operator = new StringBuilder(a[0]); for (int i = 1; i < a.length - 1; i++) { operator.append(a[i]); } sfc.setOperator(operator.toString()); sfc.setValue(a[a.length - 1]); } else { sfc.setValue(cell); } } else { sfc.setOperator(c.getOperator()); if (OperatorsOracle.operatorRequiresList(c.getOperator())) { sfc.setValue(makeInList(cell)); } else { if (!c.getOperator().equals("== null") && !c.getOperator().equals("!= null")) { sfc.setValue(cell); } } } final int constraintValueType = c.getConstraintValueType(); if ((constraintValueType == BaseSingleFieldConstraint.TYPE_LITERAL || constraintValueType == BaseSingleFieldConstraint.TYPE_RET_VALUE) && c.isBound()) { sfc.setFieldBinding(c.getBinding()); } sfc.setParameters(c.getParameters()); sfc.setConstraintValueType(c.getConstraintValueType()); sfc.setFieldType(c.getFieldType()); return sfc; }
java
private FieldConstraint makeSingleFieldConstraint(ConditionCol52 c, String cell) { SingleFieldConstraint sfc = new SingleFieldConstraint(c.getFactField()); //Condition columns can be defined as having no operator, in which case the operator //is taken from the cell's value. Pretty yucky really if we're to be able to perform //expansion and contraction of decision table columns.... this might have to go. if (no(c.getOperator())) { String[] a = cell.split("\\s"); if (a.length > 1) { //Operator might be 1 part (e.g. "==") or two parts (e.g. "not in") StringBuilder operator = new StringBuilder(a[0]); for (int i = 1; i < a.length - 1; i++) { operator.append(a[i]); } sfc.setOperator(operator.toString()); sfc.setValue(a[a.length - 1]); } else { sfc.setValue(cell); } } else { sfc.setOperator(c.getOperator()); if (OperatorsOracle.operatorRequiresList(c.getOperator())) { sfc.setValue(makeInList(cell)); } else { if (!c.getOperator().equals("== null") && !c.getOperator().equals("!= null")) { sfc.setValue(cell); } } } final int constraintValueType = c.getConstraintValueType(); if ((constraintValueType == BaseSingleFieldConstraint.TYPE_LITERAL || constraintValueType == BaseSingleFieldConstraint.TYPE_RET_VALUE) && c.isBound()) { sfc.setFieldBinding(c.getBinding()); } sfc.setParameters(c.getParameters()); sfc.setConstraintValueType(c.getConstraintValueType()); sfc.setFieldType(c.getFieldType()); return sfc; }
[ "private", "FieldConstraint", "makeSingleFieldConstraint", "(", "ConditionCol52", "c", ",", "String", "cell", ")", "{", "SingleFieldConstraint", "sfc", "=", "new", "SingleFieldConstraint", "(", "c", ".", "getFactField", "(", ")", ")", ";", "//Condition columns can be defined as having no operator, in which case the operator", "//is taken from the cell's value. Pretty yucky really if we're to be able to perform", "//expansion and contraction of decision table columns.... this might have to go.", "if", "(", "no", "(", "c", ".", "getOperator", "(", ")", ")", ")", "{", "String", "[", "]", "a", "=", "cell", ".", "split", "(", "\"\\\\s\"", ")", ";", "if", "(", "a", ".", "length", ">", "1", ")", "{", "//Operator might be 1 part (e.g. \"==\") or two parts (e.g. \"not in\")", "StringBuilder", "operator", "=", "new", "StringBuilder", "(", "a", "[", "0", "]", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "a", ".", "length", "-", "1", ";", "i", "++", ")", "{", "operator", ".", "append", "(", "a", "[", "i", "]", ")", ";", "}", "sfc", ".", "setOperator", "(", "operator", ".", "toString", "(", ")", ")", ";", "sfc", ".", "setValue", "(", "a", "[", "a", ".", "length", "-", "1", "]", ")", ";", "}", "else", "{", "sfc", ".", "setValue", "(", "cell", ")", ";", "}", "}", "else", "{", "sfc", ".", "setOperator", "(", "c", ".", "getOperator", "(", ")", ")", ";", "if", "(", "OperatorsOracle", ".", "operatorRequiresList", "(", "c", ".", "getOperator", "(", ")", ")", ")", "{", "sfc", ".", "setValue", "(", "makeInList", "(", "cell", ")", ")", ";", "}", "else", "{", "if", "(", "!", "c", ".", "getOperator", "(", ")", ".", "equals", "(", "\"== null\"", ")", "&&", "!", "c", ".", "getOperator", "(", ")", ".", "equals", "(", "\"!= null\"", ")", ")", "{", "sfc", ".", "setValue", "(", "cell", ")", ";", "}", "}", "}", "final", "int", "constraintValueType", "=", "c", ".", "getConstraintValueType", "(", ")", ";", "if", "(", "(", "constraintValueType", "==", "BaseSingleFieldConstraint", ".", "TYPE_LITERAL", "||", "constraintValueType", "==", "BaseSingleFieldConstraint", ".", "TYPE_RET_VALUE", ")", "&&", "c", ".", "isBound", "(", ")", ")", "{", "sfc", ".", "setFieldBinding", "(", "c", ".", "getBinding", "(", ")", ")", ";", "}", "sfc", ".", "setParameters", "(", "c", ".", "getParameters", "(", ")", ")", ";", "sfc", ".", "setConstraintValueType", "(", "c", ".", "getConstraintValueType", "(", ")", ")", ";", "sfc", ".", "setFieldType", "(", "c", ".", "getFieldType", "(", ")", ")", ";", "return", "sfc", ";", "}" ]
Build a normal SingleFieldConstraint for a non-otherwise cell value
[ "Build", "a", "normal", "SingleFieldConstraint", "for", "a", "non", "-", "otherwise", "cell", "value" ]
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/GuidedDTDRLPersistence.java#L954-L995
14,357
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/backend/GuidedDTDRLPersistence.java
GuidedDTDRLPersistence.makeSingleFieldConstraint
private FieldConstraint makeSingleFieldConstraint(ConditionCol52 c, List<BaseColumn> allColumns, List<List<DTCellValue52>> data) { GuidedDTDRLOtherwiseHelper.OtherwiseBuilder builder = GuidedDTDRLOtherwiseHelper.getBuilder(c); return builder.makeFieldConstraint(c, allColumns, data); }
java
private FieldConstraint makeSingleFieldConstraint(ConditionCol52 c, List<BaseColumn> allColumns, List<List<DTCellValue52>> data) { GuidedDTDRLOtherwiseHelper.OtherwiseBuilder builder = GuidedDTDRLOtherwiseHelper.getBuilder(c); return builder.makeFieldConstraint(c, allColumns, data); }
[ "private", "FieldConstraint", "makeSingleFieldConstraint", "(", "ConditionCol52", "c", ",", "List", "<", "BaseColumn", ">", "allColumns", ",", "List", "<", "List", "<", "DTCellValue52", ">", ">", "data", ")", "{", "GuidedDTDRLOtherwiseHelper", ".", "OtherwiseBuilder", "builder", "=", "GuidedDTDRLOtherwiseHelper", ".", "getBuilder", "(", "c", ")", ";", "return", "builder", ".", "makeFieldConstraint", "(", "c", ",", "allColumns", ",", "data", ")", ";", "}" ]
Build a SingleFieldConstraint for an otherwise cell value
[ "Build", "a", "SingleFieldConstraint", "for", "an", "otherwise", "cell", "value" ]
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/GuidedDTDRLPersistence.java#L998-L1006
14,358
kiegroup/drools
kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/model/AbstractModel.java
AbstractModel.generateModelId
private String generateModelId() { String mt = this.modelType.toString(); StringBuilder mid = new StringBuilder(mt); Integer lastId = null; if (generatedModelIds.containsKey(mt)) { lastId = generatedModelIds.get(mt); } else { lastId = new Integer(-1); } lastId++; mid.append(lastId); generatedModelIds.put(mt, lastId); return mid.toString(); }
java
private String generateModelId() { String mt = this.modelType.toString(); StringBuilder mid = new StringBuilder(mt); Integer lastId = null; if (generatedModelIds.containsKey(mt)) { lastId = generatedModelIds.get(mt); } else { lastId = new Integer(-1); } lastId++; mid.append(lastId); generatedModelIds.put(mt, lastId); return mid.toString(); }
[ "private", "String", "generateModelId", "(", ")", "{", "String", "mt", "=", "this", ".", "modelType", ".", "toString", "(", ")", ";", "StringBuilder", "mid", "=", "new", "StringBuilder", "(", "mt", ")", ";", "Integer", "lastId", "=", "null", ";", "if", "(", "generatedModelIds", ".", "containsKey", "(", "mt", ")", ")", "{", "lastId", "=", "generatedModelIds", ".", "get", "(", "mt", ")", ";", "}", "else", "{", "lastId", "=", "new", "Integer", "(", "-", "1", ")", ";", "}", "lastId", "++", ";", "mid", ".", "append", "(", "lastId", ")", ";", "generatedModelIds", ".", "put", "(", "mt", ",", "lastId", ")", ";", "return", "mid", ".", "toString", "(", ")", ";", "}" ]
A method that tries to generate a model identifier for those times when models arrive without an identifier @return The String value that is to be used to identify the model
[ "A", "method", "that", "tries", "to", "generate", "a", "model", "identifier", "for", "those", "times", "when", "models", "arrive", "without", "an", "identifier" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-pmml/src/main/java/org/kie/pmml/pmml_4_2/model/AbstractModel.java#L552-L565
14,359
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecisionTableFunction.java
DecisionTableFunction.toDecisionRule
private static DTDecisionRule toDecisionRule(EvaluationContext mainCtx, FEEL embeddedFEEL, int index, List<?> rule, int inputSize) { // TODO should be check indeed block of inputSize n inputs, followed by block of outputs. DTDecisionRule dr = new DTDecisionRule( index ); for ( int i = 0; i < rule.size(); i++ ) { Object o = rule.get( i ); if ( i < inputSize ) { dr.getInputEntry().add( toUnaryTest( mainCtx, o ) ); } else { FEELEventListener ruleListener = event -> mainCtx.notifyEvt( () -> new FEELEventBase(event.getSeverity(), Msg.createMessage(Msg.ERROR_COMPILE_EXPR_DT_FUNCTION_RULE_IDX, index+1, event.getMessage()), event.getSourceException())); embeddedFEEL.addListener(ruleListener); CompiledExpression compiledExpression = embeddedFEEL.compile((String) o, embeddedFEEL.newCompilerContext()); dr.getOutputEntry().add( compiledExpression ); embeddedFEEL.removeListener(ruleListener); } } return dr; }
java
private static DTDecisionRule toDecisionRule(EvaluationContext mainCtx, FEEL embeddedFEEL, int index, List<?> rule, int inputSize) { // TODO should be check indeed block of inputSize n inputs, followed by block of outputs. DTDecisionRule dr = new DTDecisionRule( index ); for ( int i = 0; i < rule.size(); i++ ) { Object o = rule.get( i ); if ( i < inputSize ) { dr.getInputEntry().add( toUnaryTest( mainCtx, o ) ); } else { FEELEventListener ruleListener = event -> mainCtx.notifyEvt( () -> new FEELEventBase(event.getSeverity(), Msg.createMessage(Msg.ERROR_COMPILE_EXPR_DT_FUNCTION_RULE_IDX, index+1, event.getMessage()), event.getSourceException())); embeddedFEEL.addListener(ruleListener); CompiledExpression compiledExpression = embeddedFEEL.compile((String) o, embeddedFEEL.newCompilerContext()); dr.getOutputEntry().add( compiledExpression ); embeddedFEEL.removeListener(ruleListener); } } return dr; }
[ "private", "static", "DTDecisionRule", "toDecisionRule", "(", "EvaluationContext", "mainCtx", ",", "FEEL", "embeddedFEEL", ",", "int", "index", ",", "List", "<", "?", ">", "rule", ",", "int", "inputSize", ")", "{", "// TODO should be check indeed block of inputSize n inputs, followed by block of outputs.", "DTDecisionRule", "dr", "=", "new", "DTDecisionRule", "(", "index", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "rule", ".", "size", "(", ")", ";", "i", "++", ")", "{", "Object", "o", "=", "rule", ".", "get", "(", "i", ")", ";", "if", "(", "i", "<", "inputSize", ")", "{", "dr", ".", "getInputEntry", "(", ")", ".", "add", "(", "toUnaryTest", "(", "mainCtx", ",", "o", ")", ")", ";", "}", "else", "{", "FEELEventListener", "ruleListener", "=", "event", "->", "mainCtx", ".", "notifyEvt", "(", "(", ")", "->", "new", "FEELEventBase", "(", "event", ".", "getSeverity", "(", ")", ",", "Msg", ".", "createMessage", "(", "Msg", ".", "ERROR_COMPILE_EXPR_DT_FUNCTION_RULE_IDX", ",", "index", "+", "1", ",", "event", ".", "getMessage", "(", ")", ")", ",", "event", ".", "getSourceException", "(", ")", ")", ")", ";", "embeddedFEEL", ".", "addListener", "(", "ruleListener", ")", ";", "CompiledExpression", "compiledExpression", "=", "embeddedFEEL", ".", "compile", "(", "(", "String", ")", "o", ",", "embeddedFEEL", ".", "newCompilerContext", "(", ")", ")", ";", "dr", ".", "getOutputEntry", "(", ")", ".", "add", "(", "compiledExpression", ")", ";", "embeddedFEEL", ".", "removeListener", "(", "ruleListener", ")", ";", "}", "}", "return", "dr", ";", "}" ]
Convert row to DTDecisionRule @param mainCtx the main context is used to identify the hosted FEELEventManager @param embeddedFEEL a possibly cached embedded FEEL to compile the output expression, error will be reported up to the mainCtx @param index @param rule @param inputSize @return
[ "Convert", "row", "to", "DTDecisionRule" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/runtime/functions/DecisionTableFunction.java#L149-L167
14,360
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/GroupElement.java
GroupElement.addChild
public void addChild(final RuleConditionElement child) { if ( (this.isNot() || this.isExists()) && (this.children.size() > 0) ) { throw new RuntimeException( this.type.toString() + " can have only a single child element. Either a single Pattern or another CE." ); } this.children.add( child ); }
java
public void addChild(final RuleConditionElement child) { if ( (this.isNot() || this.isExists()) && (this.children.size() > 0) ) { throw new RuntimeException( this.type.toString() + " can have only a single child element. Either a single Pattern or another CE." ); } this.children.add( child ); }
[ "public", "void", "addChild", "(", "final", "RuleConditionElement", "child", ")", "{", "if", "(", "(", "this", ".", "isNot", "(", ")", "||", "this", ".", "isExists", "(", ")", ")", "&&", "(", "this", ".", "children", ".", "size", "(", ")", ">", "0", ")", ")", "{", "throw", "new", "RuntimeException", "(", "this", ".", "type", ".", "toString", "(", ")", "+", "\" can have only a single child element. Either a single Pattern or another CE.\"", ")", ";", "}", "this", ".", "children", ".", "add", "(", "child", ")", ";", "}" ]
Adds a child to the current GroupElement. Restrictions are: NOT/EXISTS: can have only one child, either a single Pattern or another CE
[ "Adds", "a", "child", "to", "the", "current", "GroupElement", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/GroupElement.java#L78-L83
14,361
kiegroup/drools
drools-core/src/main/java/org/drools/core/time/TimeUtils.java
TimeUtils.calculateTemporalDistance
public static Interval[][] calculateTemporalDistance( Interval[][] constraintMatrix ) { Interval[][] result = new Interval[constraintMatrix.length][]; for( int i = 0; i < result.length; i++ ) { result[i] = new Interval[constraintMatrix[i].length]; for( int j = 0; j < result[i].length; j++ ) { result[i][j] = constraintMatrix[i][j].clone(); } } for( int k = 0; k < result.length; k++ ) { for( int i = 0; i < result.length; i++ ) { for( int j = 0; j < result.length; j++ ) { Interval interval = result[i][k].clone(); interval.add( result[k][j] ); result[i][j].intersect( interval); } } } return result; }
java
public static Interval[][] calculateTemporalDistance( Interval[][] constraintMatrix ) { Interval[][] result = new Interval[constraintMatrix.length][]; for( int i = 0; i < result.length; i++ ) { result[i] = new Interval[constraintMatrix[i].length]; for( int j = 0; j < result[i].length; j++ ) { result[i][j] = constraintMatrix[i][j].clone(); } } for( int k = 0; k < result.length; k++ ) { for( int i = 0; i < result.length; i++ ) { for( int j = 0; j < result.length; j++ ) { Interval interval = result[i][k].clone(); interval.add( result[k][j] ); result[i][j].intersect( interval); } } } return result; }
[ "public", "static", "Interval", "[", "]", "[", "]", "calculateTemporalDistance", "(", "Interval", "[", "]", "[", "]", "constraintMatrix", ")", "{", "Interval", "[", "]", "[", "]", "result", "=", "new", "Interval", "[", "constraintMatrix", ".", "length", "]", "[", "", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "length", ";", "i", "++", ")", "{", "result", "[", "i", "]", "=", "new", "Interval", "[", "constraintMatrix", "[", "i", "]", ".", "length", "]", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "result", "[", "i", "]", ".", "length", ";", "j", "++", ")", "{", "result", "[", "i", "]", "[", "j", "]", "=", "constraintMatrix", "[", "i", "]", "[", "j", "]", ".", "clone", "(", ")", ";", "}", "}", "for", "(", "int", "k", "=", "0", ";", "k", "<", "result", ".", "length", ";", "k", "++", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "result", ".", "length", ";", "i", "++", ")", "{", "for", "(", "int", "j", "=", "0", ";", "j", "<", "result", ".", "length", ";", "j", "++", ")", "{", "Interval", "interval", "=", "result", "[", "i", "]", "[", "k", "]", ".", "clone", "(", ")", ";", "interval", ".", "add", "(", "result", "[", "k", "]", "[", "j", "]", ")", ";", "result", "[", "i", "]", "[", "j", "]", ".", "intersect", "(", "interval", ")", ";", "}", "}", "}", "return", "result", ";", "}" ]
This method calculates the transitive closure of the given adjacency matrix in order to find the temporal distance between each event represented in the adjacency matrix. For more information on the calculation of the temporal distance, please refer to the paper: "Discarding Unused Temporal Information in a Production System", by Dan Teodosiu and Gunter Pollak. This method also uses an adaptation of the Floyd-Warshall algorithm to calculate the transitive closure of the interval matrix. More information can be found here: http://en.wikipedia.org/wiki/Floyd-Warshall_algorithm The adaptation of the algorithm follows the definition of the path addition and path intersection operations as defined in the paper previously mentioned. The algorithm runs in O(n^3). @param constraintMatrix the starting adjacency matrix @return the resulting temporal distance matrix
[ "This", "method", "calculates", "the", "transitive", "closure", "of", "the", "given", "adjacency", "matrix", "in", "order", "to", "find", "the", "temporal", "distance", "between", "each", "event", "represented", "in", "the", "adjacency", "matrix", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/time/TimeUtils.java#L80-L98
14,362
kiegroup/drools
drools-core/src/main/java/org/drools/core/time/TimeUtils.java
TimeUtils.parseTimeString
public static long parseTimeString( String time ) { String trimmed = time.trim(); long result = 0; if( trimmed.length() > 0 ) { Matcher mat = SIMPLE.matcher( trimmed ); if ( mat.matches() ) { int days = (mat.group( SIM_DAY ) != null) ? Integer.parseInt( mat.group( SIM_DAY ) ) : 0; int hours = (mat.group( SIM_HOU ) != null) ? Integer.parseInt( mat.group( SIM_HOU ) ) : 0; int min = (mat.group( SIM_MIN ) != null) ? Integer.parseInt( mat.group( SIM_MIN ) ) : 0; int sec = (mat.group( SIM_SEC ) != null) ? Integer.parseInt( mat.group( SIM_SEC ) ) : 0; int ms = (mat.group( SIM_MS ) != null) ? Integer.parseInt( mat.group( SIM_MS ) ) : 0; long r = days * DAY_MS + hours * HOU_MS + min * MIN_MS + sec * SEC_MS + ms; if( mat.group(SIM_SGN) != null && mat.group( SIM_SGN ).equals( "-" ) ) { r = -r; } result = r; } else if( "*".equals( trimmed ) || "+*".equals( trimmed ) ) { // positive infinity result = Long.MAX_VALUE; } else if( "-*".equals( trimmed ) ) { // negative infinity result = Long.MIN_VALUE; } else { throw new RuntimeException( "Error parsing time string: [ " + time + " ]" ); } } return result; }
java
public static long parseTimeString( String time ) { String trimmed = time.trim(); long result = 0; if( trimmed.length() > 0 ) { Matcher mat = SIMPLE.matcher( trimmed ); if ( mat.matches() ) { int days = (mat.group( SIM_DAY ) != null) ? Integer.parseInt( mat.group( SIM_DAY ) ) : 0; int hours = (mat.group( SIM_HOU ) != null) ? Integer.parseInt( mat.group( SIM_HOU ) ) : 0; int min = (mat.group( SIM_MIN ) != null) ? Integer.parseInt( mat.group( SIM_MIN ) ) : 0; int sec = (mat.group( SIM_SEC ) != null) ? Integer.parseInt( mat.group( SIM_SEC ) ) : 0; int ms = (mat.group( SIM_MS ) != null) ? Integer.parseInt( mat.group( SIM_MS ) ) : 0; long r = days * DAY_MS + hours * HOU_MS + min * MIN_MS + sec * SEC_MS + ms; if( mat.group(SIM_SGN) != null && mat.group( SIM_SGN ).equals( "-" ) ) { r = -r; } result = r; } else if( "*".equals( trimmed ) || "+*".equals( trimmed ) ) { // positive infinity result = Long.MAX_VALUE; } else if( "-*".equals( trimmed ) ) { // negative infinity result = Long.MIN_VALUE; } else { throw new RuntimeException( "Error parsing time string: [ " + time + " ]" ); } } return result; }
[ "public", "static", "long", "parseTimeString", "(", "String", "time", ")", "{", "String", "trimmed", "=", "time", ".", "trim", "(", ")", ";", "long", "result", "=", "0", ";", "if", "(", "trimmed", ".", "length", "(", ")", ">", "0", ")", "{", "Matcher", "mat", "=", "SIMPLE", ".", "matcher", "(", "trimmed", ")", ";", "if", "(", "mat", ".", "matches", "(", ")", ")", "{", "int", "days", "=", "(", "mat", ".", "group", "(", "SIM_DAY", ")", "!=", "null", ")", "?", "Integer", ".", "parseInt", "(", "mat", ".", "group", "(", "SIM_DAY", ")", ")", ":", "0", ";", "int", "hours", "=", "(", "mat", ".", "group", "(", "SIM_HOU", ")", "!=", "null", ")", "?", "Integer", ".", "parseInt", "(", "mat", ".", "group", "(", "SIM_HOU", ")", ")", ":", "0", ";", "int", "min", "=", "(", "mat", ".", "group", "(", "SIM_MIN", ")", "!=", "null", ")", "?", "Integer", ".", "parseInt", "(", "mat", ".", "group", "(", "SIM_MIN", ")", ")", ":", "0", ";", "int", "sec", "=", "(", "mat", ".", "group", "(", "SIM_SEC", ")", "!=", "null", ")", "?", "Integer", ".", "parseInt", "(", "mat", ".", "group", "(", "SIM_SEC", ")", ")", ":", "0", ";", "int", "ms", "=", "(", "mat", ".", "group", "(", "SIM_MS", ")", "!=", "null", ")", "?", "Integer", ".", "parseInt", "(", "mat", ".", "group", "(", "SIM_MS", ")", ")", ":", "0", ";", "long", "r", "=", "days", "*", "DAY_MS", "+", "hours", "*", "HOU_MS", "+", "min", "*", "MIN_MS", "+", "sec", "*", "SEC_MS", "+", "ms", ";", "if", "(", "mat", ".", "group", "(", "SIM_SGN", ")", "!=", "null", "&&", "mat", ".", "group", "(", "SIM_SGN", ")", ".", "equals", "(", "\"-\"", ")", ")", "{", "r", "=", "-", "r", ";", "}", "result", "=", "r", ";", "}", "else", "if", "(", "\"*\"", ".", "equals", "(", "trimmed", ")", "||", "\"+*\"", ".", "equals", "(", "trimmed", ")", ")", "{", "// positive infinity", "result", "=", "Long", ".", "MAX_VALUE", ";", "}", "else", "if", "(", "\"-*\"", ".", "equals", "(", "trimmed", ")", ")", "{", "// negative infinity", "result", "=", "Long", ".", "MIN_VALUE", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Error parsing time string: [ \"", "+", "time", "+", "\" ]\"", ")", ";", "}", "}", "return", "result", ";", "}" ]
Parses the given time String and returns the corresponding time in milliseconds @param time @return @throws NullPointerException if time is null
[ "Parses", "the", "given", "time", "String", "and", "returns", "the", "corresponding", "time", "in", "milliseconds" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/time/TimeUtils.java#L109-L136
14,363
kiegroup/drools
drools-beliefs/src/main/java/org/drools/beliefs/bayes/BayesInstance.java
BayesInstance.passMessage
public void passMessage( JunctionTreeClique sourceClique, JunctionTreeSeparator sep, JunctionTreeClique targetClique) { double[] sepPots = separatorStates[sep.getId()].getPotentials(); double[] oldSepPots = Arrays.copyOf(sepPots, sepPots.length); BayesVariable[] sepVars = sep.getValues().toArray(new BayesVariable[sep.getValues().size()]); if ( passMessageListener != null ) { passMessageListener.beforeProjectAndAbsorb(sourceClique, sep, targetClique, oldSepPots); } project(sepVars, cliqueStates[sourceClique.getId()], separatorStates[sep.getId()]); if ( passMessageListener != null ) { passMessageListener.afterProject(sourceClique, sep, targetClique, oldSepPots); } absorb(sepVars, cliqueStates[targetClique.getId()], separatorStates[sep.getId()], oldSepPots); if ( passMessageListener != null ) { passMessageListener.afterAbsorb(sourceClique, sep, targetClique, oldSepPots); } }
java
public void passMessage( JunctionTreeClique sourceClique, JunctionTreeSeparator sep, JunctionTreeClique targetClique) { double[] sepPots = separatorStates[sep.getId()].getPotentials(); double[] oldSepPots = Arrays.copyOf(sepPots, sepPots.length); BayesVariable[] sepVars = sep.getValues().toArray(new BayesVariable[sep.getValues().size()]); if ( passMessageListener != null ) { passMessageListener.beforeProjectAndAbsorb(sourceClique, sep, targetClique, oldSepPots); } project(sepVars, cliqueStates[sourceClique.getId()], separatorStates[sep.getId()]); if ( passMessageListener != null ) { passMessageListener.afterProject(sourceClique, sep, targetClique, oldSepPots); } absorb(sepVars, cliqueStates[targetClique.getId()], separatorStates[sep.getId()], oldSepPots); if ( passMessageListener != null ) { passMessageListener.afterAbsorb(sourceClique, sep, targetClique, oldSepPots); } }
[ "public", "void", "passMessage", "(", "JunctionTreeClique", "sourceClique", ",", "JunctionTreeSeparator", "sep", ",", "JunctionTreeClique", "targetClique", ")", "{", "double", "[", "]", "sepPots", "=", "separatorStates", "[", "sep", ".", "getId", "(", ")", "]", ".", "getPotentials", "(", ")", ";", "double", "[", "]", "oldSepPots", "=", "Arrays", ".", "copyOf", "(", "sepPots", ",", "sepPots", ".", "length", ")", ";", "BayesVariable", "[", "]", "sepVars", "=", "sep", ".", "getValues", "(", ")", ".", "toArray", "(", "new", "BayesVariable", "[", "sep", ".", "getValues", "(", ")", ".", "size", "(", ")", "]", ")", ";", "if", "(", "passMessageListener", "!=", "null", ")", "{", "passMessageListener", ".", "beforeProjectAndAbsorb", "(", "sourceClique", ",", "sep", ",", "targetClique", ",", "oldSepPots", ")", ";", "}", "project", "(", "sepVars", ",", "cliqueStates", "[", "sourceClique", ".", "getId", "(", ")", "]", ",", "separatorStates", "[", "sep", ".", "getId", "(", ")", "]", ")", ";", "if", "(", "passMessageListener", "!=", "null", ")", "{", "passMessageListener", ".", "afterProject", "(", "sourceClique", ",", "sep", ",", "targetClique", ",", "oldSepPots", ")", ";", "}", "absorb", "(", "sepVars", ",", "cliqueStates", "[", "targetClique", ".", "getId", "(", ")", "]", ",", "separatorStates", "[", "sep", ".", "getId", "(", ")", "]", ",", "oldSepPots", ")", ";", "if", "(", "passMessageListener", "!=", "null", ")", "{", "passMessageListener", ".", "afterAbsorb", "(", "sourceClique", ",", "sep", ",", "targetClique", ",", "oldSepPots", ")", ";", "}", "}" ]
Passes a message from node1 to node2. node1 projects its trgPotentials into the separator. node2 then absorbs those trgPotentials from the separator. @param sourceClique @param sep @param targetClique
[ "Passes", "a", "message", "from", "node1", "to", "node2", ".", "node1", "projects", "its", "trgPotentials", "into", "the", "separator", ".", "node2", "then", "absorbs", "those", "trgPotentials", "from", "the", "separator", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-beliefs/src/main/java/org/drools/beliefs/bayes/BayesInstance.java#L368-L387
14,364
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/impl/JavaBackedType.java
JavaBackedType.methodToCustomProperty
private static Optional<String> methodToCustomProperty(Method m) { return Optional.ofNullable(m.getAnnotation(FEELProperty.class)).map(a->a.value()); }
java
private static Optional<String> methodToCustomProperty(Method m) { return Optional.ofNullable(m.getAnnotation(FEELProperty.class)).map(a->a.value()); }
[ "private", "static", "Optional", "<", "String", ">", "methodToCustomProperty", "(", "Method", "m", ")", "{", "return", "Optional", ".", "ofNullable", "(", "m", ".", "getAnnotation", "(", "FEELProperty", ".", "class", ")", ")", ".", "map", "(", "a", "->", "a", ".", "value", "(", ")", ")", ";", "}" ]
If method m is annotated with FEELProperty, will return FEELProperty.value, otherwise empty.
[ "If", "method", "m", "is", "annotated", "with", "FEELProperty", "will", "return", "FEELProperty", ".", "value", "otherwise", "empty", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/impl/JavaBackedType.java#L42-L44
14,365
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/impl/JavaBackedType.java
JavaBackedType.of
public static Type of(Class<?> clazz) { return Optional.ofNullable( (Type) cache.computeIfAbsent( clazz, JavaBackedType::createIfAnnotated ) ).orElse( BuiltInType.UNKNOWN ); }
java
public static Type of(Class<?> clazz) { return Optional.ofNullable( (Type) cache.computeIfAbsent( clazz, JavaBackedType::createIfAnnotated ) ).orElse( BuiltInType.UNKNOWN ); }
[ "public", "static", "Type", "of", "(", "Class", "<", "?", ">", "clazz", ")", "{", "return", "Optional", ".", "ofNullable", "(", "(", "Type", ")", "cache", ".", "computeIfAbsent", "(", "clazz", ",", "JavaBackedType", "::", "createIfAnnotated", ")", ")", ".", "orElse", "(", "BuiltInType", ".", "UNKNOWN", ")", ";", "}" ]
If clazz can be represented as a JavaBackedType, returns a JavaBackedType for representing clazz. If clazz can not be represented as a JavaBackedType, returns BuiltInType.UNKNOWN. This method performs memoization when necessary. @param clazz the class to be represented as JavaBackedType @return JavaBackedType representing clazz or BuiltInType.UNKNOWN
[ "If", "clazz", "can", "be", "represented", "as", "a", "JavaBackedType", "returns", "a", "JavaBackedType", "for", "representing", "clazz", ".", "If", "clazz", "can", "not", "be", "represented", "as", "a", "JavaBackedType", "returns", "BuiltInType", ".", "UNKNOWN", ".", "This", "method", "performs", "memoization", "when", "necessary", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/impl/JavaBackedType.java#L53-L55
14,366
kiegroup/drools
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/impl/JavaBackedType.java
JavaBackedType.createIfAnnotated
private static JavaBackedType createIfAnnotated(Class<?> clazz) { if (clazz.isAnnotationPresent(FEELType.class) || Stream.of(clazz.getMethods()).anyMatch(m->m.getAnnotation(FEELProperty.class)!=null)) { return new JavaBackedType(clazz) ; } return null; }
java
private static JavaBackedType createIfAnnotated(Class<?> clazz) { if (clazz.isAnnotationPresent(FEELType.class) || Stream.of(clazz.getMethods()).anyMatch(m->m.getAnnotation(FEELProperty.class)!=null)) { return new JavaBackedType(clazz) ; } return null; }
[ "private", "static", "JavaBackedType", "createIfAnnotated", "(", "Class", "<", "?", ">", "clazz", ")", "{", "if", "(", "clazz", ".", "isAnnotationPresent", "(", "FEELType", ".", "class", ")", "||", "Stream", ".", "of", "(", "clazz", ".", "getMethods", "(", ")", ")", ".", "anyMatch", "(", "m", "->", "m", ".", "getAnnotation", "(", "FEELProperty", ".", "class", ")", "!=", "null", ")", ")", "{", "return", "new", "JavaBackedType", "(", "clazz", ")", ";", "}", "return", "null", ";", "}" ]
For internal use, returns a new JavaBackedType if clazz can be represented as such, returns null otherwise.
[ "For", "internal", "use", "returns", "a", "new", "JavaBackedType", "if", "clazz", "can", "be", "represented", "as", "such", "returns", "null", "otherwise", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/lang/impl/JavaBackedType.java#L60-L65
14,367
kiegroup/drools
drools-core/src/main/java/org/drools/core/metadata/ModifyLiteral.java
ModifyLiteral.getInverse
public <S,T> Modify<S> getInverse( T value ) { ModifyLiteral inverse = new InverseModifyLiteral( value ); ModifyTaskLiteral task = this.task; do { if ( isAffected( value, task.value ) ) { MetaProperty inv = ( (InvertibleMetaProperty) task.getProperty() ).getInverse(); inverse.addTask( inv, inv.isManyValued() ? Collections.singleton( getTarget() ) : getTarget(), task.mode == Lit.REMOVE ? Lit.REMOVE : Lit.ADD ) ; } task = task.nextTask; } while ( task != null ); return inverse; }
java
public <S,T> Modify<S> getInverse( T value ) { ModifyLiteral inverse = new InverseModifyLiteral( value ); ModifyTaskLiteral task = this.task; do { if ( isAffected( value, task.value ) ) { MetaProperty inv = ( (InvertibleMetaProperty) task.getProperty() ).getInverse(); inverse.addTask( inv, inv.isManyValued() ? Collections.singleton( getTarget() ) : getTarget(), task.mode == Lit.REMOVE ? Lit.REMOVE : Lit.ADD ) ; } task = task.nextTask; } while ( task != null ); return inverse; }
[ "public", "<", "S", ",", "T", ">", "Modify", "<", "S", ">", "getInverse", "(", "T", "value", ")", "{", "ModifyLiteral", "inverse", "=", "new", "InverseModifyLiteral", "(", "value", ")", ";", "ModifyTaskLiteral", "task", "=", "this", ".", "task", ";", "do", "{", "if", "(", "isAffected", "(", "value", ",", "task", ".", "value", ")", ")", "{", "MetaProperty", "inv", "=", "(", "(", "InvertibleMetaProperty", ")", "task", ".", "getProperty", "(", ")", ")", ".", "getInverse", "(", ")", ";", "inverse", ".", "addTask", "(", "inv", ",", "inv", ".", "isManyValued", "(", ")", "?", "Collections", ".", "singleton", "(", "getTarget", "(", ")", ")", ":", "getTarget", "(", ")", ",", "task", ".", "mode", "==", "Lit", ".", "REMOVE", "?", "Lit", ".", "REMOVE", ":", "Lit", ".", "ADD", ")", ";", "}", "task", "=", "task", ".", "nextTask", ";", "}", "while", "(", "task", "!=", "null", ")", ";", "return", "inverse", ";", "}" ]
not used for execution but for provenance logging only
[ "not", "used", "for", "execution", "but", "for", "provenance", "logging", "only" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/metadata/ModifyLiteral.java#L204-L218
14,368
kiegroup/drools
drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserBase.java
GeneratedDrlConstraintParserBase.add
<T extends Node> NodeList<T> add(NodeList<T> list, T obj) { if (list == null) { list = new NodeList<>(); } list.add(obj); return list; }
java
<T extends Node> NodeList<T> add(NodeList<T> list, T obj) { if (list == null) { list = new NodeList<>(); } list.add(obj); return list; }
[ "<", "T", "extends", "Node", ">", "NodeList", "<", "T", ">", "add", "(", "NodeList", "<", "T", ">", "list", ",", "T", "obj", ")", "{", "if", "(", "list", "==", "null", ")", "{", "list", "=", "new", "NodeList", "<>", "(", ")", ";", "}", "list", ".", "add", "(", "obj", ")", ";", "return", "list", ";", "}" ]
Add obj to list and return it. Create a new list if list is null
[ "Add", "obj", "to", "list", "and", "return", "it", ".", "Create", "a", "new", "list", "if", "list", "is", "null" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserBase.java#L218-L224
14,369
kiegroup/drools
drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserBase.java
GeneratedDrlConstraintParserBase.add
<T> List<T> add(List<T> list, T obj) { if (list == null) { list = new LinkedList<>(); } list.add(obj); return list; }
java
<T> List<T> add(List<T> list, T obj) { if (list == null) { list = new LinkedList<>(); } list.add(obj); return list; }
[ "<", "T", ">", "List", "<", "T", ">", "add", "(", "List", "<", "T", ">", "list", ",", "T", "obj", ")", "{", "if", "(", "list", "==", "null", ")", "{", "list", "=", "new", "LinkedList", "<>", "(", ")", ";", "}", "list", ".", "add", "(", "obj", ")", ";", "return", "list", ";", "}" ]
Add obj to list
[ "Add", "obj", "to", "list" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserBase.java#L229-L235
14,370
kiegroup/drools
drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserBase.java
GeneratedDrlConstraintParserBase.juggleArrayCreation
ArrayCreationExpr juggleArrayCreation(TokenRange range, List<TokenRange> levelRanges, Type type, NodeList<Expression> dimensions, List<NodeList<AnnotationExpr>> arrayAnnotations, ArrayInitializerExpr arrayInitializerExpr) { NodeList<ArrayCreationLevel> levels = new NodeList<>(); for (int i = 0; i < arrayAnnotations.size(); i++) { levels.add(new ArrayCreationLevel(levelRanges.get(i), dimensions.get(i), arrayAnnotations.get(i))); } return new ArrayCreationExpr(range, type, levels, arrayInitializerExpr); }
java
ArrayCreationExpr juggleArrayCreation(TokenRange range, List<TokenRange> levelRanges, Type type, NodeList<Expression> dimensions, List<NodeList<AnnotationExpr>> arrayAnnotations, ArrayInitializerExpr arrayInitializerExpr) { NodeList<ArrayCreationLevel> levels = new NodeList<>(); for (int i = 0; i < arrayAnnotations.size(); i++) { levels.add(new ArrayCreationLevel(levelRanges.get(i), dimensions.get(i), arrayAnnotations.get(i))); } return new ArrayCreationExpr(range, type, levels, arrayInitializerExpr); }
[ "ArrayCreationExpr", "juggleArrayCreation", "(", "TokenRange", "range", ",", "List", "<", "TokenRange", ">", "levelRanges", ",", "Type", "type", ",", "NodeList", "<", "Expression", ">", "dimensions", ",", "List", "<", "NodeList", "<", "AnnotationExpr", ">", ">", "arrayAnnotations", ",", "ArrayInitializerExpr", "arrayInitializerExpr", ")", "{", "NodeList", "<", "ArrayCreationLevel", ">", "levels", "=", "new", "NodeList", "<>", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "arrayAnnotations", ".", "size", "(", ")", ";", "i", "++", ")", "{", "levels", ".", "add", "(", "new", "ArrayCreationLevel", "(", "levelRanges", ".", "get", "(", "i", ")", ",", "dimensions", ".", "get", "(", "i", ")", ",", "arrayAnnotations", ".", "get", "(", "i", ")", ")", ")", ";", "}", "return", "new", "ArrayCreationExpr", "(", "range", ",", "type", ",", "levels", ",", "arrayInitializerExpr", ")", ";", "}" ]
Throws together an ArrayCreationExpr from a lot of pieces
[ "Throws", "together", "an", "ArrayCreationExpr", "from", "a", "lot", "of", "pieces" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserBase.java#L241-L248
14,371
kiegroup/drools
drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserBase.java
GeneratedDrlConstraintParserBase.juggleArrayType
Type juggleArrayType(Type partialType, List<ArrayType.ArrayBracketPair> additionalBrackets) { Pair<Type, List<ArrayType.ArrayBracketPair>> partialParts = unwrapArrayTypes(partialType); Type elementType = partialParts.a; List<ArrayType.ArrayBracketPair> leftMostBrackets = partialParts.b; return wrapInArrayTypes(elementType, leftMostBrackets, additionalBrackets).clone(); }
java
Type juggleArrayType(Type partialType, List<ArrayType.ArrayBracketPair> additionalBrackets) { Pair<Type, List<ArrayType.ArrayBracketPair>> partialParts = unwrapArrayTypes(partialType); Type elementType = partialParts.a; List<ArrayType.ArrayBracketPair> leftMostBrackets = partialParts.b; return wrapInArrayTypes(elementType, leftMostBrackets, additionalBrackets).clone(); }
[ "Type", "juggleArrayType", "(", "Type", "partialType", ",", "List", "<", "ArrayType", ".", "ArrayBracketPair", ">", "additionalBrackets", ")", "{", "Pair", "<", "Type", ",", "List", "<", "ArrayType", ".", "ArrayBracketPair", ">", ">", "partialParts", "=", "unwrapArrayTypes", "(", "partialType", ")", ";", "Type", "elementType", "=", "partialParts", ".", "a", ";", "List", "<", "ArrayType", ".", "ArrayBracketPair", ">", "leftMostBrackets", "=", "partialParts", ".", "b", ";", "return", "wrapInArrayTypes", "(", "elementType", ",", "leftMostBrackets", ",", "additionalBrackets", ")", ".", "clone", "(", ")", ";", "}" ]
Throws together a Type, taking care of all the array brackets
[ "Throws", "together", "a", "Type", "taking", "care", "of", "all", "the", "array", "brackets" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserBase.java#L253-L258
14,372
kiegroup/drools
drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserBase.java
GeneratedDrlConstraintParserBase.makeMessageForParseException
private String makeMessageForParseException(ParseException exception) { final StringBuilder sb = new StringBuilder("Parse error. Found "); final StringBuilder expected = new StringBuilder(); int maxExpectedTokenSequenceLength = 0; TreeSet<String> sortedOptions = new TreeSet<>(); for (int i = 0; i < exception.expectedTokenSequences.length; i++) { if (maxExpectedTokenSequenceLength < exception.expectedTokenSequences[i].length) { maxExpectedTokenSequenceLength = exception.expectedTokenSequences[i].length; } for (int j = 0; j < exception.expectedTokenSequences[i].length; j++) { sortedOptions.add(exception.tokenImage[exception.expectedTokenSequences[i][j]]); } } for (String option : sortedOptions) { expected.append(" ").append(option); } sb.append(""); Token token = exception.currentToken.next; for (int i = 0; i < maxExpectedTokenSequenceLength; i++) { String tokenText = token.image; String escapedTokenText = ParseException.add_escapes(tokenText); if (i != 0) { sb.append(" "); } if (token.kind == 0) { sb.append(exception.tokenImage[0]); break; } escapedTokenText = "\"" + escapedTokenText + "\""; String image = exception.tokenImage[token.kind]; if (image.equals(escapedTokenText)) { sb.append(image); } else { sb.append(" ") .append(escapedTokenText) .append(" ") .append(image); } token = token.next; } if (exception.expectedTokenSequences.length != 0) { int numExpectedTokens = exception.expectedTokenSequences.length; sb.append(", expected") .append(numExpectedTokens == 1 ? "" : " one of ") .append(expected.toString()); } return sb.toString(); }
java
private String makeMessageForParseException(ParseException exception) { final StringBuilder sb = new StringBuilder("Parse error. Found "); final StringBuilder expected = new StringBuilder(); int maxExpectedTokenSequenceLength = 0; TreeSet<String> sortedOptions = new TreeSet<>(); for (int i = 0; i < exception.expectedTokenSequences.length; i++) { if (maxExpectedTokenSequenceLength < exception.expectedTokenSequences[i].length) { maxExpectedTokenSequenceLength = exception.expectedTokenSequences[i].length; } for (int j = 0; j < exception.expectedTokenSequences[i].length; j++) { sortedOptions.add(exception.tokenImage[exception.expectedTokenSequences[i][j]]); } } for (String option : sortedOptions) { expected.append(" ").append(option); } sb.append(""); Token token = exception.currentToken.next; for (int i = 0; i < maxExpectedTokenSequenceLength; i++) { String tokenText = token.image; String escapedTokenText = ParseException.add_escapes(tokenText); if (i != 0) { sb.append(" "); } if (token.kind == 0) { sb.append(exception.tokenImage[0]); break; } escapedTokenText = "\"" + escapedTokenText + "\""; String image = exception.tokenImage[token.kind]; if (image.equals(escapedTokenText)) { sb.append(image); } else { sb.append(" ") .append(escapedTokenText) .append(" ") .append(image); } token = token.next; } if (exception.expectedTokenSequences.length != 0) { int numExpectedTokens = exception.expectedTokenSequences.length; sb.append(", expected") .append(numExpectedTokens == 1 ? "" : " one of ") .append(expected.toString()); } return sb.toString(); }
[ "private", "String", "makeMessageForParseException", "(", "ParseException", "exception", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "\"Parse error. Found \"", ")", ";", "final", "StringBuilder", "expected", "=", "new", "StringBuilder", "(", ")", ";", "int", "maxExpectedTokenSequenceLength", "=", "0", ";", "TreeSet", "<", "String", ">", "sortedOptions", "=", "new", "TreeSet", "<>", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "exception", ".", "expectedTokenSequences", ".", "length", ";", "i", "++", ")", "{", "if", "(", "maxExpectedTokenSequenceLength", "<", "exception", ".", "expectedTokenSequences", "[", "i", "]", ".", "length", ")", "{", "maxExpectedTokenSequenceLength", "=", "exception", ".", "expectedTokenSequences", "[", "i", "]", ".", "length", ";", "}", "for", "(", "int", "j", "=", "0", ";", "j", "<", "exception", ".", "expectedTokenSequences", "[", "i", "]", ".", "length", ";", "j", "++", ")", "{", "sortedOptions", ".", "add", "(", "exception", ".", "tokenImage", "[", "exception", ".", "expectedTokenSequences", "[", "i", "]", "[", "j", "]", "]", ")", ";", "}", "}", "for", "(", "String", "option", ":", "sortedOptions", ")", "{", "expected", ".", "append", "(", "\" \"", ")", ".", "append", "(", "option", ")", ";", "}", "sb", ".", "append", "(", "\"\"", ")", ";", "Token", "token", "=", "exception", ".", "currentToken", ".", "next", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "maxExpectedTokenSequenceLength", ";", "i", "++", ")", "{", "String", "tokenText", "=", "token", ".", "image", ";", "String", "escapedTokenText", "=", "ParseException", ".", "add_escapes", "(", "tokenText", ")", ";", "if", "(", "i", "!=", "0", ")", "{", "sb", ".", "append", "(", "\" \"", ")", ";", "}", "if", "(", "token", ".", "kind", "==", "0", ")", "{", "sb", ".", "append", "(", "exception", ".", "tokenImage", "[", "0", "]", ")", ";", "break", ";", "}", "escapedTokenText", "=", "\"\\\"\"", "+", "escapedTokenText", "+", "\"\\\"\"", ";", "String", "image", "=", "exception", ".", "tokenImage", "[", "token", ".", "kind", "]", ";", "if", "(", "image", ".", "equals", "(", "escapedTokenText", ")", ")", "{", "sb", ".", "append", "(", "image", ")", ";", "}", "else", "{", "sb", ".", "append", "(", "\" \"", ")", ".", "append", "(", "escapedTokenText", ")", ".", "append", "(", "\" \"", ")", ".", "append", "(", "image", ")", ";", "}", "token", "=", "token", ".", "next", ";", "}", "if", "(", "exception", ".", "expectedTokenSequences", ".", "length", "!=", "0", ")", "{", "int", "numExpectedTokens", "=", "exception", ".", "expectedTokenSequences", ".", "length", ";", "sb", ".", "append", "(", "\", expected\"", ")", ".", "append", "(", "numExpectedTokens", "==", "1", "?", "\"\"", ":", "\" one of \"", ")", ".", "append", "(", "expected", ".", "toString", "(", ")", ")", ";", "}", "return", "sb", ".", "toString", "(", ")", ";", "}" ]
This is the code from ParseException.initialise, modified to be more horizontal.
[ "This", "is", "the", "code", "from", "ParseException", ".", "initialise", "modified", "to", "be", "more", "horizontal", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-model/drools-constraint-parser/src/main/javacc-support/org/drools/constraint/parser/GeneratedDrlConstraintParserBase.java#L264-L316
14,373
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/ParserHelper.java
ParserHelper.pushParaphrases
public void pushParaphrases( DroolsParaphraseTypes type ) { Map<DroolsParaphraseTypes, String> activeMap = new HashMap<DroolsParaphraseTypes, String>(); activeMap.put( type, "" ); paraphrases.push( activeMap ); }
java
public void pushParaphrases( DroolsParaphraseTypes type ) { Map<DroolsParaphraseTypes, String> activeMap = new HashMap<DroolsParaphraseTypes, String>(); activeMap.put( type, "" ); paraphrases.push( activeMap ); }
[ "public", "void", "pushParaphrases", "(", "DroolsParaphraseTypes", "type", ")", "{", "Map", "<", "DroolsParaphraseTypes", ",", "String", ">", "activeMap", "=", "new", "HashMap", "<", "DroolsParaphraseTypes", ",", "String", ">", "(", ")", ";", "activeMap", ".", "put", "(", "type", ",", "\"\"", ")", ";", "paraphrases", ".", "push", "(", "activeMap", ")", ";", "}" ]
Method that adds a paraphrase type into paraphrases stack. @param type paraphrase type
[ "Method", "that", "adds", "a", "paraphrase", "type", "into", "paraphrases", "stack", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/ParserHelper.java#L376-L381
14,374
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/ParserHelper.java
ParserHelper.setParaphrasesValue
public void setParaphrasesValue( DroolsParaphraseTypes type, String value ) { paraphrases.peek().put( type, value ); }
java
public void setParaphrasesValue( DroolsParaphraseTypes type, String value ) { paraphrases.peek().put( type, value ); }
[ "public", "void", "setParaphrasesValue", "(", "DroolsParaphraseTypes", "type", ",", "String", "value", ")", "{", "paraphrases", ".", "peek", "(", ")", ".", "put", "(", "type", ",", "value", ")", ";", "}" ]
Method that sets paraphrase value for a type into paraphrases stack. @param type paraphrase type @param value paraphrase value
[ "Method", "that", "sets", "paraphrase", "value", "for", "a", "type", "into", "paraphrases", "stack", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/ParserHelper.java#L395-L399
14,375
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/KieBuilderImpl.java
KieBuilderImpl.setPomModel
public void setPomModel( PomModel pomModel ) { this.pomModel = pomModel; if ( srcMfs.isAvailable( "pom.xml" ) ) { this.pomXml = srcMfs.getBytes( "pom.xml" ); } }
java
public void setPomModel( PomModel pomModel ) { this.pomModel = pomModel; if ( srcMfs.isAvailable( "pom.xml" ) ) { this.pomXml = srcMfs.getBytes( "pom.xml" ); } }
[ "public", "void", "setPomModel", "(", "PomModel", "pomModel", ")", "{", "this", ".", "pomModel", "=", "pomModel", ";", "if", "(", "srcMfs", ".", "isAvailable", "(", "\"pom.xml\"", ")", ")", "{", "this", ".", "pomXml", "=", "srcMfs", ".", "getBytes", "(", "\"pom.xml\"", ")", ";", "}", "}" ]
This can be used for performance reason to avoid the recomputation of the pomModel when it is already available
[ "This", "can", "be", "used", "for", "performance", "reason", "to", "avoid", "the", "recomputation", "of", "the", "pomModel", "when", "it", "is", "already", "available" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/kie/builder/impl/KieBuilderImpl.java#L549-L554
14,376
kiegroup/drools
drools-core/src/main/java/org/drools/core/common/IdentityAssertMapComparator.java
IdentityAssertMapComparator.equal
public boolean equal(final Object o1, final Object o2) { if ( o1 instanceof InternalFactHandle ) { return ((InternalFactHandle) o1).getId() == ((InternalFactHandle) o2).getId(); } Object left = o1; final InternalFactHandle handle = ((InternalFactHandle) o2); if ( left == handle.getObject() ) { return true; } else if ( handle.getTraitType() == TraitTypeEnum.WRAPPED_TRAITABLE ) { return left == ( (CoreWrapper) handle.getObject() ).getCore(); } else { return false; } }
java
public boolean equal(final Object o1, final Object o2) { if ( o1 instanceof InternalFactHandle ) { return ((InternalFactHandle) o1).getId() == ((InternalFactHandle) o2).getId(); } Object left = o1; final InternalFactHandle handle = ((InternalFactHandle) o2); if ( left == handle.getObject() ) { return true; } else if ( handle.getTraitType() == TraitTypeEnum.WRAPPED_TRAITABLE ) { return left == ( (CoreWrapper) handle.getObject() ).getCore(); } else { return false; } }
[ "public", "boolean", "equal", "(", "final", "Object", "o1", ",", "final", "Object", "o2", ")", "{", "if", "(", "o1", "instanceof", "InternalFactHandle", ")", "{", "return", "(", "(", "InternalFactHandle", ")", "o1", ")", ".", "getId", "(", ")", "==", "(", "(", "InternalFactHandle", ")", "o2", ")", ".", "getId", "(", ")", ";", "}", "Object", "left", "=", "o1", ";", "final", "InternalFactHandle", "handle", "=", "(", "(", "InternalFactHandle", ")", "o2", ")", ";", "if", "(", "left", "==", "handle", ".", "getObject", "(", ")", ")", "{", "return", "true", ";", "}", "else", "if", "(", "handle", ".", "getTraitType", "(", ")", "==", "TraitTypeEnum", ".", "WRAPPED_TRAITABLE", ")", "{", "return", "left", "==", "(", "(", "CoreWrapper", ")", "handle", ".", "getObject", "(", ")", ")", ".", "getCore", "(", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Special comparator that allows FactHandles to be keys, but always checks like for like.
[ "Special", "comparator", "that", "allows", "FactHandles", "to", "be", "keys", "but", "always", "checks", "like", "for", "like", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/common/IdentityAssertMapComparator.java#L55-L70
14,377
kiegroup/drools
drools-core/src/main/java/org/drools/core/factmodel/FieldDefinition.java
FieldDefinition.getReadMethod
public String getReadMethod() { if ( getterName != null ) { return getterName; } String prefix; if ( "boolean".equals( this.type ) ) { prefix = "is"; } else { prefix = "get"; } return prefix + this.name.substring( 0, 1 ).toUpperCase() + this.name.substring( 1 ); }
java
public String getReadMethod() { if ( getterName != null ) { return getterName; } String prefix; if ( "boolean".equals( this.type ) ) { prefix = "is"; } else { prefix = "get"; } return prefix + this.name.substring( 0, 1 ).toUpperCase() + this.name.substring( 1 ); }
[ "public", "String", "getReadMethod", "(", ")", "{", "if", "(", "getterName", "!=", "null", ")", "{", "return", "getterName", ";", "}", "String", "prefix", ";", "if", "(", "\"boolean\"", ".", "equals", "(", "this", ".", "type", ")", ")", "{", "prefix", "=", "\"is\"", ";", "}", "else", "{", "prefix", "=", "\"get\"", ";", "}", "return", "prefix", "+", "this", ".", "name", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "this", ".", "name", ".", "substring", "(", "1", ")", ";", "}" ]
Creates the String name for the get method for a field with the given name and type @return
[ "Creates", "the", "String", "name", "for", "the", "get", "method", "for", "a", "field", "with", "the", "given", "name", "and", "type" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/factmodel/FieldDefinition.java#L180-L192
14,378
kiegroup/drools
drools-core/src/main/java/org/drools/core/factmodel/FieldDefinition.java
FieldDefinition.getWriteMethod
public String getWriteMethod() { return setterName != null ? setterName : "set" + this.name.substring( 0, 1 ).toUpperCase() + this.name.substring( 1 ); }
java
public String getWriteMethod() { return setterName != null ? setterName : "set" + this.name.substring( 0, 1 ).toUpperCase() + this.name.substring( 1 ); }
[ "public", "String", "getWriteMethod", "(", ")", "{", "return", "setterName", "!=", "null", "?", "setterName", ":", "\"set\"", "+", "this", ".", "name", ".", "substring", "(", "0", ",", "1", ")", ".", "toUpperCase", "(", ")", "+", "this", ".", "name", ".", "substring", "(", "1", ")", ";", "}" ]
Creates the String name for the set method for a field with the given name and type @return
[ "Creates", "the", "String", "name", "for", "the", "set", "method", "for", "a", "field", "with", "the", "given", "name", "and", "type" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/factmodel/FieldDefinition.java#L199-L202
14,379
kiegroup/drools
drools-core/src/main/java/org/drools/core/rule/TypeDeclaration.java
TypeDeclaration.matches
public boolean matches(Object clazz) { return clazz instanceof FactTemplate ? this.typeTemplate.equals( clazz ) : this.typeClass.isAssignableFrom( (Class< ? >) clazz ); }
java
public boolean matches(Object clazz) { return clazz instanceof FactTemplate ? this.typeTemplate.equals( clazz ) : this.typeClass.isAssignableFrom( (Class< ? >) clazz ); }
[ "public", "boolean", "matches", "(", "Object", "clazz", ")", "{", "return", "clazz", "instanceof", "FactTemplate", "?", "this", ".", "typeTemplate", ".", "equals", "(", "clazz", ")", ":", "this", ".", "typeClass", ".", "isAssignableFrom", "(", "(", "Class", "<", "?", ">", ")", "clazz", ")", ";", "}" ]
Returns true if the given parameter matches this type declaration
[ "Returns", "true", "if", "the", "given", "parameter", "matches", "this", "type", "declaration" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/rule/TypeDeclaration.java#L359-L363
14,380
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/compiler/DrlExprParser.java
DrlExprParser.parse
public ConstraintConnectiveDescr parse( final String text ) { ConstraintConnectiveDescr constraint = null; try { DRLLexer lexer = DRLFactory.getDRLLexer(new ANTLRStringStream(text), languageLevel); CommonTokenStream input = new CommonTokenStream( lexer ); RecognizerSharedState state = new RecognizerSharedState(); helper = new ParserHelper( input, state, languageLevel ); DRLExpressions parser = DRLFactory.getDRLExpressions(input, state, helper, languageLevel); parser.setBuildDescr( true ); parser.setLeftMostExpr( null ); // setting initial value just in case BaseDescr expr = parser.conditionalOrExpression(); if ( expr != null && !parser.hasErrors() ) { constraint = ConstraintConnectiveDescr.newAnd(); constraint.addOrMerge( expr ); } } catch ( RecognitionException e ) { helper.reportError( e ); } return constraint; }
java
public ConstraintConnectiveDescr parse( final String text ) { ConstraintConnectiveDescr constraint = null; try { DRLLexer lexer = DRLFactory.getDRLLexer(new ANTLRStringStream(text), languageLevel); CommonTokenStream input = new CommonTokenStream( lexer ); RecognizerSharedState state = new RecognizerSharedState(); helper = new ParserHelper( input, state, languageLevel ); DRLExpressions parser = DRLFactory.getDRLExpressions(input, state, helper, languageLevel); parser.setBuildDescr( true ); parser.setLeftMostExpr( null ); // setting initial value just in case BaseDescr expr = parser.conditionalOrExpression(); if ( expr != null && !parser.hasErrors() ) { constraint = ConstraintConnectiveDescr.newAnd(); constraint.addOrMerge( expr ); } } catch ( RecognitionException e ) { helper.reportError( e ); } return constraint; }
[ "public", "ConstraintConnectiveDescr", "parse", "(", "final", "String", "text", ")", "{", "ConstraintConnectiveDescr", "constraint", "=", "null", ";", "try", "{", "DRLLexer", "lexer", "=", "DRLFactory", ".", "getDRLLexer", "(", "new", "ANTLRStringStream", "(", "text", ")", ",", "languageLevel", ")", ";", "CommonTokenStream", "input", "=", "new", "CommonTokenStream", "(", "lexer", ")", ";", "RecognizerSharedState", "state", "=", "new", "RecognizerSharedState", "(", ")", ";", "helper", "=", "new", "ParserHelper", "(", "input", ",", "state", ",", "languageLevel", ")", ";", "DRLExpressions", "parser", "=", "DRLFactory", ".", "getDRLExpressions", "(", "input", ",", "state", ",", "helper", ",", "languageLevel", ")", ";", "parser", ".", "setBuildDescr", "(", "true", ")", ";", "parser", ".", "setLeftMostExpr", "(", "null", ")", ";", "// setting initial value just in case", "BaseDescr", "expr", "=", "parser", ".", "conditionalOrExpression", "(", ")", ";", "if", "(", "expr", "!=", "null", "&&", "!", "parser", ".", "hasErrors", "(", ")", ")", "{", "constraint", "=", "ConstraintConnectiveDescr", ".", "newAnd", "(", ")", ";", "constraint", ".", "addOrMerge", "(", "expr", ")", ";", "}", "}", "catch", "(", "RecognitionException", "e", ")", "{", "helper", ".", "reportError", "(", "e", ")", ";", "}", "return", "constraint", ";", "}" ]
Parse an expression from text
[ "Parse", "an", "expression", "from", "text" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/compiler/DrlExprParser.java#L48-L67
14,381
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/GuidedDecisionTable52.java
GuidedDecisionTable52.getPatterns
public List<Pattern52> getPatterns() { final List<Pattern52> patterns = new ArrayList<Pattern52>(); for (CompositeColumn<?> cc : conditionPatterns) { if (cc instanceof Pattern52) { patterns.add((Pattern52) cc); } } return Collections.unmodifiableList(patterns); }
java
public List<Pattern52> getPatterns() { final List<Pattern52> patterns = new ArrayList<Pattern52>(); for (CompositeColumn<?> cc : conditionPatterns) { if (cc instanceof Pattern52) { patterns.add((Pattern52) cc); } } return Collections.unmodifiableList(patterns); }
[ "public", "List", "<", "Pattern52", ">", "getPatterns", "(", ")", "{", "final", "List", "<", "Pattern52", ">", "patterns", "=", "new", "ArrayList", "<", "Pattern52", ">", "(", ")", ";", "for", "(", "CompositeColumn", "<", "?", ">", "cc", ":", "conditionPatterns", ")", "{", "if", "(", "cc", "instanceof", "Pattern52", ")", "{", "patterns", ".", "add", "(", "(", "Pattern52", ")", "cc", ")", ";", "}", "}", "return", "Collections", ".", "unmodifiableList", "(", "patterns", ")", ";", "}" ]
Return an immutable list of Pattern columns @return
[ "Return", "an", "immutable", "list", "of", "Pattern", "columns" ]
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/GuidedDecisionTable52.java#L153-L161
14,382
kiegroup/drools
drools-workbench-models/drools-workbench-models-guided-dtable/src/main/java/org/drools/workbench/models/guided/dtable/shared/model/GuidedDecisionTable52.java
GuidedDecisionTable52.getExpandedColumns
public List<BaseColumn> getExpandedColumns() { final List<BaseColumn> columns = new ArrayList<BaseColumn>(); columns.add(rowNumberCol); columns.add(descriptionCol); columns.addAll(metadataCols); columns.addAll(attributeCols); for (CompositeColumn<?> cc : this.conditionPatterns) { boolean explode = !(cc instanceof LimitedEntryCol); if (explode) { for (BaseColumn bc : cc.getChildColumns()) { columns.add(bc); } } else { columns.add(cc); } } for (ActionCol52 ac : this.actionCols) { if (ac instanceof BRLActionColumn) { if (ac instanceof LimitedEntryCol) { columns.add(ac); } else { final BRLActionColumn bac = (BRLActionColumn) ac; for (BRLActionVariableColumn variable : bac.getChildColumns()) { columns.add(variable); } } } else { columns.add(ac); } } return columns; }
java
public List<BaseColumn> getExpandedColumns() { final List<BaseColumn> columns = new ArrayList<BaseColumn>(); columns.add(rowNumberCol); columns.add(descriptionCol); columns.addAll(metadataCols); columns.addAll(attributeCols); for (CompositeColumn<?> cc : this.conditionPatterns) { boolean explode = !(cc instanceof LimitedEntryCol); if (explode) { for (BaseColumn bc : cc.getChildColumns()) { columns.add(bc); } } else { columns.add(cc); } } for (ActionCol52 ac : this.actionCols) { if (ac instanceof BRLActionColumn) { if (ac instanceof LimitedEntryCol) { columns.add(ac); } else { final BRLActionColumn bac = (BRLActionColumn) ac; for (BRLActionVariableColumn variable : bac.getChildColumns()) { columns.add(variable); } } } else { columns.add(ac); } } return columns; }
[ "public", "List", "<", "BaseColumn", ">", "getExpandedColumns", "(", ")", "{", "final", "List", "<", "BaseColumn", ">", "columns", "=", "new", "ArrayList", "<", "BaseColumn", ">", "(", ")", ";", "columns", ".", "add", "(", "rowNumberCol", ")", ";", "columns", ".", "add", "(", "descriptionCol", ")", ";", "columns", ".", "addAll", "(", "metadataCols", ")", ";", "columns", ".", "addAll", "(", "attributeCols", ")", ";", "for", "(", "CompositeColumn", "<", "?", ">", "cc", ":", "this", ".", "conditionPatterns", ")", "{", "boolean", "explode", "=", "!", "(", "cc", "instanceof", "LimitedEntryCol", ")", ";", "if", "(", "explode", ")", "{", "for", "(", "BaseColumn", "bc", ":", "cc", ".", "getChildColumns", "(", ")", ")", "{", "columns", ".", "add", "(", "bc", ")", ";", "}", "}", "else", "{", "columns", ".", "add", "(", "cc", ")", ";", "}", "}", "for", "(", "ActionCol52", "ac", ":", "this", ".", "actionCols", ")", "{", "if", "(", "ac", "instanceof", "BRLActionColumn", ")", "{", "if", "(", "ac", "instanceof", "LimitedEntryCol", ")", "{", "columns", ".", "add", "(", "ac", ")", ";", "}", "else", "{", "final", "BRLActionColumn", "bac", "=", "(", "BRLActionColumn", ")", "ac", ";", "for", "(", "BRLActionVariableColumn", "variable", ":", "bac", ".", "getChildColumns", "(", ")", ")", "{", "columns", ".", "add", "(", "variable", ")", ";", "}", "}", "}", "else", "{", "columns", ".", "add", "(", "ac", ")", ";", "}", "}", "return", "columns", ";", "}" ]
This method expands Composite columns into individual columns where knowledge of individual columns is necessary; for example separate columns in the user-interface or where individual columns need to be analysed. @return A List of individual columns
[ "This", "method", "expands", "Composite", "columns", "into", "individual", "columns", "where", "knowledge", "of", "individual", "columns", "is", "necessary", ";", "for", "example", "separate", "columns", "in", "the", "user", "-", "interface", "or", "where", "individual", "columns", "need", "to", "be", "analysed", "." ]
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/GuidedDecisionTable52.java#L283-L314
14,383
kiegroup/drools
drools-core/src/main/java/org/drools/core/phreak/PhreakAccumulateNode.java
PhreakAccumulateNode.removeMatch
private static void removeMatch(final AccumulateNode accNode, final Accumulate accumulate, final RightTuple rightTuple, final LeftTuple match, final InternalWorkingMemory wm, final AccumulateMemory am, final AccumulateContext accctx, final boolean reaccumulate) { // save the matching tuple LeftTuple leftTuple = match.getLeftParent(); // removing link between left and right match.unlinkFromLeftParent(); match.unlinkFromRightParent(); // if there is a subnetwork, we need to unwrap the object from inside the tuple InternalFactHandle handle = rightTuple.getFactHandle(); LeftTuple tuple = leftTuple; if (accNode.isUnwrapRightObject()) { tuple = (LeftTuple) rightTuple; handle = rightTuple.getFactHandleForEvaluation(); } if (accumulate.supportsReverse()) { // just reverse this single match accumulate.reverse(am.workingMemoryContext, accctx.context, tuple, handle, wm); } else { // otherwise need to recalculate all matches for the given leftTuple if (reaccumulate) { reaccumulateForLeftTuple(accNode, accumulate, leftTuple, wm, am, accctx); } } }
java
private static void removeMatch(final AccumulateNode accNode, final Accumulate accumulate, final RightTuple rightTuple, final LeftTuple match, final InternalWorkingMemory wm, final AccumulateMemory am, final AccumulateContext accctx, final boolean reaccumulate) { // save the matching tuple LeftTuple leftTuple = match.getLeftParent(); // removing link between left and right match.unlinkFromLeftParent(); match.unlinkFromRightParent(); // if there is a subnetwork, we need to unwrap the object from inside the tuple InternalFactHandle handle = rightTuple.getFactHandle(); LeftTuple tuple = leftTuple; if (accNode.isUnwrapRightObject()) { tuple = (LeftTuple) rightTuple; handle = rightTuple.getFactHandleForEvaluation(); } if (accumulate.supportsReverse()) { // just reverse this single match accumulate.reverse(am.workingMemoryContext, accctx.context, tuple, handle, wm); } else { // otherwise need to recalculate all matches for the given leftTuple if (reaccumulate) { reaccumulateForLeftTuple(accNode, accumulate, leftTuple, wm, am, accctx); } } }
[ "private", "static", "void", "removeMatch", "(", "final", "AccumulateNode", "accNode", ",", "final", "Accumulate", "accumulate", ",", "final", "RightTuple", "rightTuple", ",", "final", "LeftTuple", "match", ",", "final", "InternalWorkingMemory", "wm", ",", "final", "AccumulateMemory", "am", ",", "final", "AccumulateContext", "accctx", ",", "final", "boolean", "reaccumulate", ")", "{", "// save the matching tuple", "LeftTuple", "leftTuple", "=", "match", ".", "getLeftParent", "(", ")", ";", "// removing link between left and right", "match", ".", "unlinkFromLeftParent", "(", ")", ";", "match", ".", "unlinkFromRightParent", "(", ")", ";", "// if there is a subnetwork, we need to unwrap the object from inside the tuple", "InternalFactHandle", "handle", "=", "rightTuple", ".", "getFactHandle", "(", ")", ";", "LeftTuple", "tuple", "=", "leftTuple", ";", "if", "(", "accNode", ".", "isUnwrapRightObject", "(", ")", ")", "{", "tuple", "=", "(", "LeftTuple", ")", "rightTuple", ";", "handle", "=", "rightTuple", ".", "getFactHandleForEvaluation", "(", ")", ";", "}", "if", "(", "accumulate", ".", "supportsReverse", "(", ")", ")", "{", "// just reverse this single match", "accumulate", ".", "reverse", "(", "am", ".", "workingMemoryContext", ",", "accctx", ".", "context", ",", "tuple", ",", "handle", ",", "wm", ")", ";", "}", "else", "{", "// otherwise need to recalculate all matches for the given leftTuple", "if", "(", "reaccumulate", ")", "{", "reaccumulateForLeftTuple", "(", "accNode", ",", "accumulate", ",", "leftTuple", ",", "wm", ",", "am", ",", "accctx", ")", ";", "}", "}", "}" ]
Removes a match between left and right tuple
[ "Removes", "a", "match", "between", "left", "and", "right", "tuple" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/phreak/PhreakAccumulateNode.java#L771-L813
14,384
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DiagramElement.java
DiagramElement.getExtension
public org.kie.dmn.model.api.dmndi.DiagramElement.Extension getExtension() { return extension; }
java
public org.kie.dmn.model.api.dmndi.DiagramElement.Extension getExtension() { return extension; }
[ "public", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "DiagramElement", ".", "Extension", "getExtension", "(", ")", "{", "return", "extension", ";", "}" ]
Gets the value of the extension property. @return possible object is {@link DiagramElement.Extension }
[ "Gets", "the", "value", "of", "the", "extension", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DiagramElement.java#L41-L43
14,385
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DiagramElement.java
DiagramElement.setExtension
public void setExtension(org.kie.dmn.model.api.dmndi.DiagramElement.Extension value) { this.extension = value; }
java
public void setExtension(org.kie.dmn.model.api.dmndi.DiagramElement.Extension value) { this.extension = value; }
[ "public", "void", "setExtension", "(", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "DiagramElement", ".", "Extension", "value", ")", "{", "this", ".", "extension", "=", "value", ";", "}" ]
Sets the value of the extension property. @param value allowed object is {@link DiagramElement.Extension }
[ "Sets", "the", "value", "of", "the", "extension", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DiagramElement.java#L53-L55
14,386
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DiagramElement.java
DiagramElement.setStyle
public void setStyle(org.kie.dmn.model.api.dmndi.Style value) { this.style = value; }
java
public void setStyle(org.kie.dmn.model.api.dmndi.Style value) { this.style = value; }
[ "public", "void", "setStyle", "(", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "Style", "value", ")", "{", "this", ".", "style", "=", "value", ";", "}" ]
Sets the value of the style property. @param value allowed object is {@link JAXBElement }{@code <}{@link DMNStyle }{@code >} {@link JAXBElement }{@code <}{@link Style }{@code >}
[ "Sets", "the", "value", "of", "the", "style", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DiagramElement.java#L79-L81
14,387
kiegroup/drools
kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DiagramElement.java
DiagramElement.setSharedStyle
public void setSharedStyle(org.kie.dmn.model.api.dmndi.Style value) { this.sharedStyle = value; }
java
public void setSharedStyle(org.kie.dmn.model.api.dmndi.Style value) { this.sharedStyle = value; }
[ "public", "void", "setSharedStyle", "(", "org", ".", "kie", ".", "dmn", ".", "model", ".", "api", ".", "dmndi", ".", "Style", "value", ")", "{", "this", ".", "sharedStyle", "=", "value", ";", "}" ]
Sets the value of the sharedStyle property. @param value allowed object is {@link Object }
[ "Sets", "the", "value", "of", "the", "sharedStyle", "property", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-model/src/main/java/org/kie/dmn/model/v1_2/dmndi/DiagramElement.java#L103-L105
14,388
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/lang/DroolsSentence.java
DroolsSentence.addContent
public void addContent(DroolsToken token) { if (startOffset == -1) { startOffset = token.getStartIndex(); } endOffset = token.getStopIndex(); this.content.add(token); }
java
public void addContent(DroolsToken token) { if (startOffset == -1) { startOffset = token.getStartIndex(); } endOffset = token.getStopIndex(); this.content.add(token); }
[ "public", "void", "addContent", "(", "DroolsToken", "token", ")", "{", "if", "(", "startOffset", "==", "-", "1", ")", "{", "startOffset", "=", "token", ".", "getStartIndex", "(", ")", ";", "}", "endOffset", "=", "token", ".", "getStopIndex", "(", ")", ";", "this", ".", "content", ".", "add", "(", "token", ")", ";", "}" ]
Add a token to the content and sets char offset info @param token token to be stored
[ "Add", "a", "token", "to", "the", "content", "and", "sets", "char", "offset", "info" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/lang/DroolsSentence.java#L125-L131
14,389
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/visitors/RuleModelVisitor.java
RuleModelVisitor.visitActionFieldList
private void visitActionFieldList(ActionInsertFact afl) { String factType = afl.getFactType(); for (ActionFieldValue afv : afl.getFieldValues()) { InterpolationVariable var = new InterpolationVariable(afv.getValue(), afv.getType(), factType, afv.getField()); if (afv.getNature() == FieldNatureType.TYPE_TEMPLATE && !vars.containsKey(var)) { vars.put(var, vars.size()); } } }
java
private void visitActionFieldList(ActionInsertFact afl) { String factType = afl.getFactType(); for (ActionFieldValue afv : afl.getFieldValues()) { InterpolationVariable var = new InterpolationVariable(afv.getValue(), afv.getType(), factType, afv.getField()); if (afv.getNature() == FieldNatureType.TYPE_TEMPLATE && !vars.containsKey(var)) { vars.put(var, vars.size()); } } }
[ "private", "void", "visitActionFieldList", "(", "ActionInsertFact", "afl", ")", "{", "String", "factType", "=", "afl", ".", "getFactType", "(", ")", ";", "for", "(", "ActionFieldValue", "afv", ":", "afl", ".", "getFieldValues", "(", ")", ")", "{", "InterpolationVariable", "var", "=", "new", "InterpolationVariable", "(", "afv", ".", "getValue", "(", ")", ",", "afv", ".", "getType", "(", ")", ",", "factType", ",", "afv", ".", "getField", "(", ")", ")", ";", "if", "(", "afv", ".", "getNature", "(", ")", "==", "FieldNatureType", ".", "TYPE_TEMPLATE", "&&", "!", "vars", ".", "containsKey", "(", "var", ")", ")", "{", "vars", ".", "put", "(", "var", ",", "vars", ".", "size", "(", ")", ")", ";", "}", "}", "}" ]
ActionInsertFact, ActionSetField, ActionUpdateField
[ "ActionInsertFact", "ActionSetField", "ActionUpdateField" ]
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/visitors/RuleModelVisitor.java#L148-L160
14,390
kiegroup/drools
drools-workbench-models/drools-workbench-models-datamodel-api/src/main/java/org/drools/workbench/models/datamodel/rule/CompositeFactPattern.java
CompositeFactPattern.removeFactPattern
public boolean removeFactPattern( int index ) { final int newSize = ( ( index >= 0 && index < this.patterns.length ) ? this.patterns.length - 1 : this.patterns.length ); final IFactPattern[] newList = new IFactPattern[ newSize ]; boolean deleted = false; int newIdx = 0; for ( int i = 0; i < this.patterns.length; i++ ) { if ( i != index ) { newList[ newIdx ] = this.patterns[ i ]; newIdx++; } else { deleted = true; } } this.patterns = newList; return deleted; }
java
public boolean removeFactPattern( int index ) { final int newSize = ( ( index >= 0 && index < this.patterns.length ) ? this.patterns.length - 1 : this.patterns.length ); final IFactPattern[] newList = new IFactPattern[ newSize ]; boolean deleted = false; int newIdx = 0; for ( int i = 0; i < this.patterns.length; i++ ) { if ( i != index ) { newList[ newIdx ] = this.patterns[ i ]; newIdx++; } else { deleted = true; } } this.patterns = newList; return deleted; }
[ "public", "boolean", "removeFactPattern", "(", "int", "index", ")", "{", "final", "int", "newSize", "=", "(", "(", "index", ">=", "0", "&&", "index", "<", "this", ".", "patterns", ".", "length", ")", "?", "this", ".", "patterns", ".", "length", "-", "1", ":", "this", ".", "patterns", ".", "length", ")", ";", "final", "IFactPattern", "[", "]", "newList", "=", "new", "IFactPattern", "[", "newSize", "]", ";", "boolean", "deleted", "=", "false", ";", "int", "newIdx", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "this", ".", "patterns", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", "!=", "index", ")", "{", "newList", "[", "newIdx", "]", "=", "this", ".", "patterns", "[", "i", "]", ";", "newIdx", "++", ";", "}", "else", "{", "deleted", "=", "true", ";", "}", "}", "this", ".", "patterns", "=", "newList", ";", "return", "deleted", ";", "}" ]
Remove a FactPattern at the provided index. If index is less than zero or greater than or equal to the number of patterns the effect of this method is "no operation". @param index @return true if the deletion was successful, i.e. within range
[ "Remove", "a", "FactPattern", "at", "the", "provided", "index", ".", "If", "index", "is", "less", "than", "zero", "or", "greater", "than", "or", "equal", "to", "the", "number", "of", "patterns", "the", "effect", "of", "this", "method", "is", "no", "operation", "." ]
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/CompositeFactPattern.java#L91-L106
14,391
kiegroup/drools
drools-core/src/main/java/org/drools/core/factmodel/BuildUtils.java
BuildUtils.getInternalType
public static String getInternalType(String type) { String internalType = null; if ( "byte".equals( type ) ) { internalType = "B"; } else if ( "char".equals( type ) ) { internalType = "C"; } else if ( "double".equals( type ) ) { internalType = "D"; } else if ( "float".equals( type ) ) { internalType = "F"; } else if ( "int".equals( type ) ) { internalType = "I"; } else if ( "long".equals( type ) ) { internalType = "J"; } else if ( "short".equals( type ) ) { internalType = "S"; } else if ( "boolean".equals( type ) ) { internalType = "Z"; } else if ( "void".equals( type ) ) { internalType = "V"; } else if ( type != null ) { // I think this will fail for inner classes, but we don't really // support inner class generation at the moment internalType = type.replace( '.', '/' ); } return internalType; }
java
public static String getInternalType(String type) { String internalType = null; if ( "byte".equals( type ) ) { internalType = "B"; } else if ( "char".equals( type ) ) { internalType = "C"; } else if ( "double".equals( type ) ) { internalType = "D"; } else if ( "float".equals( type ) ) { internalType = "F"; } else if ( "int".equals( type ) ) { internalType = "I"; } else if ( "long".equals( type ) ) { internalType = "J"; } else if ( "short".equals( type ) ) { internalType = "S"; } else if ( "boolean".equals( type ) ) { internalType = "Z"; } else if ( "void".equals( type ) ) { internalType = "V"; } else if ( type != null ) { // I think this will fail for inner classes, but we don't really // support inner class generation at the moment internalType = type.replace( '.', '/' ); } return internalType; }
[ "public", "static", "String", "getInternalType", "(", "String", "type", ")", "{", "String", "internalType", "=", "null", ";", "if", "(", "\"byte\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"B\"", ";", "}", "else", "if", "(", "\"char\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"C\"", ";", "}", "else", "if", "(", "\"double\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"D\"", ";", "}", "else", "if", "(", "\"float\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"F\"", ";", "}", "else", "if", "(", "\"int\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"I\"", ";", "}", "else", "if", "(", "\"long\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"J\"", ";", "}", "else", "if", "(", "\"short\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"S\"", ";", "}", "else", "if", "(", "\"boolean\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"Z\"", ";", "}", "else", "if", "(", "\"void\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"V\"", ";", "}", "else", "if", "(", "type", "!=", "null", ")", "{", "// I think this will fail for inner classes, but we don't really", "// support inner class generation at the moment", "internalType", "=", "type", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "}", "return", "internalType", ";", "}" ]
Returns the corresponding internal type representation for the given type. I decided to not use the ASM Type class methods because they require resolving the actual type into a Class instance and at this point, I think it is best to delay type resolution until it is really needed. @param type @return
[ "Returns", "the", "corresponding", "internal", "type", "representation", "for", "the", "given", "type", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/factmodel/BuildUtils.java#L66-L94
14,392
kiegroup/drools
drools-core/src/main/java/org/drools/core/factmodel/BuildUtils.java
BuildUtils.getTypeDescriptor
public static String getTypeDescriptor(String type) { String internalType = null; if ( "byte".equals( type ) ) { internalType = "B"; } else if ( "char".equals( type ) ) { internalType = "C"; } else if ( "double".equals( type ) ) { internalType = "D"; } else if ( "float".equals( type ) ) { internalType = "F"; } else if ( "int".equals( type ) ) { internalType = "I"; } else if ( "long".equals( type ) ) { internalType = "J"; } else if ( "short".equals( type ) ) { internalType = "S"; } else if ( "boolean".equals( type ) ) { internalType = "Z"; } else if ( "void".equals( type ) ) { internalType = "V"; } else if ( type != null && type.startsWith( "[" ) ) { int j = 0; while ( type.charAt( ++j ) == '[' ) {} if ( type.charAt( j ) == 'L' ) { internalType = type.replace( '.', '/' ); } else { internalType = type; } } else if ( type != null ) { // I think this will fail for inner classes, but we don't really // support inner class generation at the moment internalType = "L" + type.replace( '.', '/' ) + ";"; } return internalType; }
java
public static String getTypeDescriptor(String type) { String internalType = null; if ( "byte".equals( type ) ) { internalType = "B"; } else if ( "char".equals( type ) ) { internalType = "C"; } else if ( "double".equals( type ) ) { internalType = "D"; } else if ( "float".equals( type ) ) { internalType = "F"; } else if ( "int".equals( type ) ) { internalType = "I"; } else if ( "long".equals( type ) ) { internalType = "J"; } else if ( "short".equals( type ) ) { internalType = "S"; } else if ( "boolean".equals( type ) ) { internalType = "Z"; } else if ( "void".equals( type ) ) { internalType = "V"; } else if ( type != null && type.startsWith( "[" ) ) { int j = 0; while ( type.charAt( ++j ) == '[' ) {} if ( type.charAt( j ) == 'L' ) { internalType = type.replace( '.', '/' ); } else { internalType = type; } } else if ( type != null ) { // I think this will fail for inner classes, but we don't really // support inner class generation at the moment internalType = "L" + type.replace( '.', '/' ) + ";"; } return internalType; }
[ "public", "static", "String", "getTypeDescriptor", "(", "String", "type", ")", "{", "String", "internalType", "=", "null", ";", "if", "(", "\"byte\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"B\"", ";", "}", "else", "if", "(", "\"char\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"C\"", ";", "}", "else", "if", "(", "\"double\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"D\"", ";", "}", "else", "if", "(", "\"float\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"F\"", ";", "}", "else", "if", "(", "\"int\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"I\"", ";", "}", "else", "if", "(", "\"long\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"J\"", ";", "}", "else", "if", "(", "\"short\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"S\"", ";", "}", "else", "if", "(", "\"boolean\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"Z\"", ";", "}", "else", "if", "(", "\"void\"", ".", "equals", "(", "type", ")", ")", "{", "internalType", "=", "\"V\"", ";", "}", "else", "if", "(", "type", "!=", "null", "&&", "type", ".", "startsWith", "(", "\"[\"", ")", ")", "{", "int", "j", "=", "0", ";", "while", "(", "type", ".", "charAt", "(", "++", "j", ")", "==", "'", "'", ")", "{", "}", "if", "(", "type", ".", "charAt", "(", "j", ")", "==", "'", "'", ")", "{", "internalType", "=", "type", ".", "replace", "(", "'", "'", ",", "'", "'", ")", ";", "}", "else", "{", "internalType", "=", "type", ";", "}", "}", "else", "if", "(", "type", "!=", "null", ")", "{", "// I think this will fail for inner classes, but we don't really", "// support inner class generation at the moment", "internalType", "=", "\"L\"", "+", "type", ".", "replace", "(", "'", "'", ",", "'", "'", ")", "+", "\";\"", ";", "}", "return", "internalType", ";", "}" ]
Returns the corresponding type descriptor for the given type. I decided to not use the ASM Type class methods because they require resolving the actual type into a Class instance and at this point, I think it is best to delay type resolution until it is really needed. @param type @return
[ "Returns", "the", "corresponding", "type", "descriptor", "for", "the", "given", "type", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/factmodel/BuildUtils.java#L107-L142
14,393
kiegroup/drools
drools-core/src/main/java/org/drools/core/factmodel/BuildUtils.java
BuildUtils.arrayType
public static String arrayType( String type ) { if ( isArray( type ) ) if ( type.length() == arrayDimSize(type) +1 ) { return type; } else { String ans = "Ljava/lang/Object;"; for ( int j = 0; j < arrayDimSize( type ); j++ ) { ans = "[" + ans; } return ans; } return null; }
java
public static String arrayType( String type ) { if ( isArray( type ) ) if ( type.length() == arrayDimSize(type) +1 ) { return type; } else { String ans = "Ljava/lang/Object;"; for ( int j = 0; j < arrayDimSize( type ); j++ ) { ans = "[" + ans; } return ans; } return null; }
[ "public", "static", "String", "arrayType", "(", "String", "type", ")", "{", "if", "(", "isArray", "(", "type", ")", ")", "if", "(", "type", ".", "length", "(", ")", "==", "arrayDimSize", "(", "type", ")", "+", "1", ")", "{", "return", "type", ";", "}", "else", "{", "String", "ans", "=", "\"Ljava/lang/Object;\"", ";", "for", "(", "int", "j", "=", "0", ";", "j", "<", "arrayDimSize", "(", "type", ")", ";", "j", "++", ")", "{", "ans", "=", "\"[\"", "+", "ans", ";", "}", "return", "ans", ";", "}", "return", "null", ";", "}" ]
Can only be used with internal names, i.e. after [ has been prefix
[ "Can", "only", "be", "used", "with", "internal", "names", "i", ".", "e", ".", "after", "[", "has", "been", "prefix" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/factmodel/BuildUtils.java#L148-L160
14,394
kiegroup/drools
drools-core/src/main/java/org/drools/core/factmodel/BuildUtils.java
BuildUtils.isPrimitive
public static boolean isPrimitive(String type) { boolean isPrimitive = false; if ( "byte".equals( type ) || "char".equals( type ) || "double".equals( type ) || "float".equals( type ) || "int".equals( type ) || "long".equals( type ) || "short".equals( type ) || "boolean".equals( type ) || "void".equals( type ) ) { isPrimitive = true; } return isPrimitive; }
java
public static boolean isPrimitive(String type) { boolean isPrimitive = false; if ( "byte".equals( type ) || "char".equals( type ) || "double".equals( type ) || "float".equals( type ) || "int".equals( type ) || "long".equals( type ) || "short".equals( type ) || "boolean".equals( type ) || "void".equals( type ) ) { isPrimitive = true; } return isPrimitive; }
[ "public", "static", "boolean", "isPrimitive", "(", "String", "type", ")", "{", "boolean", "isPrimitive", "=", "false", ";", "if", "(", "\"byte\"", ".", "equals", "(", "type", ")", "||", "\"char\"", ".", "equals", "(", "type", ")", "||", "\"double\"", ".", "equals", "(", "type", ")", "||", "\"float\"", ".", "equals", "(", "type", ")", "||", "\"int\"", ".", "equals", "(", "type", ")", "||", "\"long\"", ".", "equals", "(", "type", ")", "||", "\"short\"", ".", "equals", "(", "type", ")", "||", "\"boolean\"", ".", "equals", "(", "type", ")", "||", "\"void\"", ".", "equals", "(", "type", ")", ")", "{", "isPrimitive", "=", "true", ";", "}", "return", "isPrimitive", ";", "}" ]
Returns true if the provided type is a primitive type @param type @return
[ "Returns", "true", "if", "the", "provided", "type", "is", "a", "primitive", "type" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/factmodel/BuildUtils.java#L188-L194
14,395
kiegroup/drools
drools-verifier/drools-verifier-drl/src/main/java/org/drools/verifier/solver/Solver.java
Solver.add
public void add(VerifierComponent descr) { if ( subSolver != null ) { subSolver.add( descr ); } else { if ( type == OperatorDescrType.AND ) { if ( possibilityLists.isEmpty() ) { possibilityLists.add( new HashSet<VerifierComponent>() ); } for ( Set<VerifierComponent> set : possibilityLists ) { set.add( descr ); } } else if ( type == OperatorDescrType.OR ) { Set<VerifierComponent> set = new HashSet<VerifierComponent>(); set.add( descr ); possibilityLists.add( set ); } } }
java
public void add(VerifierComponent descr) { if ( subSolver != null ) { subSolver.add( descr ); } else { if ( type == OperatorDescrType.AND ) { if ( possibilityLists.isEmpty() ) { possibilityLists.add( new HashSet<VerifierComponent>() ); } for ( Set<VerifierComponent> set : possibilityLists ) { set.add( descr ); } } else if ( type == OperatorDescrType.OR ) { Set<VerifierComponent> set = new HashSet<VerifierComponent>(); set.add( descr ); possibilityLists.add( set ); } } }
[ "public", "void", "add", "(", "VerifierComponent", "descr", ")", "{", "if", "(", "subSolver", "!=", "null", ")", "{", "subSolver", ".", "add", "(", "descr", ")", ";", "}", "else", "{", "if", "(", "type", "==", "OperatorDescrType", ".", "AND", ")", "{", "if", "(", "possibilityLists", ".", "isEmpty", "(", ")", ")", "{", "possibilityLists", ".", "add", "(", "new", "HashSet", "<", "VerifierComponent", ">", "(", ")", ")", ";", "}", "for", "(", "Set", "<", "VerifierComponent", ">", "set", ":", "possibilityLists", ")", "{", "set", ".", "add", "(", "descr", ")", ";", "}", "}", "else", "if", "(", "type", "==", "OperatorDescrType", ".", "OR", ")", "{", "Set", "<", "VerifierComponent", ">", "set", "=", "new", "HashSet", "<", "VerifierComponent", ">", "(", ")", ";", "set", ".", "add", "(", "descr", ")", ";", "possibilityLists", ".", "add", "(", "set", ")", ";", "}", "}", "}" ]
Add new descr. @param descr
[ "Add", "new", "descr", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-verifier/drools-verifier-drl/src/main/java/org/drools/verifier/solver/Solver.java#L57-L75
14,396
kiegroup/drools
drools-verifier/drools-verifier-drl/src/main/java/org/drools/verifier/solver/Solver.java
Solver.end
protected void end() { if ( subSolver != null && subSolver.subSolver == null ) { if ( type == OperatorDescrType.AND ) { if ( possibilityLists.isEmpty() ) { possibilityLists.add( new HashSet<VerifierComponent>() ); } List<Set<VerifierComponent>> newPossibilities = new ArrayList<Set<VerifierComponent>>(); List<Set<VerifierComponent>> sets = subSolver.getPossibilityLists(); for ( Set<VerifierComponent> possibilityList : possibilityLists ) { for ( Set<VerifierComponent> set : sets ) { Set<VerifierComponent> newSet = new HashSet<VerifierComponent>(); newSet.addAll( possibilityList ); newSet.addAll( set ); newPossibilities.add( newSet ); } } possibilityLists = newPossibilities; } else if ( type == OperatorDescrType.OR ) { possibilityLists.addAll( subSolver.getPossibilityLists() ); } subSolver = null; } else if ( subSolver != null && subSolver.subSolver != null ) { subSolver.end(); } }
java
protected void end() { if ( subSolver != null && subSolver.subSolver == null ) { if ( type == OperatorDescrType.AND ) { if ( possibilityLists.isEmpty() ) { possibilityLists.add( new HashSet<VerifierComponent>() ); } List<Set<VerifierComponent>> newPossibilities = new ArrayList<Set<VerifierComponent>>(); List<Set<VerifierComponent>> sets = subSolver.getPossibilityLists(); for ( Set<VerifierComponent> possibilityList : possibilityLists ) { for ( Set<VerifierComponent> set : sets ) { Set<VerifierComponent> newSet = new HashSet<VerifierComponent>(); newSet.addAll( possibilityList ); newSet.addAll( set ); newPossibilities.add( newSet ); } } possibilityLists = newPossibilities; } else if ( type == OperatorDescrType.OR ) { possibilityLists.addAll( subSolver.getPossibilityLists() ); } subSolver = null; } else if ( subSolver != null && subSolver.subSolver != null ) { subSolver.end(); } }
[ "protected", "void", "end", "(", ")", "{", "if", "(", "subSolver", "!=", "null", "&&", "subSolver", ".", "subSolver", "==", "null", ")", "{", "if", "(", "type", "==", "OperatorDescrType", ".", "AND", ")", "{", "if", "(", "possibilityLists", ".", "isEmpty", "(", ")", ")", "{", "possibilityLists", ".", "add", "(", "new", "HashSet", "<", "VerifierComponent", ">", "(", ")", ")", ";", "}", "List", "<", "Set", "<", "VerifierComponent", ">", ">", "newPossibilities", "=", "new", "ArrayList", "<", "Set", "<", "VerifierComponent", ">", ">", "(", ")", ";", "List", "<", "Set", "<", "VerifierComponent", ">", ">", "sets", "=", "subSolver", ".", "getPossibilityLists", "(", ")", ";", "for", "(", "Set", "<", "VerifierComponent", ">", "possibilityList", ":", "possibilityLists", ")", "{", "for", "(", "Set", "<", "VerifierComponent", ">", "set", ":", "sets", ")", "{", "Set", "<", "VerifierComponent", ">", "newSet", "=", "new", "HashSet", "<", "VerifierComponent", ">", "(", ")", ";", "newSet", ".", "addAll", "(", "possibilityList", ")", ";", "newSet", ".", "addAll", "(", "set", ")", ";", "newPossibilities", ".", "add", "(", "newSet", ")", ";", "}", "}", "possibilityLists", "=", "newPossibilities", ";", "}", "else", "if", "(", "type", "==", "OperatorDescrType", ".", "OR", ")", "{", "possibilityLists", ".", "addAll", "(", "subSolver", ".", "getPossibilityLists", "(", ")", ")", ";", "}", "subSolver", "=", "null", ";", "}", "else", "if", "(", "subSolver", "!=", "null", "&&", "subSolver", ".", "subSolver", "!=", "null", ")", "{", "subSolver", ".", "end", "(", ")", ";", "}", "}" ]
Ends subSolvers data collection.
[ "Ends", "subSolvers", "data", "collection", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-verifier/drools-verifier-drl/src/main/java/org/drools/verifier/solver/Solver.java#L80-L114
14,397
kiegroup/drools
drools-core/src/main/java/org/drools/core/conflict/SequentialConflictResolver.java
SequentialConflictResolver.compare
public final int compare(final Activation existing, final Activation adding) { final int s1 = existing.getSalience(); final int s2 = adding.getSalience(); if ( s1 > s2 ) { return 1; } else if ( s1 < s2 ) { return -1; } return (int) (existing.getRule().getLoadOrder() - adding.getRule().getLoadOrder()); }
java
public final int compare(final Activation existing, final Activation adding) { final int s1 = existing.getSalience(); final int s2 = adding.getSalience(); if ( s1 > s2 ) { return 1; } else if ( s1 < s2 ) { return -1; } return (int) (existing.getRule().getLoadOrder() - adding.getRule().getLoadOrder()); }
[ "public", "final", "int", "compare", "(", "final", "Activation", "existing", ",", "final", "Activation", "adding", ")", "{", "final", "int", "s1", "=", "existing", ".", "getSalience", "(", ")", ";", "final", "int", "s2", "=", "adding", ".", "getSalience", "(", ")", ";", "if", "(", "s1", ">", "s2", ")", "{", "return", "1", ";", "}", "else", "if", "(", "s1", "<", "s2", ")", "{", "return", "-", "1", ";", "}", "return", "(", "int", ")", "(", "existing", ".", "getRule", "(", ")", ".", "getLoadOrder", "(", ")", "-", "adding", ".", "getRule", "(", ")", ".", "getLoadOrder", "(", ")", ")", ";", "}" ]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[ "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-core/src/main/java/org/drools/core/conflict/SequentialConflictResolver.java#L68-L80
14,398
kiegroup/drools
drools-compiler/src/main/java/org/drools/compiler/rule/builder/util/PackageBuilderUtil.java
PackageBuilderUtil.isReadLocalsFromTuple
public static boolean isReadLocalsFromTuple(final RuleBuildContext context, final AccumulateDescr accumDescr, final RuleConditionElement source) { if (accumDescr.isMultiPattern()) { return true; } PatternDescr inputPattern = accumDescr.getInputPattern(); if (inputPattern == null) { context.addError(new DescrBuildError(context.getParentDescr(), accumDescr, null, "Invalid accumulate pattern in rule '" + context.getRule().getName() + "'.")); return true; } if (source instanceof Pattern) { if ( ((Pattern) source).hasXPath() ) { return true; } if ( ((Pattern) source).getSource() instanceof EntryPointId ) { return false; } } if ( inputPattern.getSource() != null && !( inputPattern.getSource() instanceof WindowReferenceDescr ) && !( inputPattern.getSource() instanceof EntryPointDescr ) ) { return true; } return source instanceof QueryElement || ( source.getNestedElements().size() == 1 && source.getNestedElements().get( 0 ) instanceof QueryElement ); }
java
public static boolean isReadLocalsFromTuple(final RuleBuildContext context, final AccumulateDescr accumDescr, final RuleConditionElement source) { if (accumDescr.isMultiPattern()) { return true; } PatternDescr inputPattern = accumDescr.getInputPattern(); if (inputPattern == null) { context.addError(new DescrBuildError(context.getParentDescr(), accumDescr, null, "Invalid accumulate pattern in rule '" + context.getRule().getName() + "'.")); return true; } if (source instanceof Pattern) { if ( ((Pattern) source).hasXPath() ) { return true; } if ( ((Pattern) source).getSource() instanceof EntryPointId ) { return false; } } if ( inputPattern.getSource() != null && !( inputPattern.getSource() instanceof WindowReferenceDescr ) && !( inputPattern.getSource() instanceof EntryPointDescr ) ) { return true; } return source instanceof QueryElement || ( source.getNestedElements().size() == 1 && source.getNestedElements().get( 0 ) instanceof QueryElement ); }
[ "public", "static", "boolean", "isReadLocalsFromTuple", "(", "final", "RuleBuildContext", "context", ",", "final", "AccumulateDescr", "accumDescr", ",", "final", "RuleConditionElement", "source", ")", "{", "if", "(", "accumDescr", ".", "isMultiPattern", "(", ")", ")", "{", "return", "true", ";", "}", "PatternDescr", "inputPattern", "=", "accumDescr", ".", "getInputPattern", "(", ")", ";", "if", "(", "inputPattern", "==", "null", ")", "{", "context", ".", "addError", "(", "new", "DescrBuildError", "(", "context", ".", "getParentDescr", "(", ")", ",", "accumDescr", ",", "null", ",", "\"Invalid accumulate pattern in rule '\"", "+", "context", ".", "getRule", "(", ")", ".", "getName", "(", ")", "+", "\"'.\"", ")", ")", ";", "return", "true", ";", "}", "if", "(", "source", "instanceof", "Pattern", ")", "{", "if", "(", "(", "(", "Pattern", ")", "source", ")", ".", "hasXPath", "(", ")", ")", "{", "return", "true", ";", "}", "if", "(", "(", "(", "Pattern", ")", "source", ")", ".", "getSource", "(", ")", "instanceof", "EntryPointId", ")", "{", "return", "false", ";", "}", "}", "if", "(", "inputPattern", ".", "getSource", "(", ")", "!=", "null", "&&", "!", "(", "inputPattern", ".", "getSource", "(", ")", "instanceof", "WindowReferenceDescr", ")", "&&", "!", "(", "inputPattern", ".", "getSource", "(", ")", "instanceof", "EntryPointDescr", ")", ")", "{", "return", "true", ";", "}", "return", "source", "instanceof", "QueryElement", "||", "(", "source", ".", "getNestedElements", "(", ")", ".", "size", "(", ")", "==", "1", "&&", "source", ".", "getNestedElements", "(", ")", ".", "get", "(", "0", ")", "instanceof", "QueryElement", ")", ";", "}" ]
This method checks for the conditions when local declarations should be read from a tuple instead of the right object when resolving declarations in an accumulate @param accumDescr @param source @return
[ "This", "method", "checks", "for", "the", "conditions", "when", "local", "declarations", "should", "be", "read", "from", "a", "tuple", "instead", "of", "the", "right", "object", "when", "resolving", "declarations", "in", "an", "accumulate" ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/drools-compiler/src/main/java/org/drools/compiler/rule/builder/util/PackageBuilderUtil.java#L39-L72
14,399
kiegroup/drools
kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/assembler/DMNAssemblerService.java
DMNAssemblerService.compilerConfigWithKModulePrefs
public static DMNCompilerConfigurationImpl compilerConfigWithKModulePrefs(ClassLoader classLoader, ChainedProperties chainedProperties, List<DMNProfile> dmnProfiles, DMNCompilerConfigurationImpl config) { config.setRootClassLoader(classLoader); Map<String, String> dmnPrefs = new HashMap<>(); chainedProperties.mapStartsWith(dmnPrefs, ORG_KIE_DMN_PREFIX, true); config.setProperties(dmnPrefs); for (DMNProfile dmnProfile : dmnProfiles) { config.addExtensions(dmnProfile.getExtensionRegisters()); config.addDRGElementCompilers(dmnProfile.getDRGElementCompilers()); config.addFEELProfile(dmnProfile); } return config; }
java
public static DMNCompilerConfigurationImpl compilerConfigWithKModulePrefs(ClassLoader classLoader, ChainedProperties chainedProperties, List<DMNProfile> dmnProfiles, DMNCompilerConfigurationImpl config) { config.setRootClassLoader(classLoader); Map<String, String> dmnPrefs = new HashMap<>(); chainedProperties.mapStartsWith(dmnPrefs, ORG_KIE_DMN_PREFIX, true); config.setProperties(dmnPrefs); for (DMNProfile dmnProfile : dmnProfiles) { config.addExtensions(dmnProfile.getExtensionRegisters()); config.addDRGElementCompilers(dmnProfile.getDRGElementCompilers()); config.addFEELProfile(dmnProfile); } return config; }
[ "public", "static", "DMNCompilerConfigurationImpl", "compilerConfigWithKModulePrefs", "(", "ClassLoader", "classLoader", ",", "ChainedProperties", "chainedProperties", ",", "List", "<", "DMNProfile", ">", "dmnProfiles", ",", "DMNCompilerConfigurationImpl", "config", ")", "{", "config", ".", "setRootClassLoader", "(", "classLoader", ")", ";", "Map", "<", "String", ",", "String", ">", "dmnPrefs", "=", "new", "HashMap", "<>", "(", ")", ";", "chainedProperties", ".", "mapStartsWith", "(", "dmnPrefs", ",", "ORG_KIE_DMN_PREFIX", ",", "true", ")", ";", "config", ".", "setProperties", "(", "dmnPrefs", ")", ";", "for", "(", "DMNProfile", "dmnProfile", ":", "dmnProfiles", ")", "{", "config", ".", "addExtensions", "(", "dmnProfile", ".", "getExtensionRegisters", "(", ")", ")", ";", "config", ".", "addDRGElementCompilers", "(", "dmnProfile", ".", "getDRGElementCompilers", "(", ")", ")", ";", "config", ".", "addFEELProfile", "(", "dmnProfile", ")", ";", "}", "return", "config", ";", "}" ]
Returns a DMNCompilerConfiguration with the specified properties set, and applying the explicited dmnProfiles. @param classLoader @param chainedProperties applies properties --it does not do any classloading nor profile loading based on these properites, just passes the values. @param dmnProfiles applies these DMNProfile(s) to the DMNCompilerConfiguration @param config @return
[ "Returns", "a", "DMNCompilerConfiguration", "with", "the", "specified", "properties", "set", "and", "applying", "the", "explicited", "dmnProfiles", "." ]
22b0275d6dbe93070b8090948502cf46eda543c4
https://github.com/kiegroup/drools/blob/22b0275d6dbe93070b8090948502cf46eda543c4/kie-dmn/kie-dmn-core/src/main/java/org/kie/dmn/core/assembler/DMNAssemblerService.java#L248-L263