From 6e9d7383782604a43e73e50a66a805dbf3205781 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 5 Apr 2018 14:09:02 +0200 Subject: [PATCH] exo4: add a basic main loop for annotation iteration. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- exo4/{TP2 => }/Affichable.java | 0 exo4/{TP2 => }/Cercle.java | 0 exo4/{TP2 => }/ClassPreamble.java | 0 exo4/{TP2 => }/Compactable.java | 0 exo4/{TP2 => }/Entiers.java | 1 - exo4/{TP2 => }/Forme.java | 0 exo4/{TP2 => }/Image.java | 0 exo4/{TP2 => }/Liste.java | 0 exo4/Main.java | 21 +++++ exo4/{TP2/Main.java => Main.java.bak0} | 0 exo4/Makefile | 1 + exo4/{TP2 => }/Piletransformations.java | 0 exo4/{TP2 => }/Point.java | 0 exo4/{TP2 => }/Segment.java | 0 exo4/{TP2 => }/Structure.java | 0 exo4/TP2/Makefile | 101 ------------------------ 16 files changed, 22 insertions(+), 102 deletions(-) rename exo4/{TP2 => }/Affichable.java (100%) rename exo4/{TP2 => }/Cercle.java (100%) rename exo4/{TP2 => }/ClassPreamble.java (100%) rename exo4/{TP2 => }/Compactable.java (100%) rename exo4/{TP2 => }/Entiers.java (99%) rename exo4/{TP2 => }/Forme.java (100%) rename exo4/{TP2 => }/Image.java (100%) rename exo4/{TP2 => }/Liste.java (100%) rename exo4/{TP2/Main.java => Main.java.bak0} (100%) rename exo4/{TP2 => }/Piletransformations.java (100%) rename exo4/{TP2 => }/Point.java (100%) rename exo4/{TP2 => }/Segment.java (100%) rename exo4/{TP2 => }/Structure.java (100%) delete mode 100644 exo4/TP2/Makefile diff --git a/exo4/TP2/Affichable.java b/exo4/Affichable.java similarity index 100% rename from exo4/TP2/Affichable.java rename to exo4/Affichable.java diff --git a/exo4/TP2/Cercle.java b/exo4/Cercle.java similarity index 100% rename from exo4/TP2/Cercle.java rename to exo4/Cercle.java diff --git a/exo4/TP2/ClassPreamble.java b/exo4/ClassPreamble.java similarity index 100% rename from exo4/TP2/ClassPreamble.java rename to exo4/ClassPreamble.java diff --git a/exo4/TP2/Compactable.java b/exo4/Compactable.java similarity index 100% rename from exo4/TP2/Compactable.java rename to exo4/Compactable.java diff --git a/exo4/TP2/Entiers.java b/exo4/Entiers.java similarity index 99% rename from exo4/TP2/Entiers.java rename to exo4/Entiers.java index 83d983f..b11f364 100644 --- a/exo4/TP2/Entiers.java +++ b/exo4/Entiers.java @@ -116,5 +116,4 @@ class Entiers extends Structure { current_size = 0; } } - } diff --git a/exo4/TP2/Forme.java b/exo4/Forme.java similarity index 100% rename from exo4/TP2/Forme.java rename to exo4/Forme.java diff --git a/exo4/TP2/Image.java b/exo4/Image.java similarity index 100% rename from exo4/TP2/Image.java rename to exo4/Image.java diff --git a/exo4/TP2/Liste.java b/exo4/Liste.java similarity index 100% rename from exo4/TP2/Liste.java rename to exo4/Liste.java diff --git a/exo4/Main.java b/exo4/Main.java index 4075cbc..d454093 100644 --- a/exo4/Main.java +++ b/exo4/Main.java @@ -1,3 +1,6 @@ +import java.util.LinkedList; +import java.lang.reflect.Method; +import java.lang.annotation.Annotation; class Main { @@ -6,6 +9,24 @@ class Main { * @param String[] args main() function arguments array */ public static void main(String[] args) { + //FIXME: one can create a smart way of building this list + LinkedList> packageClasses = new LinkedList>(); + packageClasses.add(Entiers.class); + packageClasses.add(Forme.class); + packageClasses.add(Image.class); + packageClasses.add(Liste.class); + packageClasses.add(Piletransformations.class); + packageClasses.add(Point.class); + packageClasses.add(Segment.class); + packageClasses.add(Structure.class); + for (Class cl : packageClasses) { + ClassPreamble classPreamble = cl.getAnnotation(ClassPreamble.class); + if (classPreamble == null) + System.out.println("No annotation for " + cl.getName()); + continue; + + System.out.println("Annotation date = " + classPreamble.date()); + } } } diff --git a/exo4/TP2/Main.java b/exo4/Main.java.bak0 similarity index 100% rename from exo4/TP2/Main.java rename to exo4/Main.java.bak0 diff --git a/exo4/Makefile b/exo4/Makefile index b6e4a34..7b62634 100644 --- a/exo4/Makefile +++ b/exo4/Makefile @@ -46,6 +46,7 @@ JVM = java # NAME = Camilo Juan CLASSES = \ + ClassPreamble.java \ Main.java # diff --git a/exo4/TP2/Piletransformations.java b/exo4/Piletransformations.java similarity index 100% rename from exo4/TP2/Piletransformations.java rename to exo4/Piletransformations.java diff --git a/exo4/TP2/Point.java b/exo4/Point.java similarity index 100% rename from exo4/TP2/Point.java rename to exo4/Point.java diff --git a/exo4/TP2/Segment.java b/exo4/Segment.java similarity index 100% rename from exo4/TP2/Segment.java rename to exo4/Segment.java diff --git a/exo4/TP2/Structure.java b/exo4/Structure.java similarity index 100% rename from exo4/TP2/Structure.java rename to exo4/Structure.java diff --git a/exo4/TP2/Makefile b/exo4/TP2/Makefile deleted file mode 100644 index 849e82a..0000000 --- a/exo4/TP2/Makefile +++ /dev/null @@ -1,101 +0,0 @@ -# define compiler and compiler flag variables -# define a variable for compiler flags (JFLAGS) -# define a variable for the compiler (JC) -# define a variable for the Java Virtual Machine (JVM) - -JFLAGS = -g -JC = javac -JVM = java - -# -# Clear any default targets for building .class files from .java files; we -# will provide our own target entry to do this in this makefile. -# make has a set of default targets for different suffixes (like .c.o) -# Currently, clearing the default for .java.class is not necessary since -# make does not have a definition for this target, but later versions of -# make may, so it doesn't hurt to make sure that we clear any default -# definitions for these -# - -.SUFFIXES: .java .class - - -# -# Here is our target entry for creating .class files from .java files -# This is a target entry that uses the suffix rule syntax: -# DSTS: -# rule -# DSTS (Dependency Suffix Target Suffix) -# 'TS' is the suffix of the target file, 'DS' is the suffix of the dependency -# file, and 'rule' is the rule for building a target -# '$*' is a built-in macro that gets the basename of the current target -# Remember that there must be a < tab > before the command line ('rule') -# - -.java.class: - $(JC) $(JFLAGS) $*.java - - -# -# CLASSES is a macro consisting of N words (one for each java source file) -# When a single line is too long, use \ to split lines that then will be -# considered as a single line. For example: -# NAME = Camilo \ - Juan -# is understood as -# NAME = Camilo Juan - -CLASSES = \ - ClassPreamble.java \ - Compactable.java \ - Affichable.java \ - Structure.java \ - Point.java \ - Forme.java \ - Image.java \ - Segment.java \ - Cercle.java \ - Entiers.java \ - Liste.java \ - Piletransformations.java \ - Main.java - -# -# MAIN is a variable with the name of the file containing the main method -# - -MAIN = Main - -# -# the default make target entry -# for this example it is the target classes - -default: classes - - -# Next line is a target dependency line -# This target entry uses Suffix Replacement within a macro: -# $(macroname:string1=string2) -# In the words in the macro named 'macroname' replace 'string1' with 'string2' -# Below we are replacing the suffix .java of all words in the macro CLASSES -# with the .class suffix -# - -classes: $(CLASSES:.java=.class) - - -# Next two lines contain a target for running the program -# Remember the tab in the second line. -# $(JMV) y $(MAIN) are replaced by their values - -run: $(MAIN).class - $(JVM) $(MAIN) - -# this line is to remove all unneeded files from -# the directory when we are finished executing(saves space) -# and "cleans up" the directory of unneeded .class files -# RM is a predefined macro in make (RM = rm -f) -# - -clean: - $(RM) *.class -- 2.34.1