BeanIO 2.1包裹的段

时间:2017-08-24 16:42:01

标签: java segment

大家好我正在使用BeanIO写入CSV文件。

我有一个复杂的类结构,我想在一列中输出。以下是我正在使用的课程。 "主" class是 GprsEvent

public class GprsEvent
{
    private ListOfServiceData   listOfServiceData;
    // setters and getters omitted
}

public class ListOfServiceData implements Serializable
{
    private List<ChangeOfServiceCondition> seqOf = null;
    // setters and getters omitted
}

public class ChangeOfServiceCondition implements Serializable
{
    private RatingGroupId ratingGroup = null;
    private ChargingRuleBaseName chargingRuleBaseName = null;
    private ResultCode resultCode = null;
    private LocalSequenceNumber localSequenceNumber = null;
    private TimeStamp timeOfFirstUsage = null;
    private TimeStamp timeOfLastUsage = null;
    private CallDuration timeUsage = null;
    private ServiceConditionChange serviceConditionChange = null;
    **private EPCQoSInformation qoSInformationNeg = null;** // Complex Type
    private GSNAddress servingNodeAddress = null;
    private DataVolumeGPRS datavolumeFBCUplink = null;
    private DataVolumeGPRS datavolumeFBCDownlink = null;
    private TimeStamp timeOfReport = null;
    private FailureHandlingContinue failureHandlingContinue = null;
    private ServiceIdentifier serviceIdentifier = null;
    private BerOctetString userLocationInformation = null;
    // setters and getters omitted
}

public class EPCQoSInformation implements Serializable
{

    public byte[] code = null;
    private BerInteger qCI = null;
    private BerInteger maxRequestedBandwithUL = null;
    private BerInteger maxRequestedBandwithDL = null;
    private BerInteger guaranteedBitrateUL = null;
    private BerInteger guaranteedBitrateDL = null;
    private BerInteger aRP = null;
    // setters and getters omitted
}

我已阅读BeanIO文档并了解了如何执行我的操作:http://beanio.org/2.1/docs/reference/index.html#AdvancedTopics - 5.8.2。包裹的细分

所以这是我的beanio XML文件的一部分:

<record class="net.atos.tools.radiation.convert.event.gprs.GprsEvent"
        name="sGWRecord" maxOccurs="unbounded" minOccurs="0" order="1">

    <segment name="listOfServiceData">
    <segment name="listOfServiceData" class="net.atos.open.muc.generated.datatypes.ListOfServiceData"> 
        <segment name="changeOfServiceCondition">
        <segment name="changeOfServiceCondition" class="net.atos.open.muc.generated.datatypes.ChangeOfServiceCondition" collection="list" minOccurs="0" maxOccurs="unbounded">
             <field name="ratingGroup" type="net.atos.open.muc.generated.datatypes.RatingGroupId" />
             <field name="chargingRuleBaseName" type="net.atos.open.muc.generated.datatypes.ChargingRuleBaseName" />
             <field name="resultCode" type="net.atos.open.muc.generated.datatypes.ResultCode" />
             <field name="localSequenceNumber" type="net.atos.open.muc.generated.datatypes.localSequenceNumberp"/> 
             <field name="timeOfFirstUsage" type="net.atos.open.muc.generated.datatypes.TimeStamp"/> 
             <field name="timeOfLastUsage" type="net.atos.open.muc.generated.datatypes.TimeStamp"/> 
             <field name="timeUsage" type="net.atos.open.muc.generated.datatypes.CallDuration"/> 
             <segment name="qoSInformationNeg">
             <segment name="qoSInformationNeg" class="net.atos.open.muc.generated.datatypes.EPCQoSInformation" occursRef="timeUsage">
                    <field name="qCI" type="org.openmuc.jasn1.ber.types.BerInteger"/>
                    <field name="maxRequestedBandwithUL" type="org.openmuc.jasn1.ber.types.BerInteger"/>
                    <field name="maxRequestedBandwithDL" type="org.openmuc.jasn1.ber.types.BerInteger"/>
                    <field name="guaranteedBitrateUL" type="org.openmuc.jasn1.ber.types.BerInteger"/>
                    <field name="guaranteedBitrateDL" type="org.openmuc.jasn1.ber.types.BerInteger"/>
                    <field name="aRP" type="org.openmuc.jasn1.ber.types.BerInteger"/>
             </segment>
             </segment>
        </segment>
        </segment>
    </segment>
    </segment>  

</record>

我收到以下错误: org.beanio.BeanIOConfigurationException:无效的段&qoSInformationNeg&#39;,在段&#39; qoSInformationNeg&#39;,在段&#39; changeOfServiceCondition&#39; ;,在细分&#39; changeOfServiceCondition&#39;,在细分&#39; listOfServiceData&#39;中,在细分&#39; listOfServiceData&#39;,在记录&#39; sGWRecord&#39;中,在流&# 39; gprs&#39;:当maxOccurs大于1并且设置了类时所需的集合

1 个答案:

答案 0 :(得分:0)

好的,我自己找到了解决方案,当存在多个@Column(columnDefinition = "char") private String name; 时会出现问题。例如,在我的XML文件中,第一个列表出现是:

collection="list"

在此之后出现下一个列表:

<field name="sgsnAddressLength" type="java.lang.Integer" typeHandler="sgsnAddressLengthHandler" /> 
<field name="sgsnAddresses" type="net.atos.open.muc.generated.datatypes.GSNAddress" collection="list" occursRef="sgsnAddressLength" typeHandler="sgsnAddressesHandler" /> 

在存在第一个列表occourance的字段中,您必须添加:happenRef关键字。在我的情况下,第一个列表名称是 sgsnAddresses ,我不得不添加<segment name="changesOfServiceCondition" class="net.atos.open.muc.generated.datatypes.ChangeOfServiceCondition" collection="list" minOccurs="0" maxOccurs="1"> ,因为 sgsnAddressLength 是第一个列表出现之前的字段。