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

public Class PathConvert

extends Task
Class Inheritance
Imports
java.io.Closeable, .File, .IOException, .OutputStream, .OutputStreamWriter, .Writer, java.util.List, .Objects, .Vector, java.util.function.Consumer, .Predicate, java.util.stream.Stream, .StreamSupport, org.apache.tools.ant.BuildException, .Project, .Task, org.apache.tools.ant.taskdefs.condition.Os, org.apache.tools.ant.types.EnumeratedAttribute, .Mapper, .Path, .Reference, .Resource, .ResourceCollection, org.apache.tools.ant.types.resources.Resources, .Union, org.apache.tools.ant.util.FileNameMapper, .IdentityMapper, .PropertyOutputStream

Converts path and classpath information to a specific target OS format. The resulting formatted path is placed into the specified property.
Since
Ant 1.4

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
PathConvert.MapEntry

Helper class, holds the nested <map> values.

private abstract class
public static class
PathConvert.TargetOs

An enumeration of supported targets: "windows", "unix", "netware", and "os/2".

Field Summary

Modifier and TypeField and Description
private Resource
dest

Destination Resource

private String
dirSep

User override on directory sep char

private Mapper
mapper

Filename mapper

private static boolean
onWindows

Set if we're running on windows

private Resources
path

Path to be converted

private String
pathSep

User override on path sep char

private List<PathConvert.MapEntry>
prefixMap

Path prefix map

private boolean
private String
property

The property to receive the conversion

private Reference
refid

Reference to path/fileset to convert

private boolean
setonempty

Set if we should create a new property even if the result is empty

private String
targetOS

The target OS type

private boolean
targetWindows

Set when targetOS is set to windows

Inherited from org.apache.tools.ant.Task:
targettaskNametaskTypewrapper

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
add(ResourceCollection
the ResourceCollection to add.
rc
)

Add an arbitrary ResourceCollection.

public void
add(FileNameMapper
the mapper to add.
fileNameMapper
)

Add a nested filenamemapper.

public void
addMapper(Mapper
a Mapper value.
mapper
)

Add a mapper to convert the file names.

public PathConvert.MapEntry

Returns:

a Map to configure.
createMap
()

Create a nested MAP element.

private PathConvert.Output<?>
public Path

Returns:

a Path to be used by Ant reflection.
createPath
()

Create a nested path element.

public void
execute()

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

Do the execution.
private synchronized Resources
public boolean

Returns:

boolean
isPreserveDuplicates
()

Get the preserveDuplicates.

public boolean

Returns:

true if refid is valid.
isReference
()

Learn whether the refid attribute of this element been set.

private String

Returns:

String Updated element.
mapElement
(String
The path element to apply the map to.
elem
)

Apply the configured map to a path element.

private BuildException

Returns:

BuildException.
noChildrenAllowed
()

Creates an exception that indicates that this XML element must not have child elements if the refid attribute is set.

public void
setDest(Resource dest)

Set destination resource.

public void
setDirSep(String
directory separator string.
sep
)

Set the default directory separator string; defaults to current JVM File.separator.

public void
setPathSep(String
path separator string.
sep
)

Set the default path separator string; defaults to current JVM File.pathSeparator.

public void
setPreserveDuplicates(boolean
the boolean to set
preserveDuplicates
)

Set the preserveDuplicates.

public void
setProperty(String
the property name.
p
)

Set the name of the property into which the converted path will be placed.

public void
setRefid(Reference
the reference to a path, fileset, dirset or filelist.
r
)

Add a reference to a Path, FileSet, DirSet, or FileList defined elsewhere.

public void
setSetonempty(boolean
true or false.
setonempty
)

Set whether the specified property will be set if the result is the empty string.

public void
setTargetos(String
the target os.
target
)

Deprecated since 1.5.x. Use the method taking a TargetOs argument instead.
Set targetos to a platform to one of "windows", "unix", "netware", or "os/2"; current platform settings are used by default.
public void
setTargetos(PathConvert.TargetOs
the target os
target
)

Set targetos to a platform to one of "windows", "unix", "netware", or "os/2"; current platform settings are used by default.

private Stream<String>
private void
validateSetup()

Validate that all our parameters have been properly initialized.

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

