-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added many types in the list of avoided classes (#26)
* Added more classes from JNet * Reviewed some classes imported from JNet * Update configuration.json
- Loading branch information
1 parent
69670d1
commit d164a52
Showing
49 changed files
with
1,575 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
src/jvm/netdroid/src/main/java/org/mases/netdroid/developed/NetdroidHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
/* | ||
* Copyright 2024 MASES s.r.l. | ||
* | ||
* 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. | ||
* | ||
* Refer to LICENSE for more information. | ||
*/ | ||
|
||
package org.mases.netdroid.developed; | ||
|
||
import java.nio.ByteBuffer; | ||
import java.nio.CharBuffer; | ||
import java.nio.DoubleBuffer; | ||
import java.nio.FloatBuffer; | ||
import java.nio.IntBuffer; | ||
import java.nio.LongBuffer; | ||
import java.nio.ShortBuffer; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class NetdroidHelper { | ||
public static List<?> listFromPrimitiveArray(Object input) { | ||
if (input == null) throw new IllegalArgumentException("Input parameter is null"); | ||
|
||
if (input instanceof boolean[]) { | ||
final List<Boolean> l = new ArrayList<Boolean>(); | ||
for (final boolean s : (boolean[])input) { | ||
l.add(s); | ||
} | ||
return l; | ||
} | ||
else if (input instanceof byte[]) { | ||
final List<Byte> l = new ArrayList<Byte>(); | ||
for (final byte s : (byte[])input) { | ||
l.add(s); | ||
} | ||
return l; | ||
} | ||
else if (input instanceof char[]) { | ||
final List<Character> l = new ArrayList<Character>(); | ||
for (final char s : (char[])input) { | ||
l.add(s); | ||
} | ||
return l; | ||
} | ||
else if (input instanceof short[]) { | ||
final List<Short> l = new ArrayList<Short>(); | ||
for (final short s : (short[])input) { | ||
l.add(s); | ||
} | ||
return l; | ||
} | ||
else if (input instanceof int[]) { | ||
Integer[] array = Arrays.stream((int[])input).boxed().toArray(Integer[]::new); | ||
return Arrays.asList(array); | ||
} | ||
else if (input instanceof long[]) { | ||
Long[] array = Arrays.stream((long[])input).boxed().toArray(Long[]::new); | ||
return Arrays.asList(array); | ||
} | ||
else if (input instanceof float[]) { | ||
final List<Float> l = new ArrayList<Float>(); | ||
for (final float s : (float[])input) { | ||
l.add(s); | ||
} | ||
return l; | ||
} | ||
else if (input instanceof double[]) { | ||
Double[] array = Arrays.stream((double[])input).boxed().toArray(Double[]::new); | ||
return Arrays.asList(array); | ||
} | ||
|
||
if(!input.getClass().isArray()) throw new IllegalArgumentException("Input parameter is not an array"); | ||
|
||
throw new ClassCastException(input.getClass().getName() + " cannot be converted with this function"); | ||
} | ||
|
||
public static List<?> listFromByteBuffer(ByteBuffer input) { | ||
if (input == null) throw new IllegalArgumentException("Input parameter is null"); | ||
|
||
input.rewind(); | ||
byte[] array = new byte[input.remaining()]; | ||
input.get(array, 0, array.length); | ||
final List<Byte> l = new ArrayList<Byte>(); | ||
for (final byte s : array) { | ||
l.add(s); | ||
} | ||
return l; | ||
} | ||
|
||
public static List<?> listFromCharBuffer(CharBuffer input) { | ||
if (input == null) throw new IllegalArgumentException("Input parameter is null"); | ||
|
||
input.rewind(); | ||
char[] array = new char[input.remaining()]; | ||
input.get(array, 0, array.length); | ||
final List<Character> l = new ArrayList<Character>(); | ||
for (final char s : array) { | ||
l.add(s); | ||
} | ||
return l; | ||
} | ||
|
||
public static List<?> listFromDoubleBuffer(DoubleBuffer input) { | ||
if (input == null) throw new IllegalArgumentException("Input parameter is null"); | ||
|
||
input.rewind(); | ||
double[] array = new double[input.remaining()]; | ||
input.get(array, 0, array.length); | ||
Double[] array2 = Arrays.stream(array).boxed().toArray(Double[]::new); | ||
return Arrays.asList(array2); | ||
} | ||
|
||
public static List<?> listFromFloatBuffer(FloatBuffer input) { | ||
if (input == null) throw new IllegalArgumentException("Input parameter is null"); | ||
|
||
input.rewind(); | ||
float[] array = new float[input.remaining()]; | ||
input.get(array, 0, array.length); | ||
final List<Float> l = new ArrayList<Float>(); | ||
for (final float s : array) { | ||
l.add(s); | ||
} | ||
return l; | ||
} | ||
|
||
public static List<?> listFromIntBuffer(IntBuffer input) { | ||
if (input == null) throw new IllegalArgumentException("Input parameter is null"); | ||
|
||
input.rewind(); | ||
int[] array = new int[input.remaining()]; | ||
input.get(array, 0, array.length); | ||
Integer[] array2 = Arrays.stream(array).boxed().toArray(Integer[]::new); | ||
return Arrays.asList(array2); | ||
} | ||
|
||
public static List<?> listFromLongBuffer(LongBuffer input) { | ||
if (input == null) throw new IllegalArgumentException("Input parameter is null"); | ||
|
||
input.rewind(); | ||
long[] array = new long[input.remaining()]; | ||
input.get(array, 0, array.length); | ||
Long[] array2 = Arrays.stream(array).boxed().toArray(Long[]::new); | ||
return Arrays.asList(array2); | ||
} | ||
|
||
public static List<?> listFromShortBuffer(ShortBuffer input) { | ||
if (input == null) throw new IllegalArgumentException("Input parameter is null"); | ||
|
||
input.rewind(); | ||
short[] array = new short[input.remaining()]; | ||
input.get(array, 0, array.length); | ||
final List<Short> l = new ArrayList<Short>(); | ||
for (final short s : array) { | ||
l.add(s); | ||
} | ||
return l; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.