Jaxb #Attribute error read attribute - jaxb

I have the code and xml and xml and cannot read the xml and believe that it is for the attribute. how can I read the attribute?
This is the code:
#XmlRootElement(name = "reimpresiones")
public class RePrint {
private Integer id;
private String document;
private String numberDocument;
private String extraction;
private String client;
private String groupExtraction;
private String route;
private String deliveryNote;
private String date;
private List<RePrint> reprintList;
public RePrint() {
}
#XmlAttribute(name = "id")
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
#XmlElement(name = "client")
public String getClient() {
return client;
}
public void setClient(String client) {
this.client = client;
}
#XmlElement(name = "document")
public String getDocument() {
return document;
}
public void setDocument(String document) {
this.document = document;
}
#XmlElement(name = "numberDocument")
public String getNumberDocument() {
return numberDocument;
}
public void setNumberDocument(String numberDocument) {
this.numberDocument = numberDocument;
}
#XmlElement(name = "extraction")
public String getExtraction() {
return extraction;
}
public void setExtraction(String extraction) {
this.extraction = extraction;
}
#XmlElement(name = "groupExtraction")
public String getGroupExtraction() {
return groupExtraction;
}
public void setGroupExtraction(String groupExtraction) {
this.groupExtraction = groupExtraction;
}
#XmlElement(name = "route")
public String getRoute() {
return route;
}
public void setRoute(String route) {
this.route = route;
}
#XmlElement(name = "deliveryNote")
public String getDeliveryNote() {
return deliveryNote;
}
public void setDeliveryNote(String deliveryNote) {
this.deliveryNote = deliveryNote;
}
#XmlElement(name = "date")
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
#XmlElement(name = "reimprension")
public List<RePrint> getReprintList() {
return reprintList;
}
public void setReprintList(List<RePrint> reprintList) {
this.reprintList = reprintList;
}
}
This is the xml where there is a list of elements. I want to read "id" but i cannot.
<reimpresiones>
<reimpresion id="10574691840591525620140557591784">
<document>MATRICULA</document>
<numdocument><![CDATA[M142849865 ]]></numdocument>
<groupExtraction>1849986</groupExtraction>
<extraction>919767</extraction>
<client>780</client>
<deliveryNote><![CDATA[3600445640/01 ]]></deliveryNote>
<route>BUY</route>
<date>2014-05-05-17.59.57.919200</date>
</reimpresion>
<reimpresion id="14081953280539172820140537251728">
<document>MATRICULA</document>
<numdocument><![CDATA[M142849864 ]]></numdocument>
<groupExtraction>1849986</groupExtraction>
<extraction>919767</extraction>
<client>780</client>
<deliveryNote><![CDATA[3600445640/01 ]]></deliveryNote>
<route>BUY</route>
<date>2014-05-05-17.25.37.427752</date>
</reimpresion>
</reimpresiones>
Thank you

Related

How to render no data node as <node></node>?

