当前位置: 首页>>代码示例>>Java>>正文


Java Bytes类代码示例

本文整理汇总了Java中org.apache.wicket.util.lang.Bytes的典型用法代码示例。如果您正苦于以下问题:Java Bytes类的具体用法?Java Bytes怎么用?Java Bytes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Bytes类属于org.apache.wicket.util.lang包,在下文中一共展示了Bytes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
@Override
public String render(Bytes value, Locale locale) {
	double humanReadableSize = Long.valueOf(value.bytes()).doubleValue();
	int unitKeyIndex = 0;
	
	while (humanReadableSize > DISPLAY_LIMIT && unitKeyIndex < unitKeys.size() - 1) {
		humanReadableSize = humanReadableSize / BYTES_IN_KB;
		unitKeyIndex++;
	}
	
	DecimalFormat twoDecimalsFormat = new DecimalFormat(OUTPUT_DECIMAL_FORMAT, DecimalFormatSymbols.getInstance(locale));
	
	return new StringBuilder(twoDecimalsFormat.format(humanReadableSize)).append(" ")
			.append(getString(unitKeys.get(unitKeyIndex), locale))
			.toString();
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:17,代码来源:BytesRenderer.java

示例2: 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);
		}
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:18,代码来源:FileUploadSizeValidator.java

示例3: UploadForm

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
public UploadForm(String id) {
            super(id);

            setMultiPart(true);
            setMaxSize(Bytes.megabytes(2));

            fileUploadField = new FileUploadField("upload");
            add(fileUploadField);

            add(new Button("continuebutton"));

            Button cancel = new Button("cancelbutton"){
                public void onSubmit() {
//                    info("Cancel was pressed!");
                    setResponsePage(new GradebookPage());
                }
            };
            cancel.setDefaultFormProcessing(false);
            add(cancel);
        }
 
开发者ID:steveswinsburg,项目名称:gradebookNG,代码行数:21,代码来源:GradeImportUploadStep.java

