Example usage for com.google.gwt.core.ext.typeinfo JPrimitiveType BYTE

List of usage examples for com.google.gwt.core.ext.typeinfo JPrimitiveType BYTE

Introduction

In this page you can find the example usage for com.google.gwt.core.ext.typeinfo JPrimitiveType BYTE.

Prototype

JPrimitiveType BYTE

To view the source code for com.google.gwt.core.ext.typeinfo JPrimitiveType BYTE.

Click Source Link

Usage

From source file:com.ekuefler.supereventbus.rebind.EventRegistrationWriter.java

License:Apache License

private String getFirstParameterType(JMethod method) {
    // If the parameter type is primitive, box it
    JType type = method.getParameterTypes()[0];
    if (type.isPrimitive() != null) {
        if (type.isPrimitive() == JPrimitiveType.BOOLEAN) {
            return Boolean.class.getName();
        } else if (type.isPrimitive() == JPrimitiveType.BYTE) {
            return Byte.class.getName();
        } else if (type.isPrimitive() == JPrimitiveType.CHAR) {
            return Character.class.getName();
        } else if (type.isPrimitive() == JPrimitiveType.DOUBLE) {
            return Double.class.getName();
        } else if (type.isPrimitive() == JPrimitiveType.FLOAT) {
            return Float.class.getName();
        } else if (type.isPrimitive() == JPrimitiveType.INT) {
            return Integer.class.getName();
        } else if (type.isPrimitive() == JPrimitiveType.LONG) {
            return Long.class.getName();
        } else if (type.isPrimitive() == JPrimitiveType.SHORT) {
            return Short.class.getName();
        }/*ww w.  jav  a 2  s  . c om*/
    }

    // Otherwise return the fully-qualified type name
    return type.getQualifiedSourceName();
}

From source file:com.hiramchirino.restygwt.rebind.JsonEncoderDecoderInstanceLocator.java

License:Apache License

public JsonEncoderDecoderInstanceLocator(GeneratorContext context, TreeLogger logger)
        throws UnableToCompleteException {
    this.context = context;
    this.logger = logger;

    this.STRING_TYPE = find(String.class);
    this.JSON_VALUE_TYPE = find(JSONValue.class);
    this.DOCUMENT_TYPE = find(Document.class);
    this.MAP_TYPE = find(Map.class);
    this.SET_TYPE = find(Set.class);
    this.LIST_TYPE = find(List.class);

    builtInEncoderDecoders.put(JPrimitiveType.BOOLEAN, JSON_ENCODER_DECODER_CLASS + ".BOOLEAN");
    builtInEncoderDecoders.put(JPrimitiveType.BYTE, JSON_ENCODER_DECODER_CLASS + ".BYTE");
    builtInEncoderDecoders.put(JPrimitiveType.CHAR, JSON_ENCODER_DECODER_CLASS + ".CHAR");
    builtInEncoderDecoders.put(JPrimitiveType.SHORT, JSON_ENCODER_DECODER_CLASS + ".SHORT");
    builtInEncoderDecoders.put(JPrimitiveType.INT, JSON_ENCODER_DECODER_CLASS + ".INT");
    builtInEncoderDecoders.put(JPrimitiveType.LONG, JSON_ENCODER_DECODER_CLASS + ".LONG");
    builtInEncoderDecoders.put(JPrimitiveType.FLOAT, JSON_ENCODER_DECODER_CLASS + ".FLOAT");
    builtInEncoderDecoders.put(JPrimitiveType.DOUBLE, JSON_ENCODER_DECODER_CLASS + ".DOUBLE");
    builtInEncoderDecoders.put(find(Boolean.class), JSON_ENCODER_DECODER_CLASS + ".BOOLEAN");
    builtInEncoderDecoders.put(find(Byte.class), JSON_ENCODER_DECODER_CLASS + ".BYTE");
    builtInEncoderDecoders.put(find(Character.class), JSON_ENCODER_DECODER_CLASS + ".CHAR");
    builtInEncoderDecoders.put(find(Short.class), JSON_ENCODER_DECODER_CLASS + ".SHORT");
    builtInEncoderDecoders.put(find(Integer.class), JSON_ENCODER_DECODER_CLASS + ".INT");
    builtInEncoderDecoders.put(find(Long.class), JSON_ENCODER_DECODER_CLASS + ".LONG");
    builtInEncoderDecoders.put(find(Float.class), JSON_ENCODER_DECODER_CLASS + ".FLOAT");
    builtInEncoderDecoders.put(find(Double.class), JSON_ENCODER_DECODER_CLASS + ".DOUBLE");

    builtInEncoderDecoders.put(STRING_TYPE, JSON_ENCODER_DECODER_CLASS + ".STRING");
    builtInEncoderDecoders.put(DOCUMENT_TYPE, JSON_ENCODER_DECODER_CLASS + ".DOCUMENT");
    builtInEncoderDecoders.put(JSON_VALUE_TYPE, JSON_ENCODER_DECODER_CLASS + ".JSON_VALUE");

    builtInEncoderDecoders.put(find(Date.class), JSON_ENCODER_DECODER_CLASS + ".DATE");

}