Field Detail

destback to summary
private Resource dest

Destination Resource

dirSepback to summary
private String dirSep

User override on directory sep char

mapperback to summary
private Mapper mapper

Filename mapper

onWindowsback to summary
private static boolean onWindows

Set if we're running on windows

pathback to summary
private Resources path

Path to be converted

pathSepback to summary
private String pathSep

User override on path sep char

prefixMapback to summary
private List<PathConvert.MapEntry> prefixMap

Path prefix map

preserveDuplicatesback to summary
private boolean preserveDuplicates
propertyback to summary
private String property

The property to receive the conversion

refidback to summary
private Reference refid

Reference to path/fileset to convert

setonemptyback to summary
private boolean setonempty

Set if we should create a new property even if the result is empty

targetOSback to summary
private String targetOS

The target OS type

targetWindowsback to summary
private boolean targetWindows

Set when targetOS is set to windows

Constructor Detail

PathConvertback to summary
public PathConvert()

Method Detail

addback to summary
public void add(ResourceCollection rc)

Add an arbitrary ResourceCollection.

Parameters
rc:ResourceCollection

the ResourceCollection to add.

Since
Ant 1.7
addback to summary
public void add(FileNameMapper fileNameMapper)

Add a nested filenamemapper.

Parameters
fileNameMapper:FileNameMapper

the mapper to add.

Since
Ant 1.6.3
addMapperback to summary
public void addMapper(Mapper mapper)

Add a mapper to convert the file names.

Parameters
mapper:Mapper

a Mapper value.

createMapback to summary
public PathConvert.MapEntry createMap()

Create a nested MAP element.

Returns:PathConvert.MapEntry

a Map to configure.

createOutputback to summary
private PathConvert.Output<?> createOutput() throws IOException
Annotations
@SuppressWarnings:resource
createPathback to summary
public Path createPath()

Create a nested path element.

Returns:Path

a Path to be used by Ant reflection.

executeback to summary
public void execute() throws BuildException

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

Do the execution.

Annotations
@Override
Exceptions
BuildException:
if something is invalid.
getPathback to summary
private synchronized Resources getPath()
isPreserveDuplicatesback to summary
public boolean isPreserveDuplicates()

Get the preserveDuplicates.

Returns:boolean

boolean

Since
Ant 1.8
isReferenceback to summary
public boolean isReference()

Learn whether the refid attribute of this element been set.

Returns:boolean

true if refid is valid.

mapElementback to summary
private String mapElement(String elem)

Apply the configured map to a path element. The map is used to convert between Windows drive letters and Unix paths. If no map is configured, then the input string is returned unchanged.

Parameters
elem:String

The path element to apply the map to.

Returns:String

String Updated element.

noChildrenAllowedback to summary
private BuildException noChildrenAllowed()

Creates an exception that indicates that this XML element must not have child elements if the refid attribute is set.

Returns:BuildException

BuildException.

setDestback to summary
public void setDest(Resource dest)

Set destination resource.

Since
Ant 1.10.13
setDirSepback to summary
public void setDirSep(String sep)

Set the default directory separator string; defaults to current JVM File.separator.

Parameters
sep:String

directory separator string.

setPathSepback to summary
public void setPathSep(String sep)

Set the default path separator string; defaults to current JVM File.pathSeparator.

Parameters
sep:String

path separator string.

setPreserveDuplicatesback to summary
public void setPreserveDuplicates(boolean preserveDuplicates)

Set the preserveDuplicates.

Parameters
preserveDuplicates:boolean

the boolean to set

Since
Ant 1.8
setPropertyback to summary
public void setProperty(String p)

Set the name of the property into which the converted path will be placed.

Parameters
p:String

the property name.

setRefidback to summary
public void setRefid(Reference r)

Add a reference to a Path, FileSet, DirSet, or FileList defined elsewhere.

Parameters
r:Reference

the reference to a path, fileset, dirset or filelist.

setSetonemptyback to summary
public void setSetonempty(boolean setonempty)

Set whether the specified property will be set if the result is the empty string.

Parameters
setonempty:boolean

true or false.

Since
Ant 1.5
setTargetosback to summary
public void setTargetos(String target)

