WeiYanglu
2 years ago
2 changed files with 88 additions and 0 deletions
@ -0,0 +1,70 @@
|
||||
package com.fr.design.mainframe.simple; |
||||
|
||||
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 HashMap<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 final Map<String, String> content = new HashMap<>(); |
||||
|
||||
public void addAttr(String key, String value) { |
||||
content.put(key, value); |
||||
} |
||||
|
||||
public Map<String, String> getContent() { |
||||
return content; |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
if (reader.isAttr()) { |
||||
content.putAll(reader.getAttrs()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
writer.startTAG(name); |
||||
content.forEach(writer::attr); |
||||
writer.end(); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
return super.clone(); |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
Loading…
Reference in new issue