java - Set different aliases for same class with Xstream -


i need create xml must next example.

<eba_met:mi81  contextref="c-01" decimals="-3" unitref="u-01">0</eba_met:mi81> <eba_met:mi81  contextref="c-02" decimals="-3" unitref="u-01">0</eba_met:mi81> <eba_met:mi81  contextref="c-03" decimals="-3" unitref="u-01">0</eba_met:mi81> <eba_met:mi76  contextref="c-04" decimals="-3" unitref="u-01">0</eba_met:mi76> <eba_met:mi53  contextref="c-05" decimals="-3" unitref="u-01">0</eba_met:mi53> <eba_met:mi53  contextref="c-06" decimals="-3" unitref="u-01">0</eba_met:mi53> <eba_met:mi76  contextref="c-07" decimals="-3" unitref="u-01">0</eba_met:mi76> <eba_met:mi53  contextref="c-08" decimals="-3" unitref="u-01">0</eba_met:mi53> <eba_met:mi53  contextref="c-09" decimals="-3" unitref="u-01">0</eba_met:mi53> <eba_met:mi76  contextref="c-10" decimals="-3" unitref="u-01">0</eba_met:mi76> <eba_met:mi76  contextref="c-11" decimals="-3" unitref="u-01">0</eba_met:mi76> <eba_met:mi53  contextref="c-12" decimals="-3" unitref="u-01">0</eba_met:mi53> <eba_met:mi237 contextref="c-13" decimals="-3" unitref="u-01">0</eba_met:mi237> <eba_met:mi237 contextref="c-14" decimals="-3" unitref="u-01">0</eba_met:mi237> <eba_met:mi310 contextref="c-15" decimals="-3" unitref="u-01">0</eba_met:mi310> <eba_met:mi310 contextref="c-16" decimals="-3" unitref="u-01">0</eba_met:mi310> <eba_met:mi310 contextref="c-17" decimals="-3" unitref="u-01">0</eba_met:mi310> <eba_met:mi310 contextref="c-18" decimals="-3" unitref="u-01">0</eba_met:mi310> <eba_met:mi310 contextref="c-19" decimals="-3" unitref="u-01">0</eba_met:mi310> <eba_met:mi310 contextref="c-20" decimals="-3" unitref="u-01">0</eba_met:mi310> <eba_met:mi235 contextref="c-21" decimals="-3" unitref="u-01">0</eba_met:mi235> <eba_met:pi317 contextref="c-22" decimals="4"  unitref="u-02">0</eba_met:pi317> <eba_met:mi76  contextref="c-23" decimals="-3" unitref="u-01">0</eba_met:mi76> <eba_met:pi317 contextref="c-24" decimals="4"  unitref="u-02">0</eba_met:pi317> <eba_met:mi76  contextref="c-25" decimals="-3" unitref="u-01">0</eba_met:mi76> <eba_met:pi317 contextref="c-26" decimals="4"  unitref="u-02">0</eba_met:pi317> <eba_met:mi76  contextref="c-27" decimals="-3" unitref="u-01">0</eba_met:mi76> <eba_met:mi53  contextref="c-28" decimals="-3" unitref="u-01">0</eba_met:mi53> <eba_met:mi184 contextref="c-29" decimals="-3" unitref="u-01">0</eba_met:mi184> 

and have created next java class create eba_met:xiy nodes:

/*  * imports  */ import com.thoughtworks.xstream.annotations.xstreamalias; import com.thoughtworks.xstream.annotations.xstreamasattribute; import com.thoughtworks.xstream.annotations.xstreamconverter; import com.thoughtworks.xstream.converters.extended.toattributedvalueconverter;  @xstreamalias("eba_met") @xstreamconverter(value=toattributedvalueconverter.class, strings={"value"}) public class ebamet {    // properties   @xstreamasattribute   @xstreamalias("contextref")   private string contextref;    @xstreamasattribute   @xstreamalias("decimals")   private string decimals;    @xstreamasattribute   @xstreamalias("unitref")   private string unitref;    //value   private string value;    public ebamet(int id, string decimals, string unitid, string value) {     this.contextref = "c-" + string.format("%02d", id);     this.decimals = decimals;     this.unitref = "u-" + string.format("%02d", integer.parseint(unitid));     this.value = altvalue;   }    public string getcontextref() {     return contextref;   }    public void setcontextref(string contextref) {     this.contextref = contextref;   }    public string getdecimals() {     return decimals;   }    public void setdecimals(string decimals) {     this.decimals = decimals;   }    public string getunitref() {     return unitref;   }    public void setunitref(string unitref) {     this.unitref = unitref;   }    public string getvalue() {     return value;   }    public void setvalue(string value) {     this.value = value;   }  } 

the problem i need create in same xml file different nodes same class; given x , y create eba_met:xiy nodes. have tried xstream.alias doesn't work... help?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -