Projekt

Obecné

Profil

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

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

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

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

    
33
    public @Override String toJson(String indentation) {
34
        StringBuilder sb = new StringBuilder();
35
        sb.append("[ ");
36

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

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