All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.artifact.builder.extend.AbstractDesignExtend Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package org.artifact.builder.extend;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import cn.hutool.core.util.StrUtil;

/**
 * @author : DengYing
 * @CreateDate : 2017年11月1日 下午2:34:28
 * @Description :设计器扩展
 * 
 */
public abstract class AbstractDesignExtend {
	
	/** 注释 */
	public String remarks;
	
	
	public String getRemarks() {
		return remarks;
	}


	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}


	/**
	 * 解码扩展
	 * 
	 * @param comtent
	 * @return
	 */
	public Map decoder(String comtent) {
		Map spreadMap = new HashMap();
		comtent = comtent.trim();
		List spreads = StrUtil.split(comtent, StrUtil.C_LF, true, true);
		final char C_EQ = '=';
		for (String spread : spreads) {
			List spread_unit = StrUtil.split(spread, C_EQ, true, true);
			if (spread_unit.size() != 2) {
				continue;
			}
			String key = spread_unit.get(0);
			String val = spread_unit.get(1);
			spreadMap.put(key, val);
		}
		return spreadMap;
	}
	
	
	/**
	 * 编码码
	 * 
	 * @param map
	 * @return
	 */
	public String encoder(Map map) {
		StringBuffer sb = new StringBuffer();
		int i = 0; 
		final char C_EQ = '=';
		for (Entry e : map.entrySet()) {
			if (!"remarks".equals(e.getKey())) {
				continue;
			}
			if (i > 0) {
				sb.append("\\n");
			}
			sb.append(e.getKey()).append(C_EQ).append(e.getValue());
			i++;
		}
		return sb.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy