Package lupos.engine.operators.singleinput

Examples of lupos.engine.operators.singleinput.TypeErrorException


        || a instanceof Float || a instanceof Double)
        && !(b instanceof BigInteger || b instanceof BigDecimal
            || b instanceof Float || b instanceof Double)) {
      if (b instanceof TypedLiteral) {
        if (!(isNumeric(((TypedLiteral) b).getType())))
          throw new TypeErrorException();
      } else
        throw new TypeErrorException();
    } else if ((b instanceof BigInteger || b instanceof BigDecimal
        || b instanceof Float || b instanceof Double)
        && !(a instanceof BigInteger || a instanceof BigDecimal
            || a instanceof Float || a instanceof Double)) {
      if (a instanceof TypedLiteral) {
        if (!(isNumeric(((TypedLiteral) a).getType())))
          throw new TypeErrorException();
      } else
        throw new TypeErrorException();
    } else if (a instanceof String && !(b instanceof String)) {
      if (b instanceof TypedLiteral) {
        if (((TypedLiteral) b).getType().compareTo(
            "<http://www.w3.org/2001/XMLSchema#string>") != 0)
          throw new TypeErrorException();
      } else if(!(b instanceof Literal && ((Literal)b).isSimpleLiteral()))
        throw new TypeErrorException();
    } else if (b instanceof String && !(a instanceof String)) {
      if (a instanceof TypedLiteral) {
        if (((TypedLiteral) a).getType().compareTo(
            "<http://www.w3.org/2001/XMLSchema#string>") != 0)
          throw new TypeErrorException();
      } else if (!(a instanceof Literal && ((Literal)a).isSimpleLiteral()))
        throw new TypeErrorException();
    } else if (a instanceof TypedLiteral && b instanceof TypedLiteral) {
      final String typea = ((TypedLiteral) a).getType();
      final String typeb = ((TypedLiteral) b).getType();
      if (typea.compareTo(typeb) != 0) {
        if (isNumeric(typea) && isNumeric(typeb))
          return;
        else {
          // check compatible types
          if (!((typea
              .compareTo("<http://www.w3.org/2001/XMLSchema#dateTime>") == 0
              || typea
                  .compareTo("<http://www.w3.org/2001/XMLSchema#time>") == 0 || typea
              .compareTo("<http://www.w3.org/2001/XMLSchema#date>") == 0) && (typeb
              .compareTo("<http://www.w3.org/2001/XMLSchema#dateTime>") == 0
              || typeb
                  .compareTo("<http://www.w3.org/2001/XMLSchema#time>") == 0 || typeb
              .compareTo("<http://www.w3.org/2001/XMLSchema#date>") == 0)))
            throw new TypeErrorException();
        }
      }
    } else if ((a instanceof CodeMapLiteral || a instanceof StringLiteral)
        && b instanceof TypedLiteral) {
      if (((TypedLiteral) b).getType().compareTo(
          "<http://www.w3.org/2001/XMLSchema#string>") != 0)
        throw new TypeErrorException();
    } else if ((b instanceof CodeMapLiteral || b instanceof StringLiteral)
        && a instanceof TypedLiteral) {
      if (((TypedLiteral) a).getType().compareTo(
          "<http://www.w3.org/2001/XMLSchema#string>") != 0)
        throw new TypeErrorException();
    }
  }
View Full Code Here


    else if ((typea == Float.class || typea == Double.class
        || typea == BigInteger.class || typea == BigDecimal.class)
        && (typeb == Float.class || typeb == Double.class
            || typeb == BigInteger.class || typeb == BigDecimal.class))
      return Double.class;
    throw new TypeErrorException();
  }
View Full Code Here

        return Float.class;
      if (tl.getType().compareTo(
          "<http://www.w3.org/2001/XMLSchema#decimal>") == 0)
        return BigDecimal.class;
    }
    throw new TypeErrorException();
  }
