final ClassInfo classInfo = new ClassInfo(); Field[] fields = Demo.class.getFields(); for(final field :fields) { FieldInfo fieldInfo = new FieldInfo(field); if(field.hasAnnotation(Id.class)) { fieldInfo.setId(true); } if(field.hasAnnotation(ColumnName.class){ final ColumnName col = field.getAnnotation(ColumnName.class); fieldInfo.setColumnName(col.value()); } }
String line = bufferedReader.readLine(); while (line != null) { String[] data = line.split("\\t+"); String name = data[0]; String credits = data[2]; String description = data[3]; String professor = data[11]; ClassInfo ci = new ClassInfo(name, credits, description, professor); classInfoList.add(ci); line = bufferedReader.readLine(); }
/** * Constructs a "mock" ClassInfo using the passed values. All passed values MUST NOT BE MODIFIED AFTER THIS CALL. * Otherwise the resulting object would not conform to the contract outlined above. * * @param name the name of this class * @param superName the name of the parent class * @param flags the class attributes * @param interfaces the methodParameters this class implements * @param annotations the annotations on this class * @param hasNoArgsConstructor whether this class has a no arg constructor * @return a new mock class representation */ @Deprecated public static ClassInfo create(DotName name, DotName superName, short flags, DotName[] interfaces, Map<DotName, List<AnnotationInstance>> annotations, boolean hasNoArgsConstructor) { Type[] interfaceTypes = new Type[interfaces.length]; for (int i = 0; i < interfaces.length; i++) { interfaceTypes[i] = new ClassType(interfaces[i]); } ClassType superClassType = superName == null ? null : new ClassType(superName); return new ClassInfo(name, superClassType, flags, interfaceTypes, annotations, hasNoArgsConstructor); }
private void processClassInfo(DataInputStream data) throws IOException { short flags = (short) data.readUnsignedShort(); DotName thisName = decodeClassEntry(data.readUnsignedShort()); int superIndex = data.readUnsignedShort(); DotName superName = (superIndex != 0) ? decodeClassEntry(superIndex) : null; int numInterfaces = data.readUnsignedShort(); List<Type> interfaces = new ArrayList<Type>(numInterfaces); for (int i = 0; i < numInterfaces; i++) { interfaces.add(intern(new ClassType(decodeClassEntry(data.readUnsignedShort())))); } Type[] interfaceTypes = intern(interfaces.toArray(new Type[interfaces.size()])); Type superClassType = superName == null ? null : intern(new ClassType(superName)); this.classAnnotations = new HashMap<DotName, List<AnnotationInstance>>(); this.currentClass = new ClassInfo(thisName, superClassType, flags, interfaceTypes, classAnnotations); if (superName != null) addSubclass(superName, currentClass); for (int i = 0; i < numInterfaces; i++) { addImplementor(interfaces.get(i).name(), currentClass); } classes.put(currentClass.name(), currentClass); }
private Index readClasses(PackedDataInputStream stream, int version) throws IOException { int entries = stream.readPackedU32(); HashMap<DotName, List<ClassInfo>> subclasses = new HashMap<DotName, List<ClassInfo>>(); HashMap<DotName, List<ClassInfo>> implementors = new HashMap<DotName, List<ClassInfo>>(); HashMap<DotName, ClassInfo> classes = new HashMap<DotName, ClassInfo>(); masterAnnotations = new HashMap<DotName, List<AnnotationInstance>>(); for (int i = 0; i < entries; i++) { DotName name = classTable[stream.readPackedU32()]; DotName superName = classTable[stream.readPackedU32()]; short flags = stream.readShort(); // No copyParameters supported in version 3+ boolean hasNoArgsConstructor = version >= 3 && stream.readBoolean(); int numIntfs = stream.readPackedU32(); List<Type> interfaces = new ArrayList<Type>(numIntfs); for (int j = 0; j < numIntfs; j++) { interfaces.add(new ClassType(classTable[stream.readPackedU32()])); } Type[] interfaceTypes = interfaces.toArray(new Type[interfaces.size()]); Map<DotName, List<AnnotationInstance>> annotations = new HashMap<DotName, List<AnnotationInstance>>(); Type superClassType = superName == null ? null : new ClassType(superName); ClassInfo clazz = new ClassInfo(name, superClassType, flags, interfaceTypes, annotations, hasNoArgsConstructor); classes.put(name, clazz); addClassToMap(subclasses, superName, clazz); for (Type interfaceName : interfaces) { addClassToMap(implementors, interfaceName.name(), clazz); } readAnnotations(stream, annotations, clazz); } return Index.create(masterAnnotations, subclasses, implementors, classes); }
private ClassInfo readClassEntry(PackedDataInputStream stream, Map<DotName, List<AnnotationInstance>> masterAnnotations) throws IOException { DotName name = nameTable[stream.readPackedU32()]; short flags = (short) stream.readPackedU32(); Type superType = typeTable[stream.readPackedU32()]; Type[] typeParameters = typeListTable[stream.readPackedU32()]; Type[] interfaceTypes = typeListTable[stream.readPackedU32()]; DotName enclosingClass = nameTable[stream.readPackedU32()]; String simpleName = stringTable[stream.readPackedU32()]; ClassInfo.EnclosingMethodInfo enclosingMethod = readEnclosingMethod(stream); int size = stream.readPackedU32(); Map<DotName, List<AnnotationInstance>> annotations = new HashMap<DotName, List<AnnotationInstance>>(size); ClassInfo clazz = new ClassInfo(name, superType, flags, interfaceTypes, annotations); clazz.setTypeParameters(typeParameters); clazz.setEnclosingMethod(enclosingMethod); clazz.setInnerClassInfo(enclosingClass, simpleName); FieldInternal[] fields = readClassFields(stream, clazz); clazz.setFieldArray(fields); MethodInternal[] methods = readClassMethods(stream, clazz); clazz.setMethodArray(methods); for (int i = 0; i < size; i++) { List<AnnotationInstance> instances = convertToList(readAnnotations(stream, clazz)); if (instances.size() > 0) { DotName annotationName = instances.get(0).name(); annotations.put(annotationName, instances); addToMaster(masterAnnotations, annotationName, instances); } } return clazz; }