OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 156
Line 11... Line 11...
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.ui.light;
14
 package org.openconcerto.ui.light;
15
 
15
 
-
 
16
import org.openconcerto.utils.io.JSONConverter;
-
 
17
import org.openconcerto.utils.io.Transferable;
-
 
18
 
-
 
19
import java.io.Externalizable;
-
 
20
import java.io.IOException;
-
 
21
import java.io.ObjectInput;
-
 
22
import java.io.ObjectOutput;
16
import java.util.ArrayList;
23
import java.util.ArrayList;
17
import java.util.List;
24
import java.util.List;
18
 
25
 
19
import org.openconcerto.utils.io.JSONConverter;
-
 
20
import org.openconcerto.utils.io.Transferable;
-
 
21
import net.minidev.json.JSONArray;
26
import net.minidev.json.JSONArray;
22
import net.minidev.json.JSONObject;
27
import net.minidev.json.JSONObject;
23
 
28
 
24
public class TableContent implements Transferable {
29
public class TableContent implements Transferable, Externalizable {
25
    private static final long serialVersionUID = 3648381615123520834L;
30
    private static final long serialVersionUID = 3648381615123520834L;
26
    private String tableId;
31
    private String tableId;
27
    private List<Row> rows;
32
    private List<Row> rows;
28
 
33
 
29
    public TableContent() {
34
    public TableContent() {
Line 69... Line 74...
69
 
74
 
70
    public final synchronized Row setRow(final int index, final Row row) {
75
    public final synchronized Row setRow(final int index, final Row row) {
71
        return this.rows.set(index, row);
76
        return this.rows.set(index, row);
72
    }
77
    }
73
 
78
 
-
 
79
    public final synchronized void insertRow(final int index, final Row row) {
-
 
80
        this.rows.add(index, row);
-
 
81
    }
-
 
82
 
74
    public final synchronized Row removeRow(final int index) {
83
    public final synchronized Row removeRow(final int index) {
75
        return this.rows.remove(index);
84
        return this.rows.remove(index);
76
    }
85
    }
77
 
86
 
78
    public final synchronized boolean removeRow(final Row row) {
87
    public final synchronized boolean removeRow(final Row row) {
Line 118... Line 127...
118
                listRows.add(new Row(JSONConverter.getObjectFromJSON(o, JSONObject.class)));
127
                listRows.add(new Row(JSONConverter.getObjectFromJSON(o, JSONObject.class)));
119
            }
128
            }
120
            this.setRows(listRows);
129
            this.setRows(listRows);
121
        }
130
        }
122
    }
131
    }
-
 
132
 
-
 
133
    @Override
-
 
134
    public synchronized void writeExternal(ObjectOutput out) throws IOException {
-
 
135
        out.writeUTF(tableId);
-
 
136
        out.writeInt(rows.size());
-
 
137
        for (Row row : this.rows) {
-
 
138
            row.writeExternal(out);
-
 
139
        }
-
 
140
 
-
 
141
    }
-
 
142
 
-
 
143
    @Override
-
 
144
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-
 
145
        tableId = in.readUTF();
-
 
146
        int size = in.readInt();
-
 
147
        this.rows = new ArrayList<>(size);
-
 
148
        for (int i = 0; i < size; i++) {
-
 
149
            final Row row = new Row();
-
 
150
            row.readExternal(in);
-
 
151
            this.rows.add(row);
-
 
152
        }
-
 
153
 
-
 
154
    }
-
 
155
 
123
}
156
}