Path: blob/trunk/third_party/closure/goog/net/streams/streamparser.js
1865 views
// Copyright 2015 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.1314/**15* @fileoverview the private interface for implementing parsers responsible16* for decoding the input stream (e.g. an HTTP body) to objects per their17* specified content-types, e.g. JSON, Protobuf.18*19* A default JSON parser is provided,20*21* A Protobuf stream parser is also provided.22*/2324goog.provide('goog.net.streams.StreamParser');25262728/**29* This interface represents a stream parser.30*31* @interface32* @package33*/34goog.net.streams.StreamParser = function() {};353637/**38* Checks if the parser is aborted due to invalid input.39*40* @return {boolean} true if the input is still valid.41*/42goog.net.streams.StreamParser.prototype.isInputValid = goog.abstractMethod;434445/**46* Checks the error message.47*48* @return {?string} any debug info on the first invalid input, or null if49* the input is still valid.50*/51goog.net.streams.StreamParser.prototype.getErrorMessage = goog.abstractMethod;525354/**55* Parse the new input.56*57* Note that there is no Parser state to indicate the end of a stream.58*59* @param {string|!ArrayBuffer|!Array<number>} input The input data60* @throws {!Error} if the input is invalid, and the parser will remain invalid61* once an error has been thrown.62* @return {?Array<string|!Object>} any parsed objects (atomic messages)63* in an array, or null if more data needs be read to parse any new object.64*/65goog.net.streams.StreamParser.prototype.parse = goog.abstractMethod;666768