Projekt

Obecné

Profil

Stáhnout (1.71 KB) Statistiky
| Větev: | Tag: | Revize:
1
package jdeserialize;
2

    
3
import java.util.Map;
4

    
5
/**
6
 * <p>
7
 * Represents an array instance, including the values the comprise the array.
8
 * </p>
9
 *
10
 * <p>
11
 * Note that in arrays of primitives, the classdesc will be named "[x", where x
12
 * is the field type code representing the primitive type. See
13
 * jdeserialize.resolveJavaType() for an example of analysis/generation of
14
 * human-readable names from these class names.
15
 * </p>
16
 */
17
public class arrayobj extends contentbase {
18
    /**
19
     * Type of the array instance.
20
     */
21
    public classdesc classdesc;
22

    
23
    /**
24
     * Values of the array, in the order they were read from the stream.
25
     */
26
    public arraycoll data;
27

    
28
    public arrayobj(int handle, classdesc cd, arraycoll data) {
29
        super(contenttype.ARRAY);
30
        this.handle = handle;
31
        this.classdesc = cd;
32
        this.data = data;
33
    }
34

    
35
    public @Override String toJson(String indentation, Map<classdesc, Map<field, Object>> fielddata, boolean child) {
36
        StringBuilder sb = new StringBuilder();
37
        sb.append("[ ");
38

    
39
        for (Object el : this.data) {
40
            if (el != null) {
41
                if (el instanceof content) {
42
                    sb.append(((content) el).toJson(indentation, fielddata, child));
43
                }else{
44
                    sb.append(el.toString());
45
                }
46
                
47
                if (!el.equals(this.data.get(this.data.size() - 1))) {
48
                    sb.append(", ");
49
                }
50
            }
51
        }
52
        sb.append(" ]");
53
        return sb.toString();
54
    }
55

    
56
    public String toString() {
57
        return "[array " + jdeserialize.hex(handle) + " classdesc " + classdesc.toString() + ": " + data.toString()
58
                + "]";
59
    }
60
}
(6-6/20)