Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/third_party/closure/goog/net/streams/streamparser.js
1865 views
1
// Copyright 2015 The Closure Library Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS-IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
/**
16
* @fileoverview the private interface for implementing parsers responsible
17
* for decoding the input stream (e.g. an HTTP body) to objects per their
18
* specified content-types, e.g. JSON, Protobuf.
19
*
20
* A default JSON parser is provided,
21
*
22
* A Protobuf stream parser is also provided.
23
*/
24
25
goog.provide('goog.net.streams.StreamParser');
26
27
28
29
/**
30
* This interface represents a stream parser.
31
*
32
* @interface
33
* @package
34
*/
35
goog.net.streams.StreamParser = function() {};
36
37
38
/**
39
* Checks if the parser is aborted due to invalid input.
40
*
41
* @return {boolean} true if the input is still valid.
42
*/
43
goog.net.streams.StreamParser.prototype.isInputValid = goog.abstractMethod;
44
45
46
/**
47
* Checks the error message.
48
*
49
* @return {?string} any debug info on the first invalid input, or null if
50
* the input is still valid.
51
*/
52
goog.net.streams.StreamParser.prototype.getErrorMessage = goog.abstractMethod;
53
54
55
/**
56
* Parse the new input.
57
*
58
* Note that there is no Parser state to indicate the end of a stream.
59
*
60
* @param {string|!ArrayBuffer|!Array<number>} input The input data
61
* @throws {!Error} if the input is invalid, and the parser will remain invalid
62
* once an error has been thrown.
63
* @return {?Array<string|!Object>} any parsed objects (atomic messages)
64
* in an array, or null if more data needs be read to parse any new object.
65
*/
66
goog.net.streams.StreamParser.prototype.parse = goog.abstractMethod;
67
68