Package com.gitblit.utils

Examples of com.gitblit.utils.ByteFormat.format()


            // strip trailing slash
            basePath = basePath.substring(0, basePath.length() - 1);
          }
          for (PathModel entry : pathEntries) {
            response.getWriter().append(MessageFormat.format(pattern, basePath, entry.name,
                JGitUtils.getPermissionsFromMode(entry.mode), byteFormat.format(entry.size)));
          }
          response.getWriter().append("</tbody>");
          response.getWriter().append("</table>");
        }
        return;
View Full Code Here


      @Override
      public void populateItem(final Item<PathModel> item) {
        PathModel entry = item.getModelObject();
        item.add(WicketUtils.newImage("docIcon", "file_world_16x16.png"));
        item.add(new Label("docSize", byteFormat.format(entry.size)));
        item.add(new LinkPanel("docName", "list", StringUtils.stripFileExtension(entry.name),
            DocPage.class, WicketUtils.newPathParameter(repositoryName, id, entry.path)));

        // links
        item.add(new BookmarkablePageLink<Void>("view", DocPage.class, WicketUtils
View Full Code Here

            if (entry.isSymlink()) {
              path = JGitUtils.getStringContent(getRepository(), getCommit().getTree(), path);
              displayPath = entry.name + " -> " + path;
            }
            item.add(WicketUtils.getFileImage("pathIcon", entry.name));
            item.add(new Label("pathSize", byteFormat.format(entry.size)));
            item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
                WicketUtils.newPathParameter(repositoryName, id,
                    path)));

            // links
View Full Code Here

      long sz = com.gitblit.utils.FileUtils.folderSize(gitDir);
      repositorySizeCache.updateObject(model.name, model.lastChange, sz);
    }
    long size = repositorySizeCache.getObject(model.name);
    ByteFormat byteFormat = new ByteFormat();
    model.size = byteFormat.format(size);
    return size;
  }

  /**
   * Returns true if the repository is idle (not being accessed).
View Full Code Here

        }
        for (PathModel entry : pathEntries) {
          String pp = URLEncoder.encode(entry.name, Constants.ENCODING);
          response.getWriter().append(MessageFormat.format(pattern, basePath, pp,
              JGitUtils.getPermissionsFromMode(entry.mode),
              entry.isFile() ? byteFormat.format(entry.size) : ""));
        }
        response.getWriter().append("</tbody>");
        response.getWriter().append("</table>");
      }
    } catch (Throwable t) {
View Full Code Here

      @Override
      public void populateItem(final Item<PathModel> item) {
        PathModel entry = item.getModelObject();
        item.add(WicketUtils.newImage("docIcon", "file_world_16x16.png"));
        item.add(new Label("docSize", byteFormat.format(entry.size)));
        item.add(new LinkPanel("docName", "list", StringUtils.stripFileExtension(entry.name),
            DocPage.class, WicketUtils.newPathParameter(repositoryName, commitId, entry.path)));

        // links
        item.add(new BookmarkablePageLink<Void>("view", DocPage.class, WicketUtils
View Full Code Here

      long sz = com.gitblit.utils.FileUtils.folderSize(gitDir);
      repositorySizeCache.updateObject(model.name, model.lastChange, sz);
    }
    long size = repositorySizeCache.getObject(model.name);
    ByteFormat byteFormat = new ByteFormat();
    model.size = byteFormat.format(size);
    return size;
  }

  /**
   * Returns true if the repository is idle (not being accessed).
View Full Code Here

            if (entry.isSymlink()) {
              path = JGitUtils.getStringContent(getRepository(), getCommit().getTree(), path);
              displayPath = entry.name + " -> " + path;
            }
            item.add(WicketUtils.getFileImage("pathIcon", entry.name));
            item.add(new Label("pathSize", byteFormat.format(entry.size)));
            item.add(new LinkPanel("pathName", "list", displayPath, BlobPage.class,
                WicketUtils.newPathParameter(repositoryName, id,
                    path)));

            // links
View Full Code Here

    Locale defaultLocale = Locale.getDefault();

    try {
      Locale.setDefault(Locale.ENGLISH);
      ByteFormat format = new ByteFormat();
      assertEquals("10 b", format.format(10));
      assertEquals("10 KB", format.format(1024 * 10));
      assertEquals("1,000 KB", format.format(1024 * 1000));
      assertEquals("2.0 MB", format.format(2 * 1024 * 1000));
      assertEquals("1,000.0 MB", format.format(1024 * 1024 * 1000));
      assertEquals("2.0 GB", format.format(2 * 1024 * 1024 * 1000));
 
View Full Code Here

    try {
      Locale.setDefault(Locale.ENGLISH);
      ByteFormat format = new ByteFormat();
      assertEquals("10 b", format.format(10));
      assertEquals("10 KB", format.format(1024 * 10));
      assertEquals("1,000 KB", format.format(1024 * 1000));
      assertEquals("2.0 MB", format.format(2 * 1024 * 1000));
      assertEquals("1,000.0 MB", format.format(1024 * 1024 * 1000));
      assertEquals("2.0 GB", format.format(2 * 1024 * 1024 * 1000));
    } finally {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.