Knopflerfish OSGi 2.0.5

org.knopflerfish.ant.taskdefs.bundle
Class ByteFormatterTask

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

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

Set a property to to a formated file size in k (kilo byte), M (Mega byte) etc.

Parameters

Attribute Description Required
property The name of the property to assign the foramted value to. Yes.
unit The unit append to the formated value. E.g., byte No, default is the empty string.
value The value to format. One of value and file must be given.
file The file of get the size of and 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 a file as bytes

  <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()
          Create or update the Manifest when used as a task.
 void setFile(java.io.File file)
          Set the file to get the size of and format
 void setProperty(java.lang.String property)
          The name of the property to save the foramted value to.
 void setUnit(java.lang.String unit)
          The unit to append to the formated 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 foramted value to.


setUnit

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


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 and format

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

execute

public void execute()
Create or update the Manifest when used as a task.

Throws:
BuildException - if the manifest cannot be written.

Knopflerfish OSGi 2.0.5