本文整理汇总了Java中com.gitblit.utils.ByteFormat类的典型用法代码示例。如果您正苦于以下问题:Java ByteFormat类的具体用法?Java ByteFormat怎么用?Java ByteFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ByteFormat类属于com.gitblit.utils包,在下文中一共展示了ByteFormat类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTable
import com.gitblit.utils.ByteFormat; //导入依赖的package包/类
protected void updateTable(boolean pack) {
ServerStatus status = gitblit.getStatus();
header.setText(Translation.get("gb.status"));
version.setText(Constants.NAME + (status.isGO ? " GO v" : " WAR v") + status.version);
releaseDate.setText(status.releaseDate);
bootDate.setText(status.bootDate.toString() + " (" + Translation.getTimeUtils().timeAgo(status.bootDate)
+ ")");
url.setText(gitblit.url);
servletContainer.setText(status.servletContainer);
ByteFormat byteFormat = new ByteFormat();
heapMaximum.setText(byteFormat.format(status.heapMaximum));
heapAllocated.setText(byteFormat.format(status.heapAllocated));
heapUsed.setText(byteFormat.format(status.heapAllocated - status.heapFree) + " ("
+ byteFormat.format(status.heapFree) + " " + Translation.get("gb.free") + ")");
tableModel.setProperties(status.systemProperties);
tableModel.fireTableDataChanged();
}
示例2: DocsPage
import com.gitblit.utils.ByteFormat; //导入依赖的package包/类
public DocsPage(PageParameters params) {
super(params);
Repository r = getRepository();
List<String> extensions = GitBlit.getStrings(Keys.web.markdownExtensions);
List<PathModel> paths = JGitUtils.getDocuments(r, extensions);
final ByteFormat byteFormat = new ByteFormat();
add(new Label("header", getString("gb.docs")));
// documents list
ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);
DataView<PathModel> pathsView = new DataView<PathModel>("document", pathsDp) {
private static final long serialVersionUID = 1L;
int counter;
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", entry.name, BlobPage.class, WicketUtils
.newPathParameter(repositoryName, entry.commitId, entry.path)));
// links
item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils
.newPathParameter(repositoryName, entry.commitId, entry.path)));
item.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils
.newPathParameter(repositoryName, entry.commitId, entry.path)));
item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils
.newPathParameter(repositoryName, entry.commitId, entry.path)));
item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils
.newPathParameter(repositoryName, entry.commitId, entry.path)));
WicketUtils.setAlternatingBackground(item, counter);
counter++;
}
};
add(pathsView);
}
示例3: testByteFormat
import com.gitblit.utils.ByteFormat; //导入依赖的package包/类
@Test
public void testByteFormat() throws Exception {
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));
}