From source file:com.totsp.gwittir.rebind.beans.IntrospectorGenerator.java

License:Open Source License

private boolean box(JType type, SourceWriter writer) {
    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.INT)) {
        writer.print("new Integer( ");

        return true;
    }//from  w  ww  .  j a v  a2s . c  o m

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.LONG)) {
        writer.print("new Long( ");

        return true;
    }

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.FLOAT)) {
        writer.print("new Float( ");

        return true;
    }

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.DOUBLE)) {
        writer.print("new Double( ");

        return true;
    }

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.CHAR)) {
        writer.print("new Character( ");

        return true;
    }

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.BYTE)) {
        writer.print("new Byte( ");

        return true;
    }

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.BOOLEAN)) {
        writer.print("new Boolean( ");

        return true;
    }

    return false;
}

From source file:com.totsp.gwittir.rebind.beans.IntrospectorGenerator.java

License:Open Source License

private boolean unbox(JType type, String reference, SourceWriter writer) {
    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.INT)) {
        writer.print("((Integer) " + reference + ").intValue()");

        return true;
    }//  w  w w.  j a  va2  s  .  c o  m

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.LONG)) {
        writer.print("((Long) " + reference + ").longValue()");

        return true;
    }

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.FLOAT)) {
        writer.print("((Float) " + reference + ").floatValue()");

        return true;
    }

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.DOUBLE)) {
        writer.print("((Double) " + reference + ").doubleValue()");

        return true;
    }

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.CHAR)) {
        writer.print("((Character) " + reference + ").charValue()");

        return true;
    }

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.BYTE)) {
        writer.print("((Byte) " + reference + ").byteValue()");

        return true;
    }

    if ((type.isPrimitive() != null) && (type.isPrimitive() == JPrimitiveType.BOOLEAN)) {
        writer.print("((Boolean) " + reference + ").booleanValue()");

        return true;
    }

    writer.print("(" + type.getQualifiedSourceName() + ") " + reference);

    return false;
}

From source file:com.totsp.gwt.freezedry.rebind.Shared.java

License:Apache License

/**
 * Gets the suffix needed to make a call for a particular type. For example,
 * the <code>int</code> class needs methods named "readInt" and "writeInt".
 * /*from   w w  w  . j  av  a 2 s .  c  om*/
 * @param type the type in question
 * @return the suffix of the method to call
 */
static String getCallSuffix(JType type) {
    JParameterizedType isParameterized = type.isParameterized();
    if (isParameterized != null) {
        return getCallSuffix(isParameterized.getRawType());
    } else if (type.isPrimitive() != null) {
        if (type == JPrimitiveType.BOOLEAN) {
            return "Boolean";
        } else if (type == JPrimitiveType.BYTE) {
            return "Byte";
        } else if (type == JPrimitiveType.CHAR) {
            return "Char";
        } else if (type == JPrimitiveType.DOUBLE) {
            return "Double";
        } else if (type == JPrimitiveType.FLOAT) {
            return "Float";
        } else if (type == JPrimitiveType.INT) {
            return "Int";
        } else if (type == JPrimitiveType.LONG) {
            return "Long";
        } else if (type == JPrimitiveType.SHORT) {
            return "Short";
        } else {
            return null;
        }
    } else if (type.getQualifiedSourceName().equals("java.lang.String")) {
        return "String";
    } else {
        return "Object";
    }
}

