Browse Source

readme

master
rinoux 4 years ago
parent
commit
24b6836456
  1. 8
      README.md
  2. 19
      src/main/java/com/fr/plugin/tabledata/build/DemoTableData.java
  3. 13
      src/main/java/com/fr/plugin/tabledata/build/DemoTableDataBuilder.java

8
README.md

@ -0,0 +1,8 @@
# 数据集TableData创建插件
## 使用场景
- 如果需要以插件的方式,根据<TableData>标签的class属性解析为其它类型TableData,满足额外的数据集功能需要。
## 注意事项
- `getClassAttr`返回的Class一般是`matchPattern`方法匹配的类型,这样能保证保存TableData到xml时不会修改class属性。
- 示例插件作用是给数据集加一LastUpdateDataTime子标签存储上次修改时间,通过getLastUpdateDataTime获取。

19
src/main/java/com/fr/plugin/tabledata/build/DemoTableData.java

@ -2,9 +2,12 @@ package com.fr.plugin.tabledata.build;
import com.fr.data.impl.Connection;
import com.fr.data.impl.DBTableData;
import com.fr.general.DateUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import java.util.Date;
/**
* @author rinoux
* @version 10.0
@ -12,10 +15,10 @@ import com.fr.stable.xml.XMLableReader;
*/
public class DemoTableData extends DBTableData {
private static final String DemoTag = "ExtraInfo";
private static final String DemoTag = "LastUpdateDataTime";
private String extraInfo;
private String lastUpdateDataTime;
public DemoTableData() {
}
@ -28,12 +31,12 @@ public class DemoTableData extends DBTableData {
super(database, query);
}
public String getExtraInfo() {
return extraInfo;
public String getLastUpdateDataTime() {
return lastUpdateDataTime;
}
public void setExtraInfo(String extraInfo) {
this.extraInfo = extraInfo;
public void setLastUpdateDataTime(String lastUpdateDataTime) {
this.lastUpdateDataTime = lastUpdateDataTime;
}
@Override
@ -42,7 +45,7 @@ public class DemoTableData extends DBTableData {
if (reader.isChildNode()) {
String tagName = reader.getTagName();
if (DemoTag.equals(tagName)) {
setExtraInfo(reader.getContent());
setLastUpdateDataTime(reader.getElementValue());
}
}
}
@ -51,7 +54,7 @@ public class DemoTableData extends DBTableData {
public void writeXML(XMLPrintWriter writer) {
super.writeXML(writer);
writer.startTAG(DemoTag);
writer.textNode("some demo extra info");
writer.textNode(DateUtils.DATETIMEFORMAT2.format(new Date()));
writer.end();
}
}

13
src/main/java/com/fr/plugin/tabledata/build/DemoTableDataBuilder.java

@ -1,6 +1,7 @@
package com.fr.plugin.tabledata.build;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.base.TableData;
import com.fr.data.impl.DBTableData;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.stable.fun.impl.AbstractTableDataBuildProvider;
@ -11,14 +12,14 @@ import com.fr.stable.fun.impl.AbstractTableDataBuildProvider;
*/
@FunctionRecorder
public class DemoTableDataBuilder extends AbstractTableDataBuildProvider<DemoTableData> {
@Override
public boolean matchPattern(String tdClassName) {
return tdClassName.endsWith(".DBTableData");
public Class<? extends TableData> getAttrClass() {
return DBTableData.class;
}
@Override
@ExecuteFunctionRecord
public DemoTableData newInstance() {
return new DemoTableData();
public Class<DemoTableData> getBuildClass() {
return DemoTableData.class;
}
}

Loading…
Cancel
Save