Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. import java.lang.annotations.*;
  2. @Target({ElementType.LOCAL_VARIABLE})
  3. @Retention(RetentionPolicy.RUNTIME)
  4. public @interface DBAnnotation {
  5. String variable () default "";
  6. String table () default "";
  7. String column () default "";
  8. boolean isSource () default false;
  9. }
  10.  
  11.  
  12. public static void addFileToDB(String fileName, String fileLocation, int offerID){
  13. @DBAnnotation (variable = "fileName", table = "files", column = "FileName", isSource = true)
  14. @DBAnnotation (variable = "fileLocation", table = "files", column = "fileLocation", isSource = true)
  15.  
  16.  
  17.  
  18.  
  19. String SQLFileSelect = "SELECT FileName FROM files WHERE OfferID = ? AND FileLocation = ?;";
  20. .
  21. .
  22. .
  23. }
  24.  
  25. Duplicate annotation @File.DBAnnotation. Repeated annotations are allowed only at source level 1.8 or above
  26.  
  27. public @interface DBAnnotation {
  28. String[] variable () default "";
  29. String table () default "";
  30. String[] column () default "";
  31. boolean[] isSource () default false;
  32. }
  33. .
  34. .
  35. .
  36. @DBAnnotation (
  37. variable = {"fileName","fileLocation"},
  38. table = "files",
  39. column = {"FileName","fileLocation"},
  40. isSource = true)
  41.  
  42. variable = {"fileName","fileLocation"},
  43. table = "files",
  44. column = {"FileName","fileLocation"},
  45. isSource = true
  46.  
  47. getAnnotation(DBAnnotation.class).variable(); // will return the String array with both values.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement