use of org.apache.wicket.util.lang.Bytes in project wicket by apache.
the class MultipartServletWebRequestImpl method newFileUpload.
/**
* Factory method for creating new instances of FileUploadBase
*
* @param encoding
* The encoding to use while reading the data
* @return A new instance of FileUploadBase
*/
protected FileUploadBase newFileUpload(String encoding) {
// Configure the factory here, if desired.
ServletFileUpload fileUpload = new ServletFileUpload(fileItemFactory);
// set encoding specifically when we found it
if (encoding != null) {
fileUpload.setHeaderEncoding(encoding);
}
fileUpload.setSizeMax(getMaxSize().bytes());
Bytes fileMaxSize = getFileMaxSize();
if (fileMaxSize != null) {
fileUpload.setFileSizeMax(fileMaxSize.bytes());
}
return fileUpload;
}
use of org.apache.wicket.util.lang.Bytes in project wicket by apache.
the class BytesTest method stringOperationsCommaLocale.
/**
* @throws StringValueConversionException
*/
@Test
public void stringOperationsCommaLocale() throws StringValueConversionException {
Locale.setDefault(Locale.GERMANY);
assertTrue("1G".equals(Bytes.gigabytes(1).toString()));
assertTrue(Bytes.valueOf("15,5K").bytes() == ((15 * 1024) + 512));
final Bytes b = Bytes.kilobytes(7.3);
assertTrue(Bytes.valueOf(b.toString()).equals(b));
}
use of org.apache.wicket.util.lang.Bytes in project wicket by apache.
the class BytesTest method allOperationsCurrentLocale.
/**
* @throws StringValueConversionException
*/
@Test
public void allOperationsCurrentLocale() throws StringValueConversionException {
assertTrue(Bytes.bytes(1024).equals(Bytes.kilobytes(1)));
assertTrue(Bytes.bytes(1024 * 1024).equals(Bytes.megabytes(1)));
assertTrue("1G".equals(Bytes.gigabytes(1).toString()));
final Bytes b = Bytes.kilobytes(7.3);
assertTrue(b.equals(Bytes.kilobytes(7.3)));
assertTrue(b.greaterThan(Bytes.kilobytes(7.25)));
assertTrue(b.lessThan(Bytes.kilobytes(7.9)));
assertTrue(Bytes.valueOf(b.toString()).equals(b));
}
use of org.apache.wicket.util.lang.Bytes in project wicket by apache.
the class PageSizeDebugPanel method getDataModel.
@Override
protected IModel<String> getDataModel() {
return new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
Page enclosingPage = getPage();
long pageSize = WicketObjects.sizeof(enclosingPage);
Bytes pageSizeInBytes = (pageSize > -1 ? Bytes.bytes(pageSize) : null);
String pageSizeAsString = pageSizeInBytes != null ? pageSizeInBytes.toString() : "unknown";
return "Page: " + pageSizeAsString;
}
};
}
use of org.apache.wicket.util.lang.Bytes in project wicket by apache.
the class DebugPageManagerProvider method newDataStore.
@Override
protected IDataStore newDataStore() {
StoreSettings storeSettings = application.getStoreSettings();
File fileStoreFolder = storeSettings.getFileStoreFolder();
Bytes maxSizePerSession = storeSettings.getMaxSizePerSession();
dataStore = new DebugDiskDataStore(application.getName(), fileStoreFolder, maxSizePerSession);
return dataStore;
}
Aggregations