本文整理汇总了Java中com.sun.mirror.type.PrimitiveType类的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveType类的具体用法?Java PrimitiveType怎么用?Java PrimitiveType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrimitiveType类属于com.sun.mirror.type包,在下文中一共展示了PrimitiveType类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMethodReturnType
import com.sun.mirror.type.PrimitiveType; //导入依赖的package包/类
public static String getMethodReturnType(MethodDeclaration method, GLreturn return_annotation, boolean buffer) {
ParameterDeclaration return_param = null;
for ( ParameterDeclaration param : method.getParameters() ) {
if ( param.getSimpleName().equals(return_annotation.value()) ) {
return_param = param;
break;
}
}
if ( return_param == null )
throw new RuntimeException("The @GLreturn parameter \"" + return_annotation.value() + "\" could not be found in method: " + method);
PrimitiveType.Kind kind = NativeTypeTranslator.getPrimitiveKindFromBufferClass(Utils.getJavaType(return_param.getType()));
if ( return_param.getAnnotation(GLboolean.class) != null )
kind = PrimitiveType.Kind.BOOLEAN;
if ( kind == PrimitiveType.Kind.BYTE && (return_param.getAnnotation(GLchar.class) != null || return_param.getAnnotation(GLcharARB.class) != null) )
return "String";
else {
final String type = JavaTypeTranslator.getPrimitiveClassFromKind(kind).getName();
return buffer ? Character.toUpperCase(type.charAt(0)) + type.substring(1) : type;
}
}
示例2: getNativeTypeFromPrimitiveType
import com.sun.mirror.type.PrimitiveType; //导入依赖的package包/类
public Class<? extends Annotation> getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
Class<? extends Annotation> type;
switch ( kind ) {
case INT:
type = GLint.class;
break;
case FLOAT:
type = GLfloat.class;
break;
case SHORT:
type = GLshort.class;
break;
case BYTE:
type = GLbyte.class;
break;
case BOOLEAN:
type = GLboolean.class;
break;
case LONG:
type = GLint64.class;
break;
default:
throw new RuntimeException(kind + " is not allowed");
}
return type;
}
示例3: getSchemaGenerator
import com.sun.mirror.type.PrimitiveType; //导入依赖的package包/类
private synchronized XmlSchemaGenerator<TypeMirror, TypeDeclaration, FieldDeclaration, MethodDeclaration> getSchemaGenerator() {
if(xsdgen==null) {
xsdgen = new XmlSchemaGenerator<TypeMirror,TypeDeclaration,FieldDeclaration,MethodDeclaration>( types.getNavigator(), types );
for (Map.Entry<QName, Reference> e : additionalElementDecls.entrySet()) {
Reference value = e.getValue();
if(value!=null) {
NonElement<TypeMirror, TypeDeclaration> typeInfo = refMap.get(value);
if(typeInfo==null)
throw new IllegalArgumentException(e.getValue()+" was not specified to JavaCompiler.bind");
xsdgen.add(e.getKey(),!(value.type instanceof PrimitiveType),typeInfo);
} else {
xsdgen.add(e.getKey(),false,null);
}
}
}
return xsdgen;
}
示例4: getNativeTypeFromPrimitiveType
import com.sun.mirror.type.PrimitiveType; //导入依赖的package包/类
public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
Class type;
switch ( kind ) {
case INT:
type = GLint.class;
break;
case DOUBLE:
type = GLdouble.class;
break;
case FLOAT:
type = GLfloat.class;
break;
case SHORT:
type = GLshort.class;
break;
case BYTE:
type = GLbyte.class;
break;
case LONG:
type = GLint64EXT.class;
break;
case BOOLEAN:
type = GLboolean.class;
break;
default:
throw new RuntimeException(kind + " is not allowed");
}
return type;
}
示例5: getNativeTypeFromPrimitiveType
import com.sun.mirror.type.PrimitiveType; //导入依赖的package包/类
public Class getNativeTypeFromPrimitiveType(PrimitiveType.Kind kind) {
Class type;
switch ( kind ) {
case INT:
type = cl_int.class;
break;
case DOUBLE:
type = cl_double.class;
break;
case FLOAT:
type = cl_float.class;
break;
case SHORT:
type = cl_short.class;
break;
case BYTE:
type = cl_byte.class;
break;
case LONG:
type = cl_long.class;
break;
case BOOLEAN:
type = cl_bool.class;
break;
default:
throw new RuntimeException(kind + " is not allowed");
}
return type;
}
示例6: validateField
import com.sun.mirror.type.PrimitiveType; //导入依赖的package包/类
private static void validateField(FieldDeclaration field) {
// Check if field is "public static final"
Collection<Modifier> modifiers = field.getModifiers();
if ( modifiers.size() != 3
|| !modifiers.contains(Modifier.PUBLIC)
|| !modifiers.contains(Modifier.STATIC)
|| !modifiers.contains(Modifier.FINAL) ) {
throw new RuntimeException("Field " + field.getSimpleName() + " is not declared public static final");
}
// Check suported types (int, long, float, String)
TypeMirror field_type = field.getType();
if ( field_type instanceof PrimitiveType ) {
PrimitiveType field_type_prim = (PrimitiveType)field_type;
PrimitiveType.Kind field_kind = field_type_prim.getKind();
if ( field_kind != PrimitiveType.Kind.INT
&& field_kind != PrimitiveType.Kind.LONG
&& field_kind != PrimitiveType.Kind.FLOAT
&& field_kind != PrimitiveType.Kind.BYTE ) {
throw new RuntimeException("Field " + field.getSimpleName() + " is not of type 'int', 'long' or 'float'");
}
} else if ( "java.lang.String".equals(field_type.toString()) ) {
} else {
throw new RuntimeException("Field " + field.getSimpleName() + " is not a primitive type or String");
}
Object field_value = field.getConstantValue();
if ( field_value == null ) {
throw new RuntimeException("Field " + field.getSimpleName() + " has no initial value");
}
}
示例7: visitConstructorDeclaration
import com.sun.mirror.type.PrimitiveType; //导入依赖的package包/类
/**
* Stores information about constructors annotated with {@link Constructor},
* particularly with the {@link ConstructorParameter} annotated parameters
* and their required imports. The {@link SPAnnotationProcessor} takes this
* information and generates
* {@link SPPersisterHelper#commitObject(ca.sqlpower.dao.PersistedSPObject, Multimap, List, ca.sqlpower.dao.helper.SPPersisterHelperFactory)}
* and
* {@link SPPersisterHelper#persistObject(SPObject, int, SPPersister, ca.sqlpower.dao.session.SessionPersisterSuperConverter)}
* methods.
*
* @param d
* The {@link ConstructorDeclaration} of the constructor to
* visit.
*/
public void visitConstructorDeclaration(ConstructorDeclaration d) {
if (!constructorFound && d.getAnnotation(Constructor.class) != null
&& d.getSimpleName().equals(typeDecl.getSimpleName())) {
for (ParameterDeclaration pd : d.getParameters()) {
ConstructorParameter cp = pd.getAnnotation(ConstructorParameter.class);
if (cp != null) {
try {
TypeMirror type = pd.getType();
Class<?> c = SPAnnotationProcessorUtils.convertTypeMirrorToClass(type);
ParameterType property = cp.parameterType();
String name;
if (property.equals(ParameterType.PROPERTY)) {
name = cp.propertyName();
} else {
name = pd.getSimpleName();
}
if (type instanceof PrimitiveType) {
constructorParameters.add(
new ConstructorParameterObject(property, c, name));
} else if (type instanceof ClassType || type instanceof InterfaceType) {
constructorParameters.add(
new ConstructorParameterObject(property, c, name));
constructorImports.add(c.getName());
}
} catch (ClassNotFoundException e) {
valid = false;
e.printStackTrace();
}
}
}
constructorFound = true;
}
}
示例8: glMultiDrawElementsIndirectCountARB
import com.sun.mirror.type.PrimitiveType; //导入依赖的package包/类
@Alternate("glMultiDrawElementsIndirectCountARB")
void glMultiDrawElementsIndirectCountARB(@GLenum int mode,
@GLenum int type,
@BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 5 : stride >> 2) * maxdrawcount") @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect,
@GLintptr long drawcount,
@GLsizei int maxdrawcount,
@GLsizei int stride);
示例9: glMultiDrawElementsIndirect
import com.sun.mirror.type.PrimitiveType; //导入依赖的package包/类
@Reuse("GL43")
@Alternate("glMultiDrawElementsIndirect")
void glMultiDrawElementsIndirect(@GLenum int mode,
@GLenum int type,
@BufferObject(BufferKind.IndirectBO) @Check("(stride == 0 ? 5 : stride >> 2) * primcount") @Const @GLvoid(PrimitiveType.Kind.INT) IntBuffer indirect,
@GLsizei int primcount,
@GLsizei int stride);
示例10: getTypeMoniker
import com.sun.mirror.type.PrimitiveType; //导入依赖的package包/类
public static TypeMoniker getTypeMoniker(TypeMirror typeMirror) {
if (typeMirror instanceof PrimitiveType)
return new PrimitiveTypeMoniker((PrimitiveType)typeMirror);
else if (typeMirror instanceof ArrayType)
return new ArrayTypeMoniker((ArrayType)typeMirror);
else if (typeMirror instanceof DeclaredType)
return new DeclaredTypeMoniker((DeclaredType)typeMirror);
return getTypeMoniker(typeMirror.toString());
}