public void addDSLMapping(DSLMappingEntry entry) { DSLSentence sen = new DSLSentence(); sen.setDefinition(entry.getMappingKey()); if (entry.getSection() == DSLMappingEntry.CONDITION) { this.conditionDSLSentences.add(sen); } else if (entry.getSection() == DSLMappingEntry.CONSEQUENCE) { this.actionDSLSentences.add(sen); } else if (entry.getSection() == DSLMappingEntry.KEYWORD) { this.keywordDSLItems.add(sen); } else if (entry.getSection() == DSLMappingEntry.ANY) { this.anyScopeDSLItems.add(sen); } }
/** * Clean up constructions that exists only in the unexpanded code * * @param drl * @return */ private String cleanupExpressions(String drl) { // execute cleanup for ( final DSLMappingEntry entry : this.cleanup ) { drl = entry.getKeyPattern().matcher( drl ).replaceAll( entry.getValuePattern() ); } return drl; }
Map<String, Integer> vars = entry.getVariables(); String mappingKey = entry.getMappingKey(); String vp = entry.getValuePattern(); Pattern kp = entry.getKeyPattern(); Matcher m = kp.matcher( exp ); int startPos = 0; vp = entry.getValuePattern(); Matcher allkeyMat = allkeyPat.matcher( vp );
/** * Returns the list of mappings for the given section * @param section * @return */ public List<DSLMappingEntry> getEntries(final 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; }
logger.info( "keyword: " + entry.getMappingKey() ); logger.info( " " + entry.getKeyPattern() ); logger.info( "when: " + entry.getMappingKey() ); logger.info( " " + entry.getKeyPattern() ); logger.info( "then: " + entry.getMappingKey() ); logger.info( " " + entry.getKeyPattern() );
/** * Add the new mapping to this expander. * * @param mapping */ public void addDSLMapping(final DSLMapping mapping) { for ( DSLMappingEntry entry : mapping.getEntries() ) { if ( DSLMappingEntry.KEYWORD.equals( entry.getSection() ) ) { this.keywords.add( entry ); } else if ( DSLMappingEntry.CONDITION.equals( entry.getSection() ) ) { this.condition.add( entry ); } else if ( DSLMappingEntry.CONSEQUENCE.equals( entry.getSection() ) ) { this.consequence.add( entry ); } else { // if any, then add to them both condition and consequence this.condition.add( entry ); this.consequence.add( entry ); } } if ( mapping.getOption( "result" ) ) showResult = true; if ( mapping.getOption( "steps" ) ) showSteps = true; if ( mapping.getOption( "keyword" ) ) showKeyword = true; if ( mapping.getOption( "when" ) ) showWhen = true; if ( mapping.getOption( "then" ) ) showThen = true; if ( mapping.getOption( "usage" ) ) showUsage = true; }
public void addDSLMapping(DSLMappingEntry entry) { DSLSentence sen = new DSLSentence(); sen.setDefinition(entry.getMappingKey()); if (entry.getSection() == DSLMappingEntry.CONDITION) { this.conditionDSLSentences.add(sen); } else if (entry.getSection() == DSLMappingEntry.CONSEQUENCE) { this.actionDSLSentences.add(sen); } else if (entry.getSection() == DSLMappingEntry.KEYWORD) { this.keywordDSLItems.add(sen); } else if (entry.getSection() == DSLMappingEntry.ANY) { this.anyScopeDSLItems.add(sen); } }
@Test public void testTestAnyEnum() throws Exception { SuggestionCompletionLoader suggestionCompletionLoader = new SuggestionCompletionLoader(); ArrayList<DSLTokenizedMappingFile> dsls = new ArrayList<DSLTokenizedMappingFile>(); DSLTokenizedMappingFile dslTokenizedMappingFile = new DSLTokenizedMappingFile(); DSLMappingEntry dslMappingEntry = mock( DSLMappingEntry.class ); when( dslMappingEntry.getSection() ).thenReturn( DSLMappingEntry.ANY ); dslTokenizedMappingFile.getMapping().addEntry( dslMappingEntry ); dsls.add( dslTokenizedMappingFile ); SuggestionCompletionEngine suggestionEngine = suggestionCompletionLoader.getSuggestionEngine( "", Collections.<JarInputStream> emptyList(), dsls ); assertEquals( 1, suggestionEngine.actionDSLSentences.length ); assertEquals( 1, suggestionEngine.conditionDSLSentences.length ); assertEquals( 0, suggestionEngine.keywordDSLItems.length ); }
private void populateDSLSentences(final List<DSLTokenizedMappingFile> dsls) { for ( DSLTokenizedMappingFile file : dsls ) { for ( DSLMappingEntry entry : file.getMapping().getEntries() ) { if ( entry.getSection() == DSLMappingEntry.CONDITION ) { builder.addDSLConditionSentence( entry.getMappingKey() ); } else if ( entry.getSection() == DSLMappingEntry.CONSEQUENCE ) { builder.addDSLActionSentence( entry.getMappingKey() ); } else if ( entry.getSection() == DSLMappingEntry.KEYWORD ) { builder.addDSLMapping( entry ); } else if ( entry.getSection() == DSLMappingEntry.ANY ) { builder.addDSLConditionSentence( entry.getMappingKey() ); builder.addDSLActionSentence( entry.getMappingKey() ); } } } }
private void populateDSLSentences(final List<DSLTokenizedMappingFile> dsls) { for ( DSLTokenizedMappingFile file : dsls ) { for ( DSLMappingEntry entry : file.getMapping().getEntries() ) { if ( entry.getSection() == DSLMappingEntry.CONDITION ) { builder.addDSLConditionSentence( entry.getMappingKey() ); } else if ( entry.getSection() == DSLMappingEntry.CONSEQUENCE ) { builder.addDSLActionSentence( entry.getMappingKey() ); } else if ( entry.getSection() == DSLMappingEntry.KEYWORD ) { builder.addDSLMapping( entry ); } else if ( entry.getSection() == DSLMappingEntry.ANY ) { builder.addDSLConditionSentence( entry.getMappingKey() ); builder.addDSLActionSentence( entry.getMappingKey() ); } } } }
when(mapping1.getSection()).thenReturn(DSLMappingEntry.CONDITION ); when(mapping1.getMappingKey()).thenReturn("cond"); when(mapping2.getSection()).thenReturn(DSLMappingEntry.CONSEQUENCE ); when(mapping2.getMappingKey()).thenReturn("cons"); when(mapping3.getSection()).thenReturn(DSLMappingEntry.ANY ); when(mapping3.getMappingKey()).thenReturn("any"); when(mapping4.getSection()).thenReturn(DSLMappingEntry.KEYWORD ); when(mapping4.getMappingKey()).thenReturn("key");