View Javadoc

1   /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may	obtain a copy of the License at
7    *
8    * 	http://www.osedu.org/licenses/ECL-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krms.impl.repository.language;
17  
18  import java.util.Map;
19  import org.kuali.rice.krms.api.repository.language.NaturalLanguageTemplate;
20  import org.kuali.rice.krms.api.repository.language.NaturalLanguageTemplaterContract;
21  
22  /**
23   * A dead simple implementation of the templater contract for testing
24   * @author nwright
25   */
26  public class SimpleNaturalLanguageTemplater implements NaturalLanguageTemplaterContract {
27  
28      @Override
29      public String translate(NaturalLanguageTemplate naturalLanguageTemplate, Map<String, Object> contextMap) {
30          StringBuilder sb = new StringBuilder (naturalLanguageTemplate.getTemplate());
31          sb.append(" applied with the following ");
32          sb.append (contextMap.size());        
33          sb.append(" variables: ");
34          String comma = "";
35          for (String key : contextMap.keySet()) {
36              sb.append (comma);
37              comma = ",";
38              sb.append ("[");
39              sb.append (key);
40              sb.append ("=");
41              sb.append (contextMap.get(key));
42              sb.append ("]");
43          }
44          return sb.toString();
45      }
46       
47  }