org.chromium.sdk/src/org/chromium/sdk/internal/protocolparser/dynamicimpl/QuickParser.java
equal
deleted
inserted
replaced
|
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.JsonProtocolParseException; |
|
8 import org.chromium.sdk.internal.protocolparser.JsonSubtypeCondition; |
|
9 |
|
10 /** |
|
11 * A parser that accepts value of JSON field and outputs value in another form (e.g. string |
|
12 * is converted to enum constant) to serve field getters in JsonType interfaces. |
|
13 * The parser is called "quick" because it is supposed to employ only fast conversions. |
|
14 * The quick parser should be suitable for subtype conditions |
|
15 * (see {@link JsonSubtypeCondition} etc), because they should not take long to evaluate. |
|
16 */ |
|
17 abstract class QuickParser<T> extends SlowParser<T> { |
|
18 @Override |
|
19 public T parseValue(Object value, ObjectData thisData) throws JsonProtocolParseException { |
|
20 return parseValueQuick(value); |
|
21 } |
|
22 |
|
23 /** |
|
24 * Parses input value and returns output that doesn't need any post-processing |
|
25 * by {@link FieldLoadedFinisher} (see {@link SlowParser}). |
|
26 */ |
|
27 public abstract T parseValueQuick(Object value) throws JsonProtocolParseException; |
|
28 |
|
29 @Override |
|
30 public QuickParser<T> asQuickParser() { |
|
31 return this; |
|
32 } |
|
33 |
|
34 @Override |
|
35 public FieldLoadedFinisher getValueFinisher() { |
|
36 return null; |
|
37 } |
|
38 |
|
39 @Override |
|
40 public JsonTypeParser<?> asJsonTypeParser() { |
|
41 return null; |
|
42 } |
|
43 } |