I generated xml through jaxb , but the problem is when the data is empty then the rendered node is <node />. I want it to be <node></node>
here is my codes :
#XmlRootElement(name = "record")
public class ReglementXMLBean {
private String CODE_FOUR;
private String NUM_FACT;
private String FACT_FOU;
private String DTE_REG;
private String REF_REG;
private String MODE_REG;
private String MT_REG_DEV;
private String MT_REG;
private String DEVISE;
private String TYPE_REG;
public String getCODE_FOUR() {
return CODE_FOUR;
}
#XmlElement
public void setCODE_FOUR(String cODE_FOUR) {
CODE_FOUR = cODE_FOUR;
}
public String getNUM_FACT() {
return NUM_FACT;
}
#XmlElement
public void setNUM_FACT(String nUM_FACT) {
NUM_FACT = nUM_FACT;
}
public String getFACT_FOU() {
return FACT_FOU;
}
#XmlElement
public void setFACT_FOU(String fACT_FOU) {
FACT_FOU = fACT_FOU;
}
public String getDTE_REG() {
return DTE_REG;
}
#XmlElement
public void setDTE_REG(String dTE_REG) {
DTE_REG = dTE_REG;
}
public String getREF_REG() {
return REF_REG;
}
#XmlElement
public void setREF_REG(String rEF_REG) {
REF_REG = rEF_REG;
}
public String getMODE_REG() {
return MODE_REG;
}
#XmlElement
public void setMODE_REG(String mODE_REG) {
MODE_REG = mODE_REG;
}
public String getMT_REG_DEV() {
return MT_REG_DEV;
}
#XmlElement
public void setMT_REG_DEV(String mT_REG_DEV) {
MT_REG_DEV = mT_REG_DEV;
}
public String getMT_REG() {
return MT_REG;
}
#XmlElement
public void setMT_REG(String mT_REG) {
MT_REG = mT_REG;
}
public String getDEVISE() {
return DEVISE;
}
#XmlElement
public void setDEVISE(String dEVISE) {
DEVISE = dEVISE;
}
public String getTYPE_REG() {
return TYPE_REG;
}
#XmlElement
public void setTYPE_REG(String tYPE_REG) {
TYPE_REG = tYPE_REG;
}
}
try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) {
ReglementXMLBean reglementXMLBean = new ReglementXMLBean();
while ((line = br.readLine()) != null) {
String[] colonnes = line.split(cvsSplitBy);
reglementXMLBean.setCODE_FOUR(colonnes[0]);
reglementXMLBean.setNUM_FACT(colonnes[1]);
reglementXMLBean.setFACT_FOU(colonnes[2]);
reglementXMLBean.setDTE_REG(colonnes[3]);
reglementXMLBean.setREF_REG(colonnes[4]);
reglementXMLBean.setMODE_REG(colonnes[5]);
reglementXMLBean.setMT_REG_DEV(colonnes[6]);
reglementXMLBean.setMT_REG(colonnes[7]);
reglementXMLBean.setDEVISE(colonnes[8]);
reglementXMLBean.setTYPE_REG(colonnes[9]);
try {
JAXBContext jaxbContext = JAXBContext.newInstance(ReglementXMLBean.class);
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
jaxbMarshaller.marshal(reglementXMLBean, out);
jaxbMarshaller.marshal(reglementXMLBean, System.out);
} catch (JAXBException e) {
e.printStackTrace();
}
}
} catch (IOException e) {
e.printStackTrace();
}

issues with parcelable extension: getting unmarshalling unknown type code exception

long story short, I have one settlementItemeBase class as my father and two children. I want to make the father class parcelable so as extension happens, my two child classes be parcelable as well. I don't exactly know what I'm doing right or wrong. I searched little bit but nothing helped me.
here are my classes:
SettlementItemBase:
public class SettlementItemBase implements Parcelable{
public SettlementItemBase(){}
protected SettlementItemBase(Parcel in) {
}
public static final Creator<SettlementItemBase> CREATOR = new Creator<SettlementItemBase>() {
#Override
public SettlementItemBase createFromParcel(Parcel in) {
return new SettlementItemBase(in);
}
#Override
public SettlementItemBase[] newArray(int size) {
return new SettlementItemBase[size];
}
};
#Override
public int describeContents() {
return 0;
}
#Override
public void writeToParcel(Parcel dest, int flags) {
}
}
first child class:
public class FirstClass extends SettlementItemBase {
private int id;
private int cardId;
private String cardNumber;
private String expDate;
private String currency;
private String url;
public FirstClass(){
id = 0;
cardId = 0;
cardNumber = "";
expDate = "";
currency = "";
url = "";
}
protected FirstClass(Parcel in) {
super(in);
id = in.readInt();
cardId = in.readInt();
cardNumber = in.readString();
expDate = in.readString();
currency = in.readString();
url = in.readString();
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeInt(cardId);
dest.writeString(cardNumber);
dest.writeString(expDate);
dest.writeString(currency);
dest.writeString(url);
}
public int getId() {
return id;
}
public int getCardId() {
return cardId;
}
public String getCardNumber() {
return cardNumber;
}
public String getExpDate() {
return expDate;
}
public String getCurrency() {
return currency;
}
public String getUrl() {
return url;
}
}
second child class:
public class SecondClass extends SettlementItemBase{
private int id;
private String currency;
private String accountNumber;
private String ibanNumber;
public SecondClass(int id, String currency,
String accountNumber, String ibanNumber){
this.id = id;
this.currency = currency;
this.accountNumber = accountNumber;
this.ibanNumber = ibanNumber;
}
protected SecondClass(Parcel in){
super(in);
id = in.readInt();
currency = in.readString();
accountNumber = in.readString();
ibanNumber = in.readString();
}
#Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeString(currency);
dest.writeString(accountNumber);
dest.writeString(ibanNumber);
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCurrency() {
return currency;
}
public String getAccountNumber() {
return accountNumber;
}
public String getIbanNumber() {
return ibanNumber;
}
}
I'm passing and getting an ArrayList of both child class' items with intent putParcelableArrayListExtra and getParcelableArrayListExtra methods and get the following error:
Parcel android.os.Parcel#2d0fde33: Unmarshalling unknown type code 3276849 at offset 172
any help would be appreciated 3>
well I'm posting this for those who may run into the same problem as me.
the problem was solved after adding the Creator statement to the child classes.
for one of the child classes it would be like:
public static final Creator<FirstClass> CREATOR = new Creator<FirstClass>() {
#Override
public FirstClass createFromParcel(Parcel in) {
return new FirstClass(in);
}
#Override
public FirstClass[] newArray(int size) {
return new FirstClass[size];
}
};
hope this helps. 3>

