git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270856 13f79535-47bb-0310-9956-ffa450edef68master
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -129,55 +129,55 @@ public class Checksum extends MatchingTask implements Condition { | |||||
/** | /** | ||||
* Sets the file for which the checksum is to be calculated. | * Sets the file for which the checksum is to be calculated. | ||||
*/ | */ | ||||
public void setFile(File aFile) { | |||||
this.file = aFile; | |||||
public void setFile(File file) { | |||||
this.file = file; | |||||
} | } | ||||
/** | /** | ||||
* Sets the MessageDigest algorithm to be used | * Sets the MessageDigest algorithm to be used | ||||
* to calculate the checksum. | * to calculate the checksum. | ||||
*/ | */ | ||||
public void setAlgorithm(String aAlgorithm) { | |||||
this.algorithm = aAlgorithm; | |||||
public void setAlgorithm(String algorithm) { | |||||
this.algorithm = algorithm; | |||||
} | } | ||||
/** | /** | ||||
* Sets the MessageDigest algorithm provider to be used | * Sets the MessageDigest algorithm provider to be used | ||||
* to calculate the checksum. | * to calculate the checksum. | ||||
*/ | */ | ||||
public void setProvider(String aProvider) { | |||||
this.provider = aProvider; | |||||
public void setProvider(String provider) { | |||||
this.provider = provider; | |||||
} | } | ||||
/** | /** | ||||
* Sets the File Extension that is be to used to | * Sets the File Extension that is be to used to | ||||
* create or identify destination file | * create or identify destination file | ||||
*/ | */ | ||||
public void setFileext(String aFileext) { | |||||
this.fileext = aFileext; | |||||
public void setFileext(String fileext) { | |||||
this.fileext = fileext; | |||||
} | } | ||||
/** | /** | ||||
* Sets the property to hold the generated checksum | * Sets the property to hold the generated checksum | ||||
*/ | */ | ||||
public void setProperty(String aProperty) { | |||||
this.property = aProperty; | |||||
public void setProperty(String property) { | |||||
this.property = property; | |||||
} | } | ||||
/** | /** | ||||
* Sets verify property. This project property holds | * Sets verify property. This project property holds | ||||
* the result of a checksum verification - "true" or "false" | * the result of a checksum verification - "true" or "false" | ||||
*/ | */ | ||||
public void setVerifyproperty(String aVerifyProperty) { | |||||
this.verifyProperty = aVerifyProperty; | |||||
public void setVerifyproperty(String verifyProperty) { | |||||
this.verifyProperty = verifyProperty; | |||||
} | } | ||||
/** | /** | ||||
* Overwrite existing file irrespective of whether it is newer than | * Overwrite existing file irrespective of whether it is newer than | ||||
* the source file? Defaults to false. | * the source file? Defaults to false. | ||||
*/ | */ | ||||
public void setForceOverwrite(boolean aForceOverwrite) { | |||||
this.forceOverwrite = aForceOverwrite; | |||||
public void setForceOverwrite(boolean forceOverwrite) { | |||||
this.forceOverwrite = forceOverwrite; | |||||
} | } | ||||
/** | /** | ||||
@@ -311,24 +311,24 @@ public class Checksum extends MatchingTask implements Condition { | |||||
* Add key-value pair to the hashtable upon which | * Add key-value pair to the hashtable upon which | ||||
* to later operate upon. | * to later operate upon. | ||||
*/ | */ | ||||
private void addToIncludeFileMap(File aFile) throws BuildException { | |||||
if (aFile != null) { | |||||
if (aFile.exists()) { | |||||
private void addToIncludeFileMap(File file) throws BuildException { | |||||
if (file != null) { | |||||
if (file.exists()) { | |||||
if (property == null) { | if (property == null) { | ||||
File dest = new File(aFile.getParent(), aFile.getName() + fileext); | |||||
File dest = new File(file.getParent(), file.getName() + fileext); | |||||
if (forceOverwrite || isCondition || | if (forceOverwrite || isCondition || | ||||
(aFile.lastModified() > dest.lastModified())) { | |||||
includeFileMap.put(aFile, dest); | |||||
(file.lastModified() > dest.lastModified())) { | |||||
includeFileMap.put(file, dest); | |||||
} else { | } else { | ||||
log(aFile + " omitted as " + dest + " is up to date.", | |||||
log(file + " omitted as " + dest + " is up to date.", | |||||
Project.MSG_VERBOSE); | Project.MSG_VERBOSE); | ||||
} | } | ||||
} else { | } else { | ||||
includeFileMap.put(aFile, property); | |||||
includeFileMap.put(file, property); | |||||
} | } | ||||
} else { | } else { | ||||
String message = "Could not find file " | String message = "Could not find file " | ||||
+ aFile.getAbsolutePath() | |||||
+ file.getAbsolutePath() | |||||
+ " to generate checksum for."; | + " to generate checksum for."; | ||||
log(message); | log(message); | ||||
throw new BuildException(message, location); | throw new BuildException(message, location); | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -119,22 +119,22 @@ public class Copy extends Task { | |||||
/** | /** | ||||
* Sets a single source file to copy. | * Sets a single source file to copy. | ||||
*/ | */ | ||||
public void setFile(File aFile) { | |||||
this.file = aFile; | |||||
public void setFile(File file) { | |||||
this.file = file; | |||||
} | } | ||||
/** | /** | ||||
* Sets the destination file. | * Sets the destination file. | ||||
*/ | */ | ||||
public void setTofile(File aDestFile) { | |||||
this.destFile = aDestFile; | |||||
public void setTofile(File destFile) { | |||||
this.destFile = destFile; | |||||
} | } | ||||
/** | /** | ||||
* Sets the destination directory. | * Sets the destination directory. | ||||
*/ | */ | ||||
public void setTodir(File aDestDir) { | |||||
this.destDir = aDestDir; | |||||
public void setTodir(File destDir) { | |||||
this.destDir = destDir; | |||||
} | } | ||||
/** | /** | ||||
@@ -175,8 +175,8 @@ public class Copy extends Task { | |||||
/** | /** | ||||
* Sets filtering. | * Sets filtering. | ||||
*/ | */ | ||||
public void setFiltering(boolean aFiltering) { | |||||
this.filtering = aFiltering; | |||||
public void setFiltering(boolean filtering) { | |||||
this.filtering = filtering; | |||||
} | } | ||||
/** | /** | ||||
@@ -193,8 +193,8 @@ public class Copy extends Task { | |||||
* file will be copied into the "flattened" directory, unless | * file will be copied into the "flattened" directory, unless | ||||
* the forceoverwrite attribute is true. | * the forceoverwrite attribute is true. | ||||
*/ | */ | ||||
public void setFlatten(boolean aFlatten) { | |||||
this.flatten = aFlatten; | |||||
public void setFlatten(boolean flatten) { | |||||
this.flatten = flatten; | |||||
} | } | ||||
/** | /** | ||||
@@ -211,8 +211,8 @@ public class Copy extends Task { | |||||
/** | /** | ||||
* Used to copy empty directories. | * Used to copy empty directories. | ||||
*/ | */ | ||||
public void setIncludeEmptyDirs(boolean aIncludeEmpty) { | |||||
this.includeEmpty = aIncludeEmpty; | |||||
public void setIncludeEmptyDirs(boolean includeEmpty) { | |||||
this.includeEmpty = includeEmpty; | |||||
} | } | ||||
/** | /** | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -264,15 +264,15 @@ public class Move extends Copy { | |||||
* | * | ||||
* @throws IOException | * @throws IOException | ||||
*/ | */ | ||||
protected boolean renameFile(File sourceFile, File aDestFile, | |||||
boolean aFiltering, boolean overwrite) | |||||
protected boolean renameFile(File sourceFile, File destFile, | |||||
boolean filtering, boolean overwrite) | |||||
throws IOException, BuildException { | throws IOException, BuildException { | ||||
boolean renamed = true; | boolean renamed = true; | ||||
if (!aFiltering) { | |||||
if (!filtering) { | |||||
// ensure that parent dir of dest file exists! | // ensure that parent dir of dest file exists! | ||||
// not using getParentFile method to stay 1.1 compat | // not using getParentFile method to stay 1.1 compat | ||||
String parentPath = aDestFile.getParent(); | |||||
String parentPath = destFile.getParent(); | |||||
if (parentPath != null) { | if (parentPath != null) { | ||||
File parent = new File(parentPath); | File parent = new File(parentPath); | ||||
if (!parent.exists()) { | if (!parent.exists()) { | ||||
@@ -280,13 +280,13 @@ public class Move extends Copy { | |||||
} | } | ||||
} | } | ||||
if (aDestFile.exists()) { | |||||
if (!aDestFile.delete()) { | |||||
if (destFile.exists()) { | |||||
if (!destFile.delete()) { | |||||
throw new BuildException("Unable to remove existing file " | throw new BuildException("Unable to remove existing file " | ||||
+ aDestFile); | |||||
+ destFile); | |||||
} | } | ||||
} | } | ||||
renamed = sourceFile.renameTo(aDestFile); | |||||
renamed = sourceFile.renameTo(destFile); | |||||
} else { | } else { | ||||
renamed = false; | renamed = false; | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -88,18 +88,18 @@ public abstract class Unpack extends Task { | |||||
* mechanism do the work and also to encapsulate operations on | * mechanism do the work and also to encapsulate operations on | ||||
* the type in its own class. | * the type in its own class. | ||||
*/ | */ | ||||
public void setDest(String aDest) { | |||||
public void setDest(String dest) { | |||||
log("DEPRECATED - The setDest(String) method has been deprecated." | log("DEPRECATED - The setDest(String) method has been deprecated." | ||||
+ " Use setDest(File) instead."); | + " Use setDest(File) instead."); | ||||
setDest(project.resolveFile(aDest)); | |||||
setDest(project.resolveFile(dest)); | |||||
} | } | ||||
public void setSrc(File src) { | public void setSrc(File src) { | ||||
source = src; | source = src; | ||||
} | } | ||||
public void setDest(File aDest) { | |||||
this.dest = aDest; | |||||
public void setDest(File dest) { | |||||
this.dest = dest; | |||||
} | } | ||||
private void validate() throws BuildException { | private void validate() throws BuildException { | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -81,8 +81,8 @@ public class Os implements Condition { | |||||
public Os() {} | public Os() {} | ||||
public Os(String aFamily) { | |||||
setFamily(aFamily); | |||||
public Os(String family) { | |||||
setFamily(family); | |||||
} | } | ||||
/** | /** | ||||
@@ -104,8 +104,8 @@ public class Os implements Condition { | |||||
* | * | ||||
* @param name The OS name | * @param name The OS name | ||||
*/ | */ | ||||
public void setName(String aName) { | |||||
this.name = aName.toLowerCase(Locale.US); | |||||
public void setName(String name) { | |||||
this.name = name.toLowerCase(Locale.US); | |||||
} | } | ||||
/** | /** | ||||
@@ -113,8 +113,8 @@ public class Os implements Condition { | |||||
* | * | ||||
* @param arch The OS architecture | * @param arch The OS architecture | ||||
*/ | */ | ||||
public void setArch(String aArch) { | |||||
this.arch = aArch.toLowerCase(Locale.US); | |||||
public void setArch(String arch) { | |||||
this.arch = arch.toLowerCase(Locale.US); | |||||
} | } | ||||
/** | /** | ||||
@@ -122,8 +122,8 @@ public class Os implements Condition { | |||||
* | * | ||||
* @param version The OS version | * @param version The OS version | ||||
*/ | */ | ||||
public void setVersion(String aVersion) { | |||||
this.version = aVersion.toLowerCase(Locale.US); | |||||
public void setVersion(String version) { | |||||
this.version = version.toLowerCase(Locale.US); | |||||
} | } | ||||
/** | /** | ||||
@@ -141,8 +141,8 @@ public class Os implements Condition { | |||||
* | * | ||||
* @since 1.5 | * @since 1.5 | ||||
*/ | */ | ||||
public static boolean isFamily(String aFamily) { | |||||
return isOs(aFamily, null, null, null); | |||||
public static boolean isFamily(String family) { | |||||
return isOs(family, null, null, null); | |||||
} | } | ||||
/** | /** | ||||
@@ -151,8 +151,8 @@ public class Os implements Condition { | |||||
* | * | ||||
* @since 1.7 | * @since 1.7 | ||||
*/ | */ | ||||
public static boolean isName(String aName) { | |||||
return isOs(null, aName, null, null); | |||||
public static boolean isName(String name) { | |||||
return isOs(null, name, null, null); | |||||
} | } | ||||
/** | /** | ||||
@@ -161,8 +161,8 @@ public class Os implements Condition { | |||||
* | * | ||||
* @since 1.7 | * @since 1.7 | ||||
*/ | */ | ||||
public static boolean isArch(String aArch) { | |||||
return isOs(null, null, aArch, null); | |||||
public static boolean isArch(String arch) { | |||||
return isOs(null, null, arch, null); | |||||
} | } | ||||
/** | /** | ||||
@@ -171,8 +171,8 @@ public class Os implements Condition { | |||||
* | * | ||||
* @since 1.7 | * @since 1.7 | ||||
*/ | */ | ||||
public static boolean isVersion(String aVersion) { | |||||
return isOs(null, null, null, aVersion); | |||||
public static boolean isVersion(String version) { | |||||
return isOs(null, null, null, version); | |||||
} | } | ||||
/** | /** | ||||
@@ -186,46 +186,46 @@ public class Os implements Condition { | |||||
* | * | ||||
* @since 1.7 | * @since 1.7 | ||||
*/ | */ | ||||
public static boolean isOs(String aFamily, String aName, String aArch, | |||||
String aVersion) { | |||||
public static boolean isOs(String family, String name, String arch, | |||||
String version) { | |||||
boolean retValue = false; | boolean retValue = false; | ||||
if (aFamily != null || aName != null || aArch != null | |||||
|| aVersion != null) { | |||||
if (family != null || name != null || arch != null | |||||
|| version != null) { | |||||
boolean isFamily = true; | boolean isFamily = true; | ||||
boolean isName = true; | boolean isName = true; | ||||
boolean isArch = true; | boolean isArch = true; | ||||
boolean isVersion = true; | boolean isVersion = true; | ||||
if (aFamily != null) { | |||||
if (aFamily.equals("windows")) { | |||||
if (family != null) { | |||||
if (family.equals("windows")) { | |||||
isFamily = osName.indexOf("windows") > -1; | isFamily = osName.indexOf("windows") > -1; | ||||
} else if (aFamily.equals("os/2")) { | |||||
} else if (family.equals("os/2")) { | |||||
isFamily = osName.indexOf("os/2") > -1; | isFamily = osName.indexOf("os/2") > -1; | ||||
} else if (aFamily.equals("netware")) { | |||||
} else if (family.equals("netware")) { | |||||
isFamily = osName.indexOf("netware") > -1; | isFamily = osName.indexOf("netware") > -1; | ||||
} else if (aFamily.equals("dos")) { | |||||
} else if (family.equals("dos")) { | |||||
isFamily = pathSep.equals(";") && !isFamily("netware"); | isFamily = pathSep.equals(";") && !isFamily("netware"); | ||||
} else if (aFamily.equals("mac")) { | |||||
} else if (family.equals("mac")) { | |||||
isFamily = osName.indexOf("mac") > -1; | isFamily = osName.indexOf("mac") > -1; | ||||
} else if (aFamily.equals("unix")) { | |||||
} else if (family.equals("unix")) { | |||||
isFamily = pathSep.equals(":") | isFamily = pathSep.equals(":") | ||||
&& (!isFamily("mac") || osName.endsWith("x")); | && (!isFamily("mac") || osName.endsWith("x")); | ||||
} else { | } else { | ||||
throw new BuildException( | throw new BuildException( | ||||
"Don\'t know how to detect os family \"" | "Don\'t know how to detect os family \"" | ||||
+ aFamily + "\""); | |||||
+ family + "\""); | |||||
} | } | ||||
} | } | ||||
if (aName != null) { | |||||
isName = aName.equals(osName); | |||||
if (name != null) { | |||||
isName = name.equals(osName); | |||||
} | } | ||||
if (aArch != null) { | |||||
isArch = aArch.equals(osArch); | |||||
if (arch != null) { | |||||
isArch = arch.equals(osArch); | |||||
} | } | ||||
if (aVersion != null) { | |||||
isVersion = aVersion.equals(osVersion); | |||||
if (version != null) { | |||||
isVersion = version.equals(osVersion); | |||||
} | } | ||||
retValue = isFamily && isName && isArch && isVersion; | retValue = isFamily && isName && isArch && isVersion; | ||||
} | } | ||||
@@ -1,7 +1,7 @@ | |||||
/* | /* | ||||
* The Apache Software License, Version 1.1 | * The Apache Software License, Version 1.1 | ||||
* | * | ||||
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights | |||||
* Copyright (c) 2001 The Apache Software Foundation. All rights | |||||
* reserved. | * reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
@@ -158,72 +158,72 @@ public class Translate extends MatchingTask { | |||||
/** | /** | ||||
* Sets Family name of resource bundle | * Sets Family name of resource bundle | ||||
*/ | */ | ||||
public void setBundle(String aBundle) { | |||||
this.bundle = aBundle; | |||||
public void setBundle(String bundle) { | |||||
this.bundle = bundle; | |||||
} | } | ||||
/** | /** | ||||
* Sets locale specific language of resource bundle | * Sets locale specific language of resource bundle | ||||
*/ | */ | ||||
public void setBundleLanguage(String aBundleLanguage ) { | |||||
this.bundleLanguage = aBundleLanguage; | |||||
public void setBundleLanguage(String bundleLanguage ) { | |||||
this.bundleLanguage = bundleLanguage; | |||||
} | } | ||||
/** | /** | ||||
* Sets locale specific country of resource bundle | * Sets locale specific country of resource bundle | ||||
*/ | */ | ||||
public void setBundleCountry(String aBundleCountry) { | |||||
this.bundleCountry = aBundleCountry; | |||||
public void setBundleCountry(String bundleCountry) { | |||||
this.bundleCountry = bundleCountry; | |||||
} | } | ||||
/** | /** | ||||
* Sets locale specific variant of resource bundle | * Sets locale specific variant of resource bundle | ||||
*/ | */ | ||||
public void setBundleVariant(String aBundleVariant) { | |||||
this.bundleVariant = aBundleVariant; | |||||
public void setBundleVariant(String bundleVariant) { | |||||
this.bundleVariant = bundleVariant; | |||||
} | } | ||||
/** | /** | ||||
* Sets Destination directory | * Sets Destination directory | ||||
*/ | */ | ||||
public void setToDir(File aToDir) { | |||||
this.toDir = aToDir; | |||||
public void setToDir(File toDir) { | |||||
this.toDir = toDir; | |||||
} | } | ||||
/** | /** | ||||
* Sets starting token to identify keys | * Sets starting token to identify keys | ||||
*/ | */ | ||||
public void setStartToken(String aStartToken) { | |||||
this.startToken = aStartToken; | |||||
public void setStartToken(String startToken) { | |||||
this.startToken = startToken; | |||||
} | } | ||||
/** | /** | ||||
* Sets ending token to identify keys | * Sets ending token to identify keys | ||||
*/ | */ | ||||
public void setEndToken(String aEndToken) { | |||||
this.endToken = aEndToken; | |||||
public void setEndToken(String endToken) { | |||||
this.endToken = endToken; | |||||
} | } | ||||
/** | /** | ||||
* Sets source file encoding scheme | * Sets source file encoding scheme | ||||
*/ | */ | ||||
public void setSrcEncoding(String aSrcEncoding) { | |||||
this.srcEncoding = aSrcEncoding; | |||||
public void setSrcEncoding(String srcEncoding) { | |||||
this.srcEncoding = srcEncoding; | |||||
} | } | ||||
/** | /** | ||||
* Sets destination file encoding scheme. Defaults to source file | * Sets destination file encoding scheme. Defaults to source file | ||||
* encoding | * encoding | ||||
*/ | */ | ||||
public void setDestEncoding(String aDestEncoding) { | |||||
this.destEncoding = aDestEncoding; | |||||
public void setDestEncoding(String destEncoding) { | |||||
this.destEncoding = destEncoding; | |||||
} | } | ||||
/** | /** | ||||
* Sets Resource Bundle file encoding scheme | * Sets Resource Bundle file encoding scheme | ||||
*/ | */ | ||||
public void setBundleEncoding(String aBundleEncoding) { | |||||
this.bundleEncoding = aBundleEncoding; | |||||
public void setBundleEncoding(String bundleEncoding) { | |||||
this.bundleEncoding = bundleEncoding; | |||||
} | } | ||||
/** | /** | ||||
@@ -231,8 +231,8 @@ public class Translate extends MatchingTask { | |||||
* the source file as well as the resource bundle file? Defaults to | * the source file as well as the resource bundle file? Defaults to | ||||
* false. | * false. | ||||
*/ | */ | ||||
public void setForceOverwrite(boolean aForceOverwrite) { | |||||
this.forceOverwrite = aForceOverwrite; | |||||
public void setForceOverwrite(boolean forceOverwrite) { | |||||
this.forceOverwrite = forceOverwrite; | |||||
} | } | ||||
/** | /** | ||||
@@ -339,17 +339,17 @@ public class Translate extends MatchingTask { | |||||
* but with bundle encoding also considered while loading. | * but with bundle encoding also considered while loading. | ||||
*/ | */ | ||||
private void loadResourceMaps() throws BuildException { | private void loadResourceMaps() throws BuildException { | ||||
Locale aLocale = new Locale(bundleLanguage, | |||||
Locale locale = new Locale(bundleLanguage, | |||||
bundleCountry, | bundleCountry, | ||||
bundleVariant); | bundleVariant); | ||||
String language = aLocale.getLanguage().length() > 0 ? | |||||
"_" + aLocale.getLanguage() : | |||||
String language = locale.getLanguage().length() > 0 ? | |||||
"_" + locale.getLanguage() : | |||||
""; | ""; | ||||
String country = aLocale.getCountry().length() > 0 ? | |||||
"_" + aLocale.getCountry() : | |||||
String country = locale.getCountry().length() > 0 ? | |||||
"_" + locale.getCountry() : | |||||
""; | ""; | ||||
String variant = aLocale.getVariant().length() > 0 ? | |||||
"_" + aLocale.getVariant() : | |||||
String variant = locale.getVariant().length() > 0 ? | |||||
"_" + locale.getVariant() : | |||||
""; | ""; | ||||
String bundleFile = bundle + language + country + variant; | String bundleFile = bundle + language + country + variant; | ||||
processBundle(bundleFile, 0, false); | processBundle(bundleFile, 0, false); | ||||
@@ -365,16 +365,16 @@ public class Translate extends MatchingTask { | |||||
//Load default locale bundle files | //Load default locale bundle files | ||||
//using default file encoding scheme. | //using default file encoding scheme. | ||||
aLocale = Locale.getDefault(); | |||||
locale = Locale.getDefault(); | |||||
language = aLocale.getLanguage().length() > 0 ? | |||||
"_" + aLocale.getLanguage() : | |||||
language = locale.getLanguage().length() > 0 ? | |||||
"_" + locale.getLanguage() : | |||||
""; | ""; | ||||
country = aLocale.getCountry().length() > 0 ? | |||||
"_" + aLocale.getCountry() : | |||||
country = locale.getCountry().length() > 0 ? | |||||
"_" + locale.getCountry() : | |||||
""; | ""; | ||||
variant = aLocale.getVariant().length() > 0 ? | |||||
"_" + aLocale.getVariant() : | |||||
variant = locale.getVariant().length() > 0 ? | |||||
"_" + locale.getVariant() : | |||||
""; | ""; | ||||
bundleEncoding = System.getProperty("file.encoding"); | bundleEncoding = System.getProperty("file.encoding"); | ||||
@@ -391,19 +391,18 @@ public class Translate extends MatchingTask { | |||||
/** | /** | ||||
* Process each file that makes up this bundle. | * Process each file that makes up this bundle. | ||||
*/ | */ | ||||
private void processBundle(final String bundleFile, final int i, | |||||
final boolean checkLoaded) | |||||
throws BuildException { | |||||
String lBundleFile = bundleFile + ".properties"; | |||||
private void processBundle(String bundleFile, int i, | |||||
boolean checkLoaded) throws BuildException { | |||||
bundleFile += ".properties"; | |||||
FileInputStream ins = null; | FileInputStream ins = null; | ||||
try { | try { | ||||
ins = new FileInputStream(lBundleFile); | |||||
ins = new FileInputStream(bundleFile); | |||||
loaded = true; | loaded = true; | ||||
bundleLastModified[i] = new File(lBundleFile).lastModified(); | |||||
log("Using " + lBundleFile, Project.MSG_DEBUG); | |||||
bundleLastModified[i] = new File(bundleFile).lastModified(); | |||||
log("Using " + bundleFile, Project.MSG_DEBUG); | |||||
loadResourceMap(ins); | loadResourceMap(ins); | ||||
} catch (IOException ioe) { | } catch (IOException ioe) { | ||||
log(lBundleFile + " not found.", Project.MSG_DEBUG); | |||||
log(bundleFile + " not found.", Project.MSG_DEBUG); | |||||
//if all resource files associated with this bundle | //if all resource files associated with this bundle | ||||
//have been scanned for and still not able to | //have been scanned for and still not able to | ||||
//find a single resrouce file, throw exception | //find a single resrouce file, throw exception | ||||
@@ -525,49 +524,50 @@ public class Translate extends MatchingTask { | |||||
srcEncoding)); | srcEncoding)); | ||||
String line; | String line; | ||||
while((line = in.readLine()) != null) { | while((line = in.readLine()) != null) { | ||||
StringBuffer newline = new StringBuffer(line); | |||||
int startIndex = -1; | int startIndex = -1; | ||||
int endIndex = -1; | int endIndex = -1; | ||||
outer: while (true) { | |||||
startIndex = line.indexOf(startToken, endIndex + 1); | |||||
if (startIndex < 0 || | |||||
startIndex + 1 >= line.length()) { | |||||
break; | |||||
} | |||||
endIndex = line.indexOf(endToken, startIndex + 1); | |||||
if (endIndex < 0) { | |||||
break; | |||||
} | |||||
String matches = line.substring(startIndex + 1, | |||||
endIndex); | |||||
//If there is a white space or = or :, then | |||||
//it isn't to be treated as a valid key. | |||||
for (int k = 0; k < matches.length(); k++) { | |||||
char c = matches.charAt(k); | |||||
if (c == ':' || | |||||
c == '=' || | |||||
Character.isSpaceChar(c)) { | |||||
endIndex = endIndex - 1; | |||||
continue outer; | |||||
} | |||||
} | |||||
String replace = null; | |||||
replace = (String) resourceMap.get(matches); | |||||
//If the key hasn't been loaded into resourceMap, | |||||
//use the key itself as the value also. | |||||
if (replace == null) { | |||||
log("Warning: The key: " + matches | |||||
+ " hasn't been defined.", | |||||
Project.MSG_DEBUG); | |||||
replace = matches; | |||||
} | |||||
line = line.substring(0, startIndex) | |||||
+ replace | |||||
+ line.substring(endIndex + 1); | |||||
endIndex = startIndex + replace.length() + 1; | |||||
if (endIndex + 1 >= line.length()) { | |||||
break; | |||||
outer: while (true) { | |||||
startIndex = line.indexOf(startToken, endIndex + 1); | |||||
if (startIndex < 0 || | |||||
startIndex + 1 >= line.length()) { | |||||
break; | |||||
} | |||||
endIndex = line.indexOf(endToken, startIndex + 1); | |||||
if (endIndex < 0) { | |||||
break; | |||||
} | |||||
String matches = line.substring(startIndex + 1, | |||||
endIndex); | |||||
//If there is a white space or = or :, then | |||||
//it isn't to be treated as a valid key. | |||||
for (int k = 0; k < matches.length(); k++) { | |||||
char c = matches.charAt(k); | |||||
if (c == ':' || | |||||
c == '=' || | |||||
Character.isSpaceChar(c)) { | |||||
endIndex = endIndex - 1; | |||||
continue outer; | |||||
} | } | ||||
} | } | ||||
String replace = null; | |||||
replace = (String) resourceMap.get(matches); | |||||
//If the key hasn't been loaded into resourceMap, | |||||
//use the key itself as the value also. | |||||
if (replace == null) { | |||||
log("Warning: The key: " + matches | |||||
+ " hasn't been defined.", | |||||
Project.MSG_DEBUG); | |||||
replace = matches; | |||||
} | |||||
line = line.substring(0, startIndex) | |||||
+ replace | |||||
+ line.substring(endIndex + 1); | |||||
endIndex = startIndex + replace.length() + 1; | |||||
if (endIndex + 1 >= line.length()) { | |||||
break; | |||||
} | |||||
} | |||||
out.write(line); | out.write(line); | ||||
out.newLine(); | out.newLine(); | ||||
} | } | ||||