コード例 #1
0
  public boolean evaluateAsBoolean(Context context) throws XPathException {
    /*  48*/ boolean flag = node.evaluateAsBoolean(context);
    /*  49*/ if (flag) {
      /*  50*/ if ((value instanceof StringValue)
          || (value instanceof FragmentValue)
          || (value instanceof TextFragmentValue)) {
        /*  53*/ switch (operator) {
            /*  55*/ case 11: // '\013'
            /*  55*/ return node.evaluateAsString(context).equals(value.asString());

            /*  57*/ case 34: // '"'
            /*  57*/ return !node.evaluateAsString(context).equals(value.asString());

            /*  59*/ case 22: // '\026'
            /*  59*/ return node.evaluateAsNumber(context) < value.asNumber();

            /*  61*/ case 24: // '\030'
            /*  61*/ return node.evaluateAsNumber(context) <= value.asNumber();

            /*  63*/ case 21: // '\025'
            /*  63*/ return node.evaluateAsNumber(context) > value.asNumber();

            /*  65*/ case 23: // '\027'
            /*  65*/ return node.evaluateAsNumber(context) >= value.asNumber();
        }
        /*  67*/ throw new XPathException("Bad operator in singleton comparison");
      }
      /*  69*/ if (value instanceof NumericValue) {
        /*  70*/ switch (operator) {
            /*  72*/ case 11: // '\013'
            /*  72*/ return node.evaluateAsNumber(context) == value.asNumber();

            /*  74*/ case 34: // '"'
            /*  74*/ return node.evaluateAsNumber(context) != value.asNumber();

            /*  76*/ case 22: // '\026'
            /*  76*/ return node.evaluateAsNumber(context) < value.asNumber();

            /*  78*/ case 24: // '\030'
            /*  78*/ return node.evaluateAsNumber(context) <= value.asNumber();

            /*  80*/ case 21: // '\025'
            /*  80*/ return node.evaluateAsNumber(context) > value.asNumber();

            /*  82*/ case 23: // '\027'
            /*  82*/ return node.evaluateAsNumber(context) >= value.asNumber();
        }
        /*  84*/ throw new XPathException("Bad operator in singleton comparison");
      } else {
        /*  87*/ throw new XPathException("Unrecognized type in singleton comparison");
      }
    } else {
      /*  91*/ return false;
    }
  }
コード例 #2
0
ファイル: ComputedFunction.java プロジェクト: xxv/Units
    // -----------------------------------------------------------------
    //  Apply the function (or inverse) defined by the object
    //  to Value 'v'.
    // -----------------------------------------------------------------
    void applyTo(Value v, String inv) {
      v.completereduce();
      if (dimen != null) {
        Value dim;
        try {
          dim = Value.parse(dimen);
        } catch (EvalError e) {
          throw new EvalError(
              "Invalid dimension, "
                  + dimen
                  + ", of function "
                  + inv
                  + name
                  + ". "
                  + e.getMessage());
        }
        dim.completereduce();
        if (!dim.isCompatibleWith(v, Factor.Ignore.NONE))
          throw new EvalError(
              "Argument "
                  + v.asString()
                  + " of function "
                  + inv
                  + name
                  + " is not conformable to "
                  + dim.asString()
                  + ".");
      }

      Value result;
      try {
        result = Value.parse(def, param, v);
      } catch (EvalError e) {
        throw new EvalError(
            "Invalid definition of function '" + inv + name + "'. " + e.getMessage());
      }

      v.copyFrom(result);
    } // end applyTo
コード例 #3
0
  /**
   * Find the string value of a stylesheet variable or parameter
   *
   * <p>Returns the string value of <code>varName</code> in the current <code>context</code>.
   * Returns the empty string if the variable is not defined.
   *
   * @param context The current stylesheet context
   * @param varName The name of the variable (without the dollar sign)
   * @return The string value of the variable
   */
  protected static String getVariable(Context context, String varName) {
    Value variable = null;
    String varString = null;

    try {
      variable = Extensions.evaluate(context, "$" + varName);
      varString = variable.asString();
      return varString;
    } catch (TransformerException te) {
      System.out.println("Undefined variable: " + varName);
      return "";
    } catch (IllegalArgumentException iae) {
      System.out.println("Undefined variable: " + varName);
      return "";
    }
  }