Package org.apache.wicket.util.lang

Examples of org.apache.wicket.util.lang.Bytes


  {
    Locale.setDefault(Locale.UK);
    Assert.assertTrue("1G".equals(Bytes.gigabytes(1).toString()));
    Assert.assertTrue(Bytes.valueOf("15.5K").bytes() == ((15 * 1024) + 512));

    final Bytes b = Bytes.kilobytes(7.3);

    Assert.assertTrue(Bytes.valueOf(b.toString()).equals(b));
  }
View Full Code Here


  {
    Locale.setDefault(Locale.GERMANY);
    Assert.assertTrue("1G".equals(Bytes.gigabytes(1).toString()));
    Assert.assertTrue(Bytes.valueOf("15,5K").bytes() == ((15 * 1024) + 512));

    final Bytes b = Bytes.kilobytes(7.3);

    Assert.assertTrue(Bytes.valueOf(b.toString()).equals(b));
  }
View Full Code Here

  {
    Assert.assertTrue("1G".equals(Bytes.gigabytes(1).toString()));
    Assert.assertTrue("1,5G".equals(Bytes.gigabytes(1.5).toString(Locale.GERMAN)));
    Assert.assertTrue("1.5G".equals(Bytes.gigabytes(1.5).toString(Locale.US)));

    final Bytes b = Bytes.kilobytes(7.3);
    Assert.assertEquals(b, Bytes.valueOf(b.toString(Locale.GERMAN), Locale.GERMAN));

    Assert.assertTrue(Bytes.valueOf("15,5K", Locale.GERMAN).bytes() == ((15 * 1024) + 512));
    Assert.assertTrue(Bytes.valueOf("15.5K", Locale.US).bytes() == ((15 * 1024) + 512));
  }
View Full Code Here

  {
    Assert.assertTrue(Bytes.bytes(1024).equals(Bytes.kilobytes(1)));
    Assert.assertTrue(Bytes.bytes(1024 * 1024).equals(Bytes.megabytes(1)));
    Assert.assertTrue("1G".equals(Bytes.gigabytes(1).toString()));

    final Bytes b = Bytes.kilobytes(7.3);

    Assert.assertTrue(b.equals(Bytes.kilobytes(7.3)));
    Assert.assertTrue(b.greaterThan(Bytes.kilobytes(7.25)));
    Assert.assertTrue(b.lessThan(Bytes.kilobytes(7.9)));
    Assert.assertTrue(Bytes.valueOf(b.toString()).equals(b));
  }
View Full Code Here

  {
    Locale.setDefault(Locale.UK);
    Assert.assertTrue("1G".equals(Bytes.gigabytes(1).toString()));
    Assert.assertTrue(Bytes.valueOf("15.5K").bytes() == ((15 * 1024) + 512));

    final Bytes b = Bytes.kilobytes(7.3);

    Assert.assertTrue(Bytes.valueOf(b.toString()).equals(b));
  }
View Full Code Here

  {
    Locale.setDefault(Locale.GERMANY);
    Assert.assertTrue("1G".equals(Bytes.gigabytes(1).toString()));
    Assert.assertTrue(Bytes.valueOf("15,5K").bytes() == ((15 * 1024) + 512));

    final Bytes b = Bytes.kilobytes(7.3);

    Assert.assertTrue(Bytes.valueOf(b.toString()).equals(b));
  }
View Full Code Here

  {
    Assert.assertTrue("1G".equals(Bytes.gigabytes(1).toString()));
    Assert.assertTrue("1,5G".equals(Bytes.gigabytes(1.5).toString(Locale.GERMAN)));
    Assert.assertTrue("1.5G".equals(Bytes.gigabytes(1.5).toString(Locale.US)));

    final Bytes b = Bytes.kilobytes(7.3);
    Assert.assertEquals(b, Bytes.valueOf(b.toString(Locale.GERMAN), Locale.GERMAN));

    Assert.assertTrue(Bytes.valueOf("15,5K", Locale.GERMAN).bytes() == ((15 * 1024) + 512));
    Assert.assertTrue(Bytes.valueOf("15.5K", Locale.US).bytes() == ((15 * 1024) + 512));
  }
View Full Code Here

   *
   * @return the maximum size
   */
  public Bytes getMaxSize()
  {
    Bytes maxSize = this.maxSize;
    if (maxSize == null)
    {
      maxSize = visitChildren(Form.class, new IVisitor<Form<?>, Bytes>()
      {
        public void component(Form<?> component, IVisit<Bytes> visit)
        {
          Bytes maxSize = component.getMaxSize();
          if (maxSize != null)
          {
            visit.stop(maxSize);
          }
        }
View Full Code Here

          close(resourceStream);
        }
      }

      data.setContentDisposition(contentDisposition);
      Bytes length = resourceStream.length();
      if (length != null)
      {
        data.setContentLength(length.bytes());
      }
      data.setFileName(fileName);

      String contentType = resourceStream.getContentType();
      if (contentType == null && fileName != null && Application.exists())
View Full Code Here

      private final IModel<Bytes> totalSize = new SessionTotalSizeModel(Session.get());

      @Override
      public String getObject()
      {
        Bytes sessionSizeInBytes = size.getObject();
        String sessionSizeAsString = sessionSizeInBytes != null
          ? sessionSizeInBytes.toString() : "unknown";

        Bytes totalSizeInBytes = totalSize.getObject();
        String totalSizeAsString = totalSizeInBytes != null ? totalSizeInBytes.toString()
          : "unknown";

        return sessionSizeAsString + " / " + totalSizeAsString;
      }
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.lang.Bytes

Copyright © 2018 www.massapicom. 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.