0
我有一個具有構造函數的類:蓖麻映射陣列
public ContEmpirical(double xs[], double fs[]) {
Check.check(xs.length == fs.length + 1 && fs.length > 0,
"Empirical distribution array mismatch");
this.xs = new double[xs.length];
this.xs = xs;
this.cs = new double[xs.length];
double fTotal = 0.0;
for (int i = 0; i < fs.length; i++)
fTotal += fs[i];
cs[0] = 0;
for (int i = 0; i < fs.length; i++)
cs[i + 1] = cs[i] + fs[i]/fTotal;
}
屬性:
private double xs[], cs[];
private double fs[]; // this attribute i added to make castors life easier since it always wants to map constructor arg to class attribute.
映射文件我已經是:
<class name="tools.ContEmpirical">
<description xmlns="">
Mapping for class tools.ContEmpirical
</description>
<map-to xml="ContEmpirical"/>
<field name="xs" type="double" collection="array" set-method="%1" get-method="getXs" required="true">
<bind-xml node="attribute"/>
</field>
<field name="fs" type="double" collection="array" set-method="%2" get-method="getFs" required="true">
<bind-xml node="attribute"/>
</field></class>
然而,當我嘗試以馬歇爾爲例ContEmpirical我得到這個XML:
<ContEmpirical xs="0.2 0.3 0.4 0.8"/>
當我真的應該得到這樣的事情:
<ContEmpirical xs="0.2 0.3 0.4 0.8" fs="0.2 0.3 0.4 0.8"/>
有什麼事我是從映射失蹤?
已添加到原始帖子。 – Babyangle86 2010-03-07 10:13:04
看看第二個代碼blurb,我讓fs成爲getter和setter的一個屬性。 – Babyangle86 2010-03-10 21:29:15