示例4: setupCache

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
private void setupCache() {
    // configure cache by applying the vlo configuration settings to it
    final int pagesInApplicationCache = vloConfig.getPagesInApplicationCache();
    logger.info("Setting Wicket in-memory cache size to {}", pagesInApplicationCache);
    this.getStoreSettings().setInmemoryCacheSize(pagesInApplicationCache);

    final Bytes sessionCacheSize = Bytes.kilobytes((long) vloConfig.getSessionCacheSize());
    logger.info("Setting Wicket max size per session to {}", sessionCacheSize);
    this.getStoreSettings().setMaxSizePerSession(sessionCacheSize);
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:11,代码来源:VloWicketApplication.java

示例5: init

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
@Override
public void init() {
    super.init();

    getRequestCycleSettings().setTimeout(Duration.minutes(5));
    getRequestCycleListeners().add(new SingularServerContextListener());

    Locale.setDefault(new Locale("pt", "BR"));//NOSONAR

    getApplicationSettings().setAccessDeniedPage(Error403Page.class);
    getApplicationSettings().setPageExpiredErrorPage(Page410.class);

    // Don't forget to check your Application server for this
    getApplicationSettings().setDefaultMaximumUploadSize(Bytes.megabytes(10));

    getMarkupSettings().setStripWicketTags(true);
    getMarkupSettings().setStripComments(true);
    getMarkupSettings().setDefaultMarkupEncoding(StandardCharsets.UTF_8.name());
    getComponentOnConfigureListeners().add(component -> {
        boolean outputId = !component.getRenderBodyOnly();
        component.setOutputMarkupId(outputId).setOutputMarkupPlaceholderTag(outputId);
    });


    getComponentInstantiationListeners().add(new SpringComponentInjector(this, getApplicationContext(), true));


    new SingularAnnotatedMountScanner().mountPages(this);
    if (RuntimeConfigurationType.DEVELOPMENT == getConfigurationType()) {
        getDebugSettings().setComponentPathAttributeName("wicketdebug");
        WicketSerializationDebugUtil.configurePageSerializationDebug(this, this.getClass());
    }
}
 
开发者ID:opensingular,项目名称:singular-server,代码行数:34,代码来源:SingularServerApplication.java

示例6: setObject

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
@Override
public void setObject(Long object) {
	if (object == null) {
		bytesModel.setObject(null);
	} else {
		bytesModel.setObject(Bytes.bytes(object));
	}
	super.setObject(object);
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:10,代码来源:BytesToLongModel.java

示例7: onInitialize

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
@Override
protected void onInitialize() {
	super.onInitialize();
	final Form<Void> form = new Form<>("form");
	form.setMultiPart(true);
	form.setMaxSize(Bytes.bytes(getMaxUploadSize()));
	// Model is necessary here to avoid writing image to the User object
	form.add(fileUploadField);
	form.add(new UploadProgressBar("progress", form, fileUploadField));
	fileUploadField.add(new AjaxFormSubmitBehavior(form, "change") {
		private static final long serialVersionUID = 1L;

		@Override
		protected void onSubmit(AjaxRequestTarget target) {
			FileUpload fu = fileUploadField.getFileUpload();
			if (fu != null) {
				File temp = null;
				try {
					temp = fu.writeToTempFile();
					StoredFile sf = new StoredFile(fu.getClientFileName(), temp);
					if (sf.isImage()) {
						processImage(sf, temp);
					}
				} catch (Exception e) {
					log.error("Error", e);
				} finally {
					if (temp != null && temp.exists()) {
						log.debug("Temp file was deleted ? {}", temp.delete());
					}
					fu.closeStreams();
					fu.delete();
				}
			}
			update();
			target.add(profile, form);
		}
	});
	add(form.setOutputMarkupId(true));
	add(BootstrapFileUploadBehavior.INSTANCE);
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:41,代码来源:UploadableImagePanel.java

示例8: 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);
}
 
开发者ID:MarcGiffing,项目名称:wicket-spring-boot,代码行数:14,代码来源:TypeParser.java

示例9: DefaultFileUploadForm

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
public DefaultFileUploadForm(String name, UploadListener listener) {
    super(name, ContextHelper.get().getArtifactoryHome().getTempUploadDir().getAbsolutePath(), listener);
    add(new SubmitOnceBehavior());

    //Set maximum upload size
    int uploadMaxSizeMb = centralConfig.getDescriptor().getFileUploadMaxSizeMb();
    if (uploadMaxSizeMb > 0) {
        setMaxSize(Bytes.megabytes(uploadMaxSizeMb));
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:11,代码来源:DefaultFileUploadForm.java

示例10: LogoFileUploadForm

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
public LogoFileUploadForm(String name, UploadListener listener) {
    super(name, ContextHelper.get().getArtifactoryHome().getTempUploadDir().getAbsolutePath(), listener);
    add(new SubmitOnceBehavior());
    //Set maximum upload size
    int uploadMaxSizeMb = centralConfig.getDescriptor().getFileUploadMaxSizeMb();
    if (uploadMaxSizeMb > 0) {
        setMaxSize(Bytes.megabytes(uploadMaxSizeMb));
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:10,代码来源:LogoFileUploadForm.java

示例11: FileUploadForm

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
public FileUploadForm(String id, String userUuid, FeedbackPanel fileFeedback) {
	super(id);

	this.userUuid = userUuid;
	this.fileFeedback = fileFeedback;

	// set form to multipart mode
	setMultiPart(true);

	setMaxSize(Bytes.megabytes(sakaiProxy.getMaxProfilePictureSize()
			* ProfileConstants.MAX_GALLERY_FILE_UPLOADS));
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:13,代码来源:MyPictures.java

示例12: FileUploadForm

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
public FileUploadForm(String name, ValidatorPage page) {
	super(name);
	this.page = page;
	setMultiPart(true);
	add(fileUploadField = new FileUploadField("fileInput"));
	setMaxSize(Bytes.kilobytes(100));
}
 
开发者ID:tkuhn,项目名称:nanopub-validator,代码行数:8,代码来源:FileUploadPanel.java

示例13: FileUploadForm

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
public FileUploadForm(EntityModel<Entry> entry) {
	super("uploadForm");

	this.entry = entry;

	setMultiPart(true);
	add(fileUploadField = new FileUploadField("fileInput"));
	setMaxSize(Bytes.megabytes(50));
}
 
开发者ID:rla,项目名称:old-blog,代码行数:10,代码来源:EntryFilesPage.java

示例14: UploadLicenseForm

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
public UploadLicenseForm(String id) {
	super(id);
	
	// set this form to multipart mode (allways needed for uploads!)
          setMultiPart(true);

          // add one file input field
          add(fileUploadField = new FileUploadField("fileInput"));

          // set maximum size to 100K
          setMaxSize(Bytes.kilobytes(100));
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:13,代码来源:LicenseErrorPage.java

示例15: newSessionStore

import org.apache.wicket.util.lang.Bytes; //导入依赖的package包/类
@Override
protected ISessionStore newSessionStore() {
    DiskPageStore page = new DiskPageStore((int) Bytes.megabytes(100).bytes(), (int) Bytes.gigabytes(1.0).bytes(), 50);
    SecondLevelCacheSessionStore store = new SecondLevelCacheSessionStore(this, page);
    return store;
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:7,代码来源:VrfApplication.java


注:本文中的org.apache.wicket.util.lang.Bytes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。