Ejemplo n.º 1
0
 @Override
 public String getFilename() throws IllegalStateException {
   try {
     return StringUtils.getFilename(getURL().getPath());
   } catch (IOException e) {
     return super.getFilename();
   }
 }
  private String[] determineImportsFor(Map entries) {
    // get contained packages to do matching on the test hierarchy
    Collection containedPackages = jarCreator.getContainedPackages();
    Set cumulatedPackages = new LinkedHashSet();

    // make sure the collection package is valid
    boolean validPackageCollection = !containedPackages.isEmpty();

    boolean trace = logger.isTraceEnabled();

    for (Iterator iterator = entries.entrySet().iterator(); iterator.hasNext(); ) {
      Map.Entry entry = (Map.Entry) iterator.next();
      String resourceName = (String) entry.getKey();

      // filter out the test hierarchy
      if (resourceName.endsWith(ClassUtils.CLASS_FILE_SUFFIX)) {
        if (trace) logger.trace("Analyze imports for test bundle resource " + resourceName);
        String classFileName = StringUtils.getFilename(resourceName);
        String className =
            classFileName.substring(
                0, classFileName.length() - ClassUtils.CLASS_FILE_SUFFIX.length());
        String classPkg =
            resourceName
                .substring(0, resourceName.length() - classFileName.length())
                .replace('/', '.');

        if (classPkg.startsWith(".")) classPkg = classPkg.substring(1);

        if (classPkg.endsWith(".")) classPkg = classPkg.substring(0, classPkg.length() - 1);

        // if we don't have the package, add it
        if (validPackageCollection
            && StringUtils.hasText(classPkg)
            && !containedPackages.contains(classPkg)) {
          logger.trace(
              "Package ["
                  + classPkg
                  + "] is NOT part of the test archive; adding an import for it");
          cumulatedPackages.add(classPkg);
        }

        // otherwise parse the class byte-code
        else {
          if (trace)
            logger.trace(
                "Package ["
                    + classPkg
                    + "] is part of the test archive; parsing "
                    + className
                    + " bytecode to determine imports...");
          cumulatedPackages.addAll(
              determineImportsForClass(className, (Resource) entry.getValue()));
        }
      }
    }

    return (String[]) cumulatedPackages.toArray(new String[cumulatedPackages.size()]);
  }
 public String getPageTitle() {
   if (StringUtils.isEmpty(this.pathToPage)) return "";
   this.pageTitle = StringUtils.getFilename(this.pathToPage);
   this.pageTitle = StringUtils.stripFilenameExtension(this.pageTitle);
   this.pageTitle = StringUtils.replace(this.pageTitle, "_", " ");
   this.pageTitle = StringUtils.capitalize(this.pageTitle);
   this.pageTitle = StringUtils.trimWhitespace(this.pageTitle);
   return this.pageTitle;
 }
 /**
  * 지정한 경로에서 파일명만 추출한다. 예) "mypath/myfile.txt" -> "myfile.txt".
  *
  * @param path 파일 경로(<tt>null</tt>이 될 수도 있음)
  * @return 추출된 파일명 또는 파일명이 없는 경우 <tt>null</tt>
  */
 public static String getFilename(String path) {
   return org.springframework.util.StringUtils.getFilename(path);
 }
 /** @see org.springframework.core.io.AbstractResource#getFilename() */
 public String getFilename() throws IllegalStateException {
   if (realPath == null || realPath.length == 0) {
     return null;
   }
   return StringUtils.getFilename(realPath[0]);
 }
 /**
  * This implementation returns the name of the file that this class path resource refers to.
  *
  * @see org.springframework.util.StringUtils#getFilename(String)
  */
 @Override
 public String getFilename() {
   return StringUtils.getFilename(this.path);
 }