Python's Java equivalent to build

Is there a Java equivalent to the Python build library? I want to write "structs" as follows:

message = Struct("message",
    UBInt8("protocol"),
    UBInt16("length"),
    MetaField("data", lambda ctx: ctx["length"])
)

It does not have to be a library with some kind of abstraction using the Java language. I mean, it could be a “portable” format with an API for analyzing documents. I think this might work with XML, but it would be much uglier.

I understand that I can just interact with Python, but I do not want to do this.

+3
source share
2 answers

, , , Ragel (www.complang.org/ragel), Java-. , Construct Java. , - Scala, Groovy JavaScript.

GitHub: https://github.com/MostAwesomeDude/construct

java construct: https://github.com/ZiglioNZ/construct

, python. Java, , - java.util.Scanner, java.util.Formatter java.nio.ByteBuffer. , - , ByteBuffers.

[]

, Python Construct, ethernet, arp ipv4. https://github.com/ZiglioNZ/construct

[: ]

Java Construct 1.1.2 , . .

+2

DataInput/DataOutput ( ) / . , , - .

, - / ?

-1

Source: https://habr.com/ru/post/1796653/


All Articles