Knopflerfish OSGi 5.2.0

org.knopflerfish.ant.taskdefs.bundle
Class ByteFormatterTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.knopflerfish.ant.taskdefs.bundle.ByteFormatterTask
All Implemented Interfaces:
java.lang.Cloneable

public class ByteFormatterTask
extends org.apache.tools.ant.Task

Sets a property to a formatted value in ki, Mi, Gi, Ti, Pi, Ei, Zi and Yi with an optional unit. Here ki is short for kibi, (a contraction of kilo binary) see http://en.wikipedia.org/wiki/Kibibyte for a detailed explanation.

Parameters

Attribute Description Required
property The name of the property to assign the formatted value to. Yes.
binaryPrefixURL An URL pointing to a page explaining the binary unit suffixes. http://en.wikipedia.org/wiki/Binary_prefix#IEC_standard_prefixes
unit The unit to append to the formatted value. E.g., byte No, default is the empty string.
sep The string placed between the number and the unit. No, default is the HTML non-breaking space, " ".
value The value to format. One of value and file must be given.
file The file whose size is the value to format. One of value and file must be given.

Nested elements

Not applicable.

Examples

Format a value as bytes

  <byteformatter value="9093663"
                    property="myFormatedFilesize"
                    unit="B" />
 

Format the size of the file archive.jar appending the unit B

  <byteformatter file="archive.jar"
                    property="archive.size"
                    unit="B" />
 


Field Summary
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
ByteFormatterTask()
          Default constructor.
 
Method Summary
 void execute()
          Performs the requested formatting.
 void setBinaryPrefixURL(java.lang.String url)
          The URL that explains binary prefixes.
 void setFile(java.io.File file)
          Set the file to get the size of as the the value to format.
 void setProperty(java.lang.String property)
          The name of the property to save the formatted value to.
 void setSep(java.lang.String sep)
          The separator between the numeral and the prefixed unit.
 void setUnit(java.lang.String unit)
          The unit to append to the formatted value.
 void setValue(long value)
          Set the value to format.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteFormatterTask

public ByteFormatterTask()
Default constructor.

Method Detail

setProperty

public void setProperty(java.lang.String property)
The name of the property to save the formatted value to.

Parameters:
property - the name of the property to set.

setUnit

public void setUnit(java.lang.String unit)
The unit to append to the formatted value.

Parameters:
unit - the unit text to append to the formatted value.

setBinaryPrefixURL

public void setBinaryPrefixURL(java.lang.String url)
The URL that explains binary prefixes.

Parameters:
url - The url to let the binary prefix point to.

setSep

public void setSep(java.lang.String sep)
The separator between the numeral and the prefixed unit.

Parameters:
sep - the separator string.

setValue

public void setValue(long value)
Set the value to format.

Parameters:
value - the value to format

setFile

public void setFile(java.io.File file)
Set the file to get the size of as the the value to format.

Parameters:
file - the file to return a formatted file size for.

execute

public void execute()
Performs the requested formatting.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
BuildException - if the manifest cannot be written.

Knopflerfish OSGi 5.2.0