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 . p...
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_a...
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 ) { retur...
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 + ex...
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 ( ) ; ret...
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 ( justN...
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 = obj...
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 . r...
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 . setNe...
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 (...
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 . current...
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 . a...
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 ( ...
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 . ...
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 -- ) { ...
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 ) ...
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 ( ) . get...
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 Sin...
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 r...
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 ...
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...
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 : e...
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 DroolsP...
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 . forma...
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 (...
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 ...
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 ( st...
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 ) == DRL5Lex...
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 ; typeA...
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 (...
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 ) ;...
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 ...
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 ...
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 (...
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 ) ; } }...
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 )...
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 = makeDataRowL...
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 ] i...
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 tru...
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 . getSinkPropaga...
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 al...
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 . getP...
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 (...
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 ,...
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 ...
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 ) ) ; } i...
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 ...
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 . addC...
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 ...
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...
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 ) ...
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 ( ) ...
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 ++ ) {...
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 , load...
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 ) { retu...
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_VARIABL...
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 forma...
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 ...
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 . getD...
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 message...
Get all messages of a particular type