You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2014/07/28 16:35:51 UTC
svn commit: r1614041 [2/3] - in
/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release:
./ cmd/ util/
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/cmd/UpdateVersions.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/cmd/UpdateVersions.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/cmd/UpdateVersions.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/cmd/UpdateVersions.java Mon Jul 28 14:35:50 2014
@@ -37,7 +37,7 @@ import static org.apache.openejb.tools.r
@Command(dependsOn = Close.class)
public class UpdateVersions {
- public static void main(String... args) throws Exception {
+ public static void main(final String... args) throws Exception {
final File workingCopy = cd(new File("/home/andy/tck/release-tools/tomee-1.6.0.1.staging"));
@@ -45,11 +45,11 @@ public class UpdateVersions {
}
- private static void updateVersions(File workingCopy) throws IOException {
+ private static void updateVersions(final File workingCopy) throws IOException {
final List<File> files = collect(workingCopy, ".*pom.xml");
- for (File file : files) {
+ for (final File file : files) {
if (file.getAbsolutePath().contains("/maven/")) continue;
if (file.getAbsolutePath().contains("/examples/")) continue;
@@ -101,11 +101,11 @@ public class UpdateVersions {
}
- private static void updateVersions2(File workingCopy) throws IOException {
+ private static void updateVersions2(final File workingCopy) throws IOException {
final List<File> files = collect(workingCopy, ".*pom.xml");
- for (File file : files) {
+ for (final File file : files) {
if (!file.getAbsolutePath().contains("/examples/")) continue;
InputStream in = IO.read(file);
@@ -146,7 +146,7 @@ public class UpdateVersions {
}
- private static void update(File dest, InputStream in) throws IOException {
+ private static void update(final File dest, final InputStream in) throws IOException {
final File tmp = new File(dest.getAbsolutePath() + "~");
final OutputStream out = IO.write(tmp);
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/cmd/Vote.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/cmd/Vote.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/cmd/Vote.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/cmd/Vote.java Mon Jul 28 14:35:50 2014
@@ -34,14 +34,14 @@ import java.util.concurrent.TimeUnit;
@Command(dependsOn = {Legal.class, Binaries.class})
public class Vote {
- public static void main(String[] args) throws IOException {
+ public static void main(final String[] args) throws IOException {
final TemplateBuilder template = new Templates(Platform.aPlatform()).template("vote.vm");
- for (Field field : Release.class.getFields()) {
+ for (final Field field : Release.class.getFields()) {
try {
template.add(field.getName(), field.get(null));
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
e.printStackTrace();
}
}
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Base64.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Base64.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Base64.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Base64.java Mon Jul 28 14:35:50 2014
@@ -173,7 +173,7 @@ public class Base64 {
* @param octect The value to test
* @return <code>true</code> if the value is defined in the the base 64 alphabet, <code>false</code> otherwise.
*/
- private static boolean isBase64(byte octect) {
+ private static boolean isBase64(final byte octect) {
if (octect == PAD) {
return true;
} else if (octect < 0 || base64Alphabet[octect] == -1) {
@@ -195,7 +195,7 @@ public class Base64 {
arrayOctect = discardWhitespace(arrayOctect);
- int length = arrayOctect.length;
+ final int length = arrayOctect.length;
if (length == 0) {
// shouldn't a 0 length array be valid base64 data?
// return false;
@@ -216,7 +216,7 @@ public class Base64 {
* @param binaryData binary data to encode
* @return Base64 characters
*/
- public static byte[] encodeBase64(byte[] binaryData) {
+ public static byte[] encodeBase64(final byte[] binaryData) {
return encodeBase64(binaryData, false);
}
@@ -227,7 +227,7 @@ public class Base64 {
* @param binaryData binary data to encode
* @return Base64 characters chunked in 76 character blocks
*/
- public static byte[] encodeBase64Chunked(byte[] binaryData) {
+ public static byte[] encodeBase64Chunked(final byte[] binaryData) {
return encodeBase64(binaryData, true);
}
@@ -244,7 +244,7 @@ public class Base64 {
* @throws IOException if the parameter supplied is not
* of type byte[]
*/
- public Object decode(Object pObject) throws IOException {
+ public Object decode(final Object pObject) throws IOException {
if (!(pObject instanceof byte[])) {
throw new IOException("Parameter supplied to Base64 decode is not a byte[]");
}
@@ -258,7 +258,7 @@ public class Base64 {
* @param pArray A byte array containing Base64 character data
* @return a byte array containing binary data
*/
- public byte[] decode(byte[] pArray) {
+ public byte[] decode(final byte[] pArray) {
return decodeBase64(pArray);
}
@@ -271,10 +271,10 @@ public class Base64 {
* the base64 output into 76 character blocks
* @return Base64-encoded data.
*/
- public static byte[] encodeBase64(byte[] binaryData, boolean isChunked) {
- int lengthDataBits = binaryData.length * EIGHTBIT;
- int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
- int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
+ public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked) {
+ final int lengthDataBits = binaryData.length * EIGHTBIT;
+ final int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
+ final int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
byte encodedData[] = null;
int encodedDataLength = 0;
int nbrChunks = 0;
@@ -319,11 +319,11 @@ public class Base64 {
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
- byte val1 =
+ final byte val1 =
((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
- byte val2 =
+ final byte val2 =
((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
- byte val3 =
+ final byte val3 =
((b3 & SIGN) == 0) ? (byte) (b3 >> 6) : (byte) ((b3) >> 6 ^ 0xfc);
encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
@@ -365,7 +365,7 @@ public class Base64 {
k = (byte) (b1 & 0x03);
//log.debug("b1=" + b1);
//log.debug("b1<<2 = " + (b1>>2) );
- byte val1 =
+ final byte val1 =
((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
encodedData[encodedIndex + 1] = lookUpBase64Alphabet[k << 4];
@@ -378,9 +378,9 @@ public class Base64 {
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
- byte val1 =
+ final byte val1 =
((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
- byte val2 =
+ final byte val2 =
((b2 & SIGN) == 0) ? (byte) (b2 >> 4) : (byte) ((b2) >> 4 ^ 0xf0);
encodedData[encodedIndex] = lookUpBase64Alphabet[val1];
@@ -420,7 +420,7 @@ public class Base64 {
return new byte[0];
}
- int numberQuadruple = base64Data.length / FOURBYTE;
+ final int numberQuadruple = base64Data.length / FOURBYTE;
byte decodedData[] = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0;
@@ -480,8 +480,8 @@ public class Base64 {
* from.
* @return The data, less whitespace (see RFC 2045).
*/
- static byte[] discardWhitespace(byte[] data) {
- byte groomedData[] = new byte[data.length];
+ static byte[] discardWhitespace(final byte[] data) {
+ final byte[] groomedData = new byte[data.length];
int bytesCopied = 0;
for (int i = 0; i < data.length; i++) {
@@ -496,7 +496,7 @@ public class Base64 {
}
}
- byte packedData[] = new byte[bytesCopied];
+ final byte[] packedData = new byte[bytesCopied];
System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
@@ -512,8 +512,8 @@ public class Base64 {
* @param data The base-64 encoded data to groom
* @return The data, less non-base64 characters (see RFC 2045).
*/
- static byte[] discardNonBase64(byte[] data) {
- byte groomedData[] = new byte[data.length];
+ static byte[] discardNonBase64(final byte[] data) {
+ final byte[] groomedData = new byte[data.length];
int bytesCopied = 0;
for (int i = 0; i < data.length; i++) {
@@ -522,7 +522,7 @@ public class Base64 {
}
}
- byte packedData[] = new byte[bytesCopied];
+ final byte[] packedData = new byte[bytesCopied];
System.arraycopy(groomedData, 0, packedData, 0, bytesCopied);
@@ -544,7 +544,7 @@ public class Base64 {
* @throws IOException if the parameter supplied is not
* of type byte[]
*/
- public Object encode(Object pObject) throws IOException {
+ public Object encode(final Object pObject) throws IOException {
if (!(pObject instanceof byte[])) {
throw new IOException(
"Parameter supplied to Base64 encode is not a byte[]");
@@ -559,7 +559,7 @@ public class Base64 {
* @param pArray a byte array containing binary data
* @return A byte array containing only Base64 character data
*/
- public byte[] encode(byte[] pArray) {
+ public byte[] encode(final byte[] pArray) {
return encodeBase64(pArray, false);
}
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/CircularReferencesException.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/CircularReferencesException.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/CircularReferencesException.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/CircularReferencesException.java Mon Jul 28 14:35:50 2014
@@ -24,7 +24,7 @@ import java.util.List;
public class CircularReferencesException extends RuntimeException {
private final List<List> circuits;
- public CircularReferencesException(List<List> circuits) {
+ public CircularReferencesException(final List<List> circuits) {
this.circuits = circuits;
}
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Commands.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Commands.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Commands.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Commands.java Mon Jul 28 14:35:50 2014
@@ -30,37 +30,37 @@ import java.util.Set;
*/
public class Commands {
- public static String name(Class<?> clazz) {
+ public static String name(final Class<?> clazz) {
final Command command = clazz.getAnnotation(Command.class);
String name = command.value();
if (name.length() == 0) name = clazz.getSimpleName().toLowerCase();
return name;
}
- public static void run(String[] args, Class clazz) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+ public static void run(final String[] args, final Class clazz) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final Method main = clazz.getMethod("main", String[].class);
main.invoke(null, new Object[]{args});
}
- public static List<String> dependencies(Class<?> clazz) {
- List<String> list = new ArrayList<String>();
+ public static List<String> dependencies(final Class<?> clazz) {
+ final List<String> list = new ArrayList<String>();
final Command command = clazz.getAnnotation(Command.class);
- for (Class dep : command.dependsOn()) {
+ for (final Class dep : command.dependsOn()) {
list.add(name(dep));
}
return list;
}
- public static List<Class<?>> order(List<Class<?>> commands) {
+ public static List<Class<?>> order(final List<Class<?>> commands) {
return References.sort(commands, new References.Visitor<Class<?>>() {
@Override
- public String getName(Class<?> aClass) {
+ public String getName(final Class<?> aClass) {
return name(aClass);
}
@Override
- public Set<String> getReferences(Class<?> aClass) {
+ public Set<String> getReferences(final Class<?> aClass) {
return new HashSet<String>(dependencies(aClass));
}
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Exec.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Exec.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Exec.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Exec.java Mon Jul 28 14:35:50 2014
@@ -28,12 +28,12 @@ public class Exec {
public static Map<String, String> env = new HashMap<String, String>();
- public static File cd(String string) {
+ public static File cd(final String string) {
final File file = new File(string);
return cd(file);
}
- public static File cd(File file) {
+ public static File cd(final File file) {
System.out.println("cd " + file);
System.setProperty("user.dir", file.getAbsolutePath());
@@ -41,25 +41,25 @@ public class Exec {
return file;
}
- public static void export(String key, String value) {
+ public static void export(final String key, final String value) {
env.put(key, value);
}
- public static int exec(String program, String... args) throws RuntimeException {
+ public static int exec(final String program, final String... args) throws RuntimeException {
try {
final Process process = call(program, args);
Pipe.pipe(process);
return process.waitFor();
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException(e);
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
Thread.interrupted();
throw new RuntimeException(e);
}
}
- public static OutputStream write(String program, String... args) throws RuntimeException {
+ public static OutputStream write(final String program, final String... args) throws RuntimeException {
try {
final Process process = call(program, args);
@@ -67,12 +67,12 @@ public class Exec {
Pipe.pipe(process.getErrorStream(), System.err);
return new BufferedOutputStream(process.getOutputStream());
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException(e);
}
}
- public static InputStream read(String program, String... args) throws RuntimeException {
+ public static InputStream read(final String program, final String... args) throws RuntimeException {
try {
final Process process = call(program, args);
@@ -80,12 +80,12 @@ public class Exec {
Pipe.pipe(process.getErrorStream(), System.err);
return new BufferedInputStream(process.getInputStream());
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException(e);
}
}
- private static Process call(String program, String... args) throws IOException {
+ private static Process call(final String program, final String... args) throws IOException {
final List<String> command = new ArrayList<String>();
command.add(program);
command.addAll(Arrays.asList(args));
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Files.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Files.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Files.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Files.java Mon Jul 28 14:35:50 2014
@@ -45,9 +45,9 @@ import java.util.regex.Pattern;
*/
public class Files {
- public static File file(String... parts) {
+ public static File file(final String... parts) {
File dir = null;
- for (String part : parts) {
+ for (final String part : parts) {
if (dir == null) {
dir = new File(part);
} else {
@@ -58,8 +58,8 @@ public class Files {
return dir;
}
- public static File file(File dir, String... parts) {
- for (String part : parts) {
+ public static File file(File dir, final String... parts) {
+ for (final String part : parts) {
dir = new File(dir, part);
}
@@ -73,19 +73,19 @@ public class Files {
public static List<File> collect(final File dir, final Pattern pattern) {
return collect(dir, new FileFilter() {
@Override
- public boolean accept(File file) {
+ public boolean accept(final File file) {
return pattern.matcher(file.getAbsolutePath()).matches();
}
});
}
- public static List<File> collect(File dir, FileFilter filter) {
+ public static List<File> collect(final File dir, final FileFilter filter) {
final List<File> accepted = new ArrayList<File>();
if (filter.accept(dir)) accepted.add(dir);
final File[] files = dir.listFiles();
- if (files != null) for (File file : files) {
+ if (files != null) for (final File file : files) {
accepted.addAll(collect(file, filter));
}
@@ -109,27 +109,27 @@ public class Files {
}
}
- public static void exists(File file, String s) {
+ public static void exists(final File file, final String s) {
if (!file.exists()) throw new RuntimeException(s + " does not exist: " + file.getAbsolutePath());
}
- public static void dir(File file) {
+ public static void dir(final File file) {
if (!file.isDirectory()) throw new RuntimeException("Not a directory: " + file.getAbsolutePath());
}
- public static void file(File file) {
+ public static void file(final File file) {
if (!file.isFile()) throw new RuntimeException("Not a file: " + file.getAbsolutePath());
}
- public static void writable(File file) {
+ public static void writable(final File file) {
if (!file.canWrite()) throw new RuntimeException("Not writable: " + file.getAbsolutePath());
}
- public static void readable(File file) {
+ public static void readable(final File file) {
if (!file.canRead()) throw new RuntimeException("Not readable: " + file.getAbsolutePath());
}
- public static void mkdir(File file) {
+ public static void mkdir(final File file) {
if (file.exists()) return;
if (!file.mkdirs()) throw new RuntimeException("Cannot mkdir: " + file.getAbsolutePath());
}
@@ -140,16 +140,16 @@ public class Files {
if (!file.delete()) throw new IllegalStateException("Cannot make temp dir. Delete failed");
mkdir(file);
return file;
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new RuntimeException(e);
}
}
- public static void mkparent(File file) {
+ public static void mkparent(final File file) {
mkdirs(file.getParentFile());
}
- public static void mkdirs(File file) {
+ public static void mkdirs(final File file) {
if (!file.exists()) {
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/IO.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/IO.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/IO.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/IO.java Mon Jul 28 14:35:50 2014
@@ -27,31 +27,31 @@ import java.util.zip.ZipOutputStream;
*/
public class IO {
- public static String readString(URL url) throws IOException {
+ public static String readString(final URL url) throws IOException {
final InputStream in = url.openStream();
try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ final BufferedReader reader = new BufferedReader(new InputStreamReader(in));
return reader.readLine();
} finally {
close(in);
}
}
- public static String readString(File file) throws IOException {
+ public static String readString(final File file) throws IOException {
final FileReader in = new FileReader(file);
try {
- BufferedReader reader = new BufferedReader(in);
+ final BufferedReader reader = new BufferedReader(in);
return reader.readLine();
} finally {
close(in);
}
}
- public static Properties readProperties(InputStream in) throws IOException {
+ public static Properties readProperties(final InputStream in) throws IOException {
return readProperties(in, new Properties());
}
- public static Properties readProperties(InputStream in, Properties properties) throws IOException {
+ public static Properties readProperties(final InputStream in, final Properties properties) throws IOException {
if (in == null) throw new NullPointerException("InputStream is null");
if (properties == null) throw new NullPointerException("Properties is null");
try {
@@ -62,29 +62,29 @@ public class IO {
return properties;
}
- public static String slurp(String fileName) throws IOException {
+ public static String slurp(final String fileName) throws IOException {
return slurp(new File(fileName));
}
- public static String slurp(File file) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ public static String slurp(final File file) throws IOException {
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(file, out);
return new String(out.toByteArray());
}
- public static String slurp(InputStream in) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ public static String slurp(final InputStream in) throws IOException {
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(in, out);
return new String(out.toByteArray(), "UTF-8");
}
- public static String slurp(URL url) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ public static String slurp(final URL url) throws IOException {
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
copy(url.openStream(), out);
return new String(out.toByteArray());
}
- public static void writeString(File file, String string) throws IOException {
+ public static void writeString(final File file, final String string) throws IOException {
final FileWriter out = new FileWriter(file);
try {
final BufferedWriter bufferedWriter = new BufferedWriter(out);
@@ -99,7 +99,7 @@ public class IO {
}
}
- public static void copy(File from, OutputStream to) throws IOException {
+ public static void copy(final File from, final OutputStream to) throws IOException {
final InputStream read = read(from);
try {
copy(read, to);
@@ -108,7 +108,7 @@ public class IO {
}
}
- public static void copy(InputStream from, File to) throws IOException {
+ public static void copy(final InputStream from, final File to) throws IOException {
final OutputStream write = write(to);
try {
copy(from, write);
@@ -117,7 +117,7 @@ public class IO {
}
}
- public static void copy(InputStream from, File to, boolean append) throws IOException {
+ public static void copy(final InputStream from, final File to, final boolean append) throws IOException {
final OutputStream write = write(to, append);
try {
copy(from, write);
@@ -126,8 +126,8 @@ public class IO {
}
}
- public static void copy(InputStream from, OutputStream to) throws IOException {
- byte[] buffer = new byte[1024];
+ public static void copy(final InputStream from, final OutputStream to) throws IOException {
+ final byte[] buffer = new byte[1024];
int length = 0;
while ((length = from.read(buffer)) != -1) {
to.write(buffer, 0, length);
@@ -135,31 +135,31 @@ public class IO {
to.flush();
}
- public static ZipOutputStream zip(File file) throws IOException {
+ public static ZipOutputStream zip(final File file) throws IOException {
final OutputStream write = write(file);
return new ZipOutputStream(write);
}
- public static ZipInputStream unzip(File file) throws IOException {
+ public static ZipInputStream unzip(final File file) throws IOException {
final InputStream read = read(file);
return new ZipInputStream(read);
}
- public static void close(Closeable closeable) throws IOException {
+ public static void close(final Closeable closeable) throws IOException {
if (closeable == null) return;
try {
if (closeable instanceof Flushable) {
((Flushable) closeable).flush();
}
- } catch (IOException e) {
+ } catch (final IOException e) {
}
try {
closeable.close();
- } catch (IOException e) {
+ } catch (final IOException e) {
}
}
- public static boolean delete(File file) {
+ public static boolean delete(final File file) {
if (file == null) return false;
if (!file.delete()) {
System.err.println("Delete failed " + file.getAbsolutePath());
@@ -169,34 +169,34 @@ public class IO {
return true;
}
- public static OutputStream write(File destination) throws FileNotFoundException {
+ public static OutputStream write(final File destination) throws FileNotFoundException {
final OutputStream out = new FileOutputStream(destination);
return new BufferedOutputStream(out, 32768);
}
- public static OutputStream write(File destination, boolean append) throws FileNotFoundException {
+ public static OutputStream write(final File destination, final boolean append) throws FileNotFoundException {
final OutputStream out = new FileOutputStream(destination, append);
return new BufferedOutputStream(out, 32768);
}
- public static InputStream read(File source) throws FileNotFoundException {
+ public static InputStream read(final File source) throws FileNotFoundException {
final InputStream in = new FileInputStream(source);
return new BufferedInputStream(in, 32768);
}
- public static InputStream read(String content) {
+ public static InputStream read(final String content) {
return read(content.getBytes());
}
- public static InputStream read(String content, String encoding) throws UnsupportedEncodingException {
+ public static InputStream read(final String content, final String encoding) throws UnsupportedEncodingException {
return read(content.getBytes(encoding));
}
- public static InputStream read(byte[] content) {
+ public static InputStream read(final byte[] content) {
return new ByteArrayInputStream(content);
}
- public static InputStream read(URL url) throws IOException {
+ public static InputStream read(final URL url) throws IOException {
return url.openStream();
}
}
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/JarLocation.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/JarLocation.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/JarLocation.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/JarLocation.java Mon Jul 28 14:35:50 2014
@@ -30,11 +30,11 @@ public class JarLocation {
return jarLocation(JarLocation.class);
}
- public static File jarLocation(Class clazz) {
+ public static File jarLocation(final Class clazz) {
try {
- String classFileName = clazz.getName().replace(".", "/") + ".class";
+ final String classFileName = clazz.getName().replace(".", "/") + ".class";
- ClassLoader loader = clazz.getClassLoader();
+ final ClassLoader loader = clazz.getClassLoader();
URL url;
if (loader != null) {
url = loader.getResource(classFileName);
@@ -47,7 +47,7 @@ public class JarLocation {
}
if ("jar".equals(url.getProtocol())) {
- String spec = url.getFile();
+ final String spec = url.getFile();
int separator = spec.indexOf('!');
/*
@@ -64,28 +64,28 @@ public class JarLocation {
} else {
throw new IllegalArgumentException("Unsupported URL scheme: " + url.toExternalForm());
}
- } catch (RuntimeException e) {
+ } catch (final RuntimeException e) {
throw e;
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new IllegalStateException(e);
}
}
- private static File toFile(String classFileName, URL url) {
+ private static File toFile(final String classFileName, final URL url) {
String path = url.getFile();
path = path.substring(0, path.length() - classFileName.length());
return new File(decode(path));
}
- public static String decode(String fileName) {
+ public static String decode(final String fileName) {
if (fileName.indexOf('%') == -1) return fileName;
- StringBuilder result = new StringBuilder(fileName.length());
- ByteArrayOutputStream out = new ByteArrayOutputStream();
+ final StringBuilder result = new StringBuilder(fileName.length());
+ final ByteArrayOutputStream out = new ByteArrayOutputStream();
for (int i = 0; i < fileName.length(); ) {
- char c = fileName.charAt(i);
+ final char c = fileName.charAt(i);
if (c == '%') {
out.reset();
@@ -94,8 +94,8 @@ public class JarLocation {
throw new IllegalArgumentException("Incomplete % sequence at: " + i);
}
- int d1 = Character.digit(fileName.charAt(i + 1), 16);
- int d2 = Character.digit(fileName.charAt(i + 2), 16);
+ final int d1 = Character.digit(fileName.charAt(i + 1), 16);
+ final int d2 = Character.digit(fileName.charAt(i + 2), 16);
if (d1 == -1 || d2 == -1) {
throw new IllegalArgumentException("Invalid % sequence (" + fileName.substring(i, i + 3) + ") at: " + String.valueOf(i));
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Join.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Join.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Join.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Join.java Mon Jul 28 14:35:50 2014
@@ -28,45 +28,45 @@ public class Join {
public static final ClassCallback CLASS_CALLBACK = new ClassCallback();
- public static String join(String delimiter, Collection collection) {
+ public static String join(final String delimiter, final Collection collection) {
if (collection.size() == 0) {
return "";
}
- StringBuilder sb = new StringBuilder();
- for (Object obj : collection) {
+ final StringBuilder sb = new StringBuilder();
+ for (final Object obj : collection) {
sb.append(obj).append(delimiter);
}
return sb.substring(0, sb.length() - delimiter.length());
}
- public static String join(String delimiter, Object... collection) {
+ public static String join(final String delimiter, final Object... collection) {
if (collection.length == 0) {
return "";
}
- StringBuilder sb = new StringBuilder();
- for (Object obj : collection) {
+ final StringBuilder sb = new StringBuilder();
+ for (final Object obj : collection) {
sb.append(obj).append(delimiter);
}
return sb.substring(0, sb.length() - delimiter.length());
}
- public static <T> String join(String delimiter, NameCallback<T> nameCallback, T... collection) {
+ public static <T> String join(final String delimiter, final NameCallback<T> nameCallback, final T... collection) {
if (collection.length == 0) {
return "";
}
- StringBuilder sb = new StringBuilder();
- for (T obj : collection) {
+ final StringBuilder sb = new StringBuilder();
+ for (final T obj : collection) {
sb.append(nameCallback.getName(obj)).append(delimiter);
}
return sb.substring(0, sb.length() - delimiter.length());
}
- public static <T> String join(String delimiter, NameCallback<T> nameCallback, Collection<T> collection) {
+ public static <T> String join(final String delimiter, final NameCallback<T> nameCallback, final Collection<T> collection) {
if (collection.size() == 0) {
return "";
}
- StringBuilder sb = new StringBuilder();
- for (T obj : collection) {
+ final StringBuilder sb = new StringBuilder();
+ for (final T obj : collection) {
sb.append(nameCallback.getName(obj)).append(delimiter);
}
return sb.substring(0, sb.length() - delimiter.length());
@@ -79,14 +79,14 @@ public class Join {
public static class MethodCallback implements NameCallback<Method> {
- public String getName(Method method) {
+ public String getName(final Method method) {
return method.getName();
}
}
public static class ClassCallback implements NameCallback<Class<?>> {
- public String getName(Class<?> cls) {
+ public String getName(final Class<?> cls) {
return cls.getName();
}
}
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ListAdapter.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ListAdapter.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ListAdapter.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ListAdapter.java Mon Jul 28 14:35:50 2014
@@ -22,12 +22,12 @@ import java.util.Arrays;
import java.util.List;
public class ListAdapter extends XmlAdapter<String, List<String>> {
- public List<String> unmarshal(String s) {
- String[] strings = s.split(", *");
+ public List<String> unmarshal(final String s) {
+ final String[] strings = s.split(", *");
return new ArrayList<String>(Arrays.asList(strings));
}
- public String marshal(List<String> list) {
+ public String marshal(final List<String> list) {
return Join.join(", ", list);
}
}
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Log4jLog.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Log4jLog.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Log4jLog.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Log4jLog.java Mon Jul 28 14:35:50 2014
@@ -24,7 +24,7 @@ import org.apache.log4j.Logger;
class Log4jLog implements Options.Log {
private final Logger log;
- public Log4jLog(Logger log) {
+ public Log4jLog(final Logger log) {
this.log = log;
}
@@ -44,32 +44,32 @@ class Log4jLog implements Options.Log {
}
@Override
- public void warning(String message, Throwable t) {
+ public void warning(final String message, final Throwable t) {
log.warn(message, t);
}
@Override
- public void warning(String message) {
+ public void warning(final String message) {
log.warn(message);
}
@Override
- public void debug(String message, Throwable t) {
+ public void debug(final String message, final Throwable t) {
info(message, t);
}
@Override
- public void debug(String message) {
+ public void debug(final String message) {
info(message);
}
@Override
- public void info(String message, Throwable t) {
+ public void info(final String message, final Throwable t) {
log.info(message, t);
}
@Override
- public void info(String message) {
+ public void info(final String message) {
log.info(message);
}
}
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ObjectList.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ObjectList.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ObjectList.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ObjectList.java Mon Jul 28 14:35:50 2014
@@ -29,15 +29,15 @@ public class ObjectList<E> extends Array
public ObjectList() {
}
- public ObjectList(Collection collection) {
+ public ObjectList(final Collection collection) {
super(collection);
}
- public ObjectList(int i) {
+ public ObjectList(final int i) {
super(i);
}
- private static int compare(Object a, Object b) {
+ private static int compare(final Object a, final Object b) {
if (a instanceof Comparable) {
return ((Comparable) a).compareTo(b);
} else {
@@ -45,11 +45,11 @@ public class ObjectList<E> extends Array
}
}
- public Object min(String field) {
+ public Object min(final String field) {
return Collections.min(this, getComparator(field));
}
- public Object max(String field) {
+ public Object max(final String field) {
return Collections.max(this, getComparator(field));
}
@@ -75,19 +75,19 @@ public class ObjectList<E> extends Array
// }
// }
- public List collect(String field) {
+ public List collect(final String field) {
if (size() == 0) return this;
- Accessor accessor = new Accessor(field, this);
+ final Accessor accessor = new Accessor(field, this);
boolean ObjectData = true;
- List collection = new ArrayList();
+ final List collection = new ArrayList();
for (int i = 0; i < this.size(); i++) {
- Object Object = (Object) this.get(i);
- Object value = accessor.getValue(Object);
+ final Object Object = (Object) this.get(i);
+ final Object value = accessor.getValue(Object);
if (value instanceof List) {
- List list = (List) value;
+ final List list = (List) value;
for (int j = 0; j < list.size(); j++) {
- Object object = list.get(j);
+ final Object object = list.get(j);
collection.add(object);
ObjectData = ObjectData && object instanceof Object;
}
@@ -104,14 +104,14 @@ public class ObjectList<E> extends Array
}
}
- public ObjectList<E> unique(String field) {
+ public ObjectList<E> unique(final String field) {
if (size() == 0) return this;
- Accessor accessor = new Accessor(field, this);
- ObjectList subset = new ObjectList();
- List uniqueList = new ArrayList();
+ final Accessor accessor = new Accessor(field, this);
+ final ObjectList subset = new ObjectList();
+ final List uniqueList = new ArrayList();
for (int i = 0; i < this.size(); i++) {
- Object Object = (Object) this.get(i);
- Object value = accessor.getValue(Object);
+ final Object Object = (Object) this.get(i);
+ final Object value = accessor.getValue(Object);
if (!uniqueList.contains(value)) {
uniqueList.add(value);
subset.add(Object);
@@ -129,10 +129,10 @@ public class ObjectList<E> extends Array
* @param list
* @return new list c = a + b
*/
- public ObjectList<E> union(List list) {
- ObjectList difference = new ObjectList(this);
+ public ObjectList<E> union(final List list) {
+ final ObjectList difference = new ObjectList(this);
for (int i = 0; i < list.size(); i++) {
- Object object = list.get(i);
+ final Object object = list.get(i);
if (!this.contains(object)) {
difference.add(object);
}
@@ -150,10 +150,10 @@ public class ObjectList<E> extends Array
* @param list
* @return new list c = a && b
*/
- public ObjectList<E> intersection(List list) {
- ObjectList common = new ObjectList();
+ public ObjectList<E> intersection(final List list) {
+ final ObjectList common = new ObjectList();
for (int i = 0; i < this.size(); i++) {
- Object object = this.get(i);
+ final Object object = this.get(i);
if (list.contains(object)) {
common.add(object);
}
@@ -167,7 +167,7 @@ public class ObjectList<E> extends Array
* @param list
* @return new list c = a && b
*/
- public ObjectList<E> common(List list) {
+ public ObjectList<E> common(final List list) {
return intersection(list);
}
@@ -179,10 +179,10 @@ public class ObjectList<E> extends Array
* @param list
* @return new list c = a - b
*/
- public ObjectList<E> subtract(List list) {
- ObjectList subtract = new ObjectList(this);
+ public ObjectList<E> subtract(final List list) {
+ final ObjectList subtract = new ObjectList(this);
for (int i = 0; i < list.size(); i++) {
- Object object = list.get(i);
+ final Object object = list.get(i);
subtract.remove(object);
}
return subtract;
@@ -202,10 +202,10 @@ public class ObjectList<E> extends Array
* @param list
* @return new list c = a XOR b
*/
- public ObjectList<E> difference(List list) {
- ObjectList difference = new ObjectList(this);
+ public ObjectList<E> difference(final List list) {
+ final ObjectList difference = new ObjectList(this);
for (int i = 0; i < list.size(); i++) {
- Object object = list.get(i);
+ final Object object = list.get(i);
if (this.contains(object)) {
difference.remove(object);
} else {
@@ -215,44 +215,44 @@ public class ObjectList<E> extends Array
return difference;
}
- public int sum(String field) {
+ public int sum(final String field) {
if (size() == 0) return 0;
int sum = 0;
- Accessor accessor = new Accessor(field, this);
+ final Accessor accessor = new Accessor(field, this);
for (int i = 0; i < this.size(); i++) {
try {
- Object Object = (Object) this.get(i);
+ final Object Object = (Object) this.get(i);
sum += accessor.intValue(Object);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
}
}
return sum;
}
- public int average(String field) {
+ public int average(final String field) {
if (size() == 0) return 0;
int sum = 0;
- Accessor accessor = new Accessor(field, this);
+ final Accessor accessor = new Accessor(field, this);
int count = 0;
for (int i = 0; i < this.size(); i++) {
try {
- Object Object = (Object) this.get(i);
+ final Object Object = (Object) this.get(i);
sum += accessor.intValue(Object);
count++;
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
}
}
return (sum == 0) ? sum : sum / count;
}
- public ObjectList<E> contains(String field, String string) {
+ public ObjectList<E> contains(final String field, final String string) {
if (size() == 0) return this;
- Accessor accessor = new Accessor(field, this);
- ObjectList subset = new ObjectList();
+ final Accessor accessor = new Accessor(field, this);
+ final ObjectList subset = new ObjectList();
for (int i = 0; i < this.size(); i++) {
- Object Object = (Object) this.get(i);
- String value = accessor.stringValue(Object);
+ final Object Object = (Object) this.get(i);
+ final String value = accessor.stringValue(Object);
if (value != null && value.indexOf(string) != -1) {
subset.add(Object);
}
@@ -260,14 +260,14 @@ public class ObjectList<E> extends Array
return subset;
}
- public ObjectList<E> matches(String field, String string) {
+ public ObjectList<E> matches(final String field, final String string) {
if (size() == 0) return this;
- Pattern pattern = Pattern.compile(string);
- Accessor accessor = new Accessor(field, this);
- ObjectList subset = new ObjectList();
+ final Pattern pattern = Pattern.compile(string);
+ final Accessor accessor = new Accessor(field, this);
+ final ObjectList subset = new ObjectList();
for (int i = 0; i < this.size(); i++) {
- Object Object = (Object) this.get(i);
- String value = accessor.stringValue(Object);
+ final Object Object = (Object) this.get(i);
+ final String value = accessor.stringValue(Object);
if (value != null && pattern.matcher(value).matches()) {
subset.add(Object);
}
@@ -275,13 +275,13 @@ public class ObjectList<E> extends Array
return subset;
}
- public ObjectList<E> equals(String field, String string) {
+ public ObjectList<E> equals(final String field, final String string) {
if (size() == 0) return this;
- Accessor accessor = new Accessor(field, this);
- ObjectList subset = new ObjectList();
+ final Accessor accessor = new Accessor(field, this);
+ final ObjectList subset = new ObjectList();
for (int i = 0; i < this.size(); i++) {
- Object Object = (Object) this.get(i);
- String value = accessor.stringValue(Object);
+ final Object Object = (Object) this.get(i);
+ final String value = accessor.stringValue(Object);
if (value != null && value.equals(string)) {
subset.add(Object);
}
@@ -289,19 +289,19 @@ public class ObjectList<E> extends Array
return subset;
}
- public ObjectList<E> greater(String field, String string) {
+ public ObjectList<E> greater(final String field, final String string) {
return compareAndCollect(field, string, 1);
}
- public ObjectList<E> less(String field, String string) {
+ public ObjectList<E> less(final String field, final String string) {
return compareAndCollect(field, string, -1);
}
- public ObjectList<E> greater(String field, Object object) {
+ public ObjectList<E> greater(final String field, final Object object) {
return compareAndCollect(field, object, 1);
}
- public ObjectList<E> less(String field, Object object) {
+ public ObjectList<E> less(final String field, final Object object) {
return compareAndCollect(field, object, -1);
}
@@ -310,7 +310,7 @@ public class ObjectList<E> extends Array
*
* @param field
*/
- public ObjectList<E> ascending(String field) {
+ public ObjectList<E> ascending(final String field) {
return sort(field);
}
@@ -319,26 +319,26 @@ public class ObjectList<E> extends Array
*
* @param field
*/
- public ObjectList<E> descending(String field) {
+ public ObjectList<E> descending(final String field) {
return sort(field, true);
}
- public ObjectList<E> sort(String field) {
+ public ObjectList<E> sort(final String field) {
return sort(field, false);
}
- public ObjectList<E> sort(String field, boolean reverse) {
+ public ObjectList<E> sort(final String field, final boolean reverse) {
if (size() == 0) return this;
Comparator comparator = getComparator(field);
comparator = reverse ? new ReverseComparator(comparator) : comparator;
- ObjectList list = new ObjectList(this);
+ final ObjectList list = new ObjectList(this);
Collections.sort(list, comparator);
return list;
}
- private ObjectList compareAndCollect(String field, Object valueB, int condition) {
+ private ObjectList compareAndCollect(final String field, final Object valueB, final int condition) {
if (size() == 0) return this;
try {
@@ -350,16 +350,16 @@ public class ObjectList<E> extends Array
final Object object = get(i);
final Object valueA = accessor.getValue(object);
- int result = ObjectList.compare(valueA, valueB);
+ final int result = ObjectList.compare(valueA, valueB);
if (result / condition > 0) {
subset.add(object);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
}
}
return subset;
- } catch (Exception e) {
+ } catch (final Exception e) {
return new ObjectList();
}
}
@@ -379,18 +379,18 @@ public class ObjectList<E> extends Array
// return subset;
// }
- private Comparator getComparator(String field) {
+ private Comparator getComparator(final String field) {
return new FieldComparator(new Accessor(field, this));
}
private static class ReverseComparator implements Comparator {
private final Comparator comparator;
- public ReverseComparator(Comparator comparator) {
+ public ReverseComparator(final Comparator comparator) {
this.comparator = comparator;
}
- public int compare(Object a, Object b) {
+ public int compare(final Object a, final Object b) {
return -1 * comparator.compare(a, b);
}
}
@@ -398,16 +398,16 @@ public class ObjectList<E> extends Array
private static class FieldComparator implements Comparator {
private final Accessor accessor;
- public FieldComparator(Accessor accessor) {
+ public FieldComparator(final Accessor accessor) {
this.accessor = accessor;
}
- public int compare(Object objectA, Object objectB) {
+ public int compare(final Object objectA, final Object objectB) {
try {
- Object a = accessor.getValue((Object) objectA);
- Object b = accessor.getValue((Object) objectB);
+ final Object a = accessor.getValue((Object) objectA);
+ final Object b = accessor.getValue((Object) objectB);
return ObjectList.compare(a, b);
- } catch (Exception e) {
+ } catch (final Exception e) {
return 0;
}
}
@@ -417,40 +417,40 @@ public class ObjectList<E> extends Array
private final Method method;
- public Accessor(String field, List list) {
+ public Accessor(final String field, final List list) {
this.method = method(list, field);
}
- private Method method(List list, String field) {
+ private Method method(final List list, final String field) {
try {
final Object first = (Object) list.get(0);
final StringBuilder sb = new StringBuilder(field);
sb.setCharAt(0, Character.toUpperCase(sb.charAt(0)));
return first.getClass().getMethod("get" + sb);
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
return null;
}
- public Object getValue(Object Object) {
+ public Object getValue(final Object Object) {
try {
return method.invoke(Object);
- } catch (Exception e) {
+ } catch (final Exception e) {
return null;
}
}
- public int intValue(Object Object) throws java.lang.NumberFormatException {
- Object value = getValue(Object);
+ public int intValue(final Object Object) throws java.lang.NumberFormatException {
+ final Object value = getValue(Object);
if (value instanceof Number) {
- Number number = (Number) value;
+ final Number number = (Number) value;
return number.intValue();
}
return new Integer(value.toString()).intValue();
}
- public String stringValue(Object Object) {
+ public String stringValue(final Object Object) {
final Object value = getValue(Object);
return (value == null) ? null : value.toString();
}
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ObjectMap.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ObjectMap.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ObjectMap.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/ObjectMap.java Mon Jul 28 14:35:50 2014
@@ -30,25 +30,25 @@ public class ObjectMap extends AbstractM
private Map<String, Entry<String, Object>> attributes;
private Set<Entry<String, Object>> entries;
- public ObjectMap(Object object) {
+ public ObjectMap(final Object object) {
this(object.getClass(), object);
}
- public ObjectMap(Class clazz) {
+ public ObjectMap(final Class clazz) {
this(clazz, null);
}
- public ObjectMap(Class<?> clazz, Object object) {
+ public ObjectMap(final Class<?> clazz, final Object object) {
this.object = object;
attributes = new HashMap<String, Entry<String, Object>>();
- for (Field field : clazz.getFields()) {
+ for (final Field field : clazz.getFields()) {
final FieldEntry entry = new FieldEntry(field);
attributes.put(entry.getKey(), entry);
}
- for (Method getter : clazz.getMethods()) {
+ for (final Method getter : clazz.getMethods()) {
try {
if (getter.getName().startsWith("get")) continue;
if (getter.getParameterTypes().length != 0) continue;
@@ -60,7 +60,7 @@ public class ObjectMap extends AbstractM
final MethodEntry entry = new MethodEntry(getter, setter);
attributes.put(entry.getKey(), entry);
- } catch (NoSuchMethodException e) {
+ } catch (final NoSuchMethodException e) {
}
}
@@ -68,26 +68,26 @@ public class ObjectMap extends AbstractM
}
@Override
- public Object get(Object key) {
+ public Object get(final Object key) {
final Entry<String, Object> entry = attributes.get(key);
if (entry == null) return null;
return entry.getValue();
}
@Override
- public Object put(String key, Object value) {
+ public Object put(final String key, final Object value) {
final Entry<String, Object> entry = attributes.get(key);
if (entry == null) return null;
return entry.setValue(value);
}
@Override
- public boolean containsKey(Object key) {
+ public boolean containsKey(final Object key) {
return attributes.containsKey(key);
}
@Override
- public Object remove(Object key) {
+ public Object remove(final Object key) {
throw new UnsupportedOperationException();
}
@@ -100,7 +100,7 @@ public class ObjectMap extends AbstractM
private final Field field;
- public FieldEntry(Field field) {
+ public FieldEntry(final Field field) {
this.field = field;
}
@@ -113,18 +113,18 @@ public class ObjectMap extends AbstractM
public String getValue() {
try {
return (String) field.get(object);
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
throw new IllegalStateException(e);
}
}
@Override
- public Object setValue(Object value) {
+ public Object setValue(final Object value) {
try {
final Object replaced = getValue();
field.set(object, value);
return replaced;
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
throw new IllegalArgumentException(e);
}
}
@@ -135,8 +135,8 @@ public class ObjectMap extends AbstractM
private final Method getter;
private final Method setter;
- public MethodEntry(Method getter, Method setter) {
- StringBuilder name = new StringBuilder(getter.getName());
+ public MethodEntry(final Method getter, final Method setter) {
+ final StringBuilder name = new StringBuilder(getter.getName());
// remove 'set' or 'get'
name.delete(0, 3);
@@ -149,12 +149,12 @@ public class ObjectMap extends AbstractM
this.setter = setter;
}
- protected Object invoke(Method method, Object... args) {
+ protected Object invoke(final Method method, final Object... args) {
try {
return method.invoke(object, args);
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
throw new IllegalStateException(e);
- } catch (InvocationTargetException e) {
+ } catch (final InvocationTargetException e) {
throw new RuntimeException(e.getCause());
}
}
@@ -170,7 +170,7 @@ public class ObjectMap extends AbstractM
}
@Override
- public Object setValue(Object value) {
+ public Object setValue(final Object value) {
final Object original = getValue();
invoke(setter, value);
return original;
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Options.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Options.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Options.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Options.java Mon Jul 28 14:35:50 2014
@@ -66,11 +66,11 @@ public class Options {
private final Options parent;
private final Properties properties;
- public Options(Properties properties) {
+ public Options(final Properties properties) {
this(properties, new NullOptions());
}
- public Options(Properties properties, Options parent) {
+ public Options(final Properties properties, final Options parent) {
this.parent = parent;
this.properties = properties;
}
@@ -79,7 +79,7 @@ public class Options {
return properties;
}
- public void setLogger(Log logger) {
+ public void setLogger(final Log logger) {
parent.setLogger(logger);
}
@@ -87,128 +87,128 @@ public class Options {
return parent.getLogger();
}
- public boolean has(String property) {
+ public boolean has(final String property) {
return properties.containsKey(property) || parent.has(property);
}
- public String get(String property, String defaultValue) {
- String value = properties.getProperty(property);
+ public String get(final String property, final String defaultValue) {
+ final String value = properties.getProperty(property);
return value != null ? log(property, value) : parent.get(property, defaultValue);
}
- public <T> T get(String property, T defaultValue) {
+ public <T> T get(final String property, final T defaultValue) {
if (defaultValue == null) throw new NullPointerException("defaultValue");
- String value = properties.getProperty(property);
+ final String value = properties.getProperty(property);
if (value == null || value.equals("")) return parent.get(property, defaultValue);
try {
- Class<?> type = defaultValue.getClass();
- Constructor<?> constructor = type.getConstructor(String.class);
- T t = (T) constructor.newInstance(value);
+ final Class<?> type = defaultValue.getClass();
+ final Constructor<?> constructor = type.getConstructor(String.class);
+ final T t = (T) constructor.newInstance(value);
return log(property, t);
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
warn(property, value, e);
return parent.get(property, defaultValue);
}
}
- public int get(String property, int defaultValue) {
- String value = properties.getProperty(property);
+ public int get(final String property, final int defaultValue) {
+ final String value = properties.getProperty(property);
if (value == null || value.equals("")) return parent.get(property, defaultValue);
try {
return log(property, Integer.parseInt(value));
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
warn(property, value, e);
return parent.get(property, defaultValue);
}
}
- public long get(String property, long defaultValue) {
- String value = properties.getProperty(property);
+ public long get(final String property, final long defaultValue) {
+ final String value = properties.getProperty(property);
if (value == null || value.equals("")) return parent.get(property, defaultValue);
try {
return log(property, Long.parseLong(value));
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
warn(property, value, e);
return parent.get(property, defaultValue);
}
}
- public boolean get(String property, boolean defaultValue) {
- String value = properties.getProperty(property);
+ public boolean get(final String property, final boolean defaultValue) {
+ final String value = properties.getProperty(property);
if (value == null || value.equals("")) return parent.get(property, defaultValue);
try {
return log(property, Boolean.parseBoolean(value));
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
warn(property, value, e);
return parent.get(property, defaultValue);
}
}
- public Class<?> get(String property, Class<?> defaultValue) {
- String className = properties.getProperty(property);
+ public Class<?> get(final String property, final Class<?> defaultValue) {
+ final String className = properties.getProperty(property);
if (className == null) return parent.get(property, defaultValue);
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
return log(property, classLoader.loadClass(className));
- } catch (Exception e) {
+ } catch (final Exception e) {
getLogger().warning("Could not load " + property + " : " + className, e);
return parent.get(property, defaultValue);
}
}
- public <T extends Enum<T>> T get(String property, T defaultValue) {
- String value = properties.getProperty(property);
+ public <T extends Enum<T>> T get(final String property, final T defaultValue) {
+ final String value = properties.getProperty(property);
if (value == null || value.equals("")) return parent.get(property, defaultValue);
if (defaultValue == null) throw new IllegalArgumentException("Must supply a default for property " + property);
- Class<T> enumType = (Class<T>) defaultValue.getClass();
+ final Class<T> enumType = (Class<T>) defaultValue.getClass();
try {
return log(property, valueOf(enumType, value.toUpperCase()));
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
warn(property, value);
return parent.get(property, defaultValue);
}
}
- public <T extends Enum<T>> Set<T> getAll(String property, T... defaultValue) {
- EnumSet<T> defaults = EnumSet.copyOf(Arrays.asList(defaultValue));
+ public <T extends Enum<T>> Set<T> getAll(final String property, final T... defaultValue) {
+ final EnumSet<T> defaults = EnumSet.copyOf(Arrays.asList(defaultValue));
return getAll(property, defaults);
}
- public <T extends Enum<T>> Set<T> getAll(String property, Set<T> defaultValue) {
- Class<T> enumType;
+ public <T extends Enum<T>> Set<T> getAll(final String property, final Set<T> defaultValue) {
+ final Class<T> enumType;
try {
- T t = defaultValue.iterator().next();
+ final T t = defaultValue.iterator().next();
enumType = (Class<T>) t.getClass();
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new IllegalArgumentException("Must supply a default for property " + property);
}
return getAll(property, defaultValue, enumType);
}
- public <T extends Enum<T>> Set<T> getAll(String property, Class<T> enumType) {
+ public <T extends Enum<T>> Set<T> getAll(final String property, final Class<T> enumType) {
return getAll(property, Collections.EMPTY_SET, enumType);
}
- protected <T extends Enum<T>> Set<T> getAll(String property, Set<T> defaultValue, Class<T> enumType) {
- String value = properties.getProperty(property);
+ protected <T extends Enum<T>> Set<T> getAll(final String property, final Set<T> defaultValue, final Class<T> enumType) {
+ final String value = properties.getProperty(property);
if (value == null || value.equals("")) return parent.getAll(property, defaultValue, enumType);
@@ -223,15 +223,15 @@ public class Options {
}
try {
- String[] values = value.split(",");
- EnumSet<T> set = EnumSet.noneOf(enumType);
+ final String[] values = value.split(",");
+ final EnumSet<T> set = EnumSet.noneOf(enumType);
for (String s : values) {
s = s.trim();
set.add(valueOf(enumType, s.toUpperCase()));
}
return logAll(property, set);
- } catch (IllegalArgumentException e) {
+ } catch (final IllegalArgumentException e) {
warn(property, value);
return parent.getAll(property, defaultValue, enumType);
}
@@ -246,13 +246,13 @@ public class Options {
* @param <T>
* @return
*/
- public static <T extends Enum<T>> T valueOf(Class<T> enumType, String name) {
- Map<String, T> map = new HashMap<String, T>();
- for (T t : enumType.getEnumConstants()) {
+ public static <T extends Enum<T>> T valueOf(final Class<T> enumType, final String name) {
+ final Map<String, T> map = new HashMap<String, T>();
+ for (final T t : enumType.getEnumConstants()) {
map.put(t.name().toUpperCase(), t);
}
- T value = map.get(name.toUpperCase());
+ final T value = map.get(name.toUpperCase());
// Call Enum.valueOf for the clean exception
if (value == null || value.equals("")) Enum.valueOf(enumType, name);
@@ -260,19 +260,19 @@ public class Options {
return value;
}
- private void warn(String property, String value) {
+ private void warn(final String property, final String value) {
getLogger().warning("Cannot parse supplied value \"" + value + "\" for option \"" + property + "\"");
}
- private void warn(String property, String value, Exception e) {
+ private void warn(final String property, final String value, final Exception e) {
getLogger().warning("Cannot parse supplied value \"" + value + "\" for option \"" + property + "\"", e);
}
- private <V> V log(String property, V value) {
+ private <V> V log(final String property, final V value) {
if (!getLogger().isInfoEnabled()) return value;
if (value instanceof Class) {
- Class clazz = (Class) value;
+ final Class clazz = (Class) value;
getLogger().info("Using \'" + property + "=" + clazz.getName() + "\'");
} else {
getLogger().info("Using \'" + property + "=" + value + "\'");
@@ -280,7 +280,7 @@ public class Options {
return value;
}
- public <T extends Enum<T>> Set<T> logAll(String property, Set<T> value) {
+ public <T extends Enum<T>> Set<T> logAll(final String property, final Set<T> value) {
if (!getLogger().isInfoEnabled()) return value;
getLogger().info("Using \'" + property + "=" + join(", ", lowercase(value)) + "\'");
@@ -289,36 +289,36 @@ public class Options {
}
- protected static <T extends Enum<T>> String[] lowercase(T... items) {
- String[] values = new String[items.length];
+ protected static <T extends Enum<T>> String[] lowercase(final T... items) {
+ final String[] values = new String[items.length];
for (int i = 0; i < items.length; i++) {
values[i] = items[i].name().toLowerCase();
}
return values;
}
- protected static <T extends Enum<T>> String[] lowercase(Collection<T> items) {
- String[] values = new String[items.size()];
+ protected static <T extends Enum<T>> String[] lowercase(final Collection<T> items) {
+ final String[] values = new String[items.size()];
int i = 0;
- for (T item : items) {
+ for (final T item : items) {
values[i++] = item.name().toLowerCase();
}
return values;
}
- protected static <V extends Enum<V>> String possibleValues(V v) {
- Class<? extends Enum> enumType = v.getClass();
+ protected static <V extends Enum<V>> String possibleValues(final V v) {
+ final Class<? extends Enum> enumType = v.getClass();
return possibleValues(enumType);
}
- protected static String possibleValues(Class<? extends Enum> enumType) {
+ protected static String possibleValues(final Class<? extends Enum> enumType) {
return join(", ", lowercase(enumType.getEnumConstants()));
}
- public static String join(String delimiter, Object... collection) {
- StringBuilder sb = new StringBuilder();
- for (Object obj : collection) {
+ public static String join(final String delimiter, final Object... collection) {
+ final StringBuilder sb = new StringBuilder();
+ for (final Object obj : collection) {
sb.append(obj).append(delimiter);
}
if (collection.length > 0) sb.delete(sb.length() - delimiter.length(), sb.length());
@@ -340,53 +340,53 @@ public class Options {
}
@Override
- public void setLogger(Log logger) {
+ public void setLogger(final Log logger) {
this.logger = logger;
}
@Override
- public boolean has(String property) {
+ public boolean has(final String property) {
return false;
}
@Override
- public <T> T get(String property, T defaultValue) {
+ public <T> T get(final String property, final T defaultValue) {
return log(property, defaultValue);
}
@Override
- public int get(String property, int defaultValue) {
+ public int get(final String property, final int defaultValue) {
return log(property, defaultValue);
}
@Override
- public long get(String property, long defaultValue) {
+ public long get(final String property, final long defaultValue) {
return log(property, defaultValue);
}
@Override
- public boolean get(String property, boolean defaultValue) {
+ public boolean get(final String property, final boolean defaultValue) {
return log(property, defaultValue);
}
@Override
- public <T extends Enum<T>> T get(String property, T defaultValue) {
+ public <T extends Enum<T>> T get(final String property, final T defaultValue) {
return log(property, defaultValue);
}
@Override
- public <T extends Enum<T>> Set<T> getAll(String property, T... defaultValue) {
+ public <T extends Enum<T>> Set<T> getAll(final String property, final T... defaultValue) {
return EnumSet.copyOf(Arrays.asList(defaultValue));
}
@Override
- protected <T extends Enum<T>> Set<T> getAll(String property, Set<T> defaults, Class<T> enumType) {
+ protected <T extends Enum<T>> Set<T> getAll(final String property, final Set<T> defaults, final Class<T> enumType) {
if (getLogger().isDebugEnabled()) {
String possibleValues = " Possible values are: " + possibleValues(enumType);
possibleValues += " or NONE or ALL";
- String defaultValues;
+ final String defaultValues;
if (defaults.size() == 0) {
defaultValues = "NONE";
@@ -403,22 +403,22 @@ public class Options {
}
@Override
- public String get(String property, String defaultValue) {
+ public String get(final String property, final String defaultValue) {
return log(property, defaultValue);
}
@Override
- public Class<?> get(String property, Class<?> defaultValue) {
+ public Class<?> get(final String property, final Class<?> defaultValue) {
return log(property, defaultValue);
}
- private <V> V log(String property, V value) {
+ private <V> V log(final String property, final V value) {
if (getLogger().isDebugEnabled()) {
if (value instanceof Enum) {
- Enum anEnum = (Enum) value;
+ final Enum anEnum = (Enum) value;
getLogger().debug("Using default \'" + property + "=" + anEnum.name().toLowerCase() + "\'. Possible values are: " + possibleValues(anEnum));
} else if (value instanceof Class) {
- Class clazz = (Class) value;
+ final Class clazz = (Class) value;
getLogger().debug("Using default \'" + property + "=" + clazz.getName() + "\'");
} else if (value != null) {
logger.debug("Using default \'" + property + "=" + value + "\'");
@@ -461,22 +461,22 @@ public class Options {
return false;
}
- public void warning(String message, Throwable t) {
+ public void warning(final String message, final Throwable t) {
}
- public void warning(String message) {
+ public void warning(final String message) {
}
- public void debug(String message, Throwable t) {
+ public void debug(final String message, final Throwable t) {
}
- public void debug(String message) {
+ public void debug(final String message) {
}
- public void info(String message, Throwable t) {
+ public void info(final String message, final Throwable t) {
}
- public void info(String message) {
+ public void info(final String message) {
}
}
}
Modified: tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Pipe.java
URL: http://svn.apache.org/viewvc/tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Pipe.java?rev=1614041&r1=1614040&r2=1614041&view=diff
==============================================================================
--- tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Pipe.java (original)
+++ tomee/sandbox/release-tools/src/main/java/org/apache/openejb/tools/release/util/Pipe.java Mon Jul 28 14:35:50 2014
@@ -27,18 +27,18 @@ public final class Pipe implements Runna
private final InputStream in;
private final OutputStream out;
- public Pipe(InputStream in, OutputStream out) {
+ public Pipe(final InputStream in, final OutputStream out) {
this.in = in;
this.out = out;
}
- public static void pipe(Process process) {
+ public static void pipe(final Process process) {
pipe(process.getInputStream(), System.out);
pipe(process.getErrorStream(), System.err);
// pipe(System.in, process.getOutputStream());
}
- public static void pipe(InputStream in, OutputStream out) {
+ public static void pipe(final InputStream in, final OutputStream out) {
final Thread thread = new Thread(new Pipe(in, out));
thread.setDaemon(true);
thread.start();
@@ -48,12 +48,12 @@ public final class Pipe implements Runna
try {
int i = -1;
- byte[] buf = new byte[1024];
+ final byte[] buf = new byte[1024];
while ((i = in.read(buf)) != -1) {
out.write(buf, 0, i);
}
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
}
}