Ejemplo n.º 1
0
 public XQValue convertFromObject(Object object) throws XQTypeException {
   boolean value = false;
   if (object instanceof String) value = Conversion.toBoolean((String) object);
   else if (object instanceof Boolean) value = ((Boolean) object).booleanValue();
   else invalidCast(object);
   return new SingleBoolean(value);
 }
Ejemplo n.º 2
0
  public XQValue cast(XQItem value, EvalContext context) throws EvaluationException {
    XQItemType type = value.getItemType();

    switch (type.quickCode()) {
      case XQType.QT_STRING:
      case XQType.QT_UNTYPED:
        return new SingleBoolean(Conversion.toBoolean(value.getString().trim()));
      case XQType.QT_DEC:
      case XQType.QT_INT:
      case XQType.QT_FLOAT:
      case XQType.QT_DOUBLE: // extension
      case XQType.QT_BOOL:
        return new SingleBoolean(value.getBoolean());

      default:
        invalidCast(type);
        return null;
    }
  }