Deprecated

since 1.5.x. Use the method taking a TargetOs argument instead.

Set targetos to a platform to one of "windows", "unix", "netware", or "os/2"; current platform settings are used by default.

Parameters
target:String

the target os.

Annotations
@Deprecated
See Also
setTargetos(PathConvert.TargetOs)
setTargetosback to summary
public void setTargetos(PathConvert.TargetOs target)

Set targetos to a platform to one of "windows", "unix", "netware", or "os/2"; current platform settings are used by default.

Parameters
target:PathConvert.TargetOs

the target os

Since
Ant 1.5
streamResourcesback to summary
private Stream<String> streamResources()
validateSetupback to summary
private void validateSetup() throws BuildException

Validate that all our parameters have been properly initialized.

Exceptions
BuildException:
if something is not set up properly.
org.apache.tools.ant.taskdefs back to summary

public Class PathConvert.MapEntry

extends Object
Class Inheritance

Helper class, holds the nested <map> values. Elements will look like this: <map from="d:" to="/foo"/> When running on windows, the prefix comparison will be case insensitive.

Field Summary

Modifier and TypeField and Description
private String
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

String Updated path element after mapping.
apply
(String
Path element to process.
elem
)

Apply this map entry to a given path element.

public void
setFrom(String
the prefix string to search for; required. Note that this value is case-insensitive when the build is running on a Windows platform and case-sensitive when running on a Unix platform.
from
)

Set the "from" attribute of the map entry.

public void
setTo(String
new prefix.
to
)

Set the replacement text to use when from is matched; required.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fromback to summary
private String from
toback to summary
private String to

Constructor Detail

MapEntryback to summary
public MapEntry()

Method Detail

applyback to summary
public String apply(String elem)

Apply this map entry to a given path element.

Parameters
elem:String

Path element to process.

Returns:String

String Updated path element after mapping.

setFromback to summary
public void setFrom(String from)

Set the "from" attribute of the map entry.

Parameters
from:String

the prefix string to search for; required. Note that this value is case-insensitive when the build is running on a Windows platform and case-sensitive when running on a Unix platform.

setToback to summary
public void setTo(String to)

Set the replacement text to use when from is matched; required.

Parameters
to:String

new prefix.

org.apache.tools.ant.taskdefs back to summary

private abstract Class PathConvert.Output<T extends Closeable>

extends Object
implements Consumer<String>, Closeable
Class Inheritance
All Implemented Interfaces
java.io.Closeable, java.lang.AutoCloseable, java.util.function.Consumer

Field Summary

Modifier and TypeField and Description
pack-priv final T

Constructor Summary

AccessConstructor and Description
pack-priv
Output(T target)

Method Summary

Modifier and TypeMethod and Description
public void
accept(String
the input argument
t
)

Implements java.util.function.Consumer.accept.

Performs this operation on the given argument.
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
pack-priv abstract void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

targetback to summary
pack-priv final T target

Constructor Detail

Outputback to summary
pack-priv Output(T target)

Method Detail

acceptback to summary
public void accept(String t)

Implements java.util.function.Consumer.accept.

Doc from java.util.function.Consumer.accept.

Performs this operation on the given argument.

Parameters
t:String

the input argument

Annotations
@Override
closeback to summary
public void close() throws IOException

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
doAcceptback to summary
pack-priv abstract void doAccept(String t) throws Exception
org.apache.tools.ant.taskdefs back to summary

public Class PathConvert.TargetOs

extends EnumeratedAttribute
Class Inheritance

An enumeration of supported targets: "windows", "unix", "netware", and "os/2".

Field Summary

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:

the list of values for this enumerated attribute.
getValues
()

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

This is the only method a subclass needs to implement.
Inherited from org.apache.tools.ant.types.EnumeratedAttribute:
containsValuegetIndexgetInstancegetValueindexOfValuesetValuetoString

Constructor Detail

TargetOsback to summary
public TargetOs()

Method Detail

getValuesback to summary
public String[] getValues()

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

Doc from org.apache.tools.ant.types.EnumeratedAttribute.getValues.

This is the only method a subclass needs to implement.

Returns:String[]

the list of values for this enumerated attribute.

Annotations
@Override