/**
   * @see
   *     org.apache.wicket.resource.loader.ComponentStringResourceLoader#loadStringResource(java.lang.Class,
   *     java.lang.String, java.util.Locale, java.lang.String, java.lang.String)
   */
  @Override
  public String loadStringResource(
      Class<?> clazz,
      final String key,
      final Locale locale,
      final String style,
      final String variation) {
    if (clazz == null) {
      return null;
    }

    // Load the properties associated with the path
    IPropertiesFactory propertiesFactory = getPropertiesFactory();

    while (true) {
      Package pkg = clazz.getPackage();
      String packageName = (pkg == null) ? "" : pkg.getName();
      packageName = packageName.replace('.', '/');

      do {
        // Create the base path
        String path = filename;
        if (packageName.length() > 0) {
          path = packageName + "/" + path;
        }

        // Iterator over all the combinations
        IResourceNameIterator iter = newResourceNameIterator(path, locale, style, variation);
        while (iter.hasNext()) {
          String newPath = iter.next();

          Properties props = propertiesFactory.load(clazz, newPath);
          if (props != null) {
            // Lookup the value
            String value = props.getString(key);
            if (value != null) {
              return value;
            }
          }
        }

        // Didn't find the key yet, continue searching if possible
        packageName = Strings.beforeLast(packageName, '/');
      } while (packageName.length() > 0);

      clazz = clazz.getSuperclass();
      if (clazz == null) {
        break;
      }
    }
    // not found
    return null;
  }