|
26 | 26 |
|
27 | 27 | from __future__ import absolute_import |
28 | 28 |
|
29 | | -from typing import Optional |
| 29 | +from typing import List, Optional |
30 | 30 |
|
31 | | -from .beans import JavaClassDesc, JavaInstance # pylint:disable=W0611 |
32 | | -from .stream import DataStreamReader # pylint:disable=W0611 |
33 | 31 | from ..constants import TypeCode # pylint:disable=W0611 |
| 32 | +from .beans import ( # pylint:disable=W0611 |
| 33 | + JavaClassDesc, |
| 34 | + JavaInstance, |
| 35 | + ParsedJavaContent, |
| 36 | +) |
| 37 | +from .stream import DataStreamReader # pylint:disable=W0611 |
34 | 38 |
|
35 | 39 | # ------------------------------------------------------------------------------ |
36 | 40 |
|
|
44 | 48 | # ------------------------------------------------------------------------------ |
45 | 49 |
|
46 | 50 |
|
| 51 | +class IJavaStreamParser: |
| 52 | + """ |
| 53 | + API of the Java stream parser |
| 54 | + """ |
| 55 | + |
| 56 | + def run(self): |
| 57 | + # type: () -> List[ParsedJavaContent] |
| 58 | + """ |
| 59 | + Parses the input stream |
| 60 | + """ |
| 61 | + raise NotImplementedError |
| 62 | + |
| 63 | + def dump(self, content): |
| 64 | + # type: (List[ParsedJavaContent]) -> str |
| 65 | + """ |
| 66 | + Dumps to a string the given objects |
| 67 | + """ |
| 68 | + raise NotImplementedError |
| 69 | + |
| 70 | + def _read_content(self, type_code, block_data, class_desc=None): |
| 71 | + # type: (int, bool, Optional[JavaClassDesc]) -> ParsedJavaContent |
| 72 | + """ |
| 73 | + Parses the next content. Use with care (use only in a transformer) |
| 74 | + """ |
| 75 | + |
| 76 | + |
47 | 77 | class ObjectTransformer(object): # pylint:disable=R0205 |
48 | 78 | """ |
49 | 79 | Representation of an object transformer |
@@ -84,7 +114,7 @@ def load_array( |
84 | 114 | def load_custom_writeObject( |
85 | 115 | self, parser, reader, name |
86 | 116 | ): # pylint:disable=W0613,R0201 |
87 | | - # type: (JavaStreamParser, DataStreamReader, str) -> Optional[JavaClassDesc] |
| 117 | + # type: (IJavaStreamParser, DataStreamReader, str) -> Optional[JavaClassDesc] |
88 | 118 | """ |
89 | 119 | Reads content stored from a custom writeObject. |
90 | 120 |
|
|
0 commit comments