private String getPathRoot(final MetaClass bundleClass, final URL resource) { final String fullPath = resource.getPath(); final String resourcePath = bundleClass.getAnnotation(Bundle.class).value(); final String protocol = resource.getProtocol(); final String relativePath; if (resourcePath.startsWith("/")) relativePath = resourcePath; else // Do NOT use File.separatorChar here: Url.getPath() always uses forward-slashes relativePath = bundleClass.getPackageName().replace('.', '/'); final String pathRoot = fullPath.substring(0, fullPath.indexOf(relativePath)); return protocol + ":" + pathRoot; }
private String getPathRoot(final MetaClass bundleClass, final URL resource) { final String fullPath = resource.getPath(); final String resourcePath = bundleClass.getAnnotation(Bundle.class).value(); final String protocol = resource.getProtocol(); final String relativePath; if (resourcePath.startsWith("/")) relativePath = resourcePath; else // Do NOT use File.separatorChar here: Url.getPath() always uses forward-slashes relativePath = bundleClass.getPackageName().replace('.', '/'); final String pathRoot = fullPath.substring(0, fullPath.indexOf(relativePath)); return protocol + ":" + pathRoot; }
/** * Gets the bundle name from the @Bundle annotation. * * @param bundleAnnotatedClass */ private String getMessageBundlePath(final MetaClass bundleAnnotatedClass) { final Bundle annotation = bundleAnnotatedClass.getAnnotation(Bundle.class); final String name = annotation.value(); if (name == null) { throw new GenerationException("@Bundle: bundle name must not be null]."); } // Absolute path vs. relative path. if (name.startsWith("/")) { return name.substring(1); } else { final String packageName = bundleAnnotatedClass.getPackageName(); return packageName.replace('.', '/') + "/" + name; } }
/** * Gets the bundle name from the @Bundle annotation. * * @param bundleAnnotatedClass */ private String getMessageBundlePath(final MetaClass bundleAnnotatedClass) { final Bundle annotation = bundleAnnotatedClass.getAnnotation(Bundle.class); final String name = annotation.value(); if (name == null) { throw new GenerationException("@Bundle: bundle name must not be null]."); } // Absolute path vs. relative path. if (name.startsWith("/")) { return name.substring(1); } else { final String packageName = bundleAnnotatedClass.getPackageName(); return packageName.replace('.', '/') + "/" + name; } }