Esempio n. 1
0
  /**
   * Try to get a constant factory
   *
   * @param a the first node
   * @param b the second node
   * @param s the node type set
   * @return the constant factory
   */
  public static final ConstantType getConstantType(
      final Node<?> a, final Node<?> b, final NodeTypeSet<?> s) {
    NodeType<?, ?> t;
    int i;

    if (a != null) {
      t = a.getType();
      if (t instanceof ConstantType) {
        return ((ConstantType) t);
      }
    }

    if (b != null) {
      t = b.getType();
      if (t instanceof ConstantType) {
        return ((ConstantType) t);
      }
    }

    if (s != null) {
      for (i = s.size(); (--i) >= 0; ) {
        t = s.get(i);
        if (t instanceof ConstantType) {
          return ((ConstantType) t);
        }
      }
    }

    return DEFAULT_CONSTANT_TYPE;
  }