2 package nicobrowser.entity;
4 import javax.persistence.Column;
5 import javax.persistence.Entity;
6 import javax.persistence.GeneratedValue;
7 import javax.persistence.GenerationType;
8 import javax.persistence.Id;
9 import javax.persistence.Version;
15 public class NicoContent implements java.io.Serializable {
19 GET_INFO, GET_LOW, GET_FILE
21 private static final long serialVersionUID = 1L;
24 private String nicoId;
25 private String pageLink;
27 private String fileName;
28 private Status status = Status.GET_INFO;
29 private int failTimes;
30 private boolean convertedMp3;
31 private boolean convertedMp4;
32 private String author;
35 @GeneratedValue(strategy = GenerationType.AUTO)
40 public void setId(Long id) {
45 public Long getVersion() {
49 public void setVersion(Long version) {
50 this.version = version;
53 @Column(nullable = false)
54 public String getNicoId() {
58 protected void setNicoId(String nicoId) {
62 public String getPageLink() {
66 public void setPageLink(String pageLink) {
67 this.pageLink = pageLink;
68 String[] elm = pageLink.split("/");
69 setNicoId(elm[elm.length - 1]);
72 public String getTitle() {
76 public void setTitle(String title) {
81 public String getFileName() {
85 protected void setFileName(String fileName) {
86 if (fileName == null) {
91 StringBuilder str = new StringBuilder();
93 for (int i = 0; i < fileName.length(); i++) {
94 char c = fileName.charAt(i);
95 if (c == '\\' || c == '/' || c == ':' || c == '*' || c == '?' ||
96 c == '"' || c == '<' || c == '>' || c == '|' || c == '.') {
101 } catch (Exception e) {
104 this.fileName = str.toString();
107 @Column(nullable = false)
108 public Status getStatus() {
112 public void setStatus(Status status) {
113 this.status = status;
116 public int getFailTimes() {
120 public void setFailTimes(int failTimes) {
121 this.failTimes = failTimes;
124 @Column(nullable = false)
125 public boolean isConvertedMp3() {
129 public void setConvertedMp3(boolean convertedMp3) {
130 this.convertedMp3 = convertedMp3;
133 @Column(nullable = false)
134 public boolean isConvertedMp4() {
138 public void setConvertedMp4(boolean convertedMp4) {
139 this.convertedMp4 = convertedMp4;
142 public String getAuthor() {
146 public void setAuthor(String author) {
147 this.author = author;
151 public int hashCode() {
153 hash += (id != null ? id.hashCode() : 0);
158 public boolean equals(Object object) {
159 // TODO: Warning - this method won't work in the case the id fields are not set
160 if (!(object instanceof NicoContent)) {
163 NicoContent other = (NicoContent) object;
164 if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
171 public String toString() {
172 return new String(getTitle() + ": " + getPageLink());