forked from m0ver/tinystruct-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharticle.java
More file actions
executable file
·80 lines (65 loc) · 1.99 KB
/
article.java
File metadata and controls
executable file
·80 lines (65 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package custom.objects;
import org.tinystruct.data.component.AbstractData;
import org.tinystruct.data.component.Row;
public class article extends AbstractData {
private String bookId;
private int chapterId;
private int sectionId;
private String content;
public Integer getId()
{
return Integer.parseInt(this.Id.toString());
}
public void setBookId(String bookId)
{
this.bookId=this.setFieldAsString("bookId",bookId);
}
public String getBookId()
{
return this.bookId;
}
public void setChapterId(int chapterId)
{
this.chapterId=this.setFieldAsInt("chapterId",chapterId);
}
public int getChapterId()
{
return this.chapterId;
}
public void setSectionId(int sectionId)
{
this.sectionId=this.setFieldAsInt("sectionId",sectionId);
}
public int getSectionId()
{
return this.sectionId;
}
public void setContent(String content)
{
this.content=this.setFieldAsString("content",content);
}
public String getContent()
{
return this.content;
}
@Override
public void setData(Row row) {
if(row.getFieldInfo("id")!=null) this.setId(row.getFieldInfo("id").intValue());
if(row.getFieldInfo("book_id")!=null) this.setBookId(row.getFieldInfo("book_id").stringValue());
if(row.getFieldInfo("chapter_id")!=null) this.setChapterId(row.getFieldInfo("chapter_id").intValue());
if(row.getFieldInfo("section_id")!=null) this.setSectionId(row.getFieldInfo("section_id").intValue());
if(row.getFieldInfo("content")!=null) this.setContent(row.getFieldInfo("content").stringValue());
}
@Override
public String toString() {
StringBuffer buffer=new StringBuffer();
buffer.append("{");
buffer.append("\"Id\":"+this.getId());
buffer.append(",\"bookId\":\""+this.getBookId()+"\"");
buffer.append(",\"chapterId\":"+this.getChapterId());
buffer.append(",\"sectionId\":"+this.getSectionId());
buffer.append(",\"content\":\""+this.getContent()+"\"");
buffer.append("}");
return buffer.toString();
}
}