Top Description Inners Fields Constructors Methods
org.apache.tools.ant.taskdefs

public Class Length

extends Task
implements Condition
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.taskdefs.condition.Condition
Imports
java.io.File, .OutputStream, .PrintStream, org.apache.tools.ant.BuildException, .Project, .Task, org.apache.tools.ant.taskdefs.condition.Condition, org.apache.tools.ant.types.Comparison, .EnumeratedAttribute, .FileSet, .Resource, .ResourceCollection, org.apache.tools.ant.types.resources.FileResource, .Resources, org.apache.tools.ant.util.FileUtils, .PropertyOutputStream

Gets lengths: of files/resources, byte size; of strings, length (optionally trimmed). The task is overloaded in this way for semantic reasons, much like Available.
Since
Ant 1.6.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
private class
public static class
Length.FileMode

EnumeratedAttribute operation mode

private abstract class
public static class
Length.When

EnumeratedAttribute for the when attribute.

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private Long
private static final String
private String
private String
private Resources
private static final String
private String
private Boolean
private Comparison
Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized void
add(FileSet
the FileSet to add.
fs
)

Add a FileSet.

public synchronized void
add(ResourceCollection
the ResourceCollection to add.
c
)

Add a ResourceCollection.

public boolean

Returns:

true if the condition is true.
eval
()

Implements org.apache.tools.ant.taskdefs.condition.Condition.eval.

Fulfill the condition contract.
public void
execute()

Overrides org.apache.tools.ant.Task.execute.

Execute the length task.
private static long
getLength(String s, boolean t)

public boolean

Returns:

boolean trim setting.
getTrim
()

Learn whether strings will be trimmed.

private void
public synchronized void
setFile(File
the File whose length to retrieve.
file
)

Set the single file for this task.

public synchronized void
setLength(long
the long length to compare with.
ell
)

Set the target count number for use as a Condition.

public synchronized void
setMode(Length.FileMode
the FileMode to use.
m
)

Set the execution mode for working with files.

public synchronized void
setProperty(String
the String property key.
property
)

The property in which the length will be stored.

public synchronized void
setResource(Resource
the Resource whose length to retrieve.
resource
)

Set the single resource for this task.

public synchronized void
setString(String
String.
string
)

Set the string whose length to get.

public synchronized void
setTrim(boolean
boolean.
trim
)

Set whether to trim in string mode.

public synchronized void
setWhen(Length.When
EnumeratedAttribute When.
w
)

Set the comparison for use as a Condition.

public synchronized void
setWhen(Comparison
Comparison.
c
)

Set the comparison for use as a Condition.

private void
Inherited from org.apache.tools.ant.Task:
bindToOwnergetOwningTargetgetRuntimeConfigurableWrappergetTaskNamegetTaskTypegetWrapperhandleErrorFlushhandleErrorOutputhandleFlushhandleInputhandleOutputinitisInvalidloglogloglogmaybeConfigureperformreconfiguresetOwningTargetsetRuntimeConfigurableWrappersetTaskNamesetTaskType

Field Detail

ALLback to summary
private static final String ALL
EACHback to summary
private static final String EACH
lengthback to summary
private Long length
LENGTH_REQUIREDback to summary
private static final String LENGTH_REQUIRED
modeback to summary
private String mode
propertyback to summary
private String property
resourcesback to summary
private Resources resources
STRINGback to summary
private static final String STRING
stringback to summary
private String string
trimback to summary
private Boolean trim
whenback to summary
private Comparison when

Constructor Detail

Lengthback to summary
public Length()

Method Detail

addback to summary
public synchronized void add(FileSet fs)

Add a FileSet.

Parameters
fs:FileSet

the FileSet to add.

addback to summary
public synchronized void add(ResourceCollection c)

Add a ResourceCollection.

Parameters
c:ResourceCollection

the ResourceCollection to add.

Since
Ant 1.7
evalback to summary
public boolean eval()

Implements org.apache.tools.ant.taskdefs.condition.Condition.eval.

Fulfill the condition contract.

Returns:boolean

true if the condition is true.

Annotations
@Override
Exceptions
BuildException:
if an error occurs.
executeback to summary
public void execute()

Overrides org.apache.tools.ant.Task.execute.

Execute the length task.

Annotations
@Override
getLengthback to summary
private static long getLength(String s, boolean t)
getTrimback to summary
public boolean getTrim()

Learn whether strings will be trimmed. Default false.

Returns:boolean

boolean trim setting.

handleResourcesback to summary
private void handleResources(Length.Handler h)
setFileback to summary
public synchronized void setFile(File file)

Set the single file for this task.

Parameters
file:File

the File whose length to retrieve.

setLengthback to summary
public synchronized void setLength(long ell)

Set the target count number for use as a Condition.

Parameters
ell:long

the long length to compare with.

setModeback to summary
public synchronized void setMode(Length.FileMode m)

