Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into new-html-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
LadyCailin committed Sep 29, 2017
2 parents 63ee648 + b7607a5 commit f935722
Show file tree
Hide file tree
Showing 26 changed files with 7,230 additions and 5,058 deletions.
16 changes: 14 additions & 2 deletions src/main/java/com/laytonsmith/PureUtilities/Common/ArrayUtils.java
Expand Up @@ -129,6 +129,7 @@ public class ArrayUtils {
* @param finish The ending node (inclusive). * @param finish The ending node (inclusive).
* @return * @return
*/ */
@SuppressWarnings("unchecked")
public static <T> T [] slice(T[] array, int start, int finish){ public static <T> T [] slice(T[] array, int start, int finish){
int size = Math.abs(start - finish) + 1; int size = Math.abs(start - finish) + 1;
Object newArray = Array.newInstance(array.getClass().getComponentType(), size); Object newArray = Array.newInstance(array.getClass().getComponentType(), size);
Expand Down Expand Up @@ -365,6 +366,7 @@ public class ArrayUtils {
* @param array The "boxed" array * @param array The "boxed" array
* @return The "unboxed" array * @return The "unboxed" array
*/ */
@SuppressWarnings("UnnecessaryUnboxing")
public static char[] unbox(Character[] array){ public static char[] unbox(Character[] array){
if(array == null){ if(array == null){
return null; return null;
Expand All @@ -384,6 +386,7 @@ public static char[] unbox(Character[] array){
* @param array The "boxed" array * @param array The "boxed" array
* @return The "unboxed" array * @return The "unboxed" array
*/ */
@SuppressWarnings("UnnecessaryUnboxing")
public static byte[] unbox(Byte[] array){ public static byte[] unbox(Byte[] array){
if(array == null){ if(array == null){
return null; return null;
Expand All @@ -403,6 +406,7 @@ public static byte[] unbox(Byte[] array){
* @param array The "boxed" array * @param array The "boxed" array
* @return The "unboxed" array * @return The "unboxed" array
*/ */
@SuppressWarnings("UnnecessaryUnboxing")
public static short[] unbox(Short[] array){ public static short[] unbox(Short[] array){
if(array == null){ if(array == null){
return null; return null;
Expand All @@ -422,6 +426,7 @@ public static short[] unbox(Short[] array){
* @param array The "boxed" array * @param array The "boxed" array
* @return The "unboxed" array * @return The "unboxed" array
*/ */
@SuppressWarnings("UnnecessaryUnboxing")
public static int[] unbox(Integer[] array){ public static int[] unbox(Integer[] array){
if(array == null){ if(array == null){
return null; return null;
Expand All @@ -441,6 +446,7 @@ public static int[] unbox(Integer[] array){
* @param array The "boxed" array * @param array The "boxed" array
* @return The "unboxed" array * @return The "unboxed" array
*/ */
@SuppressWarnings("UnnecessaryUnboxing")
public static long[] unbox(Long[] array){ public static long[] unbox(Long[] array){
if(array == null){ if(array == null){
return null; return null;
Expand All @@ -460,6 +466,7 @@ public static long[] unbox(Long[] array){
* @param array The "boxed" array * @param array The "boxed" array
* @return The "unboxed" array * @return The "unboxed" array
*/ */
@SuppressWarnings("UnnecessaryUnboxing")
public static float[] unbox(Float[] array){ public static float[] unbox(Float[] array){
if(array == null){ if(array == null){
return null; return null;
Expand All @@ -479,6 +486,7 @@ public static float[] unbox(Float[] array){
* @param array The "boxed" array * @param array The "boxed" array
* @return The "unboxed" array * @return The "unboxed" array
*/ */
@SuppressWarnings("UnnecessaryUnboxing")
public static double[] unbox(Double[] array){ public static double[] unbox(Double[] array){
if(array == null){ if(array == null){
return null; return null;
Expand All @@ -498,6 +506,7 @@ public static double[] unbox(Double[] array){
* @param array The "boxed" array * @param array The "boxed" array
* @return The "unboxed" array * @return The "unboxed" array
*/ */
@SuppressWarnings("UnnecessaryUnboxing")
public static boolean[] unbox(Boolean[] array){ public static boolean[] unbox(Boolean[] array){
if(array == null){ if(array == null){
return null; return null;
Expand Down Expand Up @@ -677,10 +686,11 @@ public static Boolean[] box(boolean[] array){
* @param list * @param list
* @return * @return
*/ */
public static <T> T[] asArray(Class<T> clazz, List<?> list){ @SuppressWarnings("unchecked")
public static <T> T[] asArray(Class<T> clazz, List<T> list){
T[] obj = (T[]) Array.newInstance(clazz, list.size()); T[] obj = (T[]) Array.newInstance(clazz, list.size());
for(int i = 0; i < list.size(); i++){ for(int i = 0; i < list.size(); i++){
obj[i] = (T)list.get(i); obj[i] = list.get(i);
} }
return obj; return obj;
} }
Expand All @@ -695,6 +705,7 @@ public static <T> T[] asArray(Class<T> clazz, List<?> list){
* @param toClass * @param toClass
* @return * @return
*/ */
@SuppressWarnings("unchecked")
public static <T> T cast(Object array, Class<T> toArrayClass){ public static <T> T cast(Object array, Class<T> toArrayClass){
if(!array.getClass().isArray()){ if(!array.getClass().isArray()){
throw new ClassCastException(); throw new ClassCastException();
Expand All @@ -709,6 +720,7 @@ public static <T> T cast(Object array, Class<T> toArrayClass){
return (T)obj; return (T)obj;
} }


@SuppressWarnings("UnnecessaryUnboxing")
private static void doSet(Object array, int index, Object o){ private static void doSet(Object array, int index, Object o){
Class<?> componentType = array.getClass().getComponentType(); Class<?> componentType = array.getClass().getComponentType();
if(componentType.isPrimitive()){ if(componentType.isPrimitive()){
Expand Down
Expand Up @@ -4,6 +4,7 @@
import java.net.Proxy; import java.net.Proxy;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
Expand All @@ -24,9 +25,12 @@ public class RequestSettings {
private Proxy proxy = null; private Proxy proxy = null;
private byte[] rawParameter; private byte[] rawParameter;
private File downloadTo; private File downloadTo;
private boolean blocking = false;
private boolean disableCertChecking = false;
private boolean useDefaultTrustStore = true;
private LinkedHashMap<String, String> trustStore = new LinkedHashMap<>();
@SuppressWarnings("NonConstantLogger") @SuppressWarnings("NonConstantLogger")
private Logger logger; private Logger logger;
private boolean blocking;


/** /**
* *
Expand Down Expand Up @@ -284,4 +288,70 @@ public boolean getBlocking() {
return this.blocking; return this.blocking;
} }


/**
* Sets whether or not cert checking is disabled. If this is true, NO certificate checking is done, and all
* certificates will be considered valid. If this is true, {@link #setUseDefaultTrustStore(boolean)} and
* {@link #setTrustStore(java.util.Map)} are ignored.
*
* @param check
* @return
*/
public RequestSettings setDisableCertChecking(boolean check) {
this.disableCertChecking = check;
return this;
}

/**
* Returns whether or not the trust store should be disabled. Default is false.
*
* @return
*/
public boolean getDisableCertChecking() {
return this.disableCertChecking;
}

/**
* Sets whether or not to use the default trust store. If false, then only certificates registered using
* {@link #setTrustStore(java.util.Map)} will be accepted. If this is false, and
* {@link #setTrustStore(java.util.Map)} is false, this effectively prevents any ssl connections.
*
* @param useDefaultTrustStore
* @return
*/
public RequestSettings setUseDefaultTrustStore(boolean useDefaultTrustStore) {
this.useDefaultTrustStore = useDefaultTrustStore;
return this;
}

/**
* Returns whether or not the default trust store should be used.
*
* @return
*/
public boolean getUseDefaultTrustStore() {
return this.useDefaultTrustStore;
}

/**
* Sets the trust store. Values should be in the form: "02 79 AB D6 97 19 A2 CB E8 79 11 B2 7F AF 8D": "SHA-256"
* where the key is the fingerprint, and the value is the encryption scheme. Note that the map is cloned, and the
* original map is not used.
*
* @param trustStore The trust store to use
* @return
*/
public RequestSettings setTrustStore(LinkedHashMap<String, String> trustStore) {
this.trustStore = new LinkedHashMap<>(trustStore);
return this;
}

/**
* Returns the trust store in use. Note that the map is cloned, and the original map is not used.
*
* @return
*/
public LinkedHashMap<String, String> getTrustStore() {
return new LinkedHashMap<>(trustStore);
}

} }

0 comments on commit f935722

Please sign in to comment.