idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
7,900 | public FieldTemplate getFieldTemplate ( final String name ) { for ( int idx = 0 ; idx < this . fields . length ; idx ++ ) { if ( this . fields [ idx ] . getName ( ) . equals ( name ) ) { return this . fields [ idx ] ; } } return null ; } | A convienance method for finding the slot matching the String name . |
7,901 | public int getFieldTemplateIndex ( final String name ) { for ( int index = 0 ; index < this . fields . length ; index ++ ) { if ( this . fields [ index ] . getName ( ) . equals ( name ) ) { return index ; } } return - 1 ; } | Look up the pattern index of the slot |
7,902 | public boolean get ( int index ) { int i = index >> 6 ; if ( i >= bits . length ) return false ; int bit = index & 0x3f ; long bitmask = 1L << bit ; return ( bits [ i ] & bitmask ) != 0 ; } | Returns true or false for the specified bit index . |
7,903 | public boolean fastGet ( int index ) { assert index >= 0 && index < numBits ; int i = index >> 6 ; int bit = index & 0x3f ; long bitmask = 1L << bit ; return ( bits [ i ] & bitmask ) != 0 ; } | Returns true or false for the specified bit index . The index should be less than the OpenBitSet size |
7,904 | public int getBit ( int index ) { assert index >= 0 && index < numBits ; int i = index >> 6 ; int bit = index & 0x3f ; return ( ( int ) ( bits [ i ] >>> bit ) ) & 0x01 ; } | returns 1 if the bit is set 0 if not . The index should be less than the OpenBitSet size |
7,905 | public void set ( long index ) { int wordNum = expandingWordNum ( index ) ; int bit = ( int ) index & 0x3f ; long bitmask = 1L << bit ; bits [ wordNum ] |= bitmask ; } | sets a bit expanding the set size if necessary |
7,906 | public void fastSet ( int index ) { assert index >= 0 && index < numBits ; int wordNum = index >> 6 ; int bit = index & 0x3f ; long bitmask = 1L << bit ; bits [ wordNum ] |= bitmask ; } | Sets the bit at the specified index . The index should be less than the OpenBitSet size . |
7,907 | public void fastClear ( int index ) { assert index >= 0 && index < numBits ; int wordNum = index >> 6 ; int bit = index & 0x03f ; long bitmask = 1L << bit ; bits [ wordNum ] &= ~ bitmask ; } | clears a bit . The index should be less than the OpenBitSet size . |
7,908 | public void clear ( long index ) { int wordNum = ( int ) ( index >> 6 ) ; if ( wordNum >= wlen ) return ; int bit = ( int ) index & 0x3f ; long bitmask = 1L << bit ; bits [ wordNum ] &= ~ bitmask ; } | clears a bit allowing access beyond the current set size without changing the size . |
7,909 | public void fastFlip ( int index ) { assert index >= 0 && index < numBits ; int wordNum = index >> 6 ; int bit = index & 0x3f ; long bitmask = 1L << bit ; bits [ wordNum ] ^= bitmask ; } | flips a bit . The index should be less than the OpenBitSet size . |
7,910 | public void flip ( long index ) { int wordNum = expandingWordNum ( index ) ; int bit = ( int ) index & 0x3f ; long bitmask = 1L << bit ; bits [ wordNum ] ^= bitmask ; } | flips a bit expanding the set size if necessary |
7,911 | public static long intersectionCount ( OpenBitSet a , OpenBitSet b ) { return BitUtil . pop_intersect ( a . bits , b . bits , 0 , Math . min ( a . wlen , b . wlen ) ) ; } | Returns the popcount or cardinality of the intersection of the two sets . Neither set is modified . |
7,912 | public static long unionCount ( OpenBitSet a , OpenBitSet b ) { long tot = BitUtil . pop_union ( a . bits , b . bits , 0 , Math . min ( a . wlen , b . wlen ) ) ; if ( a . wlen < b . wlen ) { tot += BitUtil . pop_array ( b . bits , a . wlen , b . wlen - a . wlen ) ; } else if ( a . wlen > b . wlen ) { tot += BitUtil . pop_array ( a . bits , b . wlen , a . wlen - b . wlen ) ; } return tot ; } | Returns the popcount or cardinality of the union of the two sets . Neither set is modified . |
7,913 | public static long xorCount ( OpenBitSet a , OpenBitSet b ) { long tot = BitUtil . pop_xor ( a . bits , b . bits , 0 , Math . min ( a . wlen , b . wlen ) ) ; if ( a . wlen < b . wlen ) { tot += BitUtil . pop_array ( b . bits , a . wlen , b . wlen - a . wlen ) ; } else if ( a . wlen > b . wlen ) { tot += BitUtil . pop_array ( a . bits , b . wlen , a . wlen - b . wlen ) ; } return tot ; } | Returns the popcount or cardinality of the exclusive - or of the two sets . Neither set is modified . |
7,914 | public int prevSetBit ( int index ) { int i = index >> 6 ; final int subIndex ; long word ; if ( i >= wlen ) { i = wlen - 1 ; if ( i < 0 ) return - 1 ; subIndex = 63 ; word = bits [ i ] ; } else { if ( i < 0 ) return - 1 ; subIndex = index & 0x3f ; word = ( bits [ i ] << ( 63 - subIndex ) ) ; } if ( word != 0 ) { return ( i << 6 ) + subIndex - Long . numberOfLeadingZeros ( word ) ; } while ( -- i >= 0 ) { word = bits [ i ] ; if ( word != 0 ) { return ( i << 6 ) + 63 - Long . numberOfLeadingZeros ( word ) ; } } return - 1 ; } | Returns the index of the first set bit starting downwards at the index specified . - 1 is returned if there are no more set bits . |
7,915 | public static int oversize ( int minTargetSize , int bytesPerElement ) { if ( minTargetSize < 0 ) { throw new IllegalArgumentException ( "invalid array size " + minTargetSize ) ; } if ( minTargetSize == 0 ) { return 0 ; } int extra = minTargetSize >> 3 ; if ( extra < 3 ) { extra = 3 ; } int newSize = minTargetSize + extra ; if ( newSize + 7 < 0 ) { return Integer . MAX_VALUE ; } if ( JRE_IS_64BIT ) { switch ( bytesPerElement ) { case 4 : return ( newSize + 1 ) & 0x7ffffffe ; case 2 : return ( newSize + 3 ) & 0x7ffffffc ; case 1 : return ( newSize + 7 ) & 0x7ffffff8 ; case 8 : default : return newSize ; } } else { switch ( bytesPerElement ) { case 2 : return ( newSize + 1 ) & 0x7ffffffe ; case 1 : return ( newSize + 3 ) & 0x7ffffffc ; case 4 : case 8 : default : return newSize ; } } } | Returns an array size > = minTargetSize generally over - allocating exponentially to achieve amortized linear - time cost as the array grows . |
7,916 | public AttributeCol52 cloneColumn ( ) { AttributeCol52 cloned = new AttributeCol52 ( ) ; cloned . setAttribute ( getAttribute ( ) ) ; cloned . setReverseOrder ( isReverseOrder ( ) ) ; cloned . setUseRowNumber ( isUseRowNumber ( ) ) ; cloned . cloneCommonColumnConfigFrom ( this ) ; return cloned ; } | Clones this attribute column instance . |
7,917 | public boolean equal ( final Object o1 , Object o2 ) { if ( o1 == o2 ) { return true ; } if ( o1 instanceof FactHandle ) { return ( ( InternalFactHandle ) o1 ) . getId ( ) == ( ( InternalFactHandle ) o2 ) . getId ( ) ; } final InternalFactHandle handle = ( ( InternalFactHandle ) o2 ) ; o2 = handle . getObject ( ) ; return o1 == o2 || o2 . equals ( o1 ) ; } | Special comparator that allows FactHandles to be keys but always checks equals with the identity of the objects involved |
7,918 | public void setSize ( org . kie . dmn . model . api . dmndi . Dimension value ) { this . size = value ; } | Sets the value of the size property . |
7,919 | public List < org . kie . dmn . model . api . dmndi . DiagramElement > getDMNDiagramElement ( ) { if ( dmnDiagramElement == null ) { dmnDiagramElement = new ArrayList < > ( ) ; } return this . dmnDiagramElement ; } | Gets the value of the dmnDiagramElement property . |
7,920 | public Object unmarshall ( Type feelType , String value ) { if ( "null" . equals ( value ) ) { return null ; } else if ( feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . NUMBER ) ) { return BuiltInFunctions . getFunction ( NumberFunction . class ) . invoke ( value , null , null ) . cata ( justNull ( ) , Function . identity ( ) ) ; } else if ( feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . STRING ) ) { return value ; } else if ( feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . DATE ) ) { return BuiltInFunctions . getFunction ( DateFunction . class ) . invoke ( value ) . cata ( justNull ( ) , Function . identity ( ) ) ; } else if ( feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . TIME ) ) { return BuiltInFunctions . getFunction ( TimeFunction . class ) . invoke ( value ) . cata ( justNull ( ) , Function . identity ( ) ) ; } else if ( feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . DATE_TIME ) ) { return BuiltInFunctions . getFunction ( DateAndTimeFunction . class ) . invoke ( value ) . cata ( justNull ( ) , Function . identity ( ) ) ; } else if ( feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . DURATION ) ) { return BuiltInFunctions . getFunction ( DurationFunction . class ) . invoke ( value ) . cata ( justNull ( ) , Function . identity ( ) ) ; } else if ( feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . BOOLEAN ) ) { return Boolean . parseBoolean ( value ) ; } else if ( feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . RANGE ) || feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . FUNCTION ) || feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . LIST ) || feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . CONTEXT ) || feelType . equals ( org . kie . dmn . feel . lang . types . BuiltInType . UNARY_TEST ) ) { throw new UnsupportedOperationException ( "FEELStringMarshaller is unable to unmarshall complex types like: " + feelType . getName ( ) ) ; } return null ; } | Unmarshalls the given string into a FEEL value . |
7,921 | public ObjectTypeConf getObjectTypeConf ( EntryPointId entrypoint , Object object ) { Object key ; if ( object instanceof Activation ) { key = ClassObjectType . Match_ObjectType . getClassType ( ) ; } else if ( object instanceof Fact ) { key = ( ( Fact ) object ) . getFactTemplate ( ) . getName ( ) ; } else { key = object . getClass ( ) ; } ObjectTypeConf objectTypeConf = this . typeConfMap . get ( key ) ; if ( objectTypeConf == null ) { if ( object instanceof Fact ) { objectTypeConf = new FactTemplateTypeConf ( entrypoint , ( ( Fact ) object ) . getFactTemplate ( ) , this . kBase ) ; } else { objectTypeConf = new ClassObjectTypeConf ( entrypoint , ( Class < ? > ) key , this . kBase ) ; } ObjectTypeConf existing = this . typeConfMap . putIfAbsent ( key , objectTypeConf ) ; if ( existing != null ) { objectTypeConf = existing ; } } return objectTypeConf ; } | Returns the ObjectTypeConfiguration object for the given object or creates a new one if none is found in the cache |
7,922 | private String readFile ( Reader reader ) throws IOException { lineLengths = new ArrayList < Integer > ( ) ; lineLengths . add ( null ) ; LineNumberReader lnr = new LineNumberReader ( reader ) ; StringBuilder sb = new StringBuilder ( ) ; int nlCount = 0 ; boolean inEntry = false ; String line ; while ( ( line = lnr . readLine ( ) ) != null ) { lineLengths . add ( line . length ( ) ) ; Matcher commentMat = commentPat . matcher ( line ) ; if ( commentMat . matches ( ) ) { if ( inEntry ) { nlCount ++ ; } else { sb . append ( '\n' ) ; } if ( "#/" . equals ( commentMat . group ( 2 ) ) ) { String [ ] options = commentMat . group ( 1 ) . substring ( 2 ) . trim ( ) . split ( "\\s+" ) ; for ( String option : options ) { optionSet . add ( option ) ; } } continue ; } if ( entryPat . matcher ( line ) . matches ( ) ) { if ( inEntry ) { for ( int i = 0 ; i < nlCount ; i ++ ) sb . append ( '\n' ) ; } sb . append ( line ) ; nlCount = 1 ; inEntry = true ; continue ; } sb . append ( ' ' ) . append ( line ) ; nlCount ++ ; } if ( inEntry ) sb . append ( '\n' ) ; lnr . close ( ) ; return sb . toString ( ) ; } | Read a DSL file and convert it to a String . Comment lines are removed . Split lines are joined inserting a space for an EOL but maintaining the original number of lines by inserting EOLs . Options are recognized . Keeps track of original line lengths for fixing parser error messages . |
7,923 | public Pattern52 clonePattern ( ) { Pattern52 cloned = new Pattern52 ( ) ; cloned . setBoundName ( getBoundName ( ) ) ; cloned . setChildColumns ( new ArrayList < ConditionCol52 > ( getChildColumns ( ) ) ) ; cloned . setEntryPointName ( getEntryPointName ( ) ) ; cloned . setFactType ( getFactType ( ) ) ; cloned . setNegated ( isNegated ( ) ) ; cloned . setWindow ( getWindow ( ) ) ; return cloned ; } | Clones this pattern instance . |
7,924 | public void update ( Pattern52 other ) { setBoundName ( other . getBoundName ( ) ) ; setChildColumns ( other . getChildColumns ( ) ) ; setEntryPointName ( other . getEntryPointName ( ) ) ; setFactType ( other . getFactType ( ) ) ; setNegated ( other . isNegated ( ) ) ; setWindow ( other . getWindow ( ) ) ; } | Update this pattern instance properties with the given ones from other pattern instance . |
7,925 | private void visitActionFieldList ( final ActionInsertFact afl ) { String factType = afl . getFactType ( ) ; for ( ActionFieldValue afv : afl . getFieldValues ( ) ) { InterpolationVariable var = new InterpolationVariable ( afv . getValue ( ) , afv . getType ( ) , factType , afv . getField ( ) ) ; if ( afv . getNature ( ) == FieldNatureType . TYPE_TEMPLATE && ! vars . contains ( var ) ) { vars . add ( var ) ; } else { hasNonTemplateOutput = true ; } } } | ActionInsertFact ActionSetField ActionpdateField |
7,926 | public PMML loadModel ( String model , InputStream source ) { try { if ( schema == null ) { visitorBuildResults . add ( new PMMLWarning ( ResourceFactory . newInputStreamResource ( source ) , "Could not validate PMML document, schema not available" ) ) ; } final JAXBContext jc ; final ClassLoader ccl = Thread . currentThread ( ) . getContextClassLoader ( ) ; XMLStreamReader reader = null ; try { Thread . currentThread ( ) . setContextClassLoader ( PMML4Compiler . class . getClassLoader ( ) ) ; Class c = PMML4Compiler . class . getClassLoader ( ) . loadClass ( "org.dmg.pmml.pmml_4_2.descr.PMML" ) ; jc = JAXBContext . newInstance ( c ) ; XMLInputFactory xif = XMLInputFactory . newFactory ( ) ; xif . setProperty ( XMLInputFactory . IS_SUPPORTING_EXTERNAL_ENTITIES , false ) ; xif . setProperty ( XMLInputFactory . SUPPORT_DTD , true ) ; reader = xif . createXMLStreamReader ( source ) ; } finally { Thread . currentThread ( ) . setContextClassLoader ( ccl ) ; } Unmarshaller unmarshaller = jc . createUnmarshaller ( ) ; if ( schema != null ) { unmarshaller . setSchema ( schema ) ; } if ( reader != null ) { return ( PMML ) unmarshaller . unmarshal ( reader ) ; } else { this . results . add ( new PMMLError ( "Unknown error in PMML" ) ) ; return null ; } } catch ( ClassNotFoundException | XMLStreamException | JAXBException e ) { this . results . add ( new PMMLError ( e . toString ( ) ) ) ; return null ; } } | Imports a PMML source file returning a Java descriptor |
7,927 | public Memory createMemory ( final RuleBaseConfiguration config , InternalWorkingMemory wm ) { BetaMemory betaMemory = this . constraints . createBetaMemory ( config , NodeTypeEnums . AccumulateNode ) ; AccumulateMemory memory = this . accumulate . isMultiFunction ( ) ? new MultiAccumulateMemory ( betaMemory , this . accumulate . getAccumulators ( ) ) : new SingleAccumulateMemory ( betaMemory , this . accumulate . getAccumulators ( ) [ 0 ] ) ; memory . workingMemoryContext = this . accumulate . createWorkingMemoryContext ( ) ; memory . resultsContext = this . resultBinder . createContext ( ) ; return memory ; } | Creates a BetaMemory for the BetaNode s memory . |
7,928 | public List < DSLMappingEntry > getEntries ( final DSLMappingEntry . Section section ) { final List < DSLMappingEntry > list = new LinkedList < DSLMappingEntry > ( ) ; for ( final Iterator < DSLMappingEntry > it = this . entries . iterator ( ) ; it . hasNext ( ) ; ) { final DSLMappingEntry entry = it . next ( ) ; if ( entry . getSection ( ) . equals ( section ) ) { list . add ( entry ) ; } } return list ; } | Returns the list of mappings for the given section |
7,929 | private void addInitialFactPattern ( final GroupElement subrule ) { final Pattern pattern = new Pattern ( 0 , ClassObjectType . InitialFact_ObjectType ) ; subrule . addChild ( 0 , pattern ) ; } | Adds a query pattern to the given subrule |
7,930 | public void push ( final RuleConditionElement rce ) { if ( this . buildstack == null ) { this . buildstack = new LinkedList < > ( ) ; } this . buildstack . addLast ( rce ) ; } | Adds the rce to the build stack |
7,931 | ListIterator < RuleConditionElement > stackIterator ( ) { if ( this . buildstack == null ) { this . buildstack = new LinkedList < > ( ) ; } return this . buildstack . listIterator ( this . buildstack . size ( ) ) ; } | Returns a list iterator to iterate over the stacked elements |
7,932 | private Consequence visitConsequence ( VerifierComponent parent , Object o ) { TextConsequence consequence = new TextConsequence ( rule ) ; String text = o . toString ( ) ; StringBuffer buffer = new StringBuffer ( text ) ; int commentIndex = buffer . indexOf ( "//" ) ; while ( commentIndex != - 1 ) { buffer = buffer . delete ( commentIndex , buffer . indexOf ( "\n" , commentIndex ) ) ; commentIndex = buffer . indexOf ( "//" ) ; } text = buffer . toString ( ) ; text = text . replaceAll ( "\n" , "" ) ; text = text . replaceAll ( "\r" , "" ) ; text = text . replaceAll ( "\t" , "" ) ; text = text . replaceAll ( " " , "" ) ; consequence . setText ( text ) ; consequence . setParentPath ( parent . getPath ( ) ) ; consequence . setParentType ( parent . getVerifierComponentType ( ) ) ; data . add ( consequence ) ; return consequence ; } | Creates verifier object from rule consequence . Currently only supports text based consequences . |
7,933 | public void enqueue ( final Activation element ) { if ( isFull ( ) ) { grow ( ) ; } percolateUpMaxHeap ( element ) ; element . setQueued ( true ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Queue Added {} {}" , element . getQueueIndex ( ) , element ) ; } } | Inserts an Queueable into queue . |
7,934 | public Activation dequeue ( ) throws NoSuchElementException { if ( isEmpty ( ) ) { return null ; } final Activation result = this . elements [ 1 ] ; dequeue ( result . getQueueIndex ( ) ) ; return result ; } | Returns the Queueable on top of heap and remove it . |
7,935 | private void grow ( ) { final Activation [ ] elements = new Activation [ this . elements . length * 2 ] ; System . arraycopy ( this . elements , 0 , elements , 0 , this . elements . length ) ; this . elements = elements ; } | Increases the size of the heap to support additional elements |
7,936 | private void removePath ( Collection < InternalWorkingMemory > wms , RuleRemovalContext context , Map < Integer , BaseNode > stillInUse , Collection < ObjectSource > alphas , PathEndNode endNode ) { LeftTupleNode [ ] nodes = endNode . getPathNodes ( ) ; for ( int i = endNode . getPositionInPath ( ) ; i >= 0 ; i -- ) { BaseNode node = ( BaseNode ) nodes [ i ] ; boolean removed = false ; if ( NodeTypeEnums . isLeftTupleNode ( node ) ) { removed = removeLeftTupleNode ( wms , context , stillInUse , node ) ; } if ( removed ) { if ( NodeTypeEnums . isBetaNode ( node ) && ! ( ( BetaNode ) node ) . isRightInputIsRiaNode ( ) ) { alphas . add ( ( ( BetaNode ) node ) . getRightInput ( ) ) ; } else if ( node . getType ( ) == NodeTypeEnums . LeftInputAdapterNode ) { alphas . add ( ( ( LeftInputAdapterNode ) node ) . getObjectSource ( ) ) ; } } if ( NodeTypeEnums . isBetaNode ( node ) && ( ( BetaNode ) node ) . isRightInputIsRiaNode ( ) ) { endNode = ( PathEndNode ) ( ( BetaNode ) node ) . getRightInput ( ) ; removePath ( wms , context , stillInUse , alphas , endNode ) ; return ; } } } | Path s must be removed starting from the outer most path iterating towards the inner most path . Each time it reaches a subnetwork beta node the current path evaluation ends and instead the subnetwork path continues . |
7,937 | public < T extends BaseNode > T attachNode ( BuildContext context , T candidate ) { BaseNode node = null ; RuleBasePartitionId partition = null ; if ( candidate . getType ( ) == NodeTypeEnums . EntryPointNode ) { node = context . getKnowledgeBase ( ) . getRete ( ) . getEntryPointNode ( ( ( EntryPointNode ) candidate ) . getEntryPoint ( ) ) ; partition = RuleBasePartitionId . MAIN_PARTITION ; } else if ( candidate . getType ( ) == NodeTypeEnums . ObjectTypeNode ) { Map < ObjectType , ObjectTypeNode > map = context . getKnowledgeBase ( ) . getRete ( ) . getObjectTypeNodes ( context . getCurrentEntryPoint ( ) ) ; if ( map != null ) { ObjectTypeNode otn = map . get ( ( ( ObjectTypeNode ) candidate ) . getObjectType ( ) ) ; if ( otn != null ) { otn . mergeExpirationOffset ( ( ObjectTypeNode ) candidate ) ; node = otn ; } } partition = RuleBasePartitionId . MAIN_PARTITION ; } else if ( isSharingEnabledForNode ( context , candidate ) ) { if ( ( context . getTupleSource ( ) != null ) && NodeTypeEnums . isLeftTupleSink ( candidate ) ) { node = context . getTupleSource ( ) . getSinkPropagator ( ) . getMatchingNode ( candidate ) ; } else if ( ( context . getObjectSource ( ) != null ) && NodeTypeEnums . isObjectSink ( candidate ) ) { node = context . getObjectSource ( ) . getObjectSinkPropagator ( ) . getMatchingNode ( candidate ) ; } else { throw new RuntimeException ( "This is a bug on node sharing verification. Please report to development team." ) ; } } if ( node != null && ! areNodesCompatibleForSharing ( context , node , candidate ) ) { node = null ; } if ( node == null ) { node = candidate ; if ( partition == null ) { if ( context . getPartitionId ( ) == null ) { context . setPartitionId ( context . getKnowledgeBase ( ) . createNewPartitionId ( ) ) ; } partition = context . getPartitionId ( ) ; } node . setPartitionId ( context , partition ) ; node . attach ( context ) ; context . getNodes ( ) . add ( node ) ; } else { mergeNodes ( node , candidate ) ; context . releaseId ( candidate ) ; if ( partition == null && context . getPartitionId ( ) == null ) { partition = node . getPartitionId ( ) ; context . setPartitionId ( partition ) ; } } node . addAssociation ( context , context . getRule ( ) ) ; return ( T ) node ; } | Attaches a node into the network . If a node already exists that could substitute it is used instead . |
7,938 | private boolean isSharingEnabledForNode ( BuildContext context , BaseNode node ) { if ( NodeTypeEnums . isLeftTupleSource ( node ) ) { return context . getKnowledgeBase ( ) . getConfiguration ( ) . isShareBetaNodes ( ) ; } else if ( NodeTypeEnums . isObjectSource ( node ) ) { return context . getKnowledgeBase ( ) . getConfiguration ( ) . isShareAlphaNodes ( ) ; } return false ; } | Utility function to check if sharing is enabled for nodes of the given class |
7,939 | public BetaConstraints createBetaNodeConstraint ( final BuildContext context , final List < BetaNodeFieldConstraint > list , final boolean disableIndexing ) { BetaConstraints constraints ; switch ( list . size ( ) ) { case 0 : constraints = EmptyBetaConstraints . getInstance ( ) ; break ; case 1 : constraints = new SingleBetaConstraints ( list . get ( 0 ) , context . getKnowledgeBase ( ) . getConfiguration ( ) , disableIndexing ) ; break ; case 2 : constraints = new DoubleBetaConstraints ( list . toArray ( new BetaNodeFieldConstraint [ list . size ( ) ] ) , context . getKnowledgeBase ( ) . getConfiguration ( ) , disableIndexing ) ; break ; case 3 : constraints = new TripleBetaConstraints ( list . toArray ( new BetaNodeFieldConstraint [ list . size ( ) ] ) , context . getKnowledgeBase ( ) . getConfiguration ( ) , disableIndexing ) ; break ; case 4 : constraints = new QuadroupleBetaConstraints ( list . toArray ( new BetaNodeFieldConstraint [ list . size ( ) ] ) , context . getKnowledgeBase ( ) . getConfiguration ( ) , disableIndexing ) ; break ; default : constraints = new DefaultBetaConstraints ( list . toArray ( new BetaNodeFieldConstraint [ list . size ( ) ] ) , context . getKnowledgeBase ( ) . getConfiguration ( ) , disableIndexing ) ; } return constraints ; } | Creates and returns a BetaConstraints object for the given list of constraints |
7,940 | public TemporalDependencyMatrix calculateTemporalDistance ( GroupElement groupElement ) { List < Pattern > events = new ArrayList < Pattern > ( ) ; selectAllEventPatterns ( events , groupElement ) ; final int size = events . size ( ) ; if ( size >= 1 ) { Interval [ ] [ ] source = new Interval [ size ] [ ] ; for ( int row = 0 ; row < size ; row ++ ) { source [ row ] = new Interval [ size ] ; for ( int col = 0 ; col < size ; col ++ ) { if ( row == col ) { source [ row ] [ col ] = new Interval ( 0 , 0 ) ; } else { source [ row ] [ col ] = new Interval ( Interval . MIN , Interval . MAX ) ; } } } Interval [ ] [ ] result ; if ( size > 1 ) { List < Declaration > declarations = new ArrayList < Declaration > ( ) ; int eventIndex = 0 ; for ( Pattern event : events ) { declarations . add ( event . getDeclaration ( ) ) ; Map < Declaration , Interval > temporal = new HashMap < Declaration , Interval > ( ) ; gatherTemporalRelationships ( event . getConstraints ( ) , temporal ) ; for ( Map . Entry < Declaration , Interval > entry : temporal . entrySet ( ) ) { int targetIndex = declarations . indexOf ( entry . getKey ( ) ) ; Interval interval = entry . getValue ( ) ; source [ targetIndex ] [ eventIndex ] . intersect ( interval ) ; Interval reverse = new Interval ( interval . getUpperBound ( ) == Long . MAX_VALUE ? Long . MIN_VALUE : - interval . getUpperBound ( ) , interval . getLowerBound ( ) == Long . MIN_VALUE ? Long . MAX_VALUE : - interval . getLowerBound ( ) ) ; source [ eventIndex ] [ targetIndex ] . intersect ( reverse ) ; } eventIndex ++ ; } result = TimeUtils . calculateTemporalDistance ( source ) ; } else { result = source ; } return new TemporalDependencyMatrix ( result , events ) ; } return null ; } | Calculates the temporal distance between all event patterns in the given subrule . |
7,941 | public boolean equivalent ( final String method1 , final ClassReader class1 , final String method2 , final ClassReader class2 ) { return getMethodBytecode ( method1 , class1 ) . equals ( getMethodBytecode ( method2 , class2 ) ) ; } | This actually does the comparing . Class1 and Class2 are class reader instances to the respective classes . method1 and method2 are looked up on the respective classes and their contents compared . |
7,942 | public String getMethodBytecode ( final String methodName , final ClassReader classReader ) { final Tracer visit = new Tracer ( methodName ) ; classReader . accept ( visit , ClassReader . SKIP_DEBUG ) ; return visit . getText ( ) ; } | This will return a series of bytecode instructions which can be used to compare one method with another . debug info like local var declarations and line numbers are ignored so the focus is on the content . |
7,943 | public void setBounds ( org . kie . dmn . model . api . dmndi . Bounds value ) { this . bounds = value ; } | Sets the value of the bounds property . |
7,944 | public static byte [ ] streamOut ( Object object , boolean compressed ) throws IOException { ByteArrayOutputStream bytes = new ByteArrayOutputStream ( ) ; streamOut ( bytes , object , compressed ) ; bytes . flush ( ) ; bytes . close ( ) ; return bytes . toByteArray ( ) ; } | This routine would stream out the give object uncompressed or compressed depending on the given flag and store the streamed contents in the return byte array . The output contents could only be read by the corresponding streamIn method of this class . |
7,945 | public static void streamOut ( OutputStream out , Object object ) throws IOException { streamOut ( out , object , false ) ; } | This method would stream out the given object to the given output stream uncompressed . The output contents could only be read by the corresponding streamIn method of this class . |
7,946 | public static void streamOut ( OutputStream out , Object object , boolean compressed ) throws IOException { if ( compressed ) { out = new GZIPOutputStream ( out ) ; } DroolsObjectOutputStream doos = null ; try { doos = new DroolsObjectOutputStream ( out ) ; doos . writeObject ( object ) ; } finally { if ( doos != null ) { doos . close ( ) ; } if ( compressed ) { out . close ( ) ; } } } | This method would stream out the given object to the given output stream uncompressed or compressed depending on the given flag . The output contents could only be read by the corresponding streamIn methods of this class . |
7,947 | public static Object streamIn ( byte [ ] bytes , ClassLoader classLoader ) throws IOException , ClassNotFoundException { return streamIn ( bytes , classLoader , false ) ; } | This method reads the contents from the given byte array and returns the object . It is expected that the contents in the given buffer was not compressed and the content stream was written by the corresponding streamOut methods of this class . |
7,948 | public static Object streamIn ( InputStream in , ClassLoader classLoader , boolean compressed ) throws IOException , ClassNotFoundException { if ( compressed ) in = new GZIPInputStream ( in ) ; return new DroolsObjectInputStream ( in , classLoader ) . readObject ( ) ; } | This method reads the contents from the given input stream and returns the object . The contents in the given stream could be compressed or uncompressed depending on the given flag . It is assumed that the content stream was written by the corresponding streamOut methods of this class . |
7,949 | public String nameInCurrentModel ( DMNNode node ) { if ( node . getModelNamespace ( ) . equals ( this . getNamespace ( ) ) ) { return node . getName ( ) ; } else { Optional < String > lookupAlias = getImportAliasFor ( node . getModelNamespace ( ) , node . getModelName ( ) ) ; if ( lookupAlias . isPresent ( ) ) { return lookupAlias . get ( ) + "." + node . getName ( ) ; } else { return null ; } } } | Given a DMNNode compute the proper name of the node considering DMN - Imports . For DMNNode in this current model name is simply the name of the model . For imported DMNNodes this is the name with the prefix of the direct - dependency of the import name . For transitively - imported DMNNodes it is always null . |
7,950 | public PackageDescr parse ( final Resource resource , final String text ) throws DroolsParserException { this . resource = resource ; return parse ( false , text ) ; } | Parse a rule from text |
7,951 | public String getExpandedDRL ( final String source , final Reader dsl ) throws DroolsParserException { DefaultExpanderResolver resolver = getDefaultResolver ( dsl ) ; return getExpandedDRL ( source , resolver ) ; } | This will expand the DRL . useful for debugging . |
7,952 | public String getExpandedDRL ( final String source , final DefaultExpanderResolver resolver ) throws DroolsParserException { final Expander expander = resolver . get ( "*" , null ) ; final String expanded = expander . expand ( source ) ; if ( expander . hasErrors ( ) ) { String err = "" ; for ( ExpanderException ex : expander . getErrors ( ) ) { err = err + "\n Line:[" + ex . getLine ( ) + "] " + ex . getMessage ( ) ; } throw new DroolsParserException ( err ) ; } return expanded ; } | This will expand the DRL using the given expander resolver . useful for debugging . |
7,953 | private void makeErrorList ( final DRLParser parser ) { for ( final DroolsParserException recogErr : lexer . getErrors ( ) ) { final ParserError err = new ParserError ( resource , recogErr . getMessage ( ) , recogErr . getLineNumber ( ) , recogErr . getColumn ( ) ) ; this . results . add ( err ) ; } for ( final DroolsParserException recogErr : parser . getErrors ( ) ) { final ParserError err = new ParserError ( resource , recogErr . getMessage ( ) , recogErr . getLineNumber ( ) , recogErr . getColumn ( ) ) ; this . results . add ( err ) ; } } | Convert the antlr exceptions to drools parser exceptions |
7,954 | public void dumpGrid ( ) { StringBuilder dumpGridSb = new StringBuilder ( ) ; Formatter fmt = new Formatter ( dumpGridSb ) ; fmt . format ( " " ) ; for ( int iCol = 0 ; iCol < 9 ; iCol ++ ) { fmt . format ( "Col: %d " , iCol ) ; } fmt . format ( "\n" ) ; for ( int iRow = 0 ; iRow < 9 ; iRow ++ ) { fmt . format ( "Row " + iRow + ": " ) ; for ( int iCol = 0 ; iCol < 9 ; iCol ++ ) { if ( cells [ iRow ] [ iCol ] . getValue ( ) != null ) { fmt . format ( " --- %d --- " , cells [ iRow ] [ iCol ] . getValue ( ) ) ; } else { StringBuilder sb = new StringBuilder ( ) ; Set < Integer > perms = cells [ iRow ] [ iCol ] . getFree ( ) ; for ( int i = 1 ; i <= 9 ; i ++ ) { if ( perms . contains ( i ) ) { sb . append ( i ) ; } else { sb . append ( ' ' ) ; } } fmt . format ( " %-10s" , sb . toString ( ) ) ; } } fmt . format ( "\n" ) ; } fmt . close ( ) ; System . out . println ( dumpGridSb ) ; } | Nice printout of the grid . |
7,955 | private String getDataType ( final Value value ) { if ( value instanceof BigDecimalValue ) { return DataType . TYPE_NUMERIC_BIGDECIMAL ; } else if ( value instanceof BigIntegerValue ) { return DataType . TYPE_NUMERIC_BIGINTEGER ; } else if ( value instanceof BooleanValue ) { return DataType . TYPE_BOOLEAN ; } else if ( value instanceof ByteValue ) { return DataType . TYPE_NUMERIC_BYTE ; } else if ( value instanceof DateValue ) { return DataType . TYPE_DATE ; } else if ( value instanceof DoubleValue ) { return DataType . TYPE_NUMERIC_DOUBLE ; } else if ( value instanceof FloatValue ) { return DataType . TYPE_NUMERIC_FLOAT ; } else if ( value instanceof IntegerValue ) { return DataType . TYPE_NUMERIC_INTEGER ; } else if ( value instanceof LongValue ) { return DataType . TYPE_NUMERIC_LONG ; } else if ( value instanceof ShortValue ) { return DataType . TYPE_NUMERIC_SHORT ; } else if ( value instanceof EnumValue ) { return DataType . TYPE_COMPARABLE ; } return DataType . TYPE_STRING ; } | Convert a typed Value into legacy DataType |
7,956 | public String packageStatement ( PackageDescrBuilder pkg ) throws RecognitionException { String pkgName = null ; try { helper . start ( pkg , PackageDescrBuilder . class , null ) ; match ( input , DRL5Lexer . ID , DroolsSoftKeywords . PACKAGE , null , DroolsEditorType . KEYWORD ) ; if ( state . failed ) return pkgName ; pkgName = qualifiedIdentifier ( ) ; if ( state . failed ) return pkgName ; if ( state . backtracking == 0 ) { helper . setParaphrasesValue ( DroolsParaphraseTypes . PACKAGE , pkgName ) ; } if ( input . LA ( 1 ) == DRL5Lexer . SEMICOLON ) { match ( input , DRL5Lexer . SEMICOLON , null , null , DroolsEditorType . SYMBOL ) ; if ( state . failed ) return pkgName ; } } catch ( RecognitionException re ) { reportError ( re ) ; } finally { helper . end ( PackageDescrBuilder . class , pkg ) ; } return pkgName ; } | Parses a package statement and returns the name of the package or null if none is defined . |
7,957 | private boolean speculateFullAnnotation ( ) { state . backtracking ++ ; int start = input . mark ( ) ; try { exprParser . fullAnnotation ( null ) ; } catch ( RecognitionException re ) { System . err . println ( "impossible: " + re ) ; re . printStackTrace ( ) ; } boolean success = ! state . failed ; input . rewind ( start ) ; state . backtracking -- ; state . failed = false ; return success ; } | Invokes the expression parser trying to parse the annotation as a full java - style annotation |
7,958 | public String type ( ) throws RecognitionException { String type = "" ; try { int first = input . index ( ) , last = first ; match ( input , DRL5Lexer . ID , null , new int [ ] { DRL5Lexer . DOT , DRL5Lexer . LESS } , DroolsEditorType . IDENTIFIER ) ; if ( state . failed ) return type ; if ( input . LA ( 1 ) == DRL5Lexer . LESS ) { typeArguments ( ) ; if ( state . failed ) return type ; } while ( input . LA ( 1 ) == DRL5Lexer . DOT && input . LA ( 2 ) == DRL5Lexer . ID ) { match ( input , DRL5Lexer . DOT , null , new int [ ] { DRL5Lexer . ID } , DroolsEditorType . IDENTIFIER ) ; if ( state . failed ) return type ; match ( input , DRL5Lexer . ID , null , new int [ ] { DRL5Lexer . DOT } , DroolsEditorType . IDENTIFIER ) ; if ( state . failed ) return type ; if ( input . LA ( 1 ) == DRL5Lexer . LESS ) { typeArguments ( ) ; if ( state . failed ) return type ; } } while ( input . LA ( 1 ) == DRL5Lexer . LEFT_SQUARE && input . LA ( 2 ) == DRL5Lexer . RIGHT_SQUARE ) { match ( input , DRL5Lexer . LEFT_SQUARE , null , new int [ ] { DRL5Lexer . RIGHT_SQUARE } , DroolsEditorType . IDENTIFIER ) ; if ( state . failed ) return type ; match ( input , DRL5Lexer . RIGHT_SQUARE , null , null , DroolsEditorType . IDENTIFIER ) ; if ( state . failed ) return type ; } last = input . LT ( - 1 ) . getTokenIndex ( ) ; type = input . toString ( first , last ) ; type = type . replace ( " " , "" ) ; } catch ( RecognitionException re ) { reportError ( re ) ; } return type ; } | Matches a type name |
7,959 | public String typeArguments ( ) throws RecognitionException { String typeArguments = "" ; try { int first = input . index ( ) ; Token token = match ( input , DRL5Lexer . LESS , null , new int [ ] { DRL5Lexer . QUESTION , DRL5Lexer . ID } , DroolsEditorType . SYMBOL ) ; if ( state . failed ) return typeArguments ; typeArgument ( ) ; if ( state . failed ) return typeArguments ; while ( input . LA ( 1 ) == DRL5Lexer . COMMA ) { token = match ( input , DRL5Lexer . COMMA , null , new int [ ] { DRL5Lexer . QUESTION , DRL5Lexer . ID } , DroolsEditorType . IDENTIFIER ) ; if ( state . failed ) return typeArguments ; typeArgument ( ) ; if ( state . failed ) return typeArguments ; } token = match ( input , DRL5Lexer . GREATER , null , null , DroolsEditorType . SYMBOL ) ; if ( state . failed ) return typeArguments ; typeArguments = input . toString ( first , token . getTokenIndex ( ) ) ; } catch ( RecognitionException re ) { reportError ( re ) ; } return typeArguments ; } | Matches type arguments |
7,960 | public String conditionalExpression ( ) throws RecognitionException { int first = input . index ( ) ; exprParser . conditionalExpression ( ) ; if ( state . failed ) return null ; if ( state . backtracking == 0 && input . index ( ) > first ) { String expr = input . toString ( first , input . LT ( - 1 ) . getTokenIndex ( ) ) ; return expr ; } return null ; } | Matches a conditional expression |
7,961 | protected Token recoverFromMismatchedToken ( TokenStream input , int ttype , String text , int [ ] follow ) throws RecognitionException { RecognitionException e = null ; if ( mismatchIsUnwantedToken ( input , ttype , text ) ) { e = new UnwantedTokenException ( ttype , input ) ; input . consume ( ) ; reportError ( e ) ; Token matchedSymbol = input . LT ( 1 ) ; input . consume ( ) ; return matchedSymbol ; } if ( mismatchIsMissingToken ( input , follow ) ) { e = new MissingTokenException ( ttype , input , null ) ; reportError ( e ) ; return null ; } if ( text != null ) { e = new DroolsMismatchedTokenException ( ttype , text , input ) ; } else { e = new MismatchedTokenException ( ttype , input ) ; } throw e ; } | Attempt to recover from a single missing or extra token . |
7,962 | public JavaCompiler createCompiler ( final String pHint ) { final String className ; if ( pHint . indexOf ( '.' ) < 0 ) { className = "org.drools.compiler.commons.jci.compilers." + ClassUtils . toJavaCasing ( pHint ) + "JavaCompiler" ; } else { className = pHint ; } Class clazz = ( Class ) classCache . get ( className ) ; if ( clazz == null ) { try { clazz = Class . forName ( className ) ; classCache . put ( className , clazz ) ; } catch ( ClassNotFoundException e ) { clazz = null ; } } if ( clazz == null ) { return null ; } try { return ( JavaCompiler ) clazz . newInstance ( ) ; } catch ( Throwable t ) { return null ; } } | Tries to guess the class name by convention . So for compilers following the naming convention |
7,963 | public static OtherwiseBuilder getBuilder ( ConditionCol52 c ) { if ( c . getOperator ( ) . equals ( "==" ) ) { return new EqualsOtherwiseBuilder ( ) ; } else if ( c . getOperator ( ) . equals ( "!=" ) ) { return new NotEqualsOtherwiseBuilder ( ) ; } throw new IllegalArgumentException ( "ConditionCol operator does not support Otherwise values" ) ; } | Retrieve the correct OtherwiseBuilder for the given column |
7,964 | private static List < DTCellValue52 > extractColumnData ( List < List < DTCellValue52 > > data , int columnIndex ) { List < DTCellValue52 > columnData = new ArrayList < DTCellValue52 > ( ) ; for ( List < DTCellValue52 > row : data ) { columnData . add ( row . get ( columnIndex ) ) ; } return columnData ; } | Extract data relating to a single column |
7,965 | private void processClassWithByteCode ( final Class < ? > clazz , final InputStream stream , final boolean includeFinalMethods ) throws IOException { final ClassReader reader = new ClassReader ( stream ) ; final ClassFieldVisitor visitor = new ClassFieldVisitor ( clazz , includeFinalMethods , this ) ; reader . accept ( visitor , 0 ) ; if ( clazz . getSuperclass ( ) != null ) { final String name = getResourcePath ( clazz . getSuperclass ( ) ) ; final InputStream parentStream = clazz . getResourceAsStream ( name ) ; if ( parentStream != null ) { try { processClassWithByteCode ( clazz . getSuperclass ( ) , parentStream , includeFinalMethods ) ; } finally { parentStream . close ( ) ; } } else { processClassWithoutByteCode ( clazz . getSuperclass ( ) , includeFinalMethods ) ; } } if ( clazz . isInterface ( ) ) { final Class < ? > [ ] interfaces = clazz . getInterfaces ( ) ; for ( Class < ? > anInterface : interfaces ) { final String name = getResourcePath ( anInterface ) ; final InputStream parentStream = clazz . getResourceAsStream ( name ) ; if ( parentStream != null ) { try { processClassWithByteCode ( anInterface , parentStream , includeFinalMethods ) ; } finally { parentStream . close ( ) ; } } else { processClassWithoutByteCode ( anInterface , includeFinalMethods ) ; } } } } | Walk up the inheritance hierarchy recursively reading in fields |
7,966 | public FieldDefinition getField ( int index ) { if ( index >= fields . size ( ) || index < 0 ) { return null ; } Iterator < FieldDefinition > iter = fields . values ( ) . iterator ( ) ; for ( int j = 0 ; j < index ; j ++ ) { iter . next ( ) ; } return iter . next ( ) ; } | Returns the field at position index as defined by the builder using the |
7,967 | private void initDataDictionaryMap ( ) { DataDictionary dd = rawPmml . getDataDictionary ( ) ; if ( dd != null ) { dataDictionaryMap = new HashMap < > ( ) ; for ( DataField dataField : dd . getDataFields ( ) ) { PMMLDataField df = new PMMLDataField ( dataField ) ; dataDictionaryMap . put ( df . getName ( ) , df ) ; } } else { throw new IllegalStateException ( "BRMS-PMML requires a data dictionary section in the definition file" ) ; } } | Initializes the internal structure that holds data dictionary information . This initializer should be called prior to any other initializers since many other structures may have a dependency on the data dictionary . |
7,968 | public List < MiningField > getMiningFieldsForModel ( String modelId ) { PMML4Model model = modelsMap . get ( modelId ) ; if ( model != null ) { return model . getRawMiningFields ( ) ; } return null ; } | Retrieves a List of the raw MiningField objects for a given model |
7,969 | public Map < String , List < MiningField > > getMiningFields ( ) { Map < String , List < MiningField > > miningFieldsMap = new HashMap < > ( ) ; for ( PMML4Model model : getModels ( ) ) { List < MiningField > miningFields = model . getRawMiningFields ( ) ; miningFieldsMap . put ( model . getModelId ( ) , miningFields ) ; model . getChildModels ( ) ; } return miningFieldsMap ; } | Retrieves a Map with entries that consist of key - > a model identifier value - > the List of raw MiningField objects belonging to the model referenced by the key |
7,970 | public Map < String , PMML4Model > getChildModels ( String parentModelId ) { PMML4Model parent = modelsMap . get ( parentModelId ) ; Map < String , PMML4Model > childMap = parent . getChildModels ( ) ; return ( childMap != null && ! childMap . isEmpty ( ) ) ? new HashMap < > ( childMap ) : new HashMap < > ( ) ; } | Retrieves a Map whose entries consist of key - > a model identifier value - > the PMML4Model object that the key refers to where the PMML4Model indicates that it |
7,971 | public static List < List < DTCellValue52 > > makeDataLists ( Object [ ] [ ] oldData ) { List < List < DTCellValue52 > > newData = new ArrayList < List < DTCellValue52 > > ( ) ; for ( int iRow = 0 ; iRow < oldData . length ; iRow ++ ) { Object [ ] oldRow = oldData [ iRow ] ; List < DTCellValue52 > newRow = makeDataRowList ( oldRow ) ; newData . add ( newRow ) ; } return newData ; } | Convert a two - dimensional array of Strings to a List of Lists with type - safe individual entries |
7,972 | public static List < DTCellValue52 > makeDataRowList ( Object [ ] oldRow ) { List < DTCellValue52 > row = new ArrayList < DTCellValue52 > ( ) ; if ( oldRow [ 0 ] instanceof String ) { DTCellValue52 rowDcv = new DTCellValue52 ( new Integer ( ( String ) oldRow [ 0 ] ) ) ; row . add ( rowDcv ) ; } else if ( oldRow [ 0 ] instanceof Number ) { DTCellValue52 rowDcv = new DTCellValue52 ( ( ( Number ) oldRow [ 0 ] ) . intValue ( ) ) ; row . add ( rowDcv ) ; } else { DTCellValue52 rowDcv = new DTCellValue52 ( oldRow [ 0 ] ) ; row . add ( rowDcv ) ; } for ( int iCol = 1 ; iCol < oldRow . length ; iCol ++ ) { DTCellValue52 dcv = new DTCellValue52 ( oldRow [ iCol ] ) ; row . add ( dcv ) ; } return row ; } | Convert a single dimension array of Strings to a List with type - safe entries . The first entry is converted into a numerical row number |
7,973 | public static void createSegmentMemory ( LeftTupleSource tupleSource , InternalWorkingMemory wm ) { Memory mem = wm . getNodeMemory ( ( MemoryFactory ) tupleSource ) ; SegmentMemory smem = mem . getSegmentMemory ( ) ; if ( smem == null ) { createSegmentMemory ( tupleSource , mem , wm ) ; } } | Initialises the NodeSegment memory for all nodes in the segment . |
7,974 | public static boolean inSubNetwork ( RightInputAdapterNode riaNode , LeftTupleSource leftTupleSource ) { LeftTupleSource startTupleSource = riaNode . getStartTupleSource ( ) ; LeftTupleSource parent = riaNode . getLeftTupleSource ( ) ; while ( parent != startTupleSource ) { if ( parent == leftTupleSource ) { return true ; } parent = parent . getLeftTupleSource ( ) ; } return false ; } | Is the LeftTupleSource a node in the sub network for the RightInputAdapterNode To be in the same network it must be a node is after the two output of the parent and before the rianode . |
7,975 | private static int updateRiaAndTerminalMemory ( LeftTupleSource lt , LeftTupleSource originalLt , SegmentMemory smem , InternalWorkingMemory wm , boolean fromPrototype , int nodeTypesInSegment ) { nodeTypesInSegment = checkSegmentBoundary ( lt , wm , nodeTypesInSegment ) ; for ( LeftTupleSink sink : lt . getSinkPropagator ( ) . getSinks ( ) ) { if ( NodeTypeEnums . isLeftTupleSource ( sink ) ) { nodeTypesInSegment = updateRiaAndTerminalMemory ( ( LeftTupleSource ) sink , originalLt , smem , wm , fromPrototype , nodeTypesInSegment ) ; } else if ( sink . getType ( ) == NodeTypeEnums . RightInputAdaterNode ) { RiaNodeMemory riaMem = ( RiaNodeMemory ) wm . getNodeMemory ( ( MemoryFactory ) sink ) ; if ( inSubNetwork ( ( RightInputAdapterNode ) sink , originalLt ) ) { PathMemory pmem = riaMem . getRiaPathMemory ( ) ; smem . addPathMemory ( pmem ) ; if ( smem . getPos ( ) < pmem . getSegmentMemories ( ) . length ) { pmem . setSegmentMemory ( smem . getPos ( ) , smem ) ; } if ( fromPrototype ) { ObjectSink [ ] nodes = ( ( RightInputAdapterNode ) sink ) . getObjectSinkPropagator ( ) . getSinks ( ) ; for ( ObjectSink node : nodes ) { if ( NodeTypeEnums . isLeftTupleSource ( node ) && wm . getNodeMemory ( ( MemoryFactory ) node ) . getSegmentMemory ( ) == null ) { restoreSegmentFromPrototype ( wm , ( LeftTupleSource ) node , nodeTypesInSegment ) ; } } } else if ( ( pmem . getAllLinkedMaskTest ( ) & ( 1L << pmem . getSegmentMemories ( ) . length ) ) == 0 ) { ObjectSink [ ] nodes = ( ( RightInputAdapterNode ) sink ) . getObjectSinkPropagator ( ) . getSinks ( ) ; for ( ObjectSink node : nodes ) { if ( NodeTypeEnums . isLeftTupleSource ( node ) ) { createSegmentMemory ( ( LeftTupleSource ) node , wm ) ; } } } } } else if ( NodeTypeEnums . isTerminalNode ( sink ) ) { PathMemory pmem = ( PathMemory ) wm . getNodeMemory ( ( MemoryFactory ) sink ) ; smem . addPathMemory ( pmem ) ; if ( smem . getPos ( ) < pmem . getSegmentMemories ( ) . length ) { pmem . setSegmentMemory ( smem . getPos ( ) , smem ) ; if ( smem . isSegmentLinked ( ) ) { smem . notifyRuleLinkSegment ( wm ) ; } checkEagerSegmentCreation ( sink . getLeftTupleSource ( ) , wm , nodeTypesInSegment ) ; } } } return nodeTypesInSegment ; } | This adds the segment memory to the terminal node or ria node s list of memories . In the case of the terminal node this allows it to know that all segments from the tip to root are linked . In the case of the ria node its all the segments up to the start of the subnetwork . This is because the rianode only cares if all of it s segments are linked then it sets the bit of node it is the right input for . |
7,976 | public static boolean isRootNode ( LeftTupleNode node , TerminalNode removingTN ) { return node . getType ( ) == NodeTypeEnums . LeftInputAdapterNode || isNonTerminalTipNode ( node . getLeftTupleSource ( ) , removingTN ) ; } | Returns whether the node is the root of a segment . Lians are always the root of a segment . |
7,977 | public static void build ( final RuleBuildContext context ) { RuleDescr ruleDescr = context . getRuleDescr ( ) ; final RuleConditionBuilder builder = ( RuleConditionBuilder ) context . getDialect ( ) . getBuilder ( ruleDescr . getLhs ( ) . getClass ( ) ) ; if ( builder != null ) { Pattern prefixPattern = context . getPrefixPattern ( ) ; final GroupElement ce = ( GroupElement ) builder . build ( context , getLhsForRuleUnit ( context . getRule ( ) , ruleDescr . getLhs ( ) ) , prefixPattern ) ; context . getRule ( ) . setLhs ( ce ) ; } else { throw new RuntimeException ( "BUG: builder not found for descriptor class " + ruleDescr . getLhs ( ) . getClass ( ) ) ; } buildAttributes ( context ) ; if ( ! ( ruleDescr instanceof QueryDescr ) ) { ConsequenceBuilder consequenceBuilder = context . getDialect ( ) . getConsequenceBuilder ( ) ; consequenceBuilder . build ( context , RuleImpl . DEFAULT_CONSEQUENCE_NAME ) ; for ( String name : ruleDescr . getNamedConsequences ( ) . keySet ( ) ) { consequenceBuilder . build ( context , name ) ; } } } | Build the give rule into the |
7,978 | public static List < Import > getImportList ( final List < String > importCells ) { final List < Import > importList = new ArrayList < Import > ( ) ; if ( importCells == null ) return importList ; for ( String importCell : importCells ) { final StringTokenizer tokens = new StringTokenizer ( importCell , "," ) ; while ( tokens . hasMoreTokens ( ) ) { final Import imp = new Import ( ) ; imp . setClassName ( tokens . nextToken ( ) . trim ( ) ) ; importList . add ( imp ) ; } } return importList ; } | Create a list of Import model objects from cell contents . |
7,979 | public static List < Global > getVariableList ( final List < String > variableCells ) { final List < Global > variableList = new ArrayList < Global > ( ) ; if ( variableCells == null ) return variableList ; for ( String variableCell : variableCells ) { final StringTokenizer tokens = new StringTokenizer ( variableCell , "," ) ; while ( tokens . hasMoreTokens ( ) ) { final String token = tokens . nextToken ( ) ; final Global vars = new Global ( ) ; final StringTokenizer paramTokens = new StringTokenizer ( token , " " ) ; vars . setClassName ( paramTokens . nextToken ( ) ) ; if ( ! paramTokens . hasMoreTokens ( ) ) { throw new DecisionTableParseException ( "The format for global variables is incorrect. " + "It should be: [Class name, Class otherName]. But it was: [" + variableCell + "]" ) ; } vars . setIdentifier ( paramTokens . nextToken ( ) ) ; variableList . add ( vars ) ; } } return variableList ; } | Create a list of Global model objects from cell contents . |
7,980 | public static String rc2name ( int row , int col ) { StringBuilder sb = new StringBuilder ( ) ; int b = 26 ; int p = 1 ; if ( col >= b ) { col -= b ; p *= b ; } if ( col >= b * b ) { col -= b * b ; p *= b ; } while ( p > 0 ) { sb . append ( ( char ) ( col / p + ( int ) 'A' ) ) ; col %= p ; p /= b ; } sb . append ( row + 1 ) ; return sb . toString ( ) ; } | Convert spreadsheet row column numbers to a cell name . |
7,981 | public static void addNewActionType ( final Map < Integer , ActionType > actionTypeMap , final String value , final int column , final int row ) { final String ucValue = value . toUpperCase ( ) ; Code code = tag2code . get ( ucValue ) ; if ( code == null ) { code = tag2code . get ( ucValue . substring ( 0 , 1 ) ) ; } if ( code != null ) { int count = 0 ; for ( ActionType at : actionTypeMap . values ( ) ) { if ( at . getCode ( ) == code ) { count ++ ; } } if ( count >= code . getMaxCount ( ) ) { throw new DecisionTableParseException ( "Maximum number of " + code . getColHeader ( ) + "/" + code . getColShort ( ) + " columns is " + code . getMaxCount ( ) + ", in cell " + RuleSheetParserUtil . rc2name ( row , column ) ) ; } actionTypeMap . put ( new Integer ( column ) , new ActionType ( code ) ) ; } else { throw new DecisionTableParseException ( "Invalid column header: " + value + ", should be CONDITION, ACTION or attribute, " + "in cell " + RuleSheetParserUtil . rc2name ( row , column ) ) ; } } | Create a new action type that matches this cell and add it to the map keyed on that column . |
7,982 | public void addTemplate ( int row , int column , String content ) { if ( this . sourceBuilder == null ) { throw new DecisionTableParseException ( "Unexpected content \"" + content + "\" in cell " + RuleSheetParserUtil . rc2name ( row , column ) + ", leave this cell blank" ) ; } this . sourceBuilder . addTemplate ( row , column , content ) ; } | This is where a code snippet template is added . |
7,983 | public void addCellValue ( int row , int column , String content , boolean _escapeQuotesFlag , boolean trimCell ) { if ( _escapeQuotesFlag ) { int idx = content . indexOf ( "\"" ) ; if ( idx > 0 && content . indexOf ( "\"" , idx ) > - 1 ) { content = content . replace ( "\"" , "\\\"" ) ; } } this . sourceBuilder . addCellValue ( row , column , content , trimCell ) ; } | Values are added to populate the template . The source builder contained needs to be cleared when the resultant snippet is extracted . |
7,984 | public String typeArgument ( ) throws RecognitionException { String typeArgument = "" ; try { int first = input . index ( ) , last = first ; int next = input . LA ( 1 ) ; switch ( next ) { case DRL6Lexer . QUESTION : match ( input , DRL6Lexer . QUESTION , null , null , DroolsEditorType . SYMBOL ) ; if ( state . failed ) return typeArgument ; if ( helper . validateIdentifierKey ( DroolsSoftKeywords . EXTENDS ) ) { match ( input , DRL6Lexer . ID , DroolsSoftKeywords . EXTENDS , null , DroolsEditorType . SYMBOL ) ; if ( state . failed ) return typeArgument ; type ( ) ; if ( state . failed ) return typeArgument ; } else if ( helper . validateIdentifierKey ( DroolsSoftKeywords . SUPER ) ) { match ( input , DRL6Lexer . ID , DroolsSoftKeywords . SUPER , null , DroolsEditorType . SYMBOL ) ; if ( state . failed ) return typeArgument ; type ( ) ; if ( state . failed ) return typeArgument ; } break ; case DRL6Lexer . ID : type ( ) ; if ( state . failed ) return typeArgument ; break ; default : } last = input . LT ( - 1 ) . getTokenIndex ( ) ; typeArgument = input . toString ( first , last ) ; } catch ( RecognitionException re ) { reportError ( re ) ; } return typeArgument ; } | Matches a type argument |
7,985 | public String qualifiedIdentifier ( ) throws RecognitionException { String qi = "" ; try { Token first = match ( input , DRL6Lexer . ID , null , new int [ ] { DRL6Lexer . DOT } , DroolsEditorType . IDENTIFIER ) ; if ( state . failed ) return qi ; Token last = first ; while ( input . LA ( 1 ) == DRL6Lexer . DOT && input . LA ( 2 ) == DRL6Lexer . ID ) { last = match ( input , DRL6Lexer . DOT , null , new int [ ] { DRL6Lexer . ID } , DroolsEditorType . IDENTIFIER ) ; if ( state . failed ) return qi ; last = match ( input , DRL6Lexer . ID , null , new int [ ] { DRL6Lexer . DOT } , DroolsEditorType . IDENTIFIER ) ; if ( state . failed ) return qi ; } qi = input . toString ( first , last ) ; qi = qi . replace ( " " , "" ) ; } catch ( RecognitionException re ) { reportError ( re ) ; } return qi ; } | Matches a qualified identifier |
7,986 | public String chunk ( final int leftDelimiter , final int rightDelimiter , final int location ) { String chunk = "" ; int first = - 1 , last = first ; try { match ( input , leftDelimiter , null , null , DroolsEditorType . SYMBOL ) ; if ( state . failed ) return chunk ; if ( state . backtracking == 0 && location >= 0 ) { helper . emit ( location ) ; } int nests = 0 ; first = input . index ( ) ; while ( input . LA ( 1 ) != DRL6Lexer . EOF && ( input . LA ( 1 ) != rightDelimiter || nests > 0 ) ) { if ( input . LA ( 1 ) == rightDelimiter ) { nests -- ; } else if ( input . LA ( 1 ) == leftDelimiter ) { nests ++ ; } input . consume ( ) ; } last = input . LT ( - 1 ) . getTokenIndex ( ) ; for ( int i = first ; i < last + 1 ; i ++ ) { helper . emit ( input . get ( i ) , DroolsEditorType . CODE_CHUNK ) ; } match ( input , rightDelimiter , null , null , DroolsEditorType . SYMBOL ) ; if ( state . failed ) return chunk ; } catch ( RecognitionException re ) { reportError ( re ) ; } finally { if ( last >= first ) { chunk = input . toString ( first , last ) ; } } return chunk ; } | Matches a chunk started by the leftDelimiter and ended by the rightDelimiter . |
7,987 | Token match ( TokenStream input , int ttype , String text , int [ ] follow , DroolsEditorType etype ) throws RecognitionException { Token matchedSymbol = null ; matchedSymbol = input . LT ( 1 ) ; if ( input . LA ( 1 ) == ttype && ( text == null || text . equals ( matchedSymbol . getText ( ) ) ) ) { input . consume ( ) ; state . errorRecovery = false ; state . failed = false ; helper . emit ( matchedSymbol , etype ) ; return matchedSymbol ; } if ( state . backtracking > 0 ) { state . failed = true ; return matchedSymbol ; } matchedSymbol = recoverFromMismatchedToken ( input , ttype , text , follow ) ; helper . emit ( matchedSymbol , etype ) ; return matchedSymbol ; } | Match current input symbol against ttype and optionally check the text of the token against text . Attempt single token insertion or deletion error recovery . If that fails throw MismatchedTokenException . |
7,988 | private void processData ( final ResultSet rs , List < DataListener > listeners ) { try { ResultSetMetaData rsmd = rs . getMetaData ( ) ; int colCount = rsmd . getColumnCount ( ) ; int i = 0 ; while ( rs . next ( ) ) { newRow ( listeners , i , colCount ) ; for ( int cellNum = 1 ; cellNum < colCount + 1 ; cellNum ++ ) { String cell ; int sqlType = rsmd . getColumnType ( cellNum ) ; switch ( sqlType ) { case java . sql . Types . DATE : cell = rs . getDate ( cellNum ) . toString ( ) ; break ; case java . sql . Types . INTEGER : case java . sql . Types . DOUBLE : cell = String . valueOf ( rs . getInt ( cellNum ) ) ; break ; default : cell = rs . getString ( cellNum ) ; } newCell ( listeners , i , cellNum - 1 , cell , DataListener . NON_MERGED ) ; } i ++ ; } } catch ( SQLException e ) { } finishData ( listeners ) ; } | Iterate through the resultset . |
7,989 | public static String toBuildableType ( String className , ClassLoader loader ) { int arrayDim = BuildUtils . externalArrayDimSize ( className ) ; String prefix = "" ; String coreType = arrayDim == 0 ? className : className . substring ( 0 , className . indexOf ( "[" ) ) ; coreType = typeName2ClassName ( coreType , loader ) ; if ( arrayDim > 0 ) { coreType = BuildUtils . getTypeDescriptor ( coreType ) ; for ( int j = 0 ; j < arrayDim ; j ++ ) { prefix = "[" + prefix ; } } else { return coreType ; } return prefix + coreType ; } | not the cleanest logic but this is what the builders expect downstream |
7,990 | private static QName recurseUpToInferTypeRef ( DMNModelImpl model , OutputClause originalElement , DMNElement recursionIdx ) { if ( recursionIdx . getParent ( ) instanceof Decision ) { InformationItem parentVariable = ( ( Decision ) recursionIdx . getParent ( ) ) . getVariable ( ) ; if ( parentVariable != null ) { return variableTypeRefOrErrIfNull ( model , parentVariable ) ; } else { return null ; } } else if ( recursionIdx . getParent ( ) instanceof BusinessKnowledgeModel ) { InformationItem parentVariable = ( ( BusinessKnowledgeModel ) recursionIdx . getParent ( ) ) . getVariable ( ) ; if ( parentVariable != null ) { return variableTypeRefOrErrIfNull ( model , parentVariable ) ; } else { return null ; } } else if ( recursionIdx . getParent ( ) instanceof ContextEntry ) { ContextEntry parentCtxEntry = ( ContextEntry ) recursionIdx . getParent ( ) ; if ( parentCtxEntry . getVariable ( ) != null ) { return variableTypeRefOrErrIfNull ( model , parentCtxEntry . getVariable ( ) ) ; } else { Context parentCtx = ( Context ) parentCtxEntry . getParent ( ) ; if ( parentCtx . getContextEntry ( ) . get ( parentCtx . getContextEntry ( ) . size ( ) - 1 ) . equals ( parentCtxEntry ) ) { return recurseUpToInferTypeRef ( model , originalElement , parentCtx ) ; } else { MsgUtil . reportMessage ( logger , DMNMessage . Severity . ERROR , parentCtxEntry , model , null , null , Msg . MISSING_VARIABLE_ON_CONTEXT , parentCtxEntry ) ; return null ; } } } else { MsgUtil . reportMessage ( logger , DMNMessage . Severity . ERROR , originalElement , model , null , null , Msg . UNKNOWN_OUTPUT_TYPE_FOR_DT_ON_NODE , originalElement . getParentDRDElement ( ) . getIdentifierString ( ) ) ; return null ; } } | Utility method for DecisionTable with only 1 output to infer typeRef from parent |
7,991 | private static QName variableTypeRefOrErrIfNull ( DMNModelImpl model , InformationItem variable ) { if ( variable . getTypeRef ( ) != null ) { return variable . getTypeRef ( ) ; } else { MsgUtil . reportMessage ( logger , DMNMessage . Severity . ERROR , variable , model , null , null , Msg . MISSING_TYPEREF_FOR_VARIABLE , variable . getName ( ) , variable . getParentDRDElement ( ) . getIdentifierString ( ) ) ; return null ; } } | Utility method to have a error message is reported if a DMN Variable is missing typeRef . |
7,992 | public static Date parseDate ( final String input ) { try { return df . get ( ) . parse ( input ) ; } catch ( final ParseException e ) { try { return new SimpleDateFormat ( DATE_FORMAT_MASK , Locale . UK ) . parse ( input ) ; } catch ( ParseException e1 ) { throw new IllegalArgumentException ( "Invalid date input format: [" + input + "] it should follow: [" + DATE_FORMAT_MASK + "]" ) ; } } } | Use the simple date formatter to read the date from a string |
7,993 | public static Date getRightDate ( final Object object2 ) { if ( object2 == null ) { return null ; } if ( object2 instanceof String ) { return parseDate ( ( String ) object2 ) ; } else if ( object2 instanceof Date ) { return ( Date ) object2 ; } else { throw new IllegalArgumentException ( "Unable to convert " + object2 . getClass ( ) + " to a Date." ) ; } } | Converts the right hand side date as appropriate |
7,994 | public static String getDateFormatMask ( ) { String fmt = System . getProperty ( "drools.dateformat" ) ; if ( fmt == null ) { fmt = DEFAULT_FORMAT_MASK ; } return fmt ; } | Check for the system property override if it exists |
7,995 | public static boolean hasDSLSentences ( final GuidedDecisionTable52 model ) { for ( CompositeColumn < ? extends BaseColumn > column : model . getConditions ( ) ) { if ( column instanceof BRLConditionColumn ) { final BRLConditionColumn brlColumn = ( BRLConditionColumn ) column ; for ( IPattern pattern : brlColumn . getDefinition ( ) ) { if ( pattern instanceof DSLSentence ) { return true ; } } } } for ( ActionCol52 column : model . getActionCols ( ) ) { if ( column instanceof BRLActionColumn ) { final BRLActionColumn brlColumn = ( BRLActionColumn ) column ; for ( IAction action : brlColumn . getDefinition ( ) ) { if ( action instanceof DSLSentence ) { return true ; } } } } return false ; } | a DataModelOracle just to determine whether the model has DSLs is an expensive operation and not needed here . |
7,996 | public void setFillColor ( org . kie . dmn . model . api . dmndi . Color value ) { this . fillColor = value ; } | Sets the value of the fillColor property . |
7,997 | public void setStrokeColor ( org . kie . dmn . model . api . dmndi . Color value ) { this . strokeColor = value ; } | Sets the value of the strokeColor property . |
7,998 | public void setFontColor ( org . kie . dmn . model . api . dmndi . Color value ) { this . fontColor = value ; } | Sets the value of the fontColor property . |
7,999 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.