org.chromium.sdk/src/org/chromium/sdk/internal/protocolparser/dynamicimpl/SlowParser.java
changeset 2 e4420d2515f1
equal deleted inserted replaced
1:ef76fc2ac88c 2:e4420d2515f1
       
     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 
       
     9 /**
       
    10  * A parser that accepts value of JSON field and outputs value in another form (e.g. string
       
    11  * is converted to enum constant) to serve field getters in JsonType interfaces.
       
    12  * <p>
       
    13  * First the input value should be processed by {@link #parseValue(Object, ObjectData)} method
       
    14  * that returns intermediate value (that may be stored in {@link ObjectData#getFieldArray()} array).
       
    15  * Then the output value may be obtained via value post-processor, available
       
    16  * from {@link #getValueFinisher()} (which is null in most cases, but not always).
       
    17  * <p>The parser's name "slow" reads "may be slow". It means that parser may do heavy operations.
       
    18  * Alternatively parser may be (optionally) castable to {@link QuickParser}
       
    19  * via {@link #asQuickParser()} method.
       
    20  */
       
    21 abstract class SlowParser<T> {
       
    22   abstract T parseValue(Object value, ObjectData thisData) throws JsonProtocolParseException;
       
    23 
       
    24   abstract FieldLoadedFinisher getValueFinisher();
       
    25   abstract JsonTypeParser<?> asJsonTypeParser();
       
    26 
       
    27   QuickParser<T> asQuickParser() {
       
    28     return null;
       
    29   }
       
    30 }