|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 package org.chromium.sdk.internal.protocolparser.dynamicimpl; |
|
6 |
|
7 import org.chromium.sdk.internal.protocolparser.JsonType; |
|
8 |
|
9 /** |
|
10 * Stores all data for instance of json type. |
|
11 * Each implementation of json type interface is a java dynamic proxy, that holds reference |
|
12 * to {@link JsonInvocationHandler} which holds reference to this structure. ObjectData points |
|
13 * back to dynamic proxy instance in {@link #proxy}. |
|
14 */ |
|
15 class ObjectData { |
|
16 |
|
17 /** |
|
18 * Stores type-specific set of pre-parsed fields. |
|
19 */ |
|
20 private final Object[] fieldArray; |
|
21 |
|
22 /** |
|
23 * May be JSONObject (in most cases) or any |
|
24 * object (for {@link JsonType#subtypesChosenManually()}=true). |
|
25 */ |
|
26 private final Object underlyingObject; |
|
27 private final TypeHandler<?> typeHandler; |
|
28 |
|
29 /** |
|
30 * Holds reference to base type object data (or null). |
|
31 */ |
|
32 private final ObjectData superObjectData; |
|
33 private Object proxy = null; |
|
34 |
|
35 ObjectData(TypeHandler<?> typeHandler, Object inputObject, int fieldArraySize, |
|
36 ObjectData superObjectData) { |
|
37 this.superObjectData = superObjectData; |
|
38 this.typeHandler = typeHandler; |
|
39 this.underlyingObject = inputObject; |
|
40 |
|
41 if (fieldArraySize == 0) { |
|
42 fieldArray = null; |
|
43 } else { |
|
44 fieldArray = new Object[fieldArraySize]; |
|
45 } |
|
46 } |
|
47 |
|
48 void initProxy(Object proxy) { |
|
49 this.proxy = proxy; |
|
50 } |
|
51 |
|
52 Object[] getFieldArray() { |
|
53 return fieldArray; |
|
54 } |
|
55 |
|
56 Object getUnderlyingObject() { |
|
57 return underlyingObject; |
|
58 } |
|
59 |
|
60 TypeHandler<?> getTypeHandler() { |
|
61 return typeHandler; |
|
62 } |
|
63 |
|
64 ObjectData getSuperObjectData() { |
|
65 return superObjectData; |
|
66 } |
|
67 |
|
68 Object getProxy() { |
|
69 return proxy; |
|
70 } |
|
71 } |