コード例 #1
0
 @MJI
 public int read___3BII__I(
     MJIEnv env, int this_ptr, int data_array, int start, int len, FeatureExpr ctx) {
   int i = 0;
   long current_posn = env.getLongField(this_ptr, current_position).getValue();
   long current_len = env.getLongField(this_ptr, current_length).getValue();
   while (i < len && current_posn < current_len) {
     env.setByteArrayElement(
         ctx, data_array, start + i, new One<>(readByte____B(env, this_ptr, ctx)));
     i += 1;
     current_posn += 1;
   }
   if (i == 0) {
     return -1;
   }
   return i;
 }
コード例 #2
0
  @MJI
  public int encode___3CII___3B(
      MJIEnv env, int clsObjRef, int cref, int off, int len, FeatureExpr ctx) {

    int bref = env.newByteArray(len);
    for (int i = 0, j = off; i < len; i++, j++) {
      env.setByteArrayElement(
          ctx,
          bref,
          i,
          env.getCharArrayElement(cref, j)
              .map(
                  new Function<Character, Byte>() {

                    @Override
                    public Byte apply(Character c) {
                      return (byte) c.charValue();
                    }
                  }));
    }

    return bref;
  }