Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

40
LINES

< > BotCompany Repo | #1033361 // JECompressionRegime

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (14743L/93K).

1  
sclass JECompressionRegime<Data> is CompressionRegime_AnyType<IJavaExpr<Data>> {
2  
  settable bool quickEval = true;
3  
  settable bool fullEval = false;
4  
  
5  
  byte[] metaCompress(byte[] c) {
6  
    //ret gzipBytes(c);
7  
    ret c;
8  
  }
9  
  
10  
  public byte[] decompressorToBytes(IJavaExpr decompressor) {
11  
    ret metaCompress(toUtf8(str(decompressor)));
12  
  }
13  
  
14  
  public IJavaExpr decompressorFromBytes(byte[] compressed) {
15  
    print("decompressorFromBytes");
16  
    ret javaExpr(fromUtf8(gunzipBytes(compressed)));
17  
  }
18  
  
19  
  public O runDecompressor(IJavaExpr code) {
20  
    if (code == null) null;
21  
    
22  
    if (quickEval) try {
23  
      ret code.quickEval();
24  
    } catch e {
25  
      if (!fullEval)
26  
        rethrow(e);
27  
      else
28  
        printStackTrace(e);
29  
    }
30  
      
31  
    if (fullEval) {
32  
      print("*** FULL JAVA EVAL ***");
33  
      ret dm_javaEval(str(code));
34  
    }
35  
    
36  
    fail("No way to eval " + shorten(100, sfu(code)));
37  
  }
38  
  
39  
  public swappable CompressionRegime_AnyType fullRegime() { null; }
40  
}

Author comment

Began life as a copy of #1033160

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033361
Snippet name: JECompressionRegime
Eternal ID of this version: #1033361/4
Text MD5: 866fd5827648ee7c798651e3c010dcce
Transpilation MD5: 8d08838bb5bde6929c199fc13eab8f79
Author: stefan
Category: javax / recognition by compression
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-25 02:41:39
Source code size: 1018 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 204 / 305
Version history: 3 change(s)
Referenced in: [show references]