Example usage for org.apache.commons.lang.text StrSubstitutor StrSubstitutor

List of usage examples for org.apache.commons.lang.text StrSubstitutor StrSubstitutor

Introduction

In this page you can find the example usage for org.apache.commons.lang.text StrSubstitutor StrSubstitutor.

Prototype

public StrSubstitutor(StrLookup variableResolver) 

Source Link

Document

Creates a new instance and initializes it.

Usage

From source file:com.appdynamics.monitors.azure.statsCollector.AzureServiceBusStatsCollector.java

private Set<String> getResourceNames(String namespaceName, Configuration config, String resourceType)
        throws MalformedURLException {
    Map<String, String> valueMap = new HashMap<String, String>();
    Azure azure = config.getAzure();//www  .jav a2s.  com
    valueMap.put("SubscriptionId", azure.getSubscriptionId());
    valueMap.put("NameSpace", namespaceName);
    valueMap.put("ResourceType", resourceType);
    StrSubstitutor strSubstitutor = new StrSubstitutor(valueMap);
    String resourceNamesUrlString = strSubstitutor.replace(RESOURCE_NAMES_URL);
    URL resourceNamesUrl = new URL(resourceNamesUrlString);
    InputStream inputStream = processGetRequest(resourceNamesUrl, azure.getKeyStoreLocation(),
            azure.getKeyStorePassword());

    XStream xstream = new XStream();
    xstream.ignoreUnknownElements();
    xstream.processAnnotations(Feed.class);
    xstream.processAnnotations(Entry.class);
    Feed feed = (Feed) xstream.fromXML(inputStream);

    Set<String> topicNames = new HashSet<String>();
    List<Entry> entries = feed.getEntries();
    if (entries != null && !entries.isEmpty()) {
        for (Entry entry : entries) {
            topicNames.add(entry.getTitle());
        }
    }
    return topicNames;
}

From source file:com.virtualparadigm.packman.processor.JPackageManagerOld.java

public static boolean configureCommons(File tempDir, Configuration configuration) {
    logger.info("PackageManager::configure()");
    boolean status = true;
    if (tempDir != null && configuration != null && !configuration.isEmpty()) {

        Map<String, String> substitutionContext = JPackageManagerOld.createSubstitutionContext(configuration);
        StrSubstitutor strSubstitutor = new StrSubstitutor(substitutionContext);
        String templateContent = null;
        long lastModified;

        Collection<File> patchFiles = FileUtils.listFiles(
                new File(tempDir.getAbsolutePath() + "/" + JPackageManagerOld.PATCH_DIR_NAME + "/"
                        + JPackageManagerOld.PATCH_FILES_DIR_NAME),
                TEMPLATE_SUFFIX_FILE_FILTER, DirectoryFileFilter.DIRECTORY);

        if (patchFiles != null) {
            for (File pfile : patchFiles) {
                logger.debug("  processing patch fileset file: " + pfile.getAbsolutePath());
                try {
                    lastModified = pfile.lastModified();
                    templateContent = FileUtils.readFileToString(pfile);
                    templateContent = strSubstitutor.replace(templateContent);
                    FileUtils.writeStringToFile(pfile, templateContent);
                    pfile.setLastModified(lastModified);
                } catch (Exception e) {
                    e.printStackTrace();
                }/*from w w  w  .  ja v a2  s . c o  m*/
            }
        }

        Collection<File> scriptFiles = FileUtils.listFiles(
                new File(tempDir.getAbsolutePath() + "/" + JPackageManagerOld.AUTORUN_DIR_NAME),
                TEMPLATE_SUFFIX_FILE_FILTER, DirectoryFileFilter.DIRECTORY);

        if (scriptFiles != null) {
            for (File scriptfile : scriptFiles) {
                logger.debug("  processing script file: " + scriptfile.getAbsolutePath());
                try {
                    lastModified = scriptfile.lastModified();
                    templateContent = FileUtils.readFileToString(scriptfile);
                    templateContent = strSubstitutor.replace(templateContent);
                    FileUtils.writeStringToFile(scriptfile, templateContent);
                    scriptfile.setLastModified(lastModified);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
    return status;
}

From source file:com.googlecode.jatl.MarkupBuilder.java

private String expand(String text) {
    StrSubstitutor s = new StrSubstitutor(bindings);
    return s.replace(text);
}

From source file:ddf.test.itests.common.Library.java

/**
 * Variables to be replaced in a resource file should be in the format: $variableName$
 * The variable to replace in the file should also also match the parameter names of the method calling getFileContent.
 *
 * @param filePath// w w w.  j  a va 2 s. com
 * @param params
 * @return
 */
public static String getFileContent(String filePath, ImmutableMap<String, String> params) {

    StrSubstitutor strSubstitutor = new StrSubstitutor(params);

    strSubstitutor.setVariablePrefix(VARIABLE_DELIMETER);
    strSubstitutor.setVariableSuffix(VARIABLE_DELIMETER);
    String fileContent = null;

    try {
        fileContent = org.apache.commons.io.IOUtils.toString(Library.class.getResourceAsStream(filePath),
                "UTF-8");
    } catch (IOException e) {
        throw new RuntimeException("Failed to read filepath: " + filePath);
    }

    return strSubstitutor.replace(fileContent);
}

From source file:net.firejack.platform.generate.tools.Render.java

public String replace(String value) {
    Map<String, String> map = settings.get();
    StrSubstitutor substitutor = parser.get();
    if (substitutor == null && map != null) {
        substitutor = new StrSubstitutor(map);
        parser.set(substitutor);/*from   ww w .  j a v a2s  .co m*/
        return substitutor.replace(value);
    } else if (map != null && substitutor != null) {
        return substitutor.replace(value);
    }
    return value;
}

From source file:ddf.test.itests.catalog.TestSpatial.java

private String getPagingMaxRecordsQuery(int maxRecords) {
    String rawCswQuery = savedCswQueries.get("CswPagingTestLikeQuery");
    StrSubstitutor strSubstitutor = new StrSubstitutor(ImmutableMap.of("maxRecords", "" + maxRecords));

    strSubstitutor.setVariablePrefix(RESOURCE_VARIABLE_DELIMETER);
    strSubstitutor.setVariableSuffix(RESOURCE_VARIABLE_DELIMETER);
    return strSubstitutor.replace(rawCswQuery);
}

From source file:ddf.test.itests.catalog.TestSpatial.java

private String substitutePagingParams(String rawCswRecord, int testNum, String identifier) {
    StrSubstitutor strSubstitutor = new StrSubstitutor(
            ImmutableMap.of("identifier", identifier, "testNum", "" + testNum));

    strSubstitutor.setVariablePrefix(RESOURCE_VARIABLE_DELIMETER);
    strSubstitutor.setVariableSuffix(RESOURCE_VARIABLE_DELIMETER);
    return strSubstitutor.replace(rawCswRecord);
}

From source file:com.virtualparadigm.packman.processor.JPackageManager.java

public static void main(String[] args) {

    //       ST stringTemplate = null;
    //       String templateContent = null;
    //        //from w ww  . j  av  a2 s  .co  m
    //        
    //        try
    //        {
    //            Configuration configuration = new PropertiesConfiguration(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/install.properties"));
    //           
    //           
    //           templateContent = FileUtils.readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/server.xml"));
    //           templateContent = templateContent.replace("${", "\\${");
    //           System.out.println(templateContent);
    //           System.out.println();
    //           System.out.println();
    //           System.out.println();
    //           
    //           stringTemplate = new ST(JPackageManager.ST_GROUP, templateContent);
    ////           stringTemplate = new ST(FileUtils.readFileToString(pfile));
    //           JPackageManager.addTemplateAttributes(stringTemplate, configuration);
    //           templateContent = stringTemplate.render();
    //           templateContent = templateContent.replace("\\${", "${");
    //           System.out.println(templateContent);
    //        }
    //        catch(Exception e)
    //        {
    //            e.printStackTrace();
    //        }

    //       try
    //       {
    //          String str = "${foo} $bar$";
    //          str = str.replace("${", "\\${");
    //          System.out.println(str);
    //          
    //          
    //           STGroup stGroup = new STGroup('$', '$');
    //           ST stringTemplate = new ST(stGroup, str);
    //           stringTemplate.add("bar", "yoyoyo");
    //           str = stringTemplate.render();
    //           System.out.println(str);
    //           
    //          str = str.replace("\\${", "${");
    //           System.out.println(str);
    //          
    ////           STGroup stGroup = new STGroup('$', '$');
    ////           ST stringTemplate = new ST(stGroup, FileUtils.readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/logging.properties")));
    ////           ST stringTemplate = new ST(FileUtils.readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/logging.properties")));
    ////           
    ////           stringTemplate.add("bar_yo", "yoyoyo");
    ////           
    ////           
    ////           System.out.println(stringTemplate.render());
    //          
    //       }
    //       catch(Exception e)
    //       {
    //          e.printStackTrace();
    //       }

    ////       String foo = "handler.FILE.fileName=#{org.jboss.boot.log.file:boot.log}\nyoyoyoyo\nrem ###       \nREM#";
    //       String foo = "rem ### -*- batch file -*- ######################################################\r\n" + 
    //"rem #                                                                          ##\r\n" + 
    //"rem #  JBoss Bootstrap Script Configuration                                    ##\r\n" +
    //"rem #                                                                          ##\r\n" +
    //"rem #############################################################################\r\n";
    //       String regex = "(#)(\\{)([^\\}]*)(\\:)([^\\}]*)(\\})";
    ////       String regex = "(#)(\\{)([^\\{]*)(\\:)([^\\}]*)(\\})";
    ////       String regex = "(#)(\\{*)(\\:)(^*\\})";
    //       System.out.println("regex=" + regex);
    //       System.out.println("foo=" + foo);
    ////        foo = foo.replaceAll(regex, "\\$$2$3$4$5$6");
    //        foo = foo.replaceAll(regex, "\\$$2$3$4$5$6");
    //       System.out.println("foo=" + foo);

    //        VelocityEngine velocityEngine = new VelocityEngine();
    //        Properties vProps = new Properties();
    //      vProps.setProperty("resource.loader", "string");
    //      vProps.setProperty("string.resource.loader.class", "org.apache.velocity.runtime.resource.loader.StringResourceLoader");      
    //      velocityEngine.init(vProps);
    //        Template template = null;
    //        
    //        try
    //        {
    //            VelocityContext velocityContext = JPackageManager.createVelocityContext(new PropertiesConfiguration("C:/dev/workbench/paradigm-workspace/jpackage-manager/install.properties"));
    //          StringResourceRepository stringResourceRepository = StringResourceLoader.getRepository();
    //          String templateContent = null;
    //            StringWriter stringWriter = null;
    //           
    ////           templateContent = FileUtils.readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/appclient.conf.bat"));
    ////           templateContent = "rem ### -*- batch file -*- ######################################################\r\n";
    //           templateContent = "rem %%% -*- batch file -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n";
    //           
    //           
    //            Pattern pattern = Pattern.compile("(\\$)(\\{)([^\\}]*)(\\:)([^\\{]*)(\\})");
    //            Matcher matcher = pattern.matcher(templateContent);
    //            if(matcher.matches())
    //           {
    //              System.out.println("    converting # to $");
    //              matcher.replaceAll("\\$$2$3$4$5$6");
    //           }
    //            else
    //            {
    //              System.out.println("    NOPE");
    //            }
    //           
    ////           templateContent = templateContent.replaceAll("(\\$)(\\{)([^\\}]*)(\\:)([^\\}]*)(\\})", "#$2$3$4$5$6");
    //           System.out.println("content=" + templateContent);
    //           
    //           stringResourceRepository.putStringResource(JPackageManager.CURRENT_TEMPLATE_NAME, templateContent);
    //           stringWriter = new StringWriter();
    //            template = velocityEngine.getTemplate(JPackageManager.CURRENT_TEMPLATE_NAME);
    //            template.merge(velocityContext, stringWriter);
    //            
    //            templateContent = stringWriter.toString();
    //            
    //            Pattern pattern2 = Pattern.compile("(\\$)(\\{)([^\\}]*)(\\:)([^\\{]*)(\\})");
    //            Matcher matcher2 = pattern2.matcher(templateContent);
    //            if(matcher2.matches())
    //           {
    //              System.out.println("    converting # to $");
    //              matcher2.replaceAll("\\$$2$3$4$5$6");
    //           }
    //            else
    //            {
    //              System.out.println("    NOPE");
    //            }
    ////            templateContent = templateContent.replaceAll("(#)(\\{)([^\\}]*)(\\:)([^\\{]*)(\\})", "\\$$2$3$4$5$6");
    //
    //            System.out.println(templateContent);
    //        }
    //        catch(Exception e)
    //        {
    //            e.printStackTrace();
    //        }
    //        
    //        

    ////       StringTemplate templ = new StringTemplate("foo $fo$bo$r$ yo");
    ////       templ.setAttribute("success", "foobar");
    ////       templ.setAttribute("bo", "oba");
    ////        System.out.println(templ.toString());
    //        
    //        
    //        
    //        try
    //        {
    ////           StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
    //           String firstTemplate = "firstTemplate";
    //           String content = "this should ${foobar} ${foo:bar.0.1}";
    //           String updatedContent = "this should ${foobar} #{foo:bar.0.1}";
    ////           String content = "this should ${foo:bar}";
    //
    ////           System.out.println(content.matches("\\$\\{.*\\:.*\\}"));
    //           
    ////           System.out.println(content.replaceAll("\\$\\{.*\\:.*\\}", "hahaha"));
    ////           System.out.println(content.replaceAll("(\\$\\{.*)(\\:)(.*\\})", "$1-$3"));
    ////           System.out.println(content.replaceAll("(\\$\\{.*)(\\:)(.*\\})", "$1-$3"));
    ////           System.out.println(content.replaceAll("(\\$)(\\{.*)(\\:)(.*\\})", "#$2$3$4"));
    //           System.out.println(updatedContent.replaceAll("(#)(\\{)([^\\}]*)(\\:)([^\\}]*)(\\})", "\\$$2$3$4$5$6"));
    //           System.out.println(content.replaceAll("(\\$)(\\{)(.*)(\\:)(.*)(\\})", "--$2$3$4$5$6--"));
    //           System.out.println(content.replaceAll("(\\$)(\\{\\w*\\:\\w*\\})", "#$2"));
    //           
    ////           stringTemplateLoader.putTemplate(firstTemplate, "this should ${foobar} ${foo:bar}");
    ////           
    ////            freemarker.template.Configuration freeMarkerConfiguration = new freemarker.template.Configuration();
    ////            freeMarkerConfiguration.setTemplateLoader(stringTemplateLoader);
    ////           Template template = freeMarkerConfiguration.getTemplate(firstTemplate);           
    ////            Map<String, Object> valueMap = new HashMap<String, Object>();
    ////            valueMap.put("foobar", "helloworld");
    ////            
    ////            Writer out = new OutputStreamWriter(System.out);
    ////            template.process(valueMap, out);
    ////            out.flush();
    ////            
    ////            freeMarkerConfiguration.clearTemplateCache();
    //           
    //        }
    //        catch(Exception e)
    //        {
    //           e.printStackTrace();
    //        }
    //        
    //        
    //        
    //        
    //      System.out.println("");
    //      System.out.println("");
    //        
    //        

    //      VelocityEngine velocityEngine = new VelocityEngine();
    //      Properties vProps = new Properties();
    ////      vProps.put("file.resource.loader.path", "");
    //      vProps.setProperty("resource.loader", "string");
    //      vProps.setProperty("string.resource.loader.class", "org.apache.velocity.runtime.resource.loader.StringResourceLoader");      
    //      velocityEngine.init(vProps);
    //      Template template = null;
    //      
    //
    //      try
    //      {
    //         
    //         
    //         Configuration configuration = new PropertiesConfiguration(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/install.properties"));
    //           VelocityContext velocityContext = JPackageManager.createVelocityContext(configuration);
    //           
    //         
    //         StringResourceRepository repository = StringResourceLoader.getRepository();
    //         String strTemplate = FileUtils.readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/domain.sh"));
    //               
    //               
    ////         strTemplate = strTemplate.replace(":", "\\:");
    //         strTemplate = strTemplate.replaceAll("(\\$)(\\{)([^\\}]*)(\\:)([^\\}]*)(\\})", "#$2$3$4$5$6");
    //         strTemplate = strTemplate.replaceAll("(\\$)(\\{)([^\\}]*)([^a-zA-Z\\d\\_])*([^\\}]*)(\\})", "#$2$3$4$5$6");
    //         
    //System.out.println(strTemplate);         
    //      
    //         repository.putStringResource("template", strTemplate);
    //         StringWriter writer = new StringWriter();
    //         template = velocityEngine.getTemplate("template");
    //         template.merge(velocityContext, writer);
    //         
    //         
    //         String strResult = writer.toString().replaceAll("(\\#)(\\{)([^\\}]*)(\\:)([^\\}]*)(\\})", "$$2$3$4$5$6");
    //
    //         
    //         System.out.println(strResult);
    //      }
    //      catch (Exception e)
    //      {
    //          e.printStackTrace();
    //      }

    try {

        Configuration configuration = new PropertiesConfiguration(
                new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/install.properties"));

        Map<String, String> substitutionContext = JPackageManager.createSubstitutionContext(configuration);
        StrSubstitutor strSubstitutor = new StrSubstitutor(substitutionContext);

        String strTemplate = FileUtils
                .readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/domain.sh"));

        System.out.println(strTemplate);

        System.out.println(strSubstitutor.replace(strTemplate));
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:com.impetus.ankush2.ganglia.GangliaDeployer.java

public String getConfigurationContent(String host, String confFileName) throws Exception {
    String fileContent = null;//from ww w  . j av a  2 s. com
    Map<String, Object> configValues = getConfigValueMap();

    String udpRecvChannel = "udp_recv_channel {\n port = " + configValues.get("port") + " \n } ";
    // 'udp_recv_channel' value for gmond.conf
    configValues.put("udp_recv_channel", "/*" + udpRecvChannel + "*/");

    if (((String) advanceConf.get(GangliaConstants.ClusterProperties.GMETAD_HOST)).equals(host)) {
        StringBuffer nodeIpPorts = new StringBuffer();
        // Preparing a String of nodeIp:port of gmetad node used in
        // data_source in gmetad.conf.
        nodeIpPorts.append(advanceConf.get(GangliaConstants.ClusterProperties.GMETAD_HOST))
                .append(Symbols.STR_COLON);
        nodeIpPorts.append(advanceConf.get(GangliaConstants.ClusterProperties.GANGLIA_PORT));
        // Putting the nodeIpsPorts string in map
        configValues.put("nodeIpsPorts", nodeIpPorts.toString());
        // On gmond nodes other than Gmetad node commenting
        // udp_recv_channel block
        configValues.put("udp_recv_channel", udpRecvChannel);
    }
    // Reading the content of the template file
    fileContent = FileUtil.readAsString(new File(confFileName));

    // Creating a string substitutor using config values map
    StrSubstitutor sub = new StrSubstitutor(configValues);

    // Replacing the config values key found in the file content with
    // respected values.
    return sub.replace(fileContent);
}

From source file:com.virtualparadigm.packman.processor.JPackageManagerOld.java

public static void main(String[] args) {

    //       ST stringTemplate = null;
    //       String templateContent = null;
    //        //from w w w .j a va 2s  . c  o m
    //        
    //        try
    //        {
    //            Configuration configuration = new PropertiesConfiguration(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/install.properties"));
    //           
    //           
    //           templateContent = FileUtils.readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/server.xml"));
    //           templateContent = templateContent.replace("${", "\\${");
    //           System.out.println(templateContent);
    //           System.out.println();
    //           System.out.println();
    //           System.out.println();
    //           
    //           stringTemplate = new ST(JPackageManager.ST_GROUP, templateContent);
    ////           stringTemplate = new ST(FileUtils.readFileToString(pfile));
    //           JPackageManager.addTemplateAttributes(stringTemplate, configuration);
    //           templateContent = stringTemplate.render();
    //           templateContent = templateContent.replace("\\${", "${");
    //           System.out.println(templateContent);
    //        }
    //        catch(Exception e)
    //        {
    //            e.printStackTrace();
    //        }

    //       try
    //       {
    //          String str = "${foo} $bar$";
    //          str = str.replace("${", "\\${");
    //          System.out.println(str);
    //          
    //          
    //           STGroup stGroup = new STGroup('$', '$');
    //           ST stringTemplate = new ST(stGroup, str);
    //           stringTemplate.add("bar", "yoyoyo");
    //           str = stringTemplate.render();
    //           System.out.println(str);
    //           
    //          str = str.replace("\\${", "${");
    //           System.out.println(str);
    //          
    ////           STGroup stGroup = new STGroup('$', '$');
    ////           ST stringTemplate = new ST(stGroup, FileUtils.readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/logging.properties")));
    ////           ST stringTemplate = new ST(FileUtils.readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/logging.properties")));
    ////           
    ////           stringTemplate.add("bar_yo", "yoyoyo");
    ////           
    ////           
    ////           System.out.println(stringTemplate.render());
    //          
    //       }
    //       catch(Exception e)
    //       {
    //          e.printStackTrace();
    //       }

    ////       String foo = "handler.FILE.fileName=#{org.jboss.boot.log.file:boot.log}\nyoyoyoyo\nrem ###       \nREM#";
    //       String foo = "rem ### -*- batch file -*- ######################################################\r\n" + 
    //"rem #                                                                          ##\r\n" + 
    //"rem #  JBoss Bootstrap Script Configuration                                    ##\r\n" +
    //"rem #                                                                          ##\r\n" +
    //"rem #############################################################################\r\n";
    //       String regex = "(#)(\\{)([^\\}]*)(\\:)([^\\}]*)(\\})";
    ////       String regex = "(#)(\\{)([^\\{]*)(\\:)([^\\}]*)(\\})";
    ////       String regex = "(#)(\\{*)(\\:)(^*\\})";
    //       System.out.println("regex=" + regex);
    //       System.out.println("foo=" + foo);
    ////        foo = foo.replaceAll(regex, "\\$$2$3$4$5$6");
    //        foo = foo.replaceAll(regex, "\\$$2$3$4$5$6");
    //       System.out.println("foo=" + foo);

    //        VelocityEngine velocityEngine = new VelocityEngine();
    //        Properties vProps = new Properties();
    //      vProps.setProperty("resource.loader", "string");
    //      vProps.setProperty("string.resource.loader.class", "org.apache.velocity.runtime.resource.loader.StringResourceLoader");      
    //      velocityEngine.init(vProps);
    //        Template template = null;
    //        
    //        try
    //        {
    //            VelocityContext velocityContext = JPackageManager.createVelocityContext(new PropertiesConfiguration("C:/dev/workbench/paradigm-workspace/jpackage-manager/install.properties"));
    //          StringResourceRepository stringResourceRepository = StringResourceLoader.getRepository();
    //          String templateContent = null;
    //            StringWriter stringWriter = null;
    //           
    ////           templateContent = FileUtils.readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/appclient.conf.bat"));
    ////           templateContent = "rem ### -*- batch file -*- ######################################################\r\n";
    //           templateContent = "rem %%% -*- batch file -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\r\n";
    //           
    //           
    //            Pattern pattern = Pattern.compile("(\\$)(\\{)([^\\}]*)(\\:)([^\\{]*)(\\})");
    //            Matcher matcher = pattern.matcher(templateContent);
    //            if(matcher.matches())
    //           {
    //              System.out.println("    converting # to $");
    //              matcher.replaceAll("\\$$2$3$4$5$6");
    //           }
    //            else
    //            {
    //              System.out.println("    NOPE");
    //            }
    //           
    ////           templateContent = templateContent.replaceAll("(\\$)(\\{)([^\\}]*)(\\:)([^\\}]*)(\\})", "#$2$3$4$5$6");
    //           System.out.println("content=" + templateContent);
    //           
    //           stringResourceRepository.putStringResource(JPackageManager.CURRENT_TEMPLATE_NAME, templateContent);
    //           stringWriter = new StringWriter();
    //            template = velocityEngine.getTemplate(JPackageManager.CURRENT_TEMPLATE_NAME);
    //            template.merge(velocityContext, stringWriter);
    //            
    //            templateContent = stringWriter.toString();
    //            
    //            Pattern pattern2 = Pattern.compile("(\\$)(\\{)([^\\}]*)(\\:)([^\\{]*)(\\})");
    //            Matcher matcher2 = pattern2.matcher(templateContent);
    //            if(matcher2.matches())
    //           {
    //              System.out.println("    converting # to $");
    //              matcher2.replaceAll("\\$$2$3$4$5$6");
    //           }
    //            else
    //            {
    //              System.out.println("    NOPE");
    //            }
    ////            templateContent = templateContent.replaceAll("(#)(\\{)([^\\}]*)(\\:)([^\\{]*)(\\})", "\\$$2$3$4$5$6");
    //
    //            System.out.println(templateContent);
    //        }
    //        catch(Exception e)
    //        {
    //            e.printStackTrace();
    //        }
    //        
    //        

    ////       StringTemplate templ = new StringTemplate("foo $fo$bo$r$ yo");
    ////       templ.setAttribute("success", "foobar");
    ////       templ.setAttribute("bo", "oba");
    ////        System.out.println(templ.toString());
    //        
    //        
    //        
    //        try
    //        {
    ////           StringTemplateLoader stringTemplateLoader = new StringTemplateLoader();
    //           String firstTemplate = "firstTemplate";
    //           String content = "this should ${foobar} ${foo:bar.0.1}";
    //           String updatedContent = "this should ${foobar} #{foo:bar.0.1}";
    ////           String content = "this should ${foo:bar}";
    //
    ////           System.out.println(content.matches("\\$\\{.*\\:.*\\}"));
    //           
    ////           System.out.println(content.replaceAll("\\$\\{.*\\:.*\\}", "hahaha"));
    ////           System.out.println(content.replaceAll("(\\$\\{.*)(\\:)(.*\\})", "$1-$3"));
    ////           System.out.println(content.replaceAll("(\\$\\{.*)(\\:)(.*\\})", "$1-$3"));
    ////           System.out.println(content.replaceAll("(\\$)(\\{.*)(\\:)(.*\\})", "#$2$3$4"));
    //           System.out.println(updatedContent.replaceAll("(#)(\\{)([^\\}]*)(\\:)([^\\}]*)(\\})", "\\$$2$3$4$5$6"));
    //           System.out.println(content.replaceAll("(\\$)(\\{)(.*)(\\:)(.*)(\\})", "--$2$3$4$5$6--"));
    //           System.out.println(content.replaceAll("(\\$)(\\{\\w*\\:\\w*\\})", "#$2"));
    //           
    ////           stringTemplateLoader.putTemplate(firstTemplate, "this should ${foobar} ${foo:bar}");
    ////           
    ////            freemarker.template.Configuration freeMarkerConfiguration = new freemarker.template.Configuration();
    ////            freeMarkerConfiguration.setTemplateLoader(stringTemplateLoader);
    ////           Template template = freeMarkerConfiguration.getTemplate(firstTemplate);           
    ////            Map<String, Object> valueMap = new HashMap<String, Object>();
    ////            valueMap.put("foobar", "helloworld");
    ////            
    ////            Writer out = new OutputStreamWriter(System.out);
    ////            template.process(valueMap, out);
    ////            out.flush();
    ////            
    ////            freeMarkerConfiguration.clearTemplateCache();
    //           
    //        }
    //        catch(Exception e)
    //        {
    //           e.printStackTrace();
    //        }
    //        
    //        
    //        
    //        
    //      System.out.println("");
    //      System.out.println("");
    //        
    //        

    //      VelocityEngine velocityEngine = new VelocityEngine();
    //      Properties vProps = new Properties();
    ////      vProps.put("file.resource.loader.path", "");
    //      vProps.setProperty("resource.loader", "string");
    //      vProps.setProperty("string.resource.loader.class", "org.apache.velocity.runtime.resource.loader.StringResourceLoader");      
    //      velocityEngine.init(vProps);
    //      Template template = null;
    //      
    //
    //      try
    //      {
    //         
    //         
    //         Configuration configuration = new PropertiesConfiguration(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/install.properties"));
    //           VelocityContext velocityContext = JPackageManager.createVelocityContext(configuration);
    //           
    //         
    //         StringResourceRepository repository = StringResourceLoader.getRepository();
    //         String strTemplate = FileUtils.readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/domain.sh"));
    //               
    //               
    ////         strTemplate = strTemplate.replace(":", "\\:");
    //         strTemplate = strTemplate.replaceAll("(\\$)(\\{)([^\\}]*)(\\:)([^\\}]*)(\\})", "#$2$3$4$5$6");
    //         strTemplate = strTemplate.replaceAll("(\\$)(\\{)([^\\}]*)([^a-zA-Z\\d\\_])*([^\\}]*)(\\})", "#$2$3$4$5$6");
    //         
    //System.out.println(strTemplate);         
    //      
    //         repository.putStringResource("template", strTemplate);
    //         StringWriter writer = new StringWriter();
    //         template = velocityEngine.getTemplate("template");
    //         template.merge(velocityContext, writer);
    //         
    //         
    //         String strResult = writer.toString().replaceAll("(\\#)(\\{)([^\\}]*)(\\:)([^\\}]*)(\\})", "$$2$3$4$5$6");
    //
    //         
    //         System.out.println(strResult);
    //      }
    //      catch (Exception e)
    //      {
    //          e.printStackTrace();
    //      }

    try {

        Configuration configuration = new PropertiesConfiguration(
                new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/install.properties"));

        Map<String, String> substitutionContext = JPackageManagerOld.createSubstitutionContext(configuration);
        StrSubstitutor strSubstitutor = new StrSubstitutor(substitutionContext);

        String strTemplate = FileUtils
                .readFileToString(new File("C:/dev/workbench/paradigm-workspace/jpackage-manager/domain.sh"));

        System.out.println(strTemplate);

        System.out.println(strSubstitutor.replace(strTemplate));
    } catch (Exception e) {
        e.printStackTrace();
    }

}