summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/Util.java
diff options
context:
space:
mode:
authorGravatar jeff2014-07-26 19:24:00 -0400
committerGravatar jeff2014-07-26 19:24:00 -0400
commit295eceece371b516e771de93b6127bf728999483 (patch)
tree20ff6a35de79997fc338d922cae934b8872b11a9 /src/cuchaz/enigma/Util.java
downloadenigma-fork-295eceece371b516e771de93b6127bf728999483.tar.gz
enigma-fork-295eceece371b516e771de93b6127bf728999483.tar.xz
enigma-fork-295eceece371b516e771de93b6127bf728999483.zip
initial commit
so far source analysis is working. =)
Diffstat (limited to 'src/cuchaz/enigma/Util.java')
-rw-r--r--src/cuchaz/enigma/Util.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/Util.java b/src/cuchaz/enigma/Util.java
new file mode 100644
index 0000000..c51eb62
--- /dev/null
+++ b/src/cuchaz/enigma/Util.java
@@ -0,0 +1,65 @@
1/*******************************************************************************
2 * Copyright (c) 2014 Jeff Martin.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Public License v3.0
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/gpl.html
7 *
8 * Contributors:
9 * Jeff Martin - initial API and implementation
10 ******************************************************************************/
11package cuchaz.enigma;
12
13import java.io.Closeable;
14import java.io.IOException;
15import java.util.jar.JarFile;
16
17
18public class Util
19{
20 public static int combineHashesOrdered( Object ... objs )
21 {
22 final int prime = 67;
23 int result = 1;
24 for( Object obj : objs )
25 {
26 result *= prime;
27 if( obj != null )
28 {
29 result += obj.hashCode();
30 }
31 }
32 return result;
33 }
34
35 public static void closeQuietly( Closeable closeable )
36 {
37 if( closeable != null )
38 {
39 try
40 {
41 closeable.close();
42 }
43 catch( IOException ex )
44 {
45 // just ignore any further exceptions
46 }
47 }
48 }
49
50 public static void closeQuietly( JarFile jarFile )
51 {
52 // silly library should implement Closeable...
53 if( jarFile != null )
54 {
55 try
56 {
57 jarFile.close();
58 }
59 catch( IOException ex )
60 {
61 // just ignore any further exceptions
62 }
63 }
64 }
65}