本文整理汇总了Java中org.apache.wicket.util.lang.Bytes.bytes方法的典型用法代码示例。如果您正苦于以下问题:Java Bytes.bytes方法的具体用法?Java Bytes.bytes怎么用?Java Bytes.bytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.wicket.util.lang.Bytes
的用法示例。
在下文中一共展示了Bytes.bytes方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validate
import org.apache.wicket.util.lang.Bytes; //导入方法依赖的package包/类
@Override
public void validate(IValidatable<List<FileUpload>> validatable) {
for (FileUpload fileUpload : validatable.getValue()) {
Bytes fileSize = Bytes.bytes(fileUpload.getSize());
if (fileSize.greaterThan(maximum)) {
ValidationError error = new ValidationError();
if (errorResourceKey != null) {
error.addKey(errorResourceKey);
}
error.addKey(this);
error.setVariable("maximum", maximum);
error.setVariable("clientFileName", fileUpload.getClientFileName());
error.setVariable("size", fileSize);
validatable.error(error);
}
}
}
示例2: parse
import org.apache.wicket.util.lang.Bytes; //导入方法依赖的package包/类
public static Bytes parse(Long size, SessionUnit sessionUnit){
switch(sessionUnit){
case BYTES:
return Bytes.bytes(size);
case KILOBYTES:
return Bytes.kilobytes(size);
case MEGABYTES:
return Bytes.megabytes(size);
case TERABYTES:
return Bytes.terabytes(size);
}
throw new WicketSpringBootException("Could not parse size with session unit " + size + " " + sessionUnit);
}
示例3: downloadHtopTable
import org.apache.wicket.util.lang.Bytes; //导入方法依赖的package包/类
private void downloadHtopTable(Item<UIUserForList> item, final UIUserForList user) {
Link<Void> downloadHotpTableLink = new Link<Void>("download-hotp-table") {
@Override
public void onClick() {
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
hotpProvider.outputSequenceForDownload(user.getUsername(), os);
} catch (IOException e) {
throw new IllegalStateException(e);
}
final byte[] bytes = os.toByteArray();
IResourceStream resourceStream = new AbstractResourceStream() {
@Override
public Time lastModifiedTime() {
return Time.now();
}
@Override
public Bytes length() {
return Bytes.bytes(bytes.length);
}
@Override
public InputStream getInputStream() throws ResourceStreamNotFoundException {
return new ByteArrayInputStream(bytes);
}
@Override
public String getContentType() {
return "application/vnd.ms-excel";
}
@Override
public void close() throws IOException {
}
};
getRequestCycle().replaceAllRequestHandlers(new ResourceStreamRequestHandler(resourceStream,
hotpProvider.getSequenceForDownloadFileName(user.getUsername())));
}
};
downloadHotpTableLink.setVisible(hotpProvider.outputsSequenceForDownload());
item.add(downloadHotpTableLink);
}
示例4: length
import org.apache.wicket.util.lang.Bytes; //导入方法依赖的package包/类
@Override
public Bytes length() {
return inputStream == null
? Bytes.bytes(0)
: null;
}
示例5: length
import org.apache.wicket.util.lang.Bytes; //导入方法依赖的package包/类
@Override
public Bytes length(){
return Bytes.bytes(content_.length);
}
示例6: length
import org.apache.wicket.util.lang.Bytes; //导入方法依赖的package包/类
@Override
public Bytes length()
{
return Bytes.bytes(content.length);
}
示例7: length
import org.apache.wicket.util.lang.Bytes; //导入方法依赖的package包/类
@Override
public Bytes length() {
return Bytes.bytes(content.length);
}