Set the execution mode for working with files.

Parameters
m:Length.FileMode

the FileMode to use.

setPropertyback to summary
public synchronized void setProperty(String property)

The property in which the length will be stored.

Parameters
property:String

the String property key.

setResourceback to summary
public synchronized void setResource(Resource resource)

Set the single resource for this task.

Parameters
resource:Resource

the Resource whose length to retrieve.

setStringback to summary
public synchronized void setString(String string)

Set the string whose length to get.

Parameters
string:String

String.

setTrimback to summary
public synchronized void setTrim(boolean trim)

Set whether to trim in string mode. Default false.

Parameters
trim:boolean

boolean.

setWhenback to summary
public synchronized void setWhen(Length.When w)

Set the comparison for use as a Condition.

Parameters
w:Length.When

EnumeratedAttribute When.

See Also
org.apache.tools.ant.types.Comparison
setWhenback to summary
public synchronized void setWhen(Comparison c)

Set the comparison for use as a Condition.

Parameters
c:Comparison

Comparison.

Since
Ant 1.7
See Also
org.apache.tools.ant.types.Comparison
validateback to summary
private void validate()
org.apache.tools.ant.taskdefs back to summary

private Class Length.AccumHandler

extends Handler
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.taskdefs.Length.AllHandler

Field Summary

Modifier and TypeField and Description
private long

Constructor Summary

AccessConstructor and Description
pack-priv
protected

Method Summary

Modifier and TypeMethod and Description
protected long
protected synchronized void
Inherited from org.apache.tools.ant.taskdefs.Length.Handler:
completegetPs

Field Detail

accumback to summary
private long accum

Constructor Detail

AccumHandlerback to summary
pack-priv AccumHandler()
AccumHandlerback to summary
protected AccumHandler(PrintStream ps)

Method Detail

getAccumback to summary
protected long getAccum()
handleback to summary
protected synchronized void handle(Resource r)

Implements abstract org.apache.tools.ant.taskdefs.Length.Handler.handle.

Annotations
@Override
org.apache.tools.ant.taskdefs back to summary

private Class Length.AllHandler

extends AccumHandler
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
Inherited from org.apache.tools.ant.taskdefs.Length.AccumHandler:
getAccumhandle

Constructor Detail

AllHandlerback to summary
pack-priv AllHandler(PrintStream ps)

Method Detail

completeback to summary
pack-priv void complete()

Overrides org.apache.tools.ant.taskdefs.Length.Handler.complete.

Annotations
@Override
org.apache.tools.ant.taskdefs back to summary

private Class Length.EachHandler

extends Handler
Class Inheritance

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
protected void
Inherited from org.apache.tools.ant.taskdefs.Length.Handler:
completegetPs

Constructor Detail

EachHandlerback to summary
pack-priv EachHandler(PrintStream ps)

Method Detail

handleback to summary
protected void handle(Resource r)

Implements abstract org.apache.tools.ant.taskdefs.Length.Handler.handle.

Annotations
@Override
org.apache.tools.ant.taskdefs back to summary

public Class Length.FileMode

extends EnumeratedAttribute
Class Inheritance

EnumeratedAttribute operation mode

Field Summary

Modifier and TypeField and Description
pack-priv static final String[]
Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
value

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String[]

Returns:

String[].
getValues
()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

Return the possible values for FileMode.
Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
containsValuegetIndexgetInstancegetValueindexOfValuesetValuetoString

Field Detail

MODESback to summary
pack-priv static final String[] MODES

Constructor Detail

FileModeback to summary
public FileMode()

Method Detail

getValuesback to summary
public String[] getValues()

Implements abstract org.apache.tools.ant.types.EnumeratedAttribute.getValues.

Return the possible values for FileMode.

Returns:String[]

String[].

Annotations
@Override
org.apache.tools.ant.taskdefs back to summary

private abstract Class Length.Handler

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.tools.ant.taskdefs.Length.EachHandler, org.apache.tools.ant.taskdefs.Length.AccumHandler

Field Summary

Modifier and TypeField and Description
private PrintStream

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
protected PrintStream
protected abstract void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

psback to summary
private PrintStream ps

Constructor Detail

Handlerback to summary
pack-priv Handler(PrintStream ps)

Method Detail

completeback to summary
pack-priv void complete()
getPsback to summary
protected PrintStream getPs()
handleback to summary
protected abstract void handle(Resource r)
org.apache.tools.ant.taskdefs back to summary

public Class Length.When

extends Comparison
Class Inheritance

EnumeratedAttribute for the when attribute.

Field Summary

Inherited from org.apache.tools.ant.types.Comparison:
EQUALGREATERGREATER_EQUALLESSLESS_EQUALNOT_EQUAL

Constructor Summary

AccessConstructor and Description
public
When()

Method Summary

Inherited from org.apache.tools.ant.types.Comparison:
evaluategetValues

Constructor Detail

Whenback to summary
public When()