~wattazoum/livrezmoi/projectdeposit

« back to all changes in this revision

Viewing changes to SERVER/WEB-INF/src/common/model/Project.java

  • Committer: Rachid
  • Date: 2009-05-17 13:39:03 UTC
  • Revision ID: rachid@chidi-laptop-20090517133903-sp32jm8kym0g4wua
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package common.model;
 
2
 
 
3
import java.io.IOException;
 
4
import java.io.InputStream;
 
5
import java.io.ObjectOutputStream;
 
6
import java.io.OutputStream;
 
7
import java.io.Serializable;
 
8
import java.io.UnsupportedEncodingException;
 
9
import java.net.URLEncoder;
 
10
 
 
11
 
 
12
@SuppressWarnings("serial")
 
13
public class Project implements Serializable{
 
14
 
 
15
        private String name;
 
16
 
 
17
        private String version;
 
18
        
 
19
        private String file_jar;
 
20
 
 
21
        private String file_build;
 
22
 
 
23
        private String comment;
 
24
        
 
25
        private String date_depot;
 
26
 
 
27
        public static int attribut_number=6;
 
28
        
 
29
        
 
30
        public Project(String name,String version ,String file_jar, String file_build,
 
31
                        String comment, String date_depot) {
 
32
                super();
 
33
                this.name = name;
 
34
                this.version=version;
 
35
                this.file_jar = file_jar;
 
36
                this.file_build = file_build;
 
37
                this.comment = comment;
 
38
                this.date_depot=date_depot;
 
39
        }
 
40
        
 
41
        public String getVersion() {
 
42
                return version;
 
43
        }
 
44
 
 
45
        public void setVersion(String version) {
 
46
                this.version = version;
 
47
        }
 
48
 
 
49
        public String getDate_depot() {
 
50
                return date_depot;
 
51
        }
 
52
 
 
53
        public void setDate_depot(String date_depot) {
 
54
                this.date_depot = date_depot;
 
55
        }
 
56
        
 
57
        
 
58
        
 
59
        
 
60
        public String getName() {
 
61
                return name;
 
62
        }
 
63
 
 
64
        public void setName(String name) {
 
65
                this.name = name;
 
66
        }
 
67
 
 
68
        public String getFile_jar() {
 
69
                return file_jar;
 
70
        }
 
71
 
 
72
        public void setFile_jar(String file_jar) {
 
73
                this.file_jar = file_jar;
 
74
        }
 
75
 
 
76
        public String getFile_build() {
 
77
                return file_build;
 
78
        }
 
79
 
 
80
        public void setFile_build(String file_build) {
 
81
                this.file_build = file_build;
 
82
        }
 
83
 
 
84
        public String getComment() {
 
85
                return comment;
 
86
        }
 
87
 
 
88
        public void setComment(String comment) {
 
89
                this.comment = comment;
 
90
        }
 
91
 
 
92
public String[] toArray(){
 
93
                
 
94
                return new String[]{name,version,file_jar,file_build,comment,date_depot};
 
95
        }
 
96
 
 
97
        public String toserver() throws UnsupportedEncodingException{
 
98
                
 
99
                return URLEncoder.encode("name="+name+"&version="+version+"&file_jar="+file_jar+"&file_build="+file_build+"&comment="+comment+"&date="+date_depot,"UTF-8");
 
100
                
 
101
        }
 
102
        public  String encode(){
 
103
                //System.out.println("[ENCODE]="+name+","+file_jar+","+file_build+","+comment+";");
 
104
                return name+","+version+","+file_jar+","+file_build+","+comment+","+date_depot+";";
 
105
        }
 
106
        public static Project decode(String texte){
 
107
                String[] tab=texte.split(",");
 
108
                //System.out.println("[DECODE]" +texte);
 
109
//              for (int i = 0; i < tab.length; i++) {
 
110
//                      System.out.println("new project:"+tab[i]+"-");
 
111
//              }
 
112
                return new Project(tab[0],tab[1],tab[2],tab[3],tab[4],tab[5]);
 
113
                
 
114
        }
 
115
}
 
116
 
 
117
class MyInput extends OutputStream
 
118
{
 
119
        
 
120
        public StringBuffer buffer ;
 
121
        
 
122
        public MyInput(){
 
123
                buffer = new StringBuffer("");
 
124
        }
 
125
        
 
126
        @Override
 
127
        public void write(int b) throws IOException {
 
128
                buffer.append((char)b);
 
129
        }
 
130
        
 
131
        public static void main(String[] args) throws Throwable {
 
132
                MyInput out = new MyInput();
 
133
                ObjectOutputStream stream = new ObjectOutputStream(out);
 
134
                Project p = new Project("1","2","3","4","5","6");
 
135
                stream.writeObject(p);
 
136
                System.out.println(out.buffer);
 
137
        }
 
138
        
 
139
}