public ConverterCandidate(DataConverter converter) { this.converter = converter; if (converter.getTargetPath() != null) { segments = PathUtil.splitPath(converter.getTargetPath()); } } }
public static Object navigate(Object rootobj, String path, SAXalizerMappingContext mappingcontext) { if (path == null || path.equals("")) { return rootobj; } String[] components = PathUtil.splitPath(path); Object moveobj = rootobj; for (int comp = 0; comp < components.length; ++comp) { if (moveobj == null) { throw UniversalRuntimeException.accumulate( new IllegalArgumentException(), "Null value encounted in bean path at component " + (comp == 0 ? "<root>" : components[comp - 1] + " while traversing for " + components[comp])); } else { moveobj = navigateOne(moveobj, components[comp], mappingcontext); if (moveobj == UNREADABLE_PROPERTY) { throw new IllegalArgumentException("Property " + components[comp] + " is not readable for object of " + moveobj.getClass()); } } } return moveobj; }
public ShellInfo fetchShells(String fullpath, Object rootobj, boolean expectMethod) { Object moveobj = rootobj; List shells = new ArrayList(); shells.add(rootobj); String[] segments = PathUtil.splitPath(fullpath); for (int i = 0; i < segments.length; ++i) { if (expectMethod) { if (ReflectUtils.hasMethod(moveobj, segments[i])) break; } moveobj = BeanUtil.navigateOne(moveobj, segments[i], mappingcontext); if (moveobj == null || moveobj == BeanUtil.UNREADABLE_PROPERTY) { break; } shells.add(moveobj); if (moveobj instanceof DARReceiver) { break; } } ShellInfo togo = new ShellInfo(); togo.segments = segments; togo.shells = shells.toArray(); return togo; }
/** Disused method */ public List getInvalidatingEntries(String path) { ArrayList togo = new ArrayList(); String[] splitEL = PathUtil.splitPath(path); StringList goup = new StringList(); for (int i = 0; i < splitEL.length; ++ i) { goup.add(splitEL[i]); String upstring = PathUtil.buildPath(goup.toStringArray()); List deps = (List) writemap.get(upstring); if (deps != null) { togo.addAll(deps); } } return togo; } }
String[] segments = PathUtil.splitPath(oldpath); for (int i = 0; i < segments.length - 1; ++i) { moveobj = BeanUtil.navigateOne(moveobj, segments[i], mappingcontext);
/** * Takes a path ending with a greedy expression (probably .*) and appends the * "leaves" (fields) based on passed in arguments */ private void appendLeaves(Class rootclass, String pathroot, String attrprefix, StringList attnames, StringList paths) { String[] components = PathUtil.splitPath(pathroot); Class moveclass = rootclass; for (int i = 0; i < components.length; ++i) { MethodAnalyser ma = mappingcontext.getAnalyser(moveclass); String component = components[i]; AccessMethod method = ma.getAccessMethod(component); if (method == null || !(method.canGet() && method.canSet())) { throw new IllegalArgumentException( "Unable to find writeable property for path component " + component + " at " + moveclass); } moveclass = method.getAccessedType(); } MethodAnalyser ma = mappingcontext.getAnalyser(moveclass); for (int i = 0; i < ma.allgetters.length; ++i) { SAXAccessMethod method = ma.allgetters[i]; if (method.canGet() && method.canSet() && mappingcontext.generalLeafParser.isLeafType(method.getAccessedType())) { paths.add(PathUtil.composePathEncoded(pathroot, method.tagname)); attnames.add(attrprefix + method.tagname); } } }