org.exolab.castor.xml.MarshalException:无法在ClassDescriptor脚本映射错误中找到FieldDescriptor

时间:2013-07-02 09:44:28

标签: java xml mapping unmarshalling castor

我对castor的xml映射文件有问题。 这里是我要解组的xml文件:

<message type="info_message">
    <sensor type="cnr_fall_detector" id="1301">
        <value type="fall">
            <boolean>true</boolean>
        </value>
        <value type="confidence_index">
            <double>0.3</double>
        </value>
        <timestamp>09-05-2013 11:00:00</timestamp>
    </sensor>
</message>

这些是java类:

public class MetaalMessage {
    public MessageType messageType;
    public SensorType sensorType;
    public Integer sensorId;
    public List<MetaalValue> values;
    public String timestamp;
}

public class MetaalValue {
    public ValueType type;
    public String unit;

    public int integerValue;
    public boolean booleanValue;
    public double doubleValue;
    public String stringValue;
    public String timestamp;
}

与相对的吸气剂和二传手。 这是我写的映射文件:

<?xml version="1.0"?>
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd">
<mapping>
<class name="metaal.messages.MetaalMessage">
    <map-to xml="message" />

    <field name="messageType" type="metaal.messages.utils.MessageType">
     <bind-xml name="type" node="attribute" location="message" />
    </field>
    <field name="sensorType" type="metaal.messages.utils.SensorType">
      <bind-xml name="type" node="attribute" location="sensor" />
    </field>
    <field name="sensorId" type="java.lang.Integer">
      <bind-xml name="id" node="attribute" location="sensor" />
    </field>
    <field name="values" type="metaal.messages.MetaalValue" collection="arraylist">
      <bind-xml name="value" node="element" location="sensor" />
    </field>
    <field name="timestamp" type="java.lang.String">
      <bind-xml name="timestamp" node="element" location="sensor" />
    </field>
  </class>

  <class name="metaal.messages.MetaalValue">
    <field name="type" type="metaal.messages.utils.ValueType">
      <bind-xml name="type" node="attribute" location="value" />
    </field>
     <field name="unit" type="java.lang.String" required="false">
      <bind-xml name="unit" node="attribute" location="value" />
    </field>
    <field name="integerValue" type="integer" required="false">
      <bind-xml name="integer" node="element" location="value" />
    </field>
    <field name="doubleValue" type="double" required="false">
      <bind-xml name="double" node="element" location="value" />
    </field>
    <field name="stringValue" type="java.lang.String" required="false">
      <bind-xml name="string" node="element" location="value" />
    </field>
    <field name="booleanValue" type="boolean" required="false">
      <bind-xml name="boolean" node="element" location="value" />
    </field>
    <field name="timestamp" type="java.lang.String">
      <bind-xml name="timestamp" node="element" location="value" />
    </field>
  </class>
</mapping>

最后,显示的错误是:

org.exolab.castor.xml.MarshalException: Unable to find FieldDescriptor for 'boolean' in ClassDescriptor of metaal-value.{File: [not available]; line: 4; column: 13}

任何人都可以提供帮助吗?

S上。

0 个答案:

没有答案