public PathSegments consume() { return consume(1); }
/** * @see com.isotrol.impe3.api.DeviceResolver#resolveDevice(com.isotrol.impe3.api.DeviceResolutionParams) */ public ResolvedDevice resolveDevice(DeviceResolutionParams params) { final DevicesInPortal dips = params.getPortal().getDevices(); final PathSegments path = params.getPath(); Device d = dips.findDeviceByFirstSegment(path); if (d != null) { return params.resolve(d, path.consume()); } d = dips.findDeviceByLastSegment(path); if (d != null) { return params.resolve(d, path.consumeLast()); } d = dips.findDeviceByLastSegmentExtension(path); if (d != null) { return params.resolve(d, path.removeExtension()); } return null; }
/** * @see com.isotrol.impe3.api.LocaleResolver#resolveLocale(com.isotrol.impe3.api.LocaleResolutionParams) */ public ResolvedLocale resolveLocale(LocaleResolutionParams params) { Locale locale = null; PathSegments p = params.getPath(); if (p.isEmpty()) { // TODO use fallback return new ResolvedLocale(params.getPath(), params.getPortal().getDefaultLocale(), params.getParameters()); } String segment = p.get(0); locale = cache.getUnchecked(params.getPortal()).get(segment); if (locale == null) { // TODO use fallback return new ResolvedLocale(params.getPath(), params.getPortal().getDefaultLocale(), params.getParameters()); } return new ResolvedLocale(p.consume(), locale, params.getParameters()); }
public ResolvedDevice resolveDevice(DeviceResolutionParams params) { final Portal portal = params.getPortal(); final PathSegments path = params.getPath(); DevicesInPortal dips = portal.getDevices(); if (config != null && !config.includeDefault()) { dips = dips.excludeDevice(portal.getDevice()); } final Device d = portal.getDevices().findDeviceByFirstSegment(path); if (d != null) { return new ResolvedDevice(path.consume(), d, new DefaultDeviceCapabilities(d), params.getParameters()); } return null; } }