Exemplo n.º 1
0
  /** Returns the relative path. */
  public final String getClassName(Path path) {
    if (path == null) return "tmp.eval";

    String pathName = path.getFullPath();
    String pwdName = getPwd().getFullPath();

    String relPath;

    if (pathName.startsWith(pwdName)) relPath = pathName.substring(pwdName.length());
    else relPath = pathName;

    return "_quercus." + JavaCompiler.mangleName(relPath);
  }
  /**
   * Returns the mangled classname for the stylesheet. If getClassName() is not null, it will be
   * used as the mangled name.
   *
   * @param userName the user specified name for the stylesheet.
   * @return a valid Java classname for the generated stylesheet.
   */
  private String getMangledName(String userName) {
    String name = null;

    if (userName == null
        || userName.equals("anonymous.xsl")
        || userName.equals("string")
        || userName.equals("stream")) {
      userName = "******" + (new Random().nextInt() & 0x3ff) + ".xsl";
    }

    if (getClassName() == null) name = userName;
    else name = getClassName();

    if (name.startsWith("/")) name = "xsl" + name;
    else name = "xsl/" + name;

    return JavaCompiler.mangleName(name);
  }