From source file:fr.onevu.gwt.uibinder.rebind.JClassTypeAdapter.java

License:Apache License

/**
 * Returns the GWT primitive type for the given java primitive type.
 *
 * @param type the java primitive type/* w  w  w .ja v a 2  s .c o  m*/
 * @return the GWT primitive equivalent
 */
private JType adaptPrimitiveType(Class<?> type) {
    if (boolean.class.equals(type)) {
        return JPrimitiveType.BOOLEAN;
    }
    if (int.class.equals(type)) {
        return JPrimitiveType.INT;
    }
    if (char.class.equals(type)) {
        return JPrimitiveType.CHAR;
    }
    if (byte.class.equals(type)) {
        return JPrimitiveType.BYTE;
    }
    if (long.class.equals(type)) {
        return JPrimitiveType.LONG;
    }
    if (short.class.equals(type)) {
        return JPrimitiveType.SHORT;
    }
    if (float.class.equals(type)) {
        return JPrimitiveType.FLOAT;
    }
    if (double.class.equals(type)) {
        return JPrimitiveType.DOUBLE;
    }
    if (void.class.equals(type)) {
        return JPrimitiveType.VOID;
    }

    throw new IllegalArgumentException("Invalid primitive type: " + type.getName());
}

From source file:fr.onevu.gwt.uibinder.rebind.TypeOracleUtils.java

License:Apache License

/**
 * Check for a widening primitive conversion.  See
 * <a href="http://java.sun.com/docs/books/jls/second_edition/html/conversions.doc.html#25214">JLS 5.1.2</a>.
 * /*from ww  w. j  a  v  a2 s.c om*/
 * @param paramType
 * @param argType
 * @return true if assigning argType to paramType is a widening conversion
 */
private static boolean isWideningPrimitiveConversion(JPrimitiveType paramType, JPrimitiveType argType) {
    switch (paramType) {
    case DOUBLE:
        return argType != JPrimitiveType.BOOLEAN;
    case FLOAT:
        return argType != JPrimitiveType.BOOLEAN && argType != JPrimitiveType.DOUBLE;
    case LONG:
        return argType != JPrimitiveType.BOOLEAN && argType != JPrimitiveType.DOUBLE
                && argType != JPrimitiveType.FLOAT;
    case INT:
        return argType == JPrimitiveType.BYTE || argType == JPrimitiveType.SHORT
                || argType == JPrimitiveType.CHAR;
    case SHORT:
        return argType == JPrimitiveType.BYTE;
    default:
        return false;
    }
}

From source file:fr.putnami.pwt.core.service.rebind.ServiceBinderCreator.java

License:Open Source License

private void writeEndMethod(SourceWriter srcWriter, JMethod method) {
    srcWriter.println("CommandController.get().invokeCommand(commandDefinition, commandParam);");
    if (method.getReturnType().equals(JPrimitiveType.BOOLEAN)) {
        srcWriter.println("return false;");
    } else if (method.getReturnType().equals(JPrimitiveType.BYTE)
            || method.getReturnType().equals(JPrimitiveType.CHAR)
            || method.getReturnType().equals(JPrimitiveType.DOUBLE)
            || method.getReturnType().equals(JPrimitiveType.FLOAT)
            || method.getReturnType().equals(JPrimitiveType.INT)
            || method.getReturnType().equals(JPrimitiveType.LONG)
            || method.getReturnType().equals(JPrimitiveType.SHORT)) {
        srcWriter.println("return 0;");
    } else if (!method.getReturnType().equals(JPrimitiveType.VOID)) {
        srcWriter.println("return null;");
    }/*from  w w w . ja  va 2s.  co  m*/
    srcWriter.outdent();
    srcWriter.println("}");
}

From source file:fr.putnami.pwt.plugin.rest.rebind.RestServiceBinderCreator.java

License:Open Source License

private void writeEndMethod(SourceWriter srcWriter, JMethod method) {
    if (method.getReturnType().equals(JPrimitiveType.BOOLEAN)) {
        srcWriter.println("return false;");
    } else if (method.getReturnType().equals(JPrimitiveType.BYTE)
            || method.getReturnType().equals(JPrimitiveType.CHAR)
            || method.getReturnType().equals(JPrimitiveType.DOUBLE)
            || method.getReturnType().equals(JPrimitiveType.FLOAT)
            || method.getReturnType().equals(JPrimitiveType.INT)
            || method.getReturnType().equals(JPrimitiveType.LONG)
            || method.getReturnType().equals(JPrimitiveType.SHORT)) {
        srcWriter.println("return 0;");
    } else if (!method.getReturnType().equals(JPrimitiveType.VOID)) {
        srcWriter.println("return null;");
    }/* ww  w. j a va 2s  . c  o  m*/
    srcWriter.outdent();
    srcWriter.println("}");
}

From source file:org.cruxframework.crux.core.rebind.rest.CruxRestProxyCreatorFromServerMetadata.java

License:Apache License

private static List<Class<?>> getAllowedType(JType jType) {
    List<Class<?>> result = new ArrayList<Class<?>>();
    JPrimitiveType primitiveType = jType.isPrimitive();
    if (primitiveType == JPrimitiveType.INT
            || jType.getQualifiedSourceName().equals(Integer.class.getCanonicalName())) {
        result.add(Integer.TYPE);
        result.add(Integer.class);
    } else if (primitiveType == JPrimitiveType.SHORT
            || jType.getQualifiedSourceName().equals(Short.class.getCanonicalName())) {
        result.add(Short.TYPE);/*from   www . j a  v a 2s .c  o  m*/
        result.add(Short.class);
    } else if (primitiveType == JPrimitiveType.LONG
            || jType.getQualifiedSourceName().equals(Long.class.getCanonicalName())) {
        result.add(Long.TYPE);
        result.add(Long.class);
    } else if (primitiveType == JPrimitiveType.BYTE
            || jType.getQualifiedSourceName().equals(Byte.class.getCanonicalName())) {
        result.add(Byte.TYPE);
        result.add(Byte.class);
    } else if (primitiveType == JPrimitiveType.FLOAT
            || jType.getQualifiedSourceName().equals(Float.class.getCanonicalName())) {
        result.add(Float.TYPE);
        result.add(Float.class);
    } else if (primitiveType == JPrimitiveType.DOUBLE
            || jType.getQualifiedSourceName().equals(Double.class.getCanonicalName())) {
        result.add(Double.TYPE);
        result.add(Double.class);
    } else if (primitiveType == JPrimitiveType.BOOLEAN
            || jType.getQualifiedSourceName().equals(Boolean.class.getCanonicalName())) {
        result.add(Boolean.TYPE);
        result.add(Boolean.class);
    } else if (primitiveType == JPrimitiveType.CHAR
            || jType.getQualifiedSourceName().equals(Character.class.getCanonicalName())) {
        result.add(Character.TYPE);
        result.add(Character.class);
    } else if (jType.getQualifiedSourceName().equals(String.class.getCanonicalName())) {
        result.add(String.class);
    } else if (jType.getQualifiedSourceName().equals(Date.class.getCanonicalName())) {
        result.add(Date.class);
    } else if (jType.getQualifiedSourceName().equals(java.sql.Date.class.getCanonicalName())) {
        result.add(java.sql.Date.class);
    } else if (jType.getQualifiedSourceName().equals(BigInteger.class.getCanonicalName())) {
        result.add(BigInteger.class);
    } else if (jType.getQualifiedSourceName().equals(BigDecimal.class.getCanonicalName())) {
        result.add(BigDecimal.class);
    }
    return result;
}