Add recaptcha
This commit is contained in:
1 parent
550d3735c7
commit
2c3fa31e91
29 files changed
+1591
-519
No files matched your search
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2017 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.util;
|
||||
/*
|
||||
* Created by Hippo on 2017/9/4.
|
||||
*/
|
||||
|
||||
public class HashCodeUtils {
|
||||
|
||||
private static final int X = 31;
|
||||
|
||||
/**
|
||||
* <pre>{@code
|
||||
* args[0].hashCode()*31^(n-1) + args[1].hashCode()*31^(n-2) + ... + args[n-1].hashCode()
|
||||
* }</pre>
|
||||
* Returns 0 if {@code args == null}.
|
||||
*/
|
||||
public static int hashCode(Object... args) {
|
||||
if (args == null) {
|
||||
return 0;
|
||||
}
|
||||
int hash = 0;
|
||||
for (Object o: args) {
|
||||
hash = X * hash + (o != null ? o.hashCode() : 0);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
@@ -69,4 +69,54 @@ public class SqlUtils {
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static boolean getBoolean(Cursor cursor, String column, boolean defValue) {
|
||||
try {
|
||||
int index = cursor.getColumnIndex(column);
|
||||
if (index != -1) {
|
||||
return cursor.getInt(index) != 0;
|
||||
}
|
||||
} catch (Throwable e) { /* Ignore */ }
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public static int getInt(Cursor cursor, String column, int defValue) {
|
||||
try {
|
||||
int index = cursor.getColumnIndex(column);
|
||||
if (index != -1) {
|
||||
return cursor.getInt(index);
|
||||
}
|
||||
} catch (Throwable e) { /* Ignore */ }
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public static long getLong(Cursor cursor, String column, long defValue) {
|
||||
try {
|
||||
int index = cursor.getColumnIndex(column);
|
||||
if (index != -1) {
|
||||
return cursor.getLong(index);
|
||||
}
|
||||
} catch (Throwable e) { /* Ignore */ }
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public static float getFloat(Cursor cursor, String column, float defValue) {
|
||||
try {
|
||||
int index = cursor.getColumnIndex(column);
|
||||
if (index != -1) {
|
||||
return cursor.getFloat(index);
|
||||
}
|
||||
} catch (Throwable e) { /* Ignore */ }
|
||||
return defValue;
|
||||
}
|
||||
|
||||
public static String getString(Cursor cursor, String column, String defValue) {
|
||||
try {
|
||||
int index = cursor.getColumnIndex(column);
|
||||
if (index != -1) {
|
||||
return cursor.getString(index);
|
||||
}
|
||||
} catch (Throwable e) { /* Ignore */ }
|
||||
return defValue;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user