Example #1
0
  /**
   * Encode any scilab type to a buffer
   *
   * @param var the Scilab value to encode
   * @return the encoded buffer
   */
  public VectorOfDouble var2vec(ScilabType var) {
    final ScilabType value;
    if (var == null) {
      value = new ScilabDouble();
    } else {
      value = var;
    }

    if (LOG.isLoggable(Level.FINER)) {
      LOG.entering(ScilabTypeCoder.class.getCanonicalName(), "var2vec");
    }

    VectorOfDouble vec = new VectorOfDouble();
    encode(value, vec);

    // System.err.println("var2vec:" + var.toString() + ":" + toString(vec));
    if (LOG.isLoggable(Level.FINE)) {
      LOG.log(Level.FINE, "var2vec:{0}:{1}", new Object[] {var.toString(), toString(vec)});
    }

    if (LOG.isLoggable(Level.FINER)) {
      LOG.exiting(ScilabTypeCoder.class.getCanonicalName(), "var2vec");
    }

    return vec;
  }
Example #2
0
  /**
   * Decode a scilab type from a buffer
   *
   * @param vec the buffer containing encoded scilab types
   * @return the decoded scilab type
   */
  public ScilabType vec2var(VectorOfDouble vec) {
    position = 0;

    if (LOG.isLoggable(Level.FINER)) {
      LOG.entering(ScilabTypeCoder.class.getName(), "vec2var", vec);
    }

    ScilabType var = decodeHeader(vec);
    decode(vec, var);

    // System.err.println("vec2var:" + toString(vec) + ":" + var.toString());
    if (LOG.isLoggable(Level.FINE)) {
      LOG.log(Level.FINE, "vec2var:{0}:{1}", new Object[] {toString(vec), var.toString()});
    }

    if (LOG.isLoggable(Level.FINER)) {
      LOG.exiting(ScilabTypeCoder.class.getName(), "vec2var");
    }

    return var;
  }