View Full Code Here

                      .compareTo("<http://www.w3.org/2001/XMLSchema#dateTime>") == 0 || typeb
                  .compareTo("<http://www.w3.org/2001/XMLSchema#time>") == 0)) {

            if /* The following is questionable */
            (typea.compareTo(typeb) != 0)
              throw new TypeErrorException();

            final Date da = getDate((TypedLiteral) a);
            final Date db = getDate((TypedLiteral) b);
            return (da.compareTo(db) > 0);
          }
          try {
            final Object type = getCoercionType(a, b);
            if (type == BigInteger.class) {
              return getInteger(a).compareTo(getInteger(b)) > 0;
            } else if (type == Double.class) {
              return getDouble(a) > getDouble(b);
            } else if (type == Float.class) {
              return getFloat(a) > getFloat(b);
            } else if (type == BigDecimal.class) {
              return getBigDecimal(a).compareTo(getBigDecimal(b)) > 0;
            }
          } catch (final TypeErrorException tee) {
            // ignore...
          }
        }
        if (a instanceof Literal) {
          return (a.toString().compareTo(b.toString()) > 0);
        }
        if (a instanceof String) {
          return (((String) a).compareTo((String) b)) > 0;
        }
        if (a instanceof Character) {
          return (((Character) a).compareTo((Character) b)) > 0;
        }
        if (a instanceof BigInteger) {
          return ((BigInteger) a).compareTo((BigInteger) b) > 0;
        }
        if (a instanceof Double) {
          return (Double) a > (Double) b;
        }
        if (a instanceof Float) {
          return (Float) a > (Float) b;
        }
        if (a instanceof BigDecimal) {
          return ((BigDecimal) a).compareTo((BigDecimal) b) > 0;
        }
      } catch (final TypeErrorException e) {
        throw e;
      } catch (final Exception e) {
        System.out.println("not comparable via \"greater than\"\n" + e);
      }
    } else {
      if ((a instanceof Number && b instanceof TypedLiteral)
          || (b instanceof Number && a instanceof TypedLiteral)
          || (a instanceof Number && b instanceof Number)) {
        final Object type = getCoercionType(a, b);
        if (type == BigInteger.class) {
          return getInteger(a).compareTo(getInteger(b)) > 0;
        } else if (type == Double.class) {
          return getDouble(a) > getDouble(b);
        } else if (type == Float.class) {
          return getFloat(a) > getFloat(b);
        } else if (type == BigDecimal.class) {
          return getBigDecimal(a).compareTo(getBigDecimal(b)) > 0;
        }
      } else if ((a instanceof String || a instanceof Character
          || a instanceof CodeMapLiteral || a instanceof StringLiteral)
          && (b instanceof String || b instanceof Character
              || b instanceof CodeMapLiteral || b instanceof StringLiteral)) {
        final String aaa = getString(a);
        final String bbb = getString(b);
        return String.valueOf(aaa).compareTo(String.valueOf(bbb)) > 0;
      }
      if ((a instanceof StringLiteral && b instanceof TypedLiteral)
          || (b instanceof StringLiteral && a instanceof TypedLiteral)) {
        throw new TypeErrorException();
      }

      else {
        throw new TypeErrorException();
      }
    }
    return false;
  }
