source: trunk/src/ws/fugue88/jpath/Binder.java

Last change on this file was 2, checked in by dsowen, 21 years ago

Initial commit.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.1 KB
Line 
1/*
2 * Created on Aug 2, 2005
3 *
4 * $Log$
5 * Revision 1.1  2005/08/03 00:35:29  dsowen
6 * Initial commit.
7 *
8 */
9package ws.fugue88.jpath;
10
11/**
12 * @author dsowen
13 */
14class Binder {
15
16        Property getProperty(final Class type, final Identifier part)
17                        throws NoSuchPropertyException
18        {
19                try {
20                        return new MutableMethodProperty(part.getName(), type, "get"
21                                        + initialize(part.getName()), "set"
22                                        + initialize(part.getName()));
23                } catch(NoSuchMethodException e) {
24                        try {
25                                return new ImmutableMethodProperty(part.getName(), type, "get"
26                                                + initialize(part.getName()));
27                        } catch(NoSuchMethodException e1) {
28                                try {
29                                        return new FieldProperty(part.getName(), type,
30                                                        part.getName());
31                                } catch(NoSuchFieldException e2) {
32                                        try {
33                                                return new FieldProperty(part.getName(), type, "_"
34                                                                + part.getName());
35                                        } catch(NoSuchFieldException e3) {
36                                                throw new NoSuchPropertyException(type, part.getName());
37                                        }
38                                }
39                        }
40                }
41        }
42
43        private static String initialize(final String s)
44        {
45                return s.substring(0, 1).toUpperCase() + s.substring(1);
46        }
47}
Note: See TracBrowser for help on using the repository browser.