/** * オブジェクトのフィールドにデータを設定する<br> * Integer、Float、Float[]、Stringにしか対応していない * * @param obj 設定対象オブジェクト * @param fl 設定対象フィールド * @param ty 設定対象フィールドの型 * @param data 設定データ * @throws IllegalArgumentException * @throws IllegalAccessException */ protected void dataSetter(Object obj, Field fl, Class ty, String data) throws IllegalArgumentException, IllegalAccessException { // Integer型のデータを設定 if (ty.toString().equals("class java.lang.Integer")) { fl.set(obj, Integer.parseInt(data)); } // Float型のデータを設定 if (ty.toString().equals("class java.lang.Float")) { fl.set(obj, Float.parseFloat(data)); } // String型のデータを設定(""の内側) if (ty.toString().equals("class java.lang.String")) { fl.set(obj, getDoubleQuoatString(data)); } // Float[]型のデータを設定 if (ty.toString().equals("class [Ljava.lang.Float;")) { String[] s; s = data.split(" "); Float[] f = new Float[s.length]; for (int i = 0; i < s.length; i++) { f[i] = Float.parseFloat(s[i]); } fl.set(obj, f); } }
/** * Calls the callback with every parameter of the method, skipping out the offset parameter * introduced by F2J for array arguments. * * @param method * @param callback */ protected void iterateRelevantParameters( Method method, boolean offsets, ParameterCallback callback) { if (method.getParameterTypes().length == 0) return; String[] names = new String[0]; try { names = paranamer.lookupParameterNames(method, true); } catch (ParameterNamesNotFoundException e) { getLog().warn(e); } for (int i = 0; i < method.getParameterTypes().length; i++) { Class<?> param = method.getParameterTypes()[i]; if (i > 0 && !offsets && param == Integer.TYPE && method.getParameterTypes()[i - 1].isArray()) { continue; } String name; if (names.length > 0) name = names[i]; else name = "arg" + i; String offsetName = null; if (i < method.getParameterTypes().length - 1 && param.isArray() && method.getParameterTypes()[i + 1] == Integer.TYPE) offsetName = names[i + 1]; callback.process(i, param, name, offsetName); } }
/** * Defines the specified array of structs as inner structs. The array is populated if necessary * using the struct component default constructor (which must be public). * * @param structs the struct array. * @return the specified struct array. * @throws IllegalArgumentException if the specified array contains inner structs. */ protected /* <S extends Struct> S*/ Struct[] array(/*S*/ Struct[] structs) { Class structClass = null; boolean resetIndexSaved = _resetIndex; if (_resetIndex) { _bitIndex = 0; _resetIndex = false; // Ensures the array elements are sequential. } for (int i = 0; i < structs.length; ) { /*S*/ Struct struct = structs[i]; if (struct == null) { try { if (structClass == null) { String arrayName = structs.getClass().getName(); String structName = arrayName.substring(2, arrayName.length() - 1); structClass = java.lang.Class.forName(structName); /* if (structClass == null) throw new JavolutionError("Struct class: " + structName + " not found");*/ } struct = (/*S*/ Struct) structClass.newInstance(); } catch (Exception e) { System.out.println("Error with struct:" + e); return null; } } structs[i++] = inner(struct); } _resetIndex = resetIndexSaved; return (/*S*/ Struct[]) structs; }
public boolean hasOffsets(Method method) { Class<?> last = null; for (int i = 0; i < method.getParameterTypes().length; i++) { Class<?> param = method.getParameterTypes()[i]; if (last != null && last.isArray() && param.equals(Integer.TYPE)) return true; last = param; } return false; }
/** * Returns compact class host. * * @param obj Object to compact. * @return String. */ @Nullable public static Object compactObject(Object obj) { if (obj == null) return null; if (obj instanceof Enum) return obj.toString(); if (obj instanceof String || obj instanceof Boolean || obj instanceof Number) return obj; if (obj instanceof Collection) { Collection col = (Collection) obj; Object[] res = new Object[col.size()]; int i = 0; for (Object elm : col) res[i++] = compactObject(elm); return res; } if (obj.getClass().isArray()) { Class<?> arrType = obj.getClass().getComponentType(); if (arrType.isPrimitive()) { if (obj instanceof boolean[]) return Arrays.toString((boolean[]) obj); if (obj instanceof byte[]) return Arrays.toString((byte[]) obj); if (obj instanceof short[]) return Arrays.toString((short[]) obj); if (obj instanceof int[]) return Arrays.toString((int[]) obj); if (obj instanceof long[]) return Arrays.toString((long[]) obj); if (obj instanceof float[]) return Arrays.toString((float[]) obj); if (obj instanceof double[]) return Arrays.toString((double[]) obj); } Object[] arr = (Object[]) obj; int iMax = arr.length - 1; StringBuilder sb = new StringBuilder("["); for (int i = 0; i <= iMax; i++) { sb.append(compactObject(arr[i])); if (i != iMax) sb.append(", "); } sb.append("]"); return sb.toString(); } return U.compact(obj.getClass().getName()); }
int[] init(int... dimensions) { int size = dimensions.length > 0 ? dimensions[0] : 0; if (___subrecord___ == null) { final String[] indexPrefixes = { "", "s", "_", "Index", "Length", "Ref", "Header", "Info", "Table" }; for (String indexPrefix : indexPrefixes) { try { ___subrecord___ = (Class<? extends Enum>) Class.forName(getClass().getPackage().getName() + '.' + name() + indexPrefix); try { size = ___subrecord___.getField("___recordlen___").getInt(null); } catch (Exception e) { } break; } catch (ClassNotFoundException e) { } } } for (String vPrefixe1 : new String[] { "_", "", "$", "Value", }) { if (___valueclass___ != null) break; String suffix = vPrefixe1; for (String name1 : new String[] { name().toLowerCase(), name(), }) { if (___valueclass___ != null) break; final String trailName = name1; if (trailName.endsWith(suffix)) { for (String aPackage1 : new String[] { "", getClass().getPackage().getName() + ".", "java.lang.", "java.util.", }) if (___valueclass___ == null) break; else try { ___valueclass___ = Class.forName(aPackage1 + name().replace(suffix, "")); } catch (ClassNotFoundException e) { } } } } int seek = dimensions.length > 1 ? dimensions[1] : ___recordlen___; ___recordlen___ = Math.max(___recordlen___, seek + size); return new int[] {size, seek}; }
private static void tryCatch(Buffer b, Class<?> ex, Runnable thunk) { boolean caught = false; try { thunk.run(); } catch (Throwable x) { if (ex.isAssignableFrom(x.getClass())) { caught = true; } else { fail(x.getMessage() + " not expected"); } } if (!caught) fail(ex.getName() + " not thrown", b); }
protected Class<?> nioBufferClass(Class<?> clazz) { Class<?> compType = clazz.getComponentType(); if (compType == null) { return null; } else if (compType.equals(Character.TYPE)) { return CharBuffer.class; } else if (compType.equals(Integer.TYPE)) { return IntBuffer.class; } else if (compType.equals(Double.TYPE)) { return DoubleBuffer.class; } else if (compType.equals(Float.TYPE)) { return FloatBuffer.class; } else if (compType.equals(Long.TYPE)) { return LongBuffer.class; } else if (compType.equals(Short.TYPE)) { return ShortBuffer.class; // there's no boolean[]-from-ByteBuffer thing, so we're stuck with // boolean[] // } else if (compType.equals(Boolean.TYPE)) { // return ByteBuffer.class; } else { return null; } }
public String getAutoTypeFromAnnotation(AnnotationMirror annotation) { Class annotation_class = NativeTypeTranslator.getClassFromType(annotation.getAnnotationType()); if (annotation_class.equals(GLint.class)) return "GL11.GL_INT"; else if (annotation_class.equals(GLbyte.class)) return "GL11.GL_BYTE"; else if (annotation_class.equals(GLshort.class)) return "GL11.GL_SHORT"; if (annotation_class.equals(GLuint.class)) return "GL11.GL_UNSIGNED_INT"; else if (annotation_class.equals(GLubyte.class)) return "GL11.GL_UNSIGNED_BYTE"; else if (annotation_class.equals(GLushort.class)) return "GL11.GL_UNSIGNED_SHORT"; else if (annotation_class.equals(GLfloat.class)) return "GL11.GL_FLOAT"; else if (annotation_class.equals(GLdouble.class)) return "GL11.GL_DOUBLE"; else return null; }
/** * Log task mapped. * * @param log Logger. * @param clazz Task class. * @param nodes Mapped nodes. */ public static void logMapped( @Nullable IgniteLogger log, Class<?> clazz, Collection<ClusterNode> nodes) { log0( log, U.currentTimeMillis(), String.format("[%s]: MAPPED: %s", clazz.getSimpleName(), U.toShortString(nodes))); }
public static void main(String[] args) throws Exception { for (String csname : csnames) { System.out.printf("-----------------------------------%n"); String oldname = csname + "_OLD"; checkInit(csname); Charset csOld = (Charset) Class.forName(oldname).newInstance(); Charset csNew = Charset.forName(csname); char[] cc = checkEncoding(csOld, csNew); checkDecoding(csOld, csNew); compare(csNew, csOld, cc); if (csname.startsWith("x-IBM93")) { // ecdbic checkMalformed( csNew, new byte[][] { {1, 0x26, 0x0f, 0x27}, // in SBSC, no SI {1, 0x0e, 0x41, 0x41, 0xe}, // in DBSC, no SO {2, 0x0e, 0x40, 0x41, 0xe}, // illegal DB }); } else if (csname.equals("x-IBM970") || csname.equals("x-IBM1383")) { // euc_simple checkMalformed( csNew, new byte[][] { {1, 0x26, (byte) 0x8f, 0x27}, // SS2 {1, (byte) 0xa1, (byte) 0xa1, (byte) 0x8e, 0x51}, // SS3 }); } } }
private static boolean generateParameterJava( PrintWriter writer, VariableElement param, TypeInfo type_info, boolean native_stub, final boolean printTypes, boolean first_parameter, Mode mode) { Class buffer_type = Utils.getNIOBufferType(param.asType()); if (!first_parameter) { writer.print(", "); } BufferObject bo_annotation = param.getAnnotation(BufferObject.class); if (bo_annotation != null && mode == Mode.BUFFEROBJECT) { if (buffer_type == null) { throw new RuntimeException( "type of " + param + " is not a nio Buffer parameter but is annotated as buffer object"); } if (printTypes) { writer.print("long "); } writer.print(param.getSimpleName() + Utils.BUFFER_OBJECT_PARAMETER_POSTFIX); } else { if (native_stub && param.getAnnotation(PointerWrapper.class) != null) { writer.print("long "); } else { Class type = type_info.getType(); if (native_stub && (type == CharSequence.class || type == CharSequence[].class || type == PointerBuffer.class || Buffer.class.isAssignableFrom(type))) { writer.print("long "); } else if (printTypes) { writer.print(type.getSimpleName() + " "); } } AutoSize auto_size_annotation = param.getAnnotation(AutoSize.class); if (auto_size_annotation != null) { writer.print(auto_size_annotation.value() + "_"); } writer.print(param.getSimpleName()); } return false; }
public Class[] getValidAnnotationTypes(Class type) { Class[] valid_types; if (Buffer.class.isAssignableFrom(type)) valid_types = getValidBufferTypes(type); else if (type.isPrimitive()) valid_types = getValidPrimitiveTypes(type); else if (String.class.equals(type)) valid_types = new Class[] {GLubyte.class}; else valid_types = new Class[] {}; return valid_types; }
private static Class[] getValidPrimitiveTypes(Class type) { if (type.equals(long.class)) return new Class[] { GLintptrARB.class, GLuint.class, GLintptr.class, GLsizeiptrARB.class, GLsizeiptr.class, GLint64EXT.class, GLuint64EXT.class, GLint64.class, GLuint64.class }; else if (type.equals(int.class)) return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, GLuint.class, GLsizei.class }; else if (type.equals(double.class)) return new Class[] {GLclampd.class, GLdouble.class}; else if (type.equals(float.class)) return new Class[] {GLclampf.class, GLfloat.class}; else if (type.equals(short.class)) return new Class[] {GLhalf.class, GLshort.class, GLushort.class}; else if (type.equals(byte.class)) return new Class[] {GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class}; else if (type.equals(boolean.class)) return new Class[] {GLboolean.class}; else if (type.equals(void.class)) return new Class[] {GLvoid.class, GLreturn.class}; else return new Class[] {}; }
/** * Log finished. * * @param log Logger. * @param clazz Class. * @param start Start time. */ public static void logFinish(@Nullable IgniteLogger log, Class<?> clazz, long start) { final long end = U.currentTimeMillis(); log0( log, end, String.format( "[%s]: FINISHED, duration: %s", clazz.getSimpleName(), formatDuration(end - start))); }
/** * Log message. * * @param log Logger. * @param msg Message to log. * @param clazz class. * @param start start time. * @return Time when message was logged. */ public static long log(@Nullable IgniteLogger log, String msg, Class<?> clazz, long start) { final long end = U.currentTimeMillis(); log0( log, end, String.format( "[%s]: %s, duration: %s", clazz.getSimpleName(), msg, formatDuration(end - start))); return end; }
public static void main(String args[]) { Connection c = null; PreparedStatement stmt = null; try { Class.forName("org.postgresql.Driver"); c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test", "pdv", "pdv"); System.out.println("Opened database successfully"); List<String> results = new ArrayList<String>(); File dir = new File("D:/jboss/eclipse/workspace/LTF"); Iterator<File> files = FileUtils.iterateFilesAndDirs(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE); StopWatch timerAll = new StopWatch(); timerAll.start(); while (files.hasNext()) { File file = (File) files.next(); if (file.isFile()) { StopWatch timeForAFile = new StopWatch(); timeForAFile.start(); String toDB = encodeFileToBase64Binary(file); String sql = "INSERT INTO test (file_id,file_name,file_data,file_date) VALUES (nextval('test_file_id_seq'),?,?,?)"; stmt = c.prepareStatement(sql); stmt.setString(1, file.getAbsolutePath()); stmt.setString(2, toDB); stmt.setDate(3, new java.sql.Date(Calendar.getInstance().getTimeInMillis())); stmt.executeUpdate(); timeForAFile.stop(); System.out.println(timeForAFile.toString()); } } timerAll.stop(); System.out.println("================================================="); System.out.println(timerAll.toString()); stmt.close(); /* * Statement statement = null; statement = c.createStatement(); * ResultSet rs = statement.executeQuery( * "select file_data from test limit 1"); while (rs.next()) { String * encoded = rs.getString("file_data"); byte[] decoded = * Base64.getDecoder().decode(encoded); FileOutputStream fos = new * FileOutputStream("c:/temp/2.jpg"); fos.write(decoded); * fos.close(); } */ c.close(); } catch (Exception e) { System.err.println(e.getClass().getName() + ": " + e.getMessage()); System.exit(0); } System.out.println("Table created successfully"); }
/** * Tries to load a class from: the bootstrap loader, the system loader, the context loader (if one * is present) and finally the loader specified. * * @param className the name of the class to be loaded * @param fallback the fallback loader * @return the class loaded * @exception ClassNotFoundException if class is not found */ protected static final Class<?> tryToLoadClass(String className, ClassLoader fallback) throws ClassNotFoundException { ClassLoader systemClassLoader = (ClassLoader) java.security.AccessController.doPrivileged( new java.security.PrivilegedAction() { public Object run() { ClassLoader cl = Thread.currentThread().getContextClassLoader(); return (cl != null) ? cl : ClassLoader.getSystemClassLoader(); } }); try { return Class.forName(className, true, systemClassLoader); } catch (ClassNotFoundException e2) { if (fallback != null) { return Class.forName(className, true, fallback); } else { throw new ClassNotFoundException(className); } } }
private static VariableElement getAutoTypeParameter( ExecutableElement method, VariableElement target_parameter) { for (VariableElement param : method.getParameters()) { AnnotationMirror auto_annotation = Utils.getParameterAutoAnnotation(param); if (auto_annotation != null) { Class annotation_type = NativeTypeTranslator.getClassFromType(auto_annotation.getAnnotationType()); String parameter_name; if (annotation_type.equals(AutoType.class)) { parameter_name = param.getAnnotation(AutoType.class).value(); } else if (annotation_type.equals(AutoSize.class)) { parameter_name = param.getAnnotation(AutoSize.class).value(); } else { throw new RuntimeException("Unknown annotation type " + annotation_type); } if (target_parameter.getSimpleName().toString().equals(parameter_name)) { return param; } } } return null; }
private static Class[] getValidBufferTypes(Class type) { if (type.equals(IntBuffer.class)) return new Class[] {cl_int.class, cl_uint.class}; else if (type.equals(FloatBuffer.class)) return new Class[] {cl_float.class}; else if (type.equals(ByteBuffer.class)) return new Class[] {cl_byte.class, cl_char.class, cl_uchar.class, cl_void.class}; else if (type.equals(ShortBuffer.class)) return new Class[] {cl_short.class}; else if (type.equals(DoubleBuffer.class)) return new Class[] {cl_double.class}; else if (type.equals(LongBuffer.class)) return new Class[] {cl_long.class}; else if (type.equals(PointerBuffer.class)) return new Class[] {size_t.class}; else return new Class[] {}; }
@Override public Class[] getValidAnnotationTypes(Class type) { Class[] valid_types; if (Buffer.class.isAssignableFrom(type) || PointerBuffer.class.isAssignableFrom(type)) valid_types = getValidBufferTypes(type); else if (type.isPrimitive()) valid_types = getValidPrimitiveTypes(type); else if (String.class.equals(type)) valid_types = new Class[] {cl_byte.class}; else if (org.lwjgl.PointerWrapper.class.isAssignableFrom(type)) valid_types = new Class[] {PointerWrapper.class}; else if (ByteBuffer[].class == type) valid_types = new Class[] {cl_char.class, cl_uchar.class}; else if (void.class.equals(type)) valid_types = new Class[] {GLreturn.class}; else valid_types = new Class[] {}; return valid_types; }
public Class[] getValidAnnotationTypes(Class type) { Class[] valid_types; if (Buffer.class.isAssignableFrom(type)) valid_types = getValidBufferTypes(type); else if (type.isPrimitive()) valid_types = getValidPrimitiveTypes(type); else if (String.class.equals(type)) valid_types = new Class[] {GLubyte.class}; else if (org.lwjgl.PointerWrapper.class.isAssignableFrom(type)) valid_types = new Class[] {PointerWrapper.class}; else if (void.class.equals(type)) valid_types = new Class[] {GLreturn.class}; else if (PointerBuffer.class.equals(type)) valid_types = new Class[] {GLintptr.class, GLintptrARB.class, GLsizeiptr.class, GLsizeiptrARB.class}; else valid_types = new Class[] {}; return valid_types; }
@Override public String translateAnnotation(Class annotation_type) { if (annotation_type.equals(cl_uint.class) || annotation_type.equals(cl_int.class)) return "i"; else if (annotation_type.equals(cl_short.class)) return "s"; else if (annotation_type.equals(cl_byte.class)) return "b"; else if (annotation_type.equals(cl_float.class)) return "f"; else if (annotation_type.equals(cl_double.class)) return "d"; else throw new RuntimeException(annotation_type + " is not allowed"); }
private static String getDefaultResultValue(ExecutableElement method) { if (method.getAnnotation(GLreturn.class) != null) { final String type = Utils.getMethodReturnType(method, method.getAnnotation(GLreturn.class), false); if ("boolean".equals(type)) { return "false"; } else if (Character.isLowerCase(type.charAt(0))) { return "0"; } else { return "null"; } } else { final Class type = Utils.getJavaType(Utils.getMethodReturnType(method)); if (type.isPrimitive()) { if (type == boolean.class) { return "false"; } else { return "0"; } } else { return "null"; } } }
private static Class[] getValidPrimitiveTypes(Class type) { if (type.equals(long.class)) return new Class[] {cl_long.class, size_t.class, cl_bitfield.class}; else if (type.equals(int.class)) return new Class[] {cl_int.class, cl_uint.class, cl_bool.class}; else if (type.equals(double.class)) return new Class[] {cl_double.class}; else if (type.equals(float.class)) return new Class[] {cl_float.class}; else if (type.equals(short.class)) return new Class[] {cl_short.class}; else if (type.equals(byte.class)) return new Class[] {cl_byte.class, cl_char.class, cl_uchar.class}; else if (type.equals(boolean.class)) return new Class[] {cl_bool.class}; else if (type.equals(void.class)) return new Class[] {cl_void.class}; else return new Class[] {}; }
public static String constname(Class<?> cl, int val) { String ret = null; for (java.lang.reflect.Field f : cl.getFields()) { if (((f.getModifiers() & java.lang.reflect.Modifier.STATIC) != 0) && ((f.getModifiers() & java.lang.reflect.Modifier.PUBLIC) != 0) && (f.getType() == Integer.TYPE)) { int v; try { v = f.getInt(null); } catch (IllegalAccessException e) { continue; } if (v == val) { if (ret == null) ret = f.getName(); else ret = ret + " or " + f.getName(); } } } if (ret == null) return (Integer.toString(val)); return (ret); }
private static Class[] getValidBufferTypes(Class type) { if (type.equals(IntBuffer.class)) return new Class[] { GLbitfield.class, GLenum.class, GLhandleARB.class, GLint.class, GLsizei.class, GLuint.class }; else if (type.equals(FloatBuffer.class)) return new Class[] {GLclampf.class, GLfloat.class}; else if (type.equals(ByteBuffer.class)) return new Class[] { GLboolean.class, GLbyte.class, GLcharARB.class, GLchar.class, GLubyte.class, GLvoid.class }; else if (type.equals(ShortBuffer.class)) return new Class[] {GLhalf.class, GLshort.class, GLushort.class}; else if (type.equals(DoubleBuffer.class)) return new Class[] {GLclampd.class, GLdouble.class}; else if (type.equals(LongBuffer.class)) return new Class[] {GLint64EXT.class, GLuint64EXT.class}; else return new Class[] {}; }
/** * Constructs a fully specified <code>DataFlavor</code>. * * @exception NullPointerException if either <code>primaryType</code>, <code>subType</code> or * <code>representationClass</code> is null */ private DataFlavor( String primaryType, String subType, MimeTypeParameterList params, Class representationClass, String humanPresentableName) { super(); if (primaryType == null) { throw new NullPointerException("primaryType"); } if (subType == null) { throw new NullPointerException("subType"); } if (representationClass == null) { throw new NullPointerException("representationClass"); } if (params == null) params = new MimeTypeParameterList(); params.set("class", representationClass.getName()); if (humanPresentableName == null) { humanPresentableName = (String) params.get("humanPresentableName"); if (humanPresentableName == null) humanPresentableName = primaryType + "/" + subType; } try { mimeType = new MimeType(primaryType, subType, params); } catch (MimeTypeParseException mtpe) { throw new IllegalArgumentException("MimeType Parse Exception: " + mtpe.getMessage()); } this.representationClass = representationClass; this.humanPresentableName = humanPresentableName; mimeType.removeParameter("humanPresentableName"); }
private static void printParameterChecks( PrintWriter writer, ExecutableElement method, Map<VariableElement, TypeInfo> typeinfos, Mode mode, final boolean generate_error_checks) { if (mode == Mode.NORMAL) { final GenerateAutos gen_autos_annotation = method.getAnnotation(GenerateAutos.class); if (gen_autos_annotation != null && gen_autos_annotation.sizeVariables().length > 0) { // For the auto-generated parameters, declare and init a size variable (that can be reused // by @Code) for (final VariableElement param : method.getParameters()) { if (Arrays.binarySearch( gen_autos_annotation.sizeVariables(), param.getSimpleName().toString()) >= 0) { final int shifting = getBufferElementSizeExponent(typeinfos.get(param).getType()); final Check check_annotation = param.getAnnotation(Check.class); writer.print("\t\tlong " + param.getSimpleName() + "_size = "); if (check_annotation == null || !check_annotation.canBeNull()) { writer.println(param.getSimpleName() + ".remaining() << " + shifting + ";"); } else { writer.println( param.getSimpleName() + " == null ? 0 : " + param.getSimpleName() + ".remaining() << " + shifting + ";"); } } } } } for (VariableElement param : method.getParameters()) { Class java_type = Utils.getJavaType(param.asType()); if (java_type.isArray() || (Utils.isAddressableType(java_type) && (mode != Mode.BUFFEROBJECT || param.getAnnotation(BufferObject.class) == null) && (mode != Mode.AUTOS || getAutoTypeParameter(method, param) == null) && param.getAnnotation(Result.class) == null && !Utils.isReturnParameter(method, param))) { String check_value = null; boolean can_be_null = false; Check check_annotation = param.getAnnotation(Check.class); if (check_annotation != null) { check_value = check_annotation.value(); can_be_null = check_annotation.canBeNull(); } if ((Buffer.class.isAssignableFrom(java_type) || PointerBuffer.class.isAssignableFrom(java_type)) && param.getAnnotation(Constant.class) == null) { TypeInfo typeinfo = typeinfos.get(param); printParameterCheck( writer, method, param.getSimpleName().toString(), typeinfo.getType().getSimpleName(), check_value, can_be_null, param.getAnnotation(NullTerminated.class), generate_error_checks); } else if (String.class.equals(java_type)) { if (!can_be_null) { writer.println("\t\tBufferChecks.checkNotNull(" + param.getSimpleName() + ");"); } } else if (java_type.isArray()) { printArrayParameterCheck( writer, param.getSimpleName().toString(), check_value, can_be_null); } } } if (method.getAnnotation(CachedResult.class) != null) { printParameterCheck( writer, method, Utils.CACHED_BUFFER_NAME, null, null, true, null, generate_error_checks); } }
public String translateAnnotation(Class annotation_type) { if (annotation_type.equals(GLuint.class) || annotation_type.equals(GLint.class)) return "i"; else if (annotation_type.equals(GLushort.class) || annotation_type.equals(GLshort.class)) return "s"; else if (annotation_type.equals(GLubyte.class) || annotation_type.equals(GLbyte.class)) return "b"; else if (annotation_type.equals(GLfloat.class) || annotation_type.equals(GLclampf.class)) return "f"; else if (annotation_type.equals(GLdouble.class) || annotation_type.equals(GLclampd.class)) return "d"; else if (annotation_type.equals(GLhalf.class)) return "h"; else if (annotation_type.equals(GLuint64EXT.class) || annotation_type.equals(GLint64EXT.class) || annotation_type.equals(GLuint64.class) || annotation_type.equals(GLint64.class)) return "i64"; else if (annotation_type.equals(GLboolean.class) || annotation_type.equals(GLvoid.class)) return ""; else throw new RuntimeException(annotation_type + " is not allowed"); }