Results 1 to 6 of 6
Thread: java annotations - small prog
- 10-21-2008, 11:16 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 9
- Rep Power
- 0
java annotations - small prog
i've got some test-prog to write using annotations, there are some guidelines how it has to look like, so here they are:
i have to define @Bind annotation which used for chosen fields of a class let me add their values to a map behind the keys = variable names.
The process of adding and getting values to/from the map has to find his place in another class called Binder.
i'm new in java things so..... :(
things i must follow:
-----------------------
public class Test {
@Bind static double a;
@Bind static double b;
double static c;
somwhere in a method:
a = 7;
b = 12;
c = 1;
in some method of a constructor:
Binder bdr = new Binder(...)
bdr.bind();
somwhere else:
Map<..> map = bdr.getMap();
and using 'map' there should be a possibility to access the values of 'a' and 'b', but not the 'c'.
It seems to be very easy, but not for me, not now... can anyone help me to do this so i can be able to work on other things like that... thx in advance!
- 10-21-2008, 02:53 PM #2
Do you have any code for your problem?
- 10-21-2008, 03:44 PM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Can you show how you define the annotations.
- 10-22-2008, 02:03 PM #4
Member
- Join Date
- Oct 2008
- Posts
- 9
- Rep Power
- 0
k, so if i'm right there should be an apart class for the annotation:
my test-class, not sure if correct:Java Code:public @interface Bind { //and because i'm not experienced i'm not sure if there is sth needed here ? }
but i still don't know how should exactly my Binder-class look like in order to add and get those values.... just to be honest - dnt know how it exactly works :(Java Code:public class Test { @Bind static double a; @Bind static double b; static double c; public static void main(String[] args) { setValues(); Binder bdr = new Binder(a,b,c); bdr.bind(); Map<Integer,double> map = new HashMap<Integer,double>(); map = bdr.getMap(); //some for-each to get these values } private static void setValues() { a = 7; b = 12; c = 1; } }
any help now?Java Code:public class Binder { public Binder(double a, double b, double c) { // TODO } public void bind() { // TODO } public Map<Integer, Integer> getMap() { // TODO return null; } }
- 10-23-2008, 04:59 PM #5
Member
- Join Date
- Oct 2008
- Posts
- 9
- Rep Power
- 0
anybody ...?
- 10-24-2008, 05:48 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
I really mess with your question now. Are you talking about the Binder class method functionality or annotations? Can you explain it little more.
Similar Threads
-
Proofreading this small Java program
By almina in forum New To JavaReplies: 5Last Post: 10-23-2009, 07:42 AM -
want menu driven prog. who to take user i/p in the middle of the prog.
By Shyam Singh in forum New To JavaReplies: 1Last Post: 07-13-2008, 03:16 PM -
Small scale Java Editor
By Greenfrog99 in forum AWT / SwingReplies: 0Last Post: 01-27-2008, 08:46 PM -
need a prog on java 2d applet
By bachelorswalk in forum Java AppletsReplies: 0Last Post: 12-25-2007, 05:26 PM -
Small tennis simulation in Java
By diego in forum New To JavaReplies: 1Last Post: 12-02-2007, 01:32 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks