java字符串占位符替换工具类_GitHub - mawenjian/string-format-util: 一个功能强大的多层级Java字符串/占位符替换工具.A powerful Java-bas...

StringFormatUtil

StringFormatUtil是一个基于Java开发的功能强大的多层级字符串/占位符替换工具.

StringFormatUtil is a powerful Java-based multi-level string / placeholder replacement tool.

简介

其它类似替换工具的不足

尽管网络上很早就有类似的字符串/占位符替换工具,但是它们只能实现类似{replacement}形式的单层字符串/占位符替换,在使用过程中具有很大的局限性,不能满足我们的业务需要。这也是我造这个轮子的直接原因。

StringFormatUtil的优势

便捷性更高。不同于网络上的这些工具类,StringFormatUtil基于Java的反射技术,实现了字符串/占位符的多层级替换,可以实现诸如{china.beijing.haidian}形式的替换,使用上更加方便。

可定制性更强。如果我们提供的几种默认方式不能满足开发需要,开发者可以通过实现类中的PostHandleIface接口,实现对输出数据格式的个性化定制(例如:日期的格式化显示,小数精确位数的控制,等等)。

算法进行了优化。在算法实现上,我们也进行了很多的优化,从而可以保证较好的执行效率(当然,与单层替换相比,效率难免还是要低一些的,所以如果程序对时间非常敏感、而且需求简单的话,也可以考虑单层替换方案;不过一般需求根本不用考虑这么多,我们的程序在效率上完全没问题,尽管放心用)。

Introduction

Shortcomings of other similar tools

Although there are similar string / placeholder replacement tools on the Internet, they can only be implemented with a single-level string/placeholder replacement like {replacement}, with great limitations in actual use , can not meet our business needs. It is also the direct cause of my development of this tool.

Advantage of StringFormatUtil

More convenient. Different from the tools on the Internet, StringFormatUtil based on Java's reflection, achieves a string/placeholder multi-level replacement. So you can achieve such as {china.beijing.haidian} form of replacement, with more Convenience in actual use.

More customizable. If the several methods we provide can not meet your development needs, your can achieve your customization of output data formatting(eg: the date of formatted display, decimal precision bit control, etc.) by an implementation of PostHandleIface interface.

Optimized algorithm.In the imp

你可能感兴趣的:(java字符串占位符替换工具类)