- Timestamp:
- 08/19/2005 05:51:17 PM (21 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
. (modified) (1 prop)
-
src/ws/fugue88/jpath/Context.java (modified) (5 diffs)
-
src/ws/fugue88/jpath/Path.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 2 2 .classpath 3 3 .project 4 velocity.log
-
- Property svn:ignore
-
trunk/src/ws/fugue88/jpath/Context.java
r4 r5 3 3 * 4 4 * $Log$ 5 * Revision 1.3 2005/08/19 17:51:17 dsowen 6 * Fixed: NPEs when using accessors from paths, &c. Included tests. 7 * Fixed: parsing exception wasn't very enlightening. 8 * 5 9 * Revision 1.2 2005/08/12 19:01:46 dsowen 6 10 * Feature: can automatically fill missing parts of a graph. … … 18 22 package ws.fugue88.jpath; 19 23 24 import java.lang.reflect.Constructor; 20 25 import java.lang.reflect.InvocationTargetException; 21 26 import java.util.Iterator; … … 34 39 { 35 40 Context current = this; 36 Accessor accessor = null; 37 for(Iterator i = path.iterator(); i.hasNext();) { 38 accessor = current.getTargetAccessor((PathPart)i.next()); 41 for(Iterator i = path.parents().iterator(); i.hasNext();) { 42 Accessor accessor = current.getTargetAccessor((PathPart)i.next()); 39 43 Object obj = accessor.getValue(); 40 44 if(obj == null) { 41 if(_modifying && i.hasNext()) {45 if(_modifying) { 42 46 obj = createBlank(accessor.getType()); 43 47 accessor.setValue(obj); … … 48 52 current = new Context(obj, _binder, _modifying); 49 53 } 50 return accessor;54 return current.getTargetAccessor(path.terminal()); 51 55 } 52 56 … … 109 113 110 114 private Object createBlank(final Class type) throws IllegalAccessException, 111 InstantiationException 115 InstantiationException, InvocationTargetException 112 116 { 113 return type.newInstance(); 117 try { 118 final Constructor ctor = type.getDeclaredConstructor(null); 119 ctor.setAccessible(true); 120 return ctor.newInstance(null); 121 } catch(NoSuchMethodException e) { 122 throw new InstantiationException("Class " + type.getName() 123 + " must have a no-argument constructor."); 124 } 114 125 } 115 126 -
trunk/src/ws/fugue88/jpath/Path.java
r2 r5 3 3 * 4 4 * $Log$ 5 * Revision 1.2 2005/08/19 17:51:17 dsowen 6 * Fixed: NPEs when using accessors from paths, &c. Included tests. 7 * Fixed: parsing exception wasn't very enlightening. 8 * 5 9 * Revision 1.1 2005/08/03 00:35:29 dsowen 6 10 * Initial commit. … … 51 55 pp = new StringSelector(unquote(m.group(1))); 52 56 } else { 53 throw new ParseException(null, -1); 57 throw new ParseException( 58 "Expected identifier or selector, found '" 59 + (buff.length() > 40 ? buff.subSequence(0, 37) 60 + "..." : buff) + "'.", -1); 54 61 } 55 62 _parts.add(pp); … … 63 70 } 64 71 65 public Stringterminal()72 public PathPart terminal() 66 73 { 67 return ( String)_parts.get(_parts.size() - 1);74 return (PathPart)_parts.get(_parts.size() - 1); 68 75 } 69 76
Note: See TracChangeset
for help on using the changeset viewer.
