You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.0 KiB
69 lines
2.0 KiB
4 years ago
|
package com.tptj.demo.hg.table.data;
|
||
|
|
||
|
import com.fanruan.api.data.open.BaseTableData;
|
||
|
import com.fr.config.holder.Conf;
|
||
|
import com.fr.config.holder.factory.Holders;
|
||
|
import com.fr.general.data.DataModel;
|
||
|
import com.fr.general.xml.GeneralXMLTools;
|
||
|
import com.fr.intelli.record.Focus;
|
||
|
import com.fr.record.analyzer.EnableMetrics;
|
||
|
import com.fr.script.Calculator;
|
||
|
import com.fr.stable.EncodeConstants;
|
||
|
import com.fr.stable.StringUtils;
|
||
|
import com.fr.stable.xml.XMLPrintWriter;
|
||
|
import com.fr.stable.xml.XMLableReader;
|
||
|
|
||
|
/**
|
||
|
* @author 秃破天际
|
||
|
* @version 10.0
|
||
|
* Created by 秃破天际 on 2021-03-29
|
||
|
**/
|
||
|
@EnableMetrics
|
||
|
public class DemoTableData extends BaseTableData {
|
||
|
/**
|
||
|
* 自定义一些配置
|
||
|
*/
|
||
|
private Conf<String> config = Holders.simple(StringUtils.EMPTY);
|
||
|
|
||
|
public String getConfig() {
|
||
|
return config.get();
|
||
|
}
|
||
|
|
||
|
public void setConfig( String config) {
|
||
|
this.config.set(config);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
@Focus(id = "com.tptj.demo.hg.table.data.v10",text = "table data")
|
||
|
public DataModel createDataModel(Calculator calculator) {
|
||
|
return new DemoDataModel( calculator,
|
||
|
Calculator.processParameters(calculator,super.getParameters(calculator)),
|
||
|
getConfig() );
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void readXML(XMLableReader reader) {
|
||
|
super.readXML(reader);
|
||
|
if (reader.isChildNode()){
|
||
|
if ("Attributes".equals(reader.getTagName())) {
|
||
|
try{
|
||
|
String conf = new String(GeneralXMLTools.readByteArray(reader), EncodeConstants.ENCODING_UTF_8);
|
||
|
setConfig(conf);
|
||
|
}catch(Exception e){
|
||
|
setConfig(StringUtils.EMPTY);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void writeXML(XMLPrintWriter writer) {
|
||
|
super.writeXML(writer);
|
||
|
writer.startTAG("Attributes");
|
||
|
try{
|
||
|
GeneralXMLTools.writeByteArray(writer, getConfig().getBytes(EncodeConstants.ENCODING_UTF_8));
|
||
|
}catch(Exception e){}
|
||
|
writer.end();
|
||
|
}
|
||
|
}
|