一、前言
关于docbkx-maven-base-2.0.8.jar源码包中com.agilejava.docbkx.maven.ExpressionUtils表达式工具类,分别按照配置属性文件进行createTree关系Map树、获取按照Key对象进行拆分树结构splitToTree等。
二、源码说明
package com.agilejava.docbkx.maven;@b@@b@import java.util.HashMap;@b@import java.util.Iterator;@b@import java.util.Map;@b@import java.util.Properties;@b@import java.util.Set;@b@@b@public class ExpressionUtils@b@{@b@ public static final Map createTree(Properties properties)@b@ {@b@ Map map = new HashMap();@b@ Iterator iterator = properties.keySet().iterator();@b@ while (iterator.hasNext()) {@b@ String key = (String)iterator.next();@b@ splitToTree(key, properties.get(key), map);@b@ }@b@ return map;@b@ }@b@@b@ private static void splitToTree(String key, Object object, Map map) {@b@ int i = key.indexOf(46);@b@ if (i > 0) {@b@ String part = key.substring(0, i);@b@ Map submap = (Map)map.get(part);@b@ submap = (submap == null) ? new HashMap() : submap;@b@ map.put(part, submap);@b@ splitToTree(key.substring(i + 1), object, submap);@b@ } else {@b@ map.put(key, object);@b@ }@b@ }@b@}