Examples of InvalidTypeException


Examples of com.datastax.driver.core.exceptions.InvalidTypeException

        int[] indexes = getAllIndexesOf(name);
        ByteBuffer value = v == null ? null : TypeCodec.UUIDCodec.instance.serialize(v);
        for (int i = 0; i < indexes.length; i++) {
            DataType.Name type = checkType(indexes[i], DataType.Name.UUID, DataType.Name.TIMEUUID);
            if (v != null && type == DataType.Name.TIMEUUID && v.version() != 1)
                throw new InvalidTypeException(String.format("%s is not a Type 1 (time-based) UUID", v));
            setValue(indexes[i], value);
        }
        return wrapped;
    }
View Full Code Here

Examples of com.datastax.driver.core.exceptions.InvalidTypeException

    }

    public <E> T setList(int i, List<E> v) {
        DataType type = getType(i);
        if (type.getName() != DataType.Name.LIST)
            throw new InvalidTypeException(String.format("Column %s is of type %s, cannot set to a list", getName(i), type));

        if (v == null)
            return setValue(i, null);

        // If the list is empty, it will never fail validation, but otherwise we should check the list given if of the right type
        if (!v.isEmpty()) {
            // Ugly? Yes
            Class<?> providedClass = v.get(0).getClass();
            Class<?> expectedClass = type.getTypeArguments().get(0).asJavaClass();

            if (!expectedClass.isAssignableFrom(providedClass))
                throw new InvalidTypeException(String.format("Invalid value for column %s of CQL type %s, expecting list of %s but provided list of %s", getName(i), type, expectedClass, providedClass));
        }
        return setValue(i, type.codec(protocolVersion).serialize(v));
    }
View Full Code Here

Examples of com.datastax.driver.core.exceptions.InvalidTypeException

    }

    public <K, V> T setMap(int i, Map<K, V> v) {
        DataType type = getType(i);
        if (type.getName() != DataType.Name.MAP)
            throw new InvalidTypeException(String.format("Column %s is of type %s, cannot set to a map", getName(i), type));

        if (v == null)
            return setValue(i, null);

        if (!v.isEmpty()) {
            // Ugly? Yes
            Map.Entry<K, V> entry = v.entrySet().iterator().next();
            Class<?> providedKeysClass = entry.getKey().getClass();
            Class<?> providedValuesClass = entry.getValue().getClass();

            Class<?> expectedKeysClass = type.getTypeArguments().get(0).getName().javaType;
            Class<?> expectedValuesClass = type.getTypeArguments().get(1).getName().javaType;
            if (!expectedKeysClass.isAssignableFrom(providedKeysClass) || !expectedValuesClass.isAssignableFrom(providedValuesClass))
                throw new InvalidTypeException(String.format("Invalid value for column %s of CQL type %s, expecting map of %s->%s but provided map of %s->%s", getName(i), type, expectedKeysClass, expectedValuesClass, providedKeysClass, providedValuesClass));
        }
        return setValue(i, type.codec(protocolVersion).serialize(v));
    }
View Full Code Here

Examples of com.datastax.driver.core.exceptions.InvalidTypeException

    }

    public <E> T setSet(int i, Set<E> v) {
        DataType type = getType(i);
        if (type.getName() != DataType.Name.SET)
            throw new InvalidTypeException(String.format("Column %s is of type %s, cannot set to a set", getName(i), type));

        if (v == null)
            return setValue(i, null);

        if (!v.isEmpty()) {
            // Ugly? Yes
            Class<?> providedClass = v.iterator().next().getClass();
            Class<?> expectedClass = type.getTypeArguments().get(0).getName().javaType;

            if (!expectedClass.isAssignableFrom(providedClass))
                throw new InvalidTypeException(String.format("Invalid value for column %s of CQL type %s, expecting set of %s but provided set of %s", getName(i), type, expectedClass, providedClass));
        }
        return setValue(i, type.codec(protocolVersion).serialize(v));
    }
View Full Code Here

Examples of com.sun.jdi.InvalidTypeException

          JdwpCommandPacket.CT_INVOKE_METHOD, outBytes);
      switch (replyPacket.errorCode()) {
      case JdwpReplyPacket.INVALID_METHODID:
        throw new IllegalArgumentException();
      case JdwpReplyPacket.TYPE_MISMATCH:
        throw new InvalidTypeException();
      case JdwpReplyPacket.INVALID_CLASS:
        throw new ClassNotLoadedException(name());
      case JdwpReplyPacket.INVALID_THREAD:
        throw new IncompatibleThreadStateException();
      case JdwpReplyPacket.THREAD_NOT_SUSPENDED:
View Full Code Here

Examples of org.apache.camel.InvalidTypeException

     */
    public static <T> T convertToMandatoryType(Exchange exchange, Class<T> type, Object value)
        throws InvalidTypeException {
        T answer = convertToType(exchange, type, value);
        if (answer == null) {
            throw new InvalidTypeException(exchange, value, type);
        }
        return answer;
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.hbql.impl.InvalidTypeException

        else if (TypeSupport.isParentClass(DateValue.class, type0, type1, type2))
            this.setTypedExpr(new DateBetweenStmt(this.getExprArg(0), this.isNot(), this.getExprArg(1), this.getExprArg(2)));
        else if (TypeSupport.isParentClass(ByteValue.class, type0, type1, type2))
            this.setTypedExpr(new ByteBetweenStmt(this.getExprArg(0), this.isNot(), this.getExprArg(1), this.getExprArg(2)));
        else
            throw new InvalidTypeException(this.getInvalidTypeMsg(type0, type1, type2));

        return this.getTypedExpr().validateTypes(parentExpr, false);
    }
View Full Code Here

Examples of org.jboss.errai.codegen.exception.InvalidTypeException

        if (classAliases.contains(from.getFullyQualifiedName()) && classAliases.contains(to.getFullyQualifiedName())) {
          // handle convertibility between MetaClass API and java Class reference.
          return;
        }

        throw new InvalidTypeException(to.getFullyQualifiedName() + " is not assignable from "
            + from.getFullyQualifiedName());
      }
    }
  }
View Full Code Here

Examples of org.jboss.errai.codegen.framework.exception.InvalidTypeException

      throw new TypeNotIterableException(statement.generate(Context.create()));
  }

  public static void assertAssignableTypes(MetaClass from, MetaClass to) {
    if (!to.asBoxed().isAssignableFrom(from.asBoxed())) {
      throw new InvalidTypeException(to.getFullyQualifiedName() + " is not assignable from "
              + from.getFullyQualifiedName());
    }
  }
View Full Code Here

Examples of org.jboss.errai.ioc.rebind.ioc.codegen.exception.InvalidTypeException

 
  private MetaClass inferType(Context context, Object initialization) {
    Statement initStatement = GenUtil.generate(context, initialization);
    MetaClass inferredType = (initStatement != null) ? initStatement.getType() : null;
    if (inferredType == null) {
      throw new InvalidTypeException("No type specified and no initialization provided to infer the type.");
    }

    return inferredType;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.