Field attribute is coming as null while unmarshalling an xml file

Hi I am trying to convert an xml file into Java Objects using JAXB and I am very new to java. I have created the pojo classes and added some annotations but I am not sure whether they are right? I have spent hours in google but couldn't find what is wrong.
This is my xml :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<question id="1">
<answers>
<answername>java is a programming language</answername>
<id>101</id>
<postedby>ravi</postedby>
</answers>
<answers>
<answername>java is a platform</answername>
<id>102</id>
<postedby>john</postedby>
</answers>
<questionname>What is java?</questionname>
<marks set=50>
<longAnswer set=45/>
<shortAnswer set=30/>
</marks>
</question>
Pojo classes:
#XmlRootElement(name="question")
public class Question {
private int id;
private String questionname;
private List<Answer> answers;
private List<Marks> marks;
public Question() {}
public Question(int id, String questionname, List<Answer> answers, List<Marks> marks) {
super();
this.id = id;
this.questionname = questionname;
this.answers = answers;
this.marks = marks;
}
#XmlElement(name="marks")
public List<Marks> getMarks() {
return marks;
}
public void setMarks(List<Marks> marks) {
this.marks = marks;
}
#XmlAttribute
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
#XmlElement
public String getQuestionname() {
return questionname;
}
public void setQuestionname(String questionname) {
this.questionname = questionname;
}
#XmlElement
public List<Answer> getAnswers() {
return answers;
}
public void setAnswers(List<Answer> answers) {
this.answers = answers;
}
}
public class Answer {
private int id;
private String answername;
private String postedby;
public Answer() {}
public Answer(int id, String answername, String postedby) {
super();
this.id = id;
this.answername = answername;
this.postedby = postedby;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAnswername() {
return answername;
}
public void setAnswername(String answername) {
this.answername = answername;
}
public String getPostedby() {
return postedby;
}
public void setPostedby(String postedby) {
this.postedby = postedby;
}
}
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
public class Marks {
private LongAnswer longAnswer ;
private ShortAnswer shortAnswer;
private String set;
#XmlAttribute
public String getSet() {
return set;
}
public void setSet(String set) {
this.set = set;
}
#XmlElement(name="longAnswer")
public LongAnswer getLongAnswer() {
return longAnswer;
}
public void setLongAnswer(LongAnswer longAnswer) {
this.longAnswer = longAnswer;
}
#XmlElement(name="shortAnswer")
public ShortAnswer getShortAnswer() {
return shortAnswer;
}
public void setShortAnswer(ShortAnswer shortAnswer) {
this.shortAnswer = shortAnswer;
}
}
public class LongAnswer {
private String set;
public String getSet() {
return set;
}
public void setSet(String set) {
this.set = set;
}
public class ShortAnswer {
private String set;
public String getSet() {
return set;
}
public void setSet(String set) {
this.set = set;
}
}
Can anyone tell me how to annotate the 'marks' model class and how to set 'longAnswer' and 'shortAnswer' field. Because i am getting null values for them.
You should annotate your set properties with #XmlAttribute. Otherwise it looks quite fine.
What you could also do is create an XML Schema for you XML and compile it.

response.body returns null using retrofit:2.3.0

my json data is this
{
"data":[
{
"id":"4",
"totalOpns":"40000",
"killedDrugPer":"320",
"arrestedDrugPer":"17683",
"houseVisited":"4000",
"userSurrenderers":"45000",
"pusherSurrenderers":"15000",
"totalSurrenderers":"60000",
"killedPNPPerOpns":"40",
"woundedPNPPerOpns":"70",
"killedAFPPerOpns":"100",
"woundedAFPPerOpns":"10",
"date":"2017-07-12 13:57:34.000"
}
]
}
and my data model is this
package com.androidtutorialpoint.retrofitandroid;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
public class Student implements Serializable {
//Variables that are in our json
#SerializedName("id")
#Expose
private String id;
#SerializedName("totalOpns")
#Expose
private String totalOpns;
#SerializedName("killedDrugPer")
#Expose
private String killedDrugPer;
#SerializedName("arrestedDrugPer")
#Expose
private String arrestedDrugPer;
#SerializedName("houseVisited")
#Expose
private String houseVisited;
#SerializedName("userSurrenderers")
#Expose
private String userSurrenderers;
#SerializedName("pusherSurrenderers")
#Expose
private String pusherSurrenderers;
#SerializedName("totalSurrenderers")
#Expose
private String totalSurrenderers;
#SerializedName("killedPNPPerOpns")
#Expose
private String killedPNPPerOpns;
#SerializedName("woundedPNPPerOpns")
#Expose
private String woundedPNPPerOpns;
#SerializedName("killedAFPPerOpns")
#Expose
private String killedAFPPerOpns;
#SerializedName("woundedAFPPerOpns")
#Expose
private String woundedAFPPerOpns;
#SerializedName("date")
#Expose
private String date;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTotalOpns() {
return totalOpns;
}
public void setTotalOpns(String totalOpns) {
this.totalOpns = totalOpns;
}
public String getKilledDrugPer() {
return killedDrugPer;
}
public void setKilledDrugPer(String killedDrugPer) {
this.killedDrugPer = killedDrugPer;
}
public String getArrestedDrugPer() {
return arrestedDrugPer;
}
public void setArrestedDrugPer(String arrestedDrugPer) {
this.arrestedDrugPer = arrestedDrugPer;
}
public String getHouseVisited() {
return houseVisited;
}
public void setHouseVisited(String houseVisited) {
this.houseVisited = houseVisited;
}
public String getUserSurrenderers() {
return userSurrenderers;
}
public void setUserSurrenderers(String userSurrenderers) {
this.userSurrenderers = userSurrenderers;
}
public String getPusherSurrenderers() {
return pusherSurrenderers;
}
public void setPusherSurrenderers(String pusherSurrenderers) {
this.pusherSurrenderers = pusherSurrenderers;
}
public String getTotalSurrenderers() {
return totalSurrenderers;
}
public void setTotalSurrenderers(String totalSurrenderers) {
this.totalSurrenderers = totalSurrenderers;
}
public String getKilledPNPPerOpns() {
return killedPNPPerOpns;
}
public void setKilledPNPPerOpns(String killedPNPPerOpns) {
this.killedPNPPerOpns = killedPNPPerOpns;
}
public String getWoundedPNPPerOpns() {
return woundedPNPPerOpns;
}
public void setWoundedPNPPerOpns(String woundedPNPPerOpns) {
this.woundedPNPPerOpns = woundedPNPPerOpns;
}
public String getKilledAFPPerOpns() {
return killedAFPPerOpns;
}
public void setKilledAFPPerOpns(String killedAFPPerOpns) {
this.killedAFPPerOpns = killedAFPPerOpns;
}
public String getWoundedAFPPerOpns() {
return woundedAFPPerOpns;
}
public void setWoundedAFPPerOpns(String woundedAFPPerOpns) {
this.woundedAFPPerOpns = woundedAFPPerOpns;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
}
and the interface is this
package com.androidtutorialpoint.retrofitandroid;
import retrofit2.Call;
import retrofit2.http.GET;
public interface RetrofitObjectAPI {
/*
* Retrofit get annotation with our URL
* And our method that will return us details of student.
*/
// #GET("JSONTESTING/index.php")
#GET("getJson")
Call<Student> getStudentDetails();
}
and in my main is this
private void getRetrofitObject() {
HttpLoggingInterceptor.Level logLevel = HttpLoggingInterceptor.Level.BODY;
HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
// set your desired log level
logging.setLevel(logLevel);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
// add your other interceptors …
// add logging as last interceptor
httpClient.addInterceptor(logging); // <-- this is the important line!
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(url)
.addConverterFactory(GsonConverterFactory.create())
.client(httpClient.build())
.build();
RetrofitObjectAPI service = retrofit.create(RetrofitObjectAPI.class);
Call<Student> call = service.getStudentDetails();
call.enqueue(new Callback<Student>() {
#Override
public void onResponse(Call<Student> call, Response<Student> response) {
try {
if (response.isSuccessful()) {
text_id_1.setText("StudentId : " + response.body().getId());
text_name_1.setText("StudentName : " + response.body().getTotalOpns());
text_marks_1.setText("StudentMarks : " + response.body().getArrestedDrugPer());
} else {
//unsuccessful response
}
} catch (Exception e) {
Log.d("onResponse", "There is an error");
e.printStackTrace();
}
}
#Override
public void onFailure(Call<Student> call, Throwable t) {
Log.d("onFailure", t.toString());
}
});
}
and in my logcat is this, i can see the json data but on my response.body returns null.
logcat
What should I do?
You are getting a response but there is issue in deserialization.
Reason being the Call<Student> is not the type it will be serialized to becuase you are getting a List of Students(JSONArray).
add this class
MyResponse
public class MyResponse {
#SerializedName("data")
#Expose
private List<Student> data = null;
public List<Student> getData() {
return data;
}
public void setData(List<Student> data) {
this.data = data;
}
}
and change your call to:
#GET("getJson")
Call<MyResponse> getStudentDetails();
Now you will get response body
and how to retrive?
List<Student> students = response.body().getData();
This will do..:)

Unmarshalling jaxB doesn't work, objects null

I have a problem with jaxB. There is no exception and here is my xml ;
<event>
<event_datetimeGMT>2015-02-27 17:00</event_datetimeGMT>
<gamenumber>443364144</gamenumber>
<sporttype>Basketball</sporttype>
<league>Adriatic</league>
<IsLive>No</IsLive>
<participants>
<participant>
<participant_name>Cedevita</participant_name>
<contestantnum>1001</contestantnum>
<rotnum>1001</rotnum>
<visiting_home_draw>Home</visiting_home_draw>
</participant>
<participant>
<participant_name>Mega Leks</participant_name>
<contestantnum>1002</contestantnum>
<rotnum>1002</rotnum>
<visiting_home_draw>Visiting</visiting_home_draw>
</participant>
</participants>
<periods>
<period>
<period_number>0</period_number>
<period_description>Game</period_description>
<periodcutoff_datetimeGMT>2015-02-27 17:00</periodcutoff_datetimeGMT>
<period_status>I</period_status>
<period_update>open</period_update>
<spread_maximum>500</spread_maximum>
<moneyline_maximum>500</moneyline_maximum>
<total_maximum>500</total_maximum>
<moneyline>
<moneyline_visiting>583</moneyline_visiting>
<moneyline_home>-720</moneyline_home>
</moneyline>
<spread>
<spread_visiting>12</spread_visiting>
<spread_adjust_visiting>-104</spread_adjust_visiting>
<spread_home>-12</spread_home>
<spread_adjust_home>-106</spread_adjust_home>
</spread>
<total>
<total_points>164</total_points>
<over_adjust>-101</over_adjust>
<under_adjust>-109</under_adjust>
</total>
</period>
</periods>
here is main class ;
#XmlRootElement (name = "pinnacle_line_feed")
public class PinnacleLineFeed {
private Long PinnacleFeedTime;
private Long lastContest;
private Long lastGame;
private List<Event> events;
#XmlAttribute(name = "PinnacleFeedTime")
public Long getPinnacleFeedTime() {
return PinnacleFeedTime;
}
public void setPinnacleFeedTime(Long pinnacleFeedTime) {
PinnacleFeedTime = pinnacleFeedTime;
}
#XmlAttribute (name = "lastContest")
public Long getLastContest() {
return lastContest;
}
public void setLastContest(Long lastContest) {
this.lastContest = lastContest;
}
#XmlAttribute (name = "lastGame")
public Long getLastGame() {
return lastGame;
}
public void setLastGame(Long lastGame) {
this.lastGame = lastGame;
}
#XmlElement (name = "events")
public List<Event> getEvents() {
return events;
}
public void setEvents(List<Event> events) {
this.events = events;
}
}
you can see full xml from the url which i shared at my first post
and here is my pojos ;
public class Event {
private String event_datetimeGMT;
private Long gamenumber;
private String sporttype;
private String league;
private String IsLive;
private List<Participant> participants;
private List<Period> periods;
#XmlAttribute (name = "event_datetimeGMT")
public String getEvent_datetimeGMT() {
return event_datetimeGMT;
}
public void setEvent_datetimeGMT(String event_datetimeGMT) {
this.event_datetimeGMT = event_datetimeGMT;
}
#XmlAttribute (name = "gamenumber")
public Long getGamenumber() {
return gamenumber;
}
public void setGamenumber(Long gamenumber) {
this.gamenumber = gamenumber;
}
#XmlAttribute (name = "sporttype")
public String getSporttype() {
return sporttype;
}
public void setSporttype(String sporttype) {
this.sporttype = sporttype;
}
#XmlAttribute (name = "league")
public String getLeague() {
return league;
}
public void setLeague(String league) {
this.league = league;
}
#XmlAttribute (name = "IsLive")
public String getIsLive() {
return IsLive;
}
public void setIsLive(String isLive) {
this.IsLive = isLive;
}
#XmlElement(name = "participant")
public List<Participant> getParticipants() {
return participants;
}
public void setParticipants(List<Participant> participants) {
this.participants = participants;
}
#XmlElement(name = "period")
public List<Period> getPeriods() {
return periods;
}
public void setPeriods(List<Period> periods) {
this.periods = periods;
}
}
public class Participants {
private List<Participant> participants;
#XmlElement(name = "participant")
public List<Participant> getParticipants() {
return participants;
}
public void setParticipants(List<Participant> participants) {
this.participants = participants;
}
}
public class Participant {
private String participant_name;
private Long contestantnum;
private Long rotnum;
private String visiting_home_draw;
#XmlAttribute(name = "participant_name")
public String getParticipant_name() {
return participant_name;
}
public void setParticipant_name(String participant_name) {
this.participant_name = participant_name;
}
#XmlAttribute (name = "contestantnum")
public Long getContestantnum() {
return contestantnum;
}
public void setContestantnum(Long contestantnum) {
this.contestantnum = contestantnum;
}
#XmlAttribute (name = "rotnum")
public Long getRotnum() {
return rotnum;
}
public void setRotnum(Long rotnum) {
this.rotnum = rotnum;
}
#XmlAttribute (name = "visiting_home_draw")
public String getVisiting_home_draw() {
return visiting_home_draw;
}
public void setVisiting_home_draw(String visiting_home_draw) {
this.visiting_home_draw = visiting_home_draw;
}
}
public class Periods {
private List<Period> periods;
#XmlElement(name = "period")
public List<Period> getPeriods() {
return periods;
}
public void setPeriods(List<Period> periods) {
this.periods = periods;
}
}
public class Period {
private int period_number;
private String period_description;
private String periodcutoff_datetimeGMT;
private String period_status;
private String period_update;
private int spread_maximum;
private int moneyline_maximum;
private int total_maximum;
private Moneyline moneyline;
private Spread spread;
private Total total;
#XmlAttribute(name = "period_number")
public int getPeriod_number() {
return period_number;
}
public void setPeriod_number(int period_number) {
this.period_number = period_number;
}
#XmlAttribute(name = "period_description")
public String getPeriod_description() {
return period_description;
}
public void setPeriod_description(String period_description) {
this.period_description = period_description;
}
#XmlAttribute(name = "periodcutoff_datetimeGMT")
public String getPeriodcutoff_datetimeGMT() {
return periodcutoff_datetimeGMT;
}
public void setPeriodcutoff_datetimeGMT(String periodcutoff_datetimeGMT) {
this.periodcutoff_datetimeGMT = periodcutoff_datetimeGMT;
}
#XmlAttribute(name = "period_status")
public String getPeriod_status() {
return period_status;
}
public void setPeriod_status(String period_status) {
this.period_status = period_status;
}
#XmlAttribute(name = "period_update")
public String getPeriod_update() {
return period_update;
}
public void setPeriod_update(String period_update) {
this.period_update = period_update;
}
#XmlAttribute(name = "spread_maximum")
public int getSpread_maximum() {
return spread_maximum;
}
public void setSpread_maximum(int spread_maximum) {
this.spread_maximum = spread_maximum;
}
#XmlAttribute(name = "moneyline_maximum")
public int getMoneyline_maximum() {
return moneyline_maximum;
}
public void setMoneyline_maximum(int moneyline_maximum) {
this.moneyline_maximum = moneyline_maximum;
}
#XmlAttribute(name = "total_maximum")
public int getTotal_maximum() {
return total_maximum;
}
public void setTotal_maximum(int total_maximum) {
this.total_maximum = total_maximum;
}
#XmlElement (name = "moneyline")
public Moneyline getMoneyline() {
return moneyline;
}
public void setMoneyline(Moneyline moneyline) {
this.moneyline = moneyline;
}
#XmlElement (name = "spread")
public Spread getSpread() {
return spread;
}
public void setSpread(Spread spread) {
this.spread = spread;
}
#XmlElement (name = "total")
public Total getTotal() {
return total;
}
public void setTotal(Total total) {
this.total = total;
}
}
public class Moneyline {
private int moneyline_visiting;
private int moneyline_home;
#XmlAttribute(name = "moneyline_visiting")
public int getMoneyline_visiting() {
return moneyline_visiting;
}
public void setMoneyline_visiting(int moneyline_visiting) {
this.moneyline_visiting = moneyline_visiting;
}
#XmlAttribute(name = "moneyline_home")
public int getMoneyline_home() {
return moneyline_home;
}
public void setMoneyline_home(int moneyline_home) {
this.moneyline_home = moneyline_home;
}
}
public class Spread {
private int spread_visiting;
private int spread_adjust_visiting;
private int spread_home;
private int spread_adjust_home;
#XmlAttribute(name = "spread_visiting")
public int getSpread_visiting() {
return spread_visiting;
}
public void setSpread_visiting(int spread_visiting) {
this.spread_visiting = spread_visiting;
}
#XmlAttribute(name = "spread_adjust_visiting")
public int getSpread_adjust_visiting() {
return spread_adjust_visiting;
}
public void setSpread_adjust_visiting(int spread_adjust_visiting) {
this.spread_adjust_visiting = spread_adjust_visiting;
}
#XmlAttribute(name = "spread_home")
public int getSpread_home() {
return spread_home;
}
public void setSpread_home(int spread_home) {
this.spread_home = spread_home;
}
#XmlAttribute(name = "spread_adjust_home")
public int getSpread_adjust_home() {
return spread_adjust_home;
}
public void setSpread_adjust_home(int spread_adjust_home) {
this.spread_adjust_home = spread_adjust_home;
}
}
public class Total {
private int total_points;
private int over_adjust;
private int under_adjust;
#XmlAttribute(name = "total_points")
public int getTotal_points() {
return total_points;
}
public void setTotal_points(int total_points) {
this.total_points = total_points;
}
#XmlAttribute(name = "over_adjust")
public int getOver_adjust() {
return over_adjust;
}
public void setOver_adjust(int over_adjust) {
this.over_adjust = over_adjust;
}
#XmlAttribute(name = "under_adjust")
public int getUnder_adjust() {
return under_adjust;
}
public void setUnder_adjust(int under_adjust) {
this.under_adjust = under_adjust;
}
}
and my test method ;
private static void unmarshall() {
try {
JAXBContext jc = JAXBContext.newInstance(PinnacleLineFeed.class);
URL url = new URL("http://xml.pinnaclesports.com/pinnacleFeed.aspx?");
Unmarshaller unmarshaller = jc.createUnmarshaller();
PinnacleLineFeed pinnacleLineFeed = (PinnacleLineFeed) unmarshaller.unmarshal(url);
System.out.println("bakıcez");
} catch (Exception ex) {
ex.printStackTrace();
}
}
When i try to unmarshall this xml, all fields are null. And there is no exception. Can anyone help ?

Resources