jchtseg

command
v0.0.0-...-8ebcefe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2020 License: MIT Imports: 8 Imported by: 0

README

jchtseg

The java API for chtseg is done by compiling GO file into C shared library which can be called by java JNA. There are web pages which may help besides JNA document:

Installation and test

Please run

make all

and it will produce jchtseg.so and jchtseg.h for you to call from java. Please take a look on .h file for the declaration of public functions.

After JNA is installed and making it to your CLASSPATH, you can run the test file

java jtest.java

to see the sample output.

How to use

Let's take jtest.java for example.

Decalring the go function interface by extending Library class

public interface ChtsegLib extends Library {
    TwoStringsResult Getchtseg(String db, String conn, String teststr);
}

and set/create an instance refering to it from main class

private static String LIB_PATH = new File("jchtseg.so").getAbsolutePath();
static ChtsegLib INSTANCE = (ChtsegLib) Native.loadLibrary(LIB_PATH, ChtsegLib.class);

then call the function directly

ChtsegResult segRet = INSTANCE.Getchtseg(db, conn, test);

Given three parameters for input:

  • db : must be "sqlite3" or "mysql"
  • conn : should be db file path or connection string user:password@conntype(ip:port)/dbname regarding to db
  • test : string to be processed

The output format should meet the form denoted in .h file like the structure decalred in java file:

public class ChtsegResult extends Structure implements Structure.ByValue {
    public String r0;
    public String r1;

    protected List<String> getFieldOrder() {
        return Arrays.asList("r0", "r1");
    }
}

where r0 and r1 are json output and error message respectively. You can compare the json output with the test string while running jtest.java.

To do

Provide more sophisticated settings or functions.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL