|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
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; |
|
|
|
@ -14,7 +16,7 @@ import java.util.Map;
|
|
|
|
|
*/ |
|
|
|
|
public class SimpleDesignerConfig implements XMLable { |
|
|
|
|
|
|
|
|
|
private static final HashMap<String, SimpleDesignerConfig> configs = new HashMap<>(); |
|
|
|
|
private static final Map<String, SimpleDesignerConfig> configs = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
private SimpleDesignerConfig(String name) { |
|
|
|
|
this.name = name; |
|
|
|
@ -31,42 +33,51 @@ public class SimpleDesignerConfig implements XMLable {
|
|
|
|
|
|
|
|
|
|
private String name = ""; |
|
|
|
|
|
|
|
|
|
private HashMap<String, String> content = new HashMap<>(); |
|
|
|
|
private JSONObject content = new JSONObject(); |
|
|
|
|
|
|
|
|
|
public void addAttr(String key, String value) { |
|
|
|
|
content.put(key, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Map<String, String> getContent() { |
|
|
|
|
public JSONObject getContent() { |
|
|
|
|
return content; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setContent(JSONObject content) { |
|
|
|
|
this.content = content; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void readXML(XMLableReader reader) { |
|
|
|
|
if (reader.isAttr()) { |
|
|
|
|
content.putAll(reader.getAttrs()); |
|
|
|
|
String rawContent = reader.getAttrAsString("content", null); |
|
|
|
|
if (StringUtils.isNotBlank(rawContent)) { |
|
|
|
|
this.content = new JSONObject(rawContent); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void writeXML(XMLPrintWriter writer) { |
|
|
|
|
writer.startTAG(name); |
|
|
|
|
content.forEach(writer::attr); |
|
|
|
|
if (this.content != null) { |
|
|
|
|
writer.attr("content", this.content.toString()); |
|
|
|
|
} |
|
|
|
|
writer.end(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Object clone() throws CloneNotSupportedException { |
|
|
|
|
SimpleDesignerConfig cloned = (SimpleDesignerConfig) super.clone(); |
|
|
|
|
cloned.content = new HashMap<>(content); |
|
|
|
|
if (this.content != null) { |
|
|
|
|
cloned.content = new JSONObject(this.content.toString()); |
|
|
|
|
} |
|
|
|
|
cloned.name = this.name; |
|
|
|
|
return cloned; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String getName() { |
|
|
|
|
return name; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setName(String name) { |
|
|
|
|
this.name = name; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|