简体   繁体   English

Java的UniObjects读取目标代码文件

[英]UniObjects for Java read object code file

I am reading from a UniVerse database using UniObjects for Java using the UniFile.read() method. 我正在使用UniFile.read()方法从使用Java的UniObjects的UniVerse数据库中读取。 This is an example of the type of code I use for this. 这是我为此使用的代码类型的示例。

...
UniFile uFile = uSession.open ("ORDERS");
UniDataSet datasetRequest = getUnidatasetRequest();
UniDataSet datasetResult = uFile.read(datasetRequest);  
...

For most queries this works, but when I try to read an object file (eg SOMEFILE.O ), this read truncates the records within the file. 对于大多数查询,此方法有效,但是当我尝试读取目标文件(例如SOMEFILE.O )时,此读取将截断文件中的记录。 I am thinking that the special characters in the object code are causing problems. 我认为目标代码中的特殊字符引起了问题。

Is there a way to read object code records using UniObjects for Java? 有没有一种方法可以使用UniObjects for Java读取目标代码记录?

This is what we ended up doing: 我们最终要做的是:

I couldn't find a way to make the dataset read the binary code, so I read the items one at a time using a subroutine. 我找不到一种使数据集读取二进制代码的方法,因此我使用子例程一次读取一个项目。 Before the items could be read I had to install and run a UniBasic subroutine on the database to encode the item into base 64 using something like this: 在读取项目之前,我必须在数据库上安装并运行UniBasic子例程,以使用以下方法将项目编码为base 64:

...

LOOP
    READBLK A.BYTE FROM FILE, 1 THEN NULL ELSE DONE = TRUE
UNTIL DONE DO
    TO.ENCODE = TO.ENCODE : A.BYTE
REPEAT
ENCODE('Base64', 1, TO.ENCODE, 1, RET.VALUE, 1)

...

This subroutine returned the base 64 encoded item as a String to UOJ and then it could be decoded and no data was lost. 该子例程将以64为基数的编码项作为String给UOJ,然后可以对其进行解码,并且不会丢失任何数据。 Here is an example of the Java Code: 这是Java代码的示例:

...
UniSubroutine readBlkSub = unisession.subroutine(routineName, 4);
readBlkSub.setArg(0, getNameID());
readBlkSub.setArg(1, itemName);
readBlkSub.call();
final String SUCCESS = "0";
if (readBlkSub.getArg(3).equals(SUCCESS)) {
    encodedObjectCode = readBlkSub.getArg(2);
    sun.misc.BASE64Decoder decoder = new BASE64Decoder();
    byte[] decodedBytes = decoder.decodeBuffer(encodedObjectCode);
    ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM