• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tcalmant / python-javaobj / 31607645069

12 Aug 2026 02:35PM UTC coverage: 92.1% (-0.1%) from 92.232%
31607645069

Pull #73

github

web-flow
Merge bc199b4ff into 08d0f2047
Pull Request #73: Fixed the wrong type hints and declared the package as typed

9 of 14 new or added lines in 5 files covered. (64.29%)

3008 of 3266 relevant lines covered (92.1%)

0.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.82
/javaobj/v2/api.py
1
#!/usr/bin/env python3
2
"""
3
Definition of the object transformer API
4

5
:authors: Thomas Calmant
6
:license: Apache License 2.0
7
:version: 0.6.1
8
:status: Alpha
9

10
..
11

12
    Copyright 2026 Thomas Calmant
13

14
    Licensed under the Apache License, Version 2.0 (the "License");
15
    you may not use this file except in compliance with the License.
16
    You may obtain a copy of the License at
17

18
        http://www.apache.org/licenses/LICENSE-2.0
19

20
    Unless required by applicable law or agreed to in writing, software
21
    distributed under the License is distributed on an "AS IS" BASIS,
22
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
    See the License for the specific language governing permissions and
24
    limitations under the License.
25
"""
26

27
from __future__ import absolute_import
1✔
28

29
from typing import List, Optional  # noqa: F401
1✔
30

31
from ..constants import TypeCode  # noqa: F401
1✔
32
from .beans import (  # noqa: F401
1✔
33
    JavaClassDesc,
34
    JavaInstance,
35
    ParsedJavaContent,
36
)
37
from .stream import DataStreamReader  # noqa: F401
1✔
38

39
# ------------------------------------------------------------------------------
40

41
# Module version
42
__version_info__ = (0, 6, 1)
1✔
43
__version__ = ".".join(str(x) for x in __version_info__)
1✔
44

45
# Documentation strings format
46
__docformat__ = "restructuredtext en"
1✔
47

48
# ------------------------------------------------------------------------------
49

50

51
class IJavaStreamParser:
1✔
52
    """
53
    API of the Java stream parser
54
    """
55

56
    def run(self):
1✔
57
        # type: () -> List[Optional[ParsedJavaContent]]
58
        """
59
        Parses the input stream
60
        """
61
        raise NotImplementedError
×
62

63
    def dump(self, content):
1✔
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):
1✔
71
        # type: (int, bool, Optional[JavaClassDesc]) -> Optional[ParsedJavaContent]
72
        """
73
        Parses the next content. Use with care (use only in a transformer)
74

75
        :return: The parsed content, None if the stream holds TC_NULL
76
        """
NEW
77
        raise NotImplementedError
×
78

79

80
class ObjectTransformer(object):  # pylint:disable=R0205
1✔
81
    """
82
    Representation of an object transformer
83
    """
84

85
    def create_instance(self, classdesc):  # pylint:disable=W0613,R0201
1✔
86
        # type: (JavaClassDesc) -> Optional[JavaInstance]
87
        """
88
        Transforms a parsed Java object into a Python object.
89

90
        The result must be a JavaInstance bean, or None if the transformer
91
        doesn't support this kind of instance.
92

93
        :param classdesc: The description of a Java class
94
        :return: The Python form of the object, or the original JavaObject
95
        """
96
        return None
×
97

98
    def load_array(
1✔
99
        self, reader, type_code, size
100
    ):  # pylint:disable=W0613,R0201
101
        # type: (DataStreamReader, TypeCode, int) -> Optional[list]
102
        """
103
        Loads and returns the content of a Java array, if possible.
104

105
        The result of this method must be the content of the array, i.e. a list
106
        or an array. It will be stored in a JavaArray bean created by the
107
        parser.
108

109
        This method must return None if it can't handle the array.
110

111
        :param reader: The data stream reader
112
        :param type_code: Type of the elements of the array
113
        :param size: Number of elements in the array
114
        """
115
        return None
1✔
116

117
    def load_custom_writeObject(
1✔
118
        self, parser, reader, name
119
    ):  # pylint:disable=W0613,R0201
120
        # type: (IJavaStreamParser, DataStreamReader, str) -> Optional[JavaClassDesc]
121
        """
122
        Reads content stored from a custom writeObject.
123

124
        This method is called only if the class description has both the
125
        ``SC_SERIALIZABLE`` and ``SC_WRITE_METHOD`` flags set.
126

127
        The stream parsing will stop and fail if this method returns None.
128

129
        :param parser: The JavaStreamParser in use
130
        :param reader: The data stream reader
131
        :param name: The class description name
132
        :return: A Java class description, if handled, else None
133
        """
134
        return None
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc