Exemplo n.º 1
0
  /**
   * Returns whether the specified Structure is compatible with NTUnion.
   *
   * <p>Checks if the specified Structure is compatible with this version of NTUnion through the
   * introspection interface.
   *
   * @param structure the Structure to test
   * @return (false,true) if (is not, is) a compatible NTUnion
   */
  public static boolean isCompatible(Structure structure) {
    if (structure == null) return false;

    Union valueField = structure.getField(Union.class, "value");
    if (valueField == null) return false;

    NTField ntField = NTField.get();

    Field field = structure.getField("descriptor");
    if (field != null) {
      Scalar descriptorField = structure.getField(Scalar.class, "descriptor");
      if (descriptorField == null || descriptorField.getScalarType() != ScalarType.pvString)
        return false;
    }

    field = structure.getField("alarm");
    if (field != null && !ntField.isAlarm(field)) return false;

    field = structure.getField("timeStamp");
    if (field != null && !ntField.isTimeStamp(field)) return false;

    return true;
  }
Exemplo n.º 2
0
 /**
  * Returns whether the specified Structure reports to be a compatible NTUnion.
  *
  * <p>Checks if the specified Structure reports compatibility with this version of NTUnion through
  * its type ID, including checking version numbers. The return value does not depend on whether
  * the structure is actually compatible in terms of its introspection type.
  *
  * @param structure the Structure to test
  * @return (false,true) if (is not, is) a compatible NTUnion
  */
 public static boolean is_a(Structure structure) {
   return NTUtils.is_a(structure.getID(), URI);
 }