Browse Source
* commit '321f06299cd1d571de40a5c910ba22456c5a1d0e': REPORT-77337 表头排序-表头区域异常 REPORT-74376 存储结构变化 REPORT-74376 clone下map REPORT-74376 支持存储FVS设计器相关配置new-design
superman
2 years ago
3 changed files with 104 additions and 1 deletions
@ -0,0 +1,83 @@
|
||||
package com.fr.design.mainframe.simple; |
||||
|
||||
import com.fr.json.JSONObject; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author Wei |
||||
* 一个简单属性(字符串)存储类,用于自定义简单属性的存储 |
||||
* 如:getInstance("FVSDesignerConfig")可在FineReportEnv.xml中定义一个<FVSDesignerConfig></>存储FVS相关配置 |
||||
*/ |
||||
public class SimpleDesignerConfig implements XMLable { |
||||
|
||||
private static final Map<String, SimpleDesignerConfig> configs = new HashMap<>(); |
||||
|
||||
private SimpleDesignerConfig(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public static SimpleDesignerConfig getInstance(String name) { |
||||
SimpleDesignerConfig config = configs.get(name); |
||||
if (config == null) { |
||||
config = new SimpleDesignerConfig(name); |
||||
configs.put(name, config); |
||||
} |
||||
return config; |
||||
} |
||||
|
||||
private String name = ""; |
||||
|
||||
private JSONObject content = new JSONObject(); |
||||
|
||||
public void addAttr(String key, String value) { |
||||
content.put(key, value); |
||||
} |
||||
|
||||
public JSONObject getContent() { |
||||
return content; |
||||
} |
||||
|
||||
public void setContent(JSONObject content) { |
||||
this.content = content; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
if (reader.isAttr()) { |
||||
String rawContent = reader.getAttrAsString("content", null); |
||||
if (StringUtils.isNotBlank(rawContent)) { |
||||
this.content = new JSONObject(rawContent); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
writer.startTAG(name); |
||||
if (this.content != null) { |
||||
writer.attr("content", this.content.toString()); |
||||
} |
||||
writer.end(); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
SimpleDesignerConfig cloned = (SimpleDesignerConfig) super.clone(); |
||||
if (this.content != null) { |
||||
cloned.content = new JSONObject(this.content.toString()); |
||||
} |
||||
cloned.name = this.name; |
||||
return cloned; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
} |
Loading…
Reference in new issue