idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
8,000
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
8,001
public void mapNodeToCliqueFamily ( OpenBitSet [ ] varNodeToCliques , JunctionTreeClique [ ] jtNodes ) { for ( int i = 0 ; i < varNodeToCliques . length ; i ++ ) { GraphNode < BayesVariable > varNode = graph . getNode ( i ) ; OpenBitSet parents = new OpenBitSet ( ) ; int count = 0 ; for ( Edge edge : varNode . getInEdges ( ) ) { parents . set ( edge . getOutGraphNode ( ) . getId ( ) ) ; count ++ ; } if ( count == 0 ) { } 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 ; for ( int j = cliques . nextSetBit ( 0 ) ; j >= 0 ; j = cliques . nextSetBit ( j + 1 ) ) { JunctionTreeClique jtNode = jtNodes [ j ] ; 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 .
8,002
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
8,003
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
8,004
protected void marshalPackageHeader ( final RuleModel model , final StringBuilder buf ) { PackageNameWriter . write ( buf , model ) ; ImportsWriter . write ( buf , model ) ; }
Append package name and imports to DRL
8,005
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' ) ; } }
Append rule header
8,006
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 ; } } if ( ! hasDialect ) { RuleAttribute attr = new RuleAttribute ( "dialect" , DRLConstraintValueBuilder . DEFAULT_DIALECT ) ; buf . append ( "\t" ) ; buf . append ( attr ) ; buf . append ( "\n" ) ; } }
Marshal model attributes
8,007
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
8,008
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 ( ) ) { buf . delete ( buf . length ( ) - 5 , buf . length ( ) ) ; buf . append ( "\n" ) ; buf . append ( indentation ) ; buf . append ( ")\n" ) ; } } }
Marshal LHS patterns
8,009
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 .
8,010
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
8,011
public void removeConstraint ( final int idx ) { 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 .
8,012
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 ] ; while ( entry != null ) { if ( matches ( entry , tuple , hashCode , ! left ) ) { return entry ; } entry = entry . getNext ( ) ; } 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 .
8,013
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 .
8,014
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 .
8,015
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 .
8,016
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 .
8,017
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 .
8,018
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 .
8,019
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 ) { 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" ) ) ) { pattern . addConstraint ( new NegConstraint ( false ) ) ; } context . getDeclarationResolver ( ) . popBuildStack ( ) ; return pattern ; }
Build a pattern for the given descriptor in the current context and using the given utils object
8,020
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 { 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
8,021
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
8,022
public void blockExcept ( Integer ... values ) { free . clear ( ) ; for ( Integer value : values ) { free . add ( value ) ; } }
Redefine the set of acceptable values for this cell .
8,023
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
8,024
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
8,025
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
8,026
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
8,027
public Object unmarshall ( Type feelType , String value ) { return feel . evaluate ( value ) ; }
Unmarshalls the string into a FEEL value by executing it .
8,028
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 .
8,029
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 .
8,030
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
8,031
public MetadataCol52 cloneColumn ( ) { MetadataCol52 cloned = new MetadataCol52 ( ) ; cloned . setMetadata ( getMetadata ( ) ) ; cloned . cloneCommonColumnConfigFrom ( this ) ; return cloned ; }
Clones this metadata column instance .
8,032
public Map < String , Declaration > getDeclarations ( RuleImpl rule , String consequenceName ) { Map < String , Declaration > declarations = new HashMap < String , Declaration > ( ) ; for ( RuleConditionElement aBuildStack : this . buildStack ) { if ( aBuildStack instanceof GroupElement && ( ( GroupElement ) aBuildStack ) . getType ( ) == GroupElement . Type . OR ) { continue ; } 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
8,033
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
8,034
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 .
8,035
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
8,036
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 .
8,037
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 ;
8,038
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 .
8,039
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
8,040
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
8,041
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
8,042
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 .
8,043
@ SuppressWarnings ( "unchecked" ) public < T > T get ( Contextual < T > contextual ) { Bean bean = ( Bean ) contextual ; 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 .
8,044
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 .
8,045
public List < DecisionService > getDecisionService ( ) { return drgElement . stream ( ) . filter ( DecisionService . class :: isInstance ) . map ( DecisionService . class :: cast ) . collect ( Collectors . toList ( ) ) ; }
Implementing support for internal model
8,046
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 .
8,047
private URL getCleanedUrl ( URL originalUrl , String originalPath ) { try { return new URL ( StringUtils . cleanPath ( originalPath ) ) ; } catch ( MalformedURLException ex ) { return originalUrl ; } }
Determine a cleaned URL for the given original URL .
8,048
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 .
8,049
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 .
8,050
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
8,051
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
8,052
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
8,053
private FieldConstraint makeSingleFieldConstraint ( ConditionCol52 c , String cell ) { SingleFieldConstraint sfc = new SingleFieldConstraint ( c . getFactField ( ) ) ; if ( no ( c . getOperator ( ) ) ) { String [ ] a = cell . split ( "\\s" ) ; if ( a . length > 1 ) { 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
8,054
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
8,055
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
8,056
private static DTDecisionRule toDecisionRule ( EvaluationContext mainCtx , FEEL embeddedFEEL , int index , List < ? > rule , int inputSize ) { 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
8,057
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 .
8,058
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 .
8,059
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 ) ) { result = Long . MAX_VALUE ; } else if ( "-*" . equals ( trimmed ) ) { 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
8,060
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 .
8,061
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 .
8,062
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 .
8,063
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 .
8,064
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
8,065
< 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
8,066
< T > List < T > add ( List < T > list , T obj ) { if ( list == null ) { list = new LinkedList < > ( ) ; } list . add ( obj ) ; return list ; }
Add obj to list
8,067
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
8,068
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
8,069
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 .
8,070
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 .
8,071
public void setParaphrasesValue ( DroolsParaphraseTypes type , String value ) { paraphrases . peek ( ) . put ( type , value ) ; }
Method that sets paraphrase value for a type into paraphrases stack .
8,072
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
8,073
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 .
8,074
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
8,075
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
8,076
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
8,077
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 ) ; 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
8,078
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
8,079
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 .
8,080
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 ) { LeftTuple leftTuple = match . getLeftParent ( ) ; match . unlinkFromLeftParent ( ) ; match . unlinkFromRightParent ( ) ; InternalFactHandle handle = rightTuple . getFactHandle ( ) ; LeftTuple tuple = leftTuple ; if ( accNode . isUnwrapRightObject ( ) ) { tuple = ( LeftTuple ) rightTuple ; handle = rightTuple . getFactHandleForEvaluation ( ) ; } if ( accumulate . supportsReverse ( ) ) { accumulate . reverse ( am . workingMemoryContext , accctx . context , tuple , handle , wm ) ; } else { if ( reaccumulate ) { reaccumulateForLeftTuple ( accNode , accumulate , leftTuple , wm , am , accctx ) ; } } }
Removes a match between left and right tuple
8,081
public org . kie . dmn . model . api . dmndi . DiagramElement . Extension getExtension ( ) { return extension ; }
Gets the value of the extension property .
8,082
public void setExtension ( org . kie . dmn . model . api . dmndi . DiagramElement . Extension value ) { this . extension = value ; }
Sets the value of the extension property .
8,083
public void setStyle ( org . kie . dmn . model . api . dmndi . Style value ) { this . style = value ; }
Sets the value of the style property .
8,084
public void setSharedStyle ( org . kie . dmn . model . api . dmndi . Style value ) { this . sharedStyle = value ; }
Sets the value of the sharedStyle property .
8,085
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
8,086
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
8,087
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 .
8,088
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 ) { internalType = type . replace ( '.' , '/' ) ; } return internalType ; }
Returns the corresponding internal type representation for the given type .
8,089
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 ) { internalType = "L" + type . replace ( '.' , '/' ) + ";" ; } return internalType ; }
Returns the corresponding type descriptor for the given type .
8,090
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
8,091
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
8,092
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 .
8,093
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 .
8,094
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 ( ) ) ; }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8,095
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
8,096
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 .
8,097
private String determineResultClassName ( ClassObjectType objType ) { String className = objType . getClassName ( ) ; if ( List . class . getName ( ) . equals ( className ) ) { className = ArrayList . class . getName ( ) ; } else if ( Set . class . getName ( ) . equals ( className ) ) { className = HashSet . class . getName ( ) ; } else if ( Collection . class . getName ( ) . equals ( className ) ) { className = ArrayList . class . getName ( ) ; } return className ; }
If the user uses an interface as a result type use a default concrete class .
8,098
protected static ClassWriter buildClassHeader ( Class < ? > superClass , String className ) { ClassWriter cw = createClassWriter ( superClass . getClassLoader ( ) , Opcodes . ACC_PUBLIC + Opcodes . ACC_SUPER , className , null , Type . getInternalName ( superClass ) , null ) ; cw . visitSource ( null , null ) ; return cw ; }
Builds the class header
8,099
private static void build3ArgConstructor ( final Class < ? > superClazz , final String className , final ClassWriter cw ) { MethodVisitor mv ; { mv = cw . visitMethod ( Opcodes . ACC_PUBLIC , "<init>" , Type . getMethodDescriptor ( Type . VOID_TYPE , Type . getType ( int . class ) , Type . getType ( Class . class ) , Type . getType ( ValueType . class ) ) , null , null ) ; mv . visitCode ( ) ; final Label l0 = new Label ( ) ; mv . visitLabel ( l0 ) ; mv . visitVarInsn ( Opcodes . ALOAD , 0 ) ; mv . visitVarInsn ( Opcodes . ILOAD , 1 ) ; mv . visitVarInsn ( Opcodes . ALOAD , 2 ) ; mv . visitVarInsn ( Opcodes . ALOAD , 3 ) ; mv . visitMethodInsn ( Opcodes . INVOKESPECIAL , Type . getInternalName ( superClazz ) , "<init>" , Type . getMethodDescriptor ( Type . VOID_TYPE , Type . getType ( int . class ) , Type . getType ( Class . class ) , Type . getType ( ValueType . class ) ) ) ; final Label l1 = new Label ( ) ; mv . visitLabel ( l1 ) ; mv . visitInsn ( Opcodes . RETURN ) ; final Label l2 = new Label ( ) ; mv . visitLabel ( l2 ) ; mv . visitLocalVariable ( "this" , "L" + className + ";" , null , l0 , l2 , 0 ) ; mv . visitLocalVariable ( "index" , Type . getDescriptor ( int . class ) , null , l0 , l2 , 1 ) ; mv . visitLocalVariable ( "fieldType" , Type . getDescriptor ( Class . class ) , null , l0 , l2 , 2 ) ; mv . visitLocalVariable ( "valueType" , Type . getDescriptor ( ValueType . class ) , null , l0 , l2 , 3 ) ; mv . visitMaxs ( 0 , 0 ) ; mv . visitEnd ( ) ; } }
Creates a constructor for the field extractor receiving the index field type and value type