Skip to content

Commit b38465a

Browse files
committed
调整构造器方法
增加了扩展信息
1 parent c601957 commit b38465a

File tree

8 files changed

+488
-2
lines changed

8 files changed

+488
-2
lines changed

ofdrw-core/src/main/java/org/ofdrw/core/basicType/ST_Loc.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.ofdrw.core.basicType;
22

3+
4+
import org.dom4j.Element;
5+
36
/**
47
* 包结构内文件的路径,“.”表示当前路径,“..”表示符路径
58
* <p>
@@ -41,6 +44,18 @@ public static ST_Loc getInstance(String loc) {
4144
return new ST_Loc(loc.trim());
4245
}
4346

47+
/**
48+
* 从实例中获取 路径
49+
* @param e 元素
50+
* @return 路径对象
51+
*/
52+
public static ST_Loc getInstance(Element e){
53+
if (e == null) {
54+
return null;
55+
}
56+
return getInstance(e.getTextTrim());
57+
}
58+
4459
public String getLoc() {
4560
return loc;
4661
}

ofdrw-core/src/main/java/org/ofdrw/core/customTags/CustomTag.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public CustomTag(Element proxy) {
1818
super(proxy);
1919
}
2020

21-
protected CustomTag() {
21+
public CustomTag() {
2222
super("CustomTag");
2323
}
2424

ofdrw-core/src/main/java/org/ofdrw/core/customTags/CustomTags.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public CustomTags(Element proxy) {
2727
super(proxy);
2828
}
2929

30-
protected CustomTags() {
30+
public CustomTags() {
3131
super("CustomTags");
3232
}
3333

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
package org.ofdrw.core.extensions;
2+
3+
import org.dom4j.Element;
4+
import org.ofdrw.core.Const;
5+
import org.ofdrw.core.OFDElement;
6+
import org.ofdrw.core.basicType.ST_Loc;
7+
import org.ofdrw.core.basicType.ST_RefID;
8+
9+
import java.time.LocalDate;
10+
import java.util.List;
11+
12+
/**
13+
* 扩展信息节点
14+
* <p>
15+
* 17 扩展信息 图 83 表 6
16+
*
17+
* @author 权观宇
18+
* @since 2019-11-20 06:09:49
19+
*/
20+
public class CT_Extension extends OFDElement {
21+
public CT_Extension(Element proxy) {
22+
super(proxy);
23+
}
24+
25+
public CT_Extension() {
26+
super("Extension");
27+
}
28+
29+
/**
30+
* 【必选 属性】
31+
* 设置 用于生成或解释该自定义对象数据的扩展应用程序名称
32+
*
33+
* @param appName 用于生成或解释该自定义对象数据的扩展应用程序名称
34+
* @return this
35+
*/
36+
public CT_Extension setAppName(String appName) {
37+
if (appName == null || appName.trim().length() == 0) {
38+
throw new IllegalArgumentException("用于生成或解释该自定义对象数据的扩展应用程序名称(AppName)不能为空");
39+
}
40+
this.addAttribute("AppName", appName);
41+
return this;
42+
}
43+
44+
/**
45+
* 【必选 属性】
46+
* 获取 用于生成或解释该自定义对象数据的扩展应用程序名称
47+
*
48+
* @return 用于生成或解释该自定义对象数据的扩展应用程序名称
49+
*/
50+
public String getAppName() {
51+
String str = this.attributeValue("AppName");
52+
if (str == null || str.trim().length() == 0) {
53+
throw new IllegalArgumentException("用于生成或解释该自定义对象数据的扩展应用程序名称(AppName)不能为空");
54+
}
55+
return str;
56+
}
57+
58+
/**
59+
* 【可选 属性】
60+
* 设置 形成此扩展信息的软件厂商标识
61+
*
62+
* @param company 形成此扩展信息的软件厂商标识
63+
* @return this
64+
*/
65+
public CT_Extension setCompany(String company) {
66+
if (company == null || company.trim().length() == 0) {
67+
this.removeAttr("Company");
68+
return this;
69+
}
70+
this.addAttribute("Company", company);
71+
return this;
72+
}
73+
74+
/**
75+
* 【可选 属性】
76+
* 获取 形成此扩展信息的软件厂商标识
77+
*
78+
* @return 形成此扩展信息的软件厂商标识
79+
*/
80+
public String getCompany() {
81+
return this.attributeValue("Company");
82+
}
83+
84+
/**
85+
* 【可选 属性】
86+
* 设置 形成此扩展信息的软件版本
87+
*
88+
* @param appVersion 形成此扩展信息的软件版本
89+
* @return this
90+
*/
91+
public CT_Extension setAppVersion(String appVersion) {
92+
if (appVersion == null || appVersion.trim().length() == 0) {
93+
this.removeAttr("AppVersion");
94+
return this;
95+
}
96+
this.addAttribute("AppVersion", appVersion);
97+
return this;
98+
}
99+
100+
/**
101+
* 【可选 属性】
102+
* 获取 形成此扩展信息的软件版本
103+
*
104+
* @return 形成此扩展信息的软件版本
105+
*/
106+
public String getAppVersion() {
107+
return this.attributeValue("AppVersion");
108+
}
109+
110+
/**
111+
* 【可选 属性】
112+
* 设置 形成此扩展信息的日期时间
113+
*
114+
* @param date 形成此扩展信息的日期时间
115+
* @return this
116+
*/
117+
public CT_Extension setDate(LocalDate date) {
118+
if (date == null) {
119+
this.removeAttr("Date");
120+
return this;
121+
}
122+
this.addAttribute("Date", date.format(Const.DATE_FORMATTER));
123+
return this;
124+
}
125+
126+
/**
127+
* 【可选 属性】
128+
* 获取 形成此扩展信息的日期时间
129+
*
130+
* @return 形成此扩展信息的日期时间
131+
*/
132+
public LocalDate getDate() {
133+
String str = this.attributeValue("Date");
134+
if (str == null || str.trim().length() == 0) {
135+
return null;
136+
}
137+
return LocalDate.parse(str, Const.DATE_FORMATTER);
138+
}
139+
140+
/**
141+
* 【可选 属性】
142+
* 设置 引用扩展项针对的文档项目的标识
143+
*
144+
* @param refId 引用扩展项针对的文档项目的标识
145+
* @return this
146+
*/
147+
public CT_Extension setRefId(ST_RefID refId) {
148+
if (refId == null) {
149+
this.removeAttr("RefId");
150+
return this;
151+
}
152+
this.addAttribute("RefId", refId.toString());
153+
return this;
154+
}
155+
156+
/**
157+
* 【可选 属性】
158+
* 获取 引用扩展项针对的文档项目的标识
159+
*
160+
* @return 引用扩展项针对的文档项目的标识
161+
*/
162+
public ST_RefID getRefId() {
163+
return ST_RefID.getInstance(this.attributeValue("RefId"));
164+
}
165+
166+
/**
167+
* 【必选 属性】
168+
* 增加 属性
169+
*
170+
* @param property 属性
171+
* @return this
172+
*/
173+
public CT_Extension addProperty(Property property) {
174+
if (property == null) {
175+
return this;
176+
}
177+
this.add(property);
178+
return this;
179+
}
180+
181+
/**
182+
* 【必选 属性】
183+
* 获取 属性列表
184+
*
185+
* @return 属性列表
186+
*/
187+
public List<Property> getPropertys() {
188+
return this.getOFDElements("Property", Property::new);
189+
}
190+
191+
/**
192+
* 【必选】
193+
* 增加 扩展数据文件所在位置
194+
* <p>
195+
* 用于扩展大量信息
196+
*
197+
* @param extendData 扩展数据文件所在位置
198+
* @return this
199+
*/
200+
public CT_Extension addExtendData(ST_Loc extendData) {
201+
if (extendData == null) {
202+
return this;
203+
}
204+
this.addOFDEntity("ExtendData", extendData);
205+
return this;
206+
}
207+
208+
/**
209+
* 【必选】
210+
* 获取 扩展数据文件所在位置序列
211+
* <p>
212+
* 用于扩展大量信息
213+
*
214+
* @return 扩展数据文件所在位置序列
215+
*/
216+
public List<ST_Loc> getExtendDatas() {
217+
return this.getOFDElements("ExtendData", ST_Loc::getInstance);
218+
}
219+
220+
/**
221+
* 【必选】
222+
* 增加 扩展复杂属性
223+
* <p>
224+
* 使用xs:anyType,用于较复杂的扩展
225+
*
226+
* @param data 扩展复杂属性
227+
* @return this
228+
*/
229+
public CT_Extension addData(Element data) {
230+
if (data == null) {
231+
return this;
232+
}
233+
this.add(data);
234+
return this;
235+
}
236+
237+
/**
238+
* 【必选】
239+
* 获取 扩展复杂属性序列
240+
* <p>
241+
* 使用xs:anyType,用于较复杂的扩展
242+
*
243+
* @return 扩展复杂属性序列
244+
*/
245+
public List<Element> getDatas() {
246+
return this.elements("Data");
247+
}
248+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package org.ofdrw.core.extensions;
2+
3+
import org.dom4j.Element;
4+
import org.ofdrw.core.OFDElement;
5+
6+
import java.util.List;
7+
8+
/**
9+
* 扩展信息
10+
* <p>
11+
* 扩展信息列表的入口文件在 7.5 文档根节点中定义。
12+
* 扩展信息列表文件的根节点名为 Extensions,其下
13+
* 由 0 到多个扩展信息节点(Extension)组成,扩展
14+
* 信息列表的根节点结构如图 83 所示。
15+
*
16+
* <p>
17+
* 17 扩展信息 图 83 表 64
18+
*
19+
* @author 权观宇
20+
* @since 2019-11-20 05:40:27
21+
*/
22+
public class Extensions extends OFDElement {
23+
public Extensions(Element proxy) {
24+
super(proxy);
25+
}
26+
27+
public Extensions() {
28+
super("Extensions");
29+
}
30+
31+
/**
32+
* 【可选】
33+
* 增加 扩展信息节点
34+
*
35+
* @param extension 扩展信息节点
36+
* @return this
37+
*/
38+
public Extensions addExtension(CT_Extension extension) {
39+
if (extension == null) {
40+
return this;
41+
}
42+
this.add(extension);
43+
return this;
44+
}
45+
46+
/**
47+
* 【可选】
48+
* 获取 扩展信息节点序列
49+
*
50+
* @return 扩展信息节点
51+
*/
52+
public List<CT_Extension> getExtensions() {
53+
return this.getOFDElements("Extension", CT_Extension::new);
54+
}
55+
}

0 commit comments

Comments
 (0)