/** * Saves current mapping into a DSL mapping file * @param out * @throws IOException */ public void saveMapping(final Writer out) throws IOException { for ( final Iterator it = this.mapping.getEntries().iterator(); it.hasNext(); ) { out.write( it.next().toString() ); out.write( "\n" ); } }
/** * 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; }
((entry_scope)entry_stack.peek()).retval.setValuePattern(((entry_scope)entry_stack.peek()).valuebuffer.toString()); mappingEntry = ((entry_scope)entry_stack.peek()).retval; ((mapping_file_scope)mapping_file_stack.peek()).retval.addEntry(mappingEntry);
mapping.setOptions( optionSet ); setMapping( mapping ); List<ParserError> moderr = new ArrayList<ParserError>();
@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 ); }
/** * Method to return the current mapping as a String object * @return */ public String dumpFile() { final StringBuilder buf = new StringBuilder(); for ( final Iterator it = this.mapping.getEntries().iterator(); it.hasNext(); ) { buf.append( it.next() ); buf.append( "\n" ); } return buf.toString(); }
/** * Saves the given mapping into a DSL mapping file * * @param out * @param mapping * @throws IOException */ public static void saveMapping(final Writer out, final DSLMapping mapping) throws IOException { for ( final Iterator it = mapping.getEntries().iterator(); it.hasNext(); ) { out.write( it.next().toString() ); out.write( "\n" ); } }
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() ); } } } }