View Full Code Here

        // type.compareTo("<http://www.w3.org/2001/XMLSchema#integer>")
        // == 0
        if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#nonPositiveInteger>") == 0
            && bi.compareTo(new BigInteger("0")) > 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#negativeInteger>") == 0
            && bi.compareTo(new BigInteger("0")) >= 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#long>") == 0
            && bi.compareTo(new BigInteger("-9223372036854775808")) < 0
            && bi.compareTo(new BigInteger("9223372036854775807")) > 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#int>") == 0
            && bi.compareTo(new BigInteger("-2147483648")) < 0
            && bi.compareTo(new BigInteger("2147483647")) > 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#short>") == 0
            && bi.compareTo(new BigInteger("-32768")) < 0
            && bi.compareTo(new BigInteger("32767")) > 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#byte>") == 0
            && bi.compareTo(new BigInteger("-128")) < 0
            && bi.compareTo(new BigInteger("127")) > 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#nonNegativeInteger>") == 0
            && bi.compareTo(new BigInteger("0")) < 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#unsignedLong>") == 0
            && bi.compareTo(new BigInteger("0")) < 0
            && bi.compareTo(new BigInteger("18446744073709551615")) > 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#unsignedInt>") == 0
            && bi.compareTo(new BigInteger("0")) < 0
            && bi.compareTo(new BigInteger("4294967295")) > 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#unsignedShort>") == 0
            && bi.compareTo(new BigInteger("0")) < 0
            && bi.compareTo(new BigInteger("65535")) > 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#unsignedByte>") == 0
            && bi.compareTo(new BigInteger("0")) < 0
            && bi.compareTo(new BigInteger("255")) > 0)
          throw new TypeErrorException();
        else if (type
            .compareTo("<http://www.w3.org/2001/XMLSchema#positiveInteger>") == 0
            && bi.compareTo(new BigInteger("0")) <= 0)
          throw new TypeErrorException();
      } catch (final NumberFormatException nfe) {
        throw new TypeErrorException();
      }

    } else if (type.compareTo("<http://www.w3.org/2001/XMLSchema#float>") == 0) {
      try {
        Float.parseFloat(realContentWithoutDoubleQuote);
      } catch (final NumberFormatException nfe) {
        throw new TypeErrorException();
      }
    } else if (type.compareTo("<http://www.w3.org/2001/XMLSchema#double>") == 0) {
      try {
        Double.parseDouble(realContentWithoutDoubleQuote);
      } catch (final NumberFormatException nfe) {
        throw new TypeErrorException();
      }
    } else if (type.compareTo("<http://www.w3.org/2001/XMLSchema#decimal>") == 0) {
      try {
        new BigDecimal(realContentWithoutDoubleQuote);
        // any exponent is not allowed for the representation of
        // decimals! (The rest has been checked in the previous line!)
        if (realContentWithoutDoubleQuote.contains("e")
            || realContentWithoutDoubleQuote.contains("E")) {
          throw new TypeErrorException();
        }
      } catch (final NumberFormatException nfe) {
        throw new TypeErrorException();
      }
    } else if (isDate(type)) {
      try {
        getDate(realContentWithoutDoubleQuote);
      } catch (final Exception e) {
        throw new TypeErrorException();
      }
    } else if (type.compareTo("<http://www.w3.org/2001/XMLSchema#boolean>") == 0) {
      if (!(realContentWithoutDoubleQuote.compareTo("true") == 0
          || realContentWithoutDoubleQuote.compareTo("false") == 0
          || realContentWithoutDoubleQuote.compareTo("0") == 0 || realContentWithoutDoubleQuote
          .compareTo("1") == 0))
        throw new TypeErrorException();
    }

    // created casted TypedLiteral!
    try {
      return LiteralFactory.createTypedLiteral(realContent, type);
    } catch (final URISyntaxException e) {
      throw new TypeErrorException();
    }
  }
View Full Code Here

    } else if (type == Double.class) {
      Double left = Helper.getDouble(leftObject);
      Double right = Helper.getDouble(rightObject);
      return left + right;
    }
    throw new TypeErrorException();
  }
View Full Code Here

    } else if (type == Double.class) {
      Double left = Helper.getDouble(leftObject);
      Double right = Helper.getDouble(rightObject);
      return left - right;
    }
    throw new TypeErrorException();
  }
View Full Code Here

    } else if (type == Double.class) {
      Double left = Helper.getDouble(leftObject);
      Double right = Helper.getDouble(rightObject);
      return left * right;
    }
    throw new TypeErrorException();
  }
View Full Code Here

        return left / right;
      }
    } catch(Exception e){
      // ignore...
    }
    throw new TypeErrorException();
  }
View Full Code Here

      throws TypeErrorException {
    if (!(arg0.getClass() == Literal.class
        || arg0.getClass() == StringLiteral.class
        || arg0.getClass() == CodeMapLiteral.class || arg0 instanceof String
            )) {
      throw new TypeErrorException();
    }
    return getString(arg0);
  }
View Full Code Here

TOP

Related Classes of lupos.engine.operators.singleinput.